Skip to content

Commit dcfc951

Browse files
committed
fmt
1 parent 1fc31d0 commit dcfc951

File tree

8 files changed

+15
-6
lines changed

8 files changed

+15
-6
lines changed

yarn-project/p2p/src/services/libp2p/libp2p_service.ts

+6
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
132132
this.reqresp,
133133
);
134134

135+
// Update gossipsub score params
136+
this.node.services.pubsub.score.params.appSpecificScore = (peerId: string) => {
137+
return this.peerManager.getPeerScore(peerId);
138+
};
139+
this.node.services.pubsub.score.params.appSpecificWeight = 10;
140+
135141
this.attestationValidator = new AttestationValidator(epochCache);
136142
this.blockProposalValidator = new BlockProposalValidator(epochCache);
137143
this.epochProofQuoteValidator = new EpochProofQuoteValidator(epochCache);

yarn-project/p2p/src/services/peer-manager/peer_scoring.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class PeerScoring {
8888
}
8989

9090
public getScoreState(peerId: string): PeerScoreState {
91-
// TODO: permanently store banned peers?
91+
// TODO(#11329): permanently store banned peers?
9292
const score = this.getScore(peerId);
9393
if (score < MIN_SCORE_BEFORE_BAN) {
9494
return PeerScoreState.Banned;

yarn-project/p2p/src/services/reqresp/protocols/goodbye.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function prettyGoodbyeReason(reason: GoodByeReason): string {
5454
return 'low_score';
5555
case GoodByeReason.BANNED:
5656
return 'banned';
57-
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/11328): implement
57+
// TODO(#11328): implement
5858
case GoodByeReason.WRONG_NETWORK:
5959
return 'wrong_network';
6060
case GoodByeReason.UNKNOWN:
@@ -81,8 +81,12 @@ export class GoodbyeProtocolHandler {
8181
}
8282

8383
/**
84-
* Handles the goodbye request.
85-
* @param _msg - The goodbye request message.
84+
* Handles the goodbye request. In request response, the goodbye request is handled by the peer manager.
85+
*
86+
* @dev Implemented as returning a function as the function is bound in the libp2p service, however
87+
* its implementation is here to keep functionality together.
88+
*
89+
* @param peerManager - The peer manager.
8690
* @returns A resolved promise with the goodbye response.
8791
*/
8892
export function reqGoodbyeHandler(peerManager: PeerManager): ReqRespSubProtocolHandler {

yarn-project/p2p/src/services/reqresp/rate_limiter/rate_limits.ts yarn-project/p2p/src/services/reqresp/rate-limiter/rate_limits.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const DEFAULT_RATE_LIMITS: ReqRespSubProtocolRateLimits = {
3232
quotaCount: 10,
3333
},
3434
},
35-
// TODO(md): feels like goodbye is an exception to the rule here
3635
[ReqRespSubProtocol.GOODBYE]: {
3736
peerLimit: {
3837
quotaTimeMs: 1000,

yarn-project/p2p/src/services/reqresp/reqresp.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
startNodes,
1616
stopNodes,
1717
} from '../../mocks/index.js';
18-
import { PeerManager } from '../peer-manager/peer_manager.js';
18+
import { type PeerManager } from '../peer-manager/peer_manager.js';
1919
import { type PeerScoring } from '../peer-manager/peer_scoring.js';
2020
import { ReqRespSubProtocol, RequestableBuffer } from './interface.js';
2121
import { GoodByeReason, reqGoodbyeHandler } from './protocols/goodbye.js';

0 commit comments

Comments
 (0)