Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Jan 19, 2025
1 parent b755ab5 commit cc0ca50
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions yarn-project/p2p/src/services/libp2p/libp2p_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
this.reqresp,
);

// Update gossipsub score params
this.node.services.pubsub.score.params.appSpecificScore = (peerId: string) => {
return this.peerManager.getPeerScore(peerId);
};
this.node.services.pubsub.score.params.appSpecificWeight = 10;

this.attestationValidator = new AttestationValidator(epochCache);
this.blockProposalValidator = new BlockProposalValidator(epochCache);
this.epochProofQuoteValidator = new EpochProofQuoteValidator(epochCache);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/p2p/src/services/peer-manager/peer_scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class PeerScoring {
}

public getScoreState(peerId: string): PeerScoreState {
// TODO: permanently store banned peers?
// TODO(#11329): permanently store banned peers?
const score = this.getScore(peerId);
if (score < MIN_SCORE_BEFORE_BAN) {
return PeerScoreState.Banned;
Expand Down
10 changes: 7 additions & 3 deletions yarn-project/p2p/src/services/reqresp/protocols/goodbye.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function prettyGoodbyeReason(reason: GoodByeReason): string {
return 'low_score';
case GoodByeReason.BANNED:
return 'banned';
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/11328): implement
// TODO(#11328): implement
case GoodByeReason.WRONG_NETWORK:
return 'wrong_network';
case GoodByeReason.UNKNOWN:
Expand All @@ -81,8 +81,12 @@ export class GoodbyeProtocolHandler {
}

/**
* Handles the goodbye request.
* @param _msg - The goodbye request message.
* Handles the goodbye request. In request response, the goodbye request is handled by the peer manager.
*
* @dev Implemented as returning a function as the function is bound in the libp2p service, however
* its implementation is here to keep functionality together.
*
* @param peerManager - The peer manager.
* @returns A resolved promise with the goodbye response.
*/
export function reqGoodbyeHandler(peerManager: PeerManager): ReqRespSubProtocolHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const DEFAULT_RATE_LIMITS: ReqRespSubProtocolRateLimits = {
quotaCount: 10,
},
},
// TODO(md): feels like goodbye is an exception to the rule here
[ReqRespSubProtocol.GOODBYE]: {
peerLimit: {
quotaTimeMs: 1000,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/p2p/src/services/reqresp/reqresp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
startNodes,
stopNodes,
} from '../../mocks/index.js';
import { PeerManager } from '../peer-manager/peer_manager.js';
import { type PeerManager } from '../peer-manager/peer_manager.js';
import { type PeerScoring } from '../peer-manager/peer_scoring.js';
import { ReqRespSubProtocol, RequestableBuffer } from './interface.js';
import { GoodByeReason, reqGoodbyeHandler } from './protocols/goodbye.js';
Expand Down

0 comments on commit cc0ca50

Please sign in to comment.