Skip to content

Commit

Permalink
fix: expose env var for batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Oct 29, 2024
1 parent 98f6f08 commit 7eda135
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
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 @@ -63,6 +63,7 @@ export type EnvVar =
| 'OTEL_SERVICE_NAME'
| 'OUTBOX_CONTRACT_ADDRESS'
| 'P2P_BLOCK_CHECK_INTERVAL_MS'
| 'P2P_BLOCK_REQUEST_BATCH_SIZE'
| 'P2P_ENABLED'
| 'P2P_GOSSIPSUB_D'
| 'P2P_GOSSIPSUB_DHI'
Expand Down
5 changes: 2 additions & 3 deletions yarn-project/p2p/src/client/p2p_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ export class P2PClient extends WithTracer implements P2P {
) {
super(telemetryClient, 'P2PClient');

const { blockCheckIntervalMS, l2QueueSize } = getP2PConfigFromEnv();
const { blockCheckIntervalMS, blockRequestBatchSize } = getP2PConfigFromEnv();

this.blockStream = new L2BlockStream(l2BlockSource, this, this, {
batchSize: l2QueueSize,
batchSize: blockRequestBatchSize,
pollIntervalMS: blockCheckIntervalMS,
});

Expand Down Expand Up @@ -642,7 +642,6 @@ export class P2PClient extends WithTracer implements P2P {
const txsToDelete: TxHash[] = [];
for (const tx of this.txPool.getAllTxs()) {
// every tx that's been generated against a block that has now been pruned is no longer valid
// NOTE (alexg): I think this check against block hash instead of block number?
if (tx.data.constants.globalVariables.blockNumber.toNumber() > latestBlock) {
txsToDelete.push(tx.getTxHash());
}
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/p2p/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export interface P2PConfig extends P2PReqRespConfig {
*/
blockCheckIntervalMS: number;

/**
* The number of blocks to fetch in a single batch.
*/
blockRequestBatchSize: number;

/**
* The frequency in which to check for new peers.
*/
Expand Down Expand Up @@ -295,6 +300,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
description: 'The chain id of the L1 chain.',
...numberConfigHelper(31337),
},
blockRequestBatchSize: {
env: 'P2P_BLOCK_REQUEST_BATCH_SIZE',
description: 'The number of blocks to fetch in a single batch.',
...numberConfigHelper(20),
},
...p2pReqRespConfigMappings,
};

Expand Down

0 comments on commit 7eda135

Please sign in to comment.