Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions yarn-project/foundation/src/config/env_var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export type EnvVar =
| 'P2P_L2_QUEUE_SIZE'
| 'P2P_MAX_PEERS'
| 'P2P_PEER_CHECK_INTERVAL_MS'
| 'P2P_PEER_FAILED_BAN_TIME_MS'
| 'P2P_PEER_PENALTY_VALUES'
| 'P2P_QUERY_FOR_IP'
| 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('ProposalTxCollector Benchmarks', () => {
bootstrapNodesAsFullPeers: true,
maxPeerCount: PEERS_PER_RUN + 1,
peerCheckIntervalMS: 1000,
peerFailedBanTimeMs: 5_000,
dialTimeoutMs: 10_000,
individualRequestTimeoutMs: 30_000,
};
Expand Down
8 changes: 8 additions & 0 deletions yarn-project/p2p/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export interface P2PConfig
/** The frequency in which to check for new peers. */
peerCheckIntervalMS: number;

/** How long to ban a peer after it fails MAX_DIAL_ATTEMPTS dials. */
peerFailedBanTimeMs: number;

/** Size of queue of L2 blocks to store. */
l2QueueSize: number;

Expand Down Expand Up @@ -254,6 +257,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
description: 'The frequency in which to check for new peers.',
...numberConfigHelper(30_000),
},
peerFailedBanTimeMs: {
env: 'P2P_PEER_FAILED_BAN_TIME_MS',
description: 'How long to ban a peer after it fails maximum dial attempts.',
...numberConfigHelper(5 * 60 * 1000),
},
l2QueueSize: {
env: 'P2P_L2_QUEUE_SIZE',
description: 'Size of queue of L2 blocks to store.',
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/p2p/src/services/peer-manager/peer_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { PeerScoreState, type PeerScoring } from './peer_scoring.js';
const MAX_DIAL_ATTEMPTS = 3;
const MAX_CACHED_PEERS = 100;
const MAX_CACHED_PEER_AGE_MS = 5 * 60 * 1000; // 5 minutes
const FAILED_PEER_BAN_TIME_MS = 5 * 60 * 1000; // 5 minutes timeout after failing MAX_DIAL_ATTEMPTS
const DEFAULT_FAILED_PEER_BAN_TIME_MS = 5 * 60 * 1000; // 5 minutes timeout after failing MAX_DIAL_ATTEMPTS
const GOODBYE_DIAL_TIMEOUT_MS = 1000;
const FAILED_AUTH_HANDSHAKE_EXPIRY_MS = 60 * 60 * 1000; // 1 hour

Expand Down Expand Up @@ -776,7 +776,8 @@ export class PeerManager implements PeerManagerInterface {
// Add to timed out peers
this.timedOutPeers.set(id, {
peerId: id,
timeoutUntilMs: this.dateProvider.now() + FAILED_PEER_BAN_TIME_MS,
timeoutUntilMs:
this.dateProvider.now() + (this.config.peerFailedBanTimeMs ?? DEFAULT_FAILED_PEER_BAN_TIME_MS),
});
}
}
Expand Down
Loading