Skip to content

Commit 9cc815a

Browse files
committed
chore(e2e): toggle mbps in e2e tests (#20315)
- Updates the configuration on some e2e epochs and p2p tests in order to run with multiple blocks per slot. - Updates the fixed ports to be overridden via env vars so we can run multiple e2e tests in parallel without having them clash with each other. - Updates the l1-reorg tests so they don't assume they run on the first epoch (since setup can take variable time) Fixes A-239
1 parent 74a3427 commit 9cc815a

11 files changed

Lines changed: 337 additions & 107 deletions

File tree

yarn-project/end-to-end/src/e2e_epochs/epochs_invalidate_block.parallel.test.ts

Lines changed: 77 additions & 63 deletions
Large diffs are not rendered by default.

yarn-project/end-to-end/src/e2e_epochs/epochs_l1_reorgs.test.ts renamed to yarn-project/end-to-end/src/e2e_epochs/epochs_l1_reorgs.parallel.test.ts

Lines changed: 151 additions & 30 deletions
Large diffs are not rendered by default.

yarn-project/end-to-end/src/e2e_epochs/epochs_test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Archiver } from '@aztec/archiver';
12
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
23
import { getTimestampRangeForEpoch } from '@aztec/aztec.js/block';
34
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
@@ -319,7 +320,10 @@ export class EpochsTestContext {
319320
this.logger.info(`Waiting until last slot of submission window for epoch ${epochNumber} at ${date}`, {
320321
oneSlotBefore,
321322
});
322-
await waitUntilL1Timestamp(this.l1Client, oneSlotBefore);
323+
// Use a timeout that accounts for the full proof submission window
324+
const proofSubmissionWindowDuration =
325+
this.constants.proofSubmissionEpochs * this.epochDuration * this.L2_SLOT_DURATION_IN_S;
326+
await waitUntilL1Timestamp(this.l1Client, oneSlotBefore, undefined, proofSubmissionWindowDuration * 2);
323327
}
324328

325329
/** Waits for the aztec node to sync to the target block number. */
@@ -394,6 +398,38 @@ export class EpochsTestContext {
394398
expect(result).toBe(expectedSuccess);
395399
}
396400

401+
/** Verifies at least one checkpoint has the target number of blocks (for MBPS validation). */
402+
public async assertMultipleBlocksPerSlot(targetBlockCount: number) {
403+
const archiver = (this.context.aztecNode as AztecNodeService).getBlockSource() as Archiver;
404+
const checkpoints = await archiver.getCheckpoints(CheckpointNumber(1), 50);
405+
406+
this.logger.warn(`Retrieved ${checkpoints.length} checkpoints from archiver`, {
407+
checkpoints: checkpoints.map(pc => pc.checkpoint.getStats()),
408+
});
409+
410+
let expectedBlockNumber = checkpoints[0].checkpoint.blocks[0].number;
411+
let targetFound = false;
412+
413+
for (const checkpoint of checkpoints) {
414+
const blockCount = checkpoint.checkpoint.blocks.length;
415+
targetFound = targetFound || blockCount >= targetBlockCount;
416+
417+
this.logger.verbose(`Checkpoint ${checkpoint.checkpoint.number} has ${blockCount} blocks`, {
418+
checkpoint: checkpoint.checkpoint.getStats(),
419+
});
420+
421+
for (let i = 0; i < blockCount; i++) {
422+
const block = checkpoint.checkpoint.blocks[i];
423+
expect(block.indexWithinCheckpoint).toBe(i);
424+
expect(block.checkpointNumber).toBe(checkpoint.checkpoint.number);
425+
expect(block.number).toBe(expectedBlockNumber);
426+
expectedBlockNumber++;
427+
}
428+
}
429+
430+
expect(targetFound).toBe(true);
431+
}
432+
397433
public watchSequencerEvents(
398434
sequencers: SequencerClient[],
399435
getMetadata: (i: number) => Record<string, any> = () => ({}),

yarn-project/end-to-end/src/e2e_p2p/multiple_validators_sentinel.parallel.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ import 'jest-extended';
1010
import os from 'os';
1111
import path from 'path';
1212

13+
import { getBootNodeUdpPort } from '../fixtures/fixtures.js';
1314
import { createNodes, createNonValidatorNode } from '../fixtures/setup_p2p_test.js';
1415
import { P2PNetworkTest } from './p2p_network.js';
1516

1617
const NUM_NODES = 2;
1718
const VALIDATORS_PER_NODE = 3;
1819
const NUM_VALIDATORS = NUM_NODES * VALIDATORS_PER_NODE;
19-
const BOOT_NODE_UDP_PORT = 4500;
20+
const BOOT_NODE_UDP_PORT = getBootNodeUdpPort();
2021
const SLOT_COUNT = 3;
2122
const EPOCH_DURATION = 2;
22-
const ETHEREUM_SLOT_DURATION = 4;
23-
const AZTEC_SLOT_DURATION = 8;
23+
const ETHEREUM_SLOT_DURATION = 8;
24+
const AZTEC_SLOT_DURATION = 36;
2425

2526
const DATA_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'validators-sentinel-'));
2627

@@ -46,6 +47,9 @@ describe('e2e_p2p_multiple_validators_sentinel', () => {
4647
aztecTargetCommitteeSize: NUM_VALIDATORS,
4748
aztecSlotDuration: AZTEC_SLOT_DURATION,
4849
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
50+
blockDurationMs: 6000,
51+
l1PublishingTime: 8,
52+
enforceTimeTable: true,
4953
aztecProofSubmissionEpochs: 1024, // effectively do not reorg
5054
listenAddress: '127.0.0.1',
5155
minTxsPerBlock: 0,

yarn-project/end-to-end/src/e2e_p2p/reqresp/utils.ts

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ import { createLogger } from '@aztec/aztec.js/log';
33
import { waitForTx } from '@aztec/aztec.js/node';
44
import { Tx } from '@aztec/aztec.js/tx';
55
import { RollupContract } from '@aztec/ethereum/contracts';
6-
import { SlotNumber } from '@aztec/foundation/branded-types';
6+
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
77
import { timesAsync } from '@aztec/foundation/collection';
88
import { retryUntil } from '@aztec/foundation/retry';
99

10-
import { jest } from '@jest/globals';
10+
import { expect, jest } from '@jest/globals';
1111
import fs from 'fs';
1212
import os from 'os';
1313
import path from 'path';
1414

15-
import { shouldCollectMetrics } from '../../fixtures/fixtures.js';
15+
import { getBootNodeUdpPort, shouldCollectMetrics } from '../../fixtures/fixtures.js';
1616
import { createNodes } from '../../fixtures/setup_p2p_test.js';
17-
import { P2PNetworkTest, SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES, WAIT_FOR_TX_TIMEOUT } from '../p2p_network.js';
17+
import { P2PNetworkTest, WAIT_FOR_TX_TIMEOUT } from '../p2p_network.js';
1818
import { prepareTransactions } from '../shared.js';
1919

2020
// Don't set this to a higher value than 9 because each node will use a different L1 publisher account and anvil seeds
2121
export const NUM_VALIDATORS = 6;
22-
export const NUM_TXS_PER_NODE = 2;
23-
export const BOOT_NODE_UDP_PORT = 4500;
22+
export const NUM_TXS_PER_NODE = 4;
23+
export const BOOT_NODE_UDP_PORT = getBootNodeUdpPort();
2424

2525
export const createReqrespDataDir = () => fs.mkdtempSync(path.join(os.tmpdir(), 'reqresp-'));
2626

@@ -38,8 +38,14 @@ export async function createReqrespTest(options: ReqrespOptions = {}): Promise<P
3838
// To collect metrics - run in aztec-packages `docker compose --profile metrics up`
3939
metricsPort: shouldCollectMetrics(),
4040
initialConfig: {
41-
...SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES,
42-
aztecSlotDuration: 24,
41+
ethereumSlotDuration: 8,
42+
aztecSlotDuration: 36,
43+
blockDurationMs: 6000,
44+
l1PublishingTime: 8,
45+
minTxsPerBlock: 1,
46+
maxTxsPerBlock: 2,
47+
enforceTimeTable: true,
48+
aztecProofSubmissionEpochs: 1024, // effectively do not reorg
4349
...(disableStatusHandshake ? { p2pDisableStatusHandshake: true } : {}),
4450
listenAddress: '127.0.0.1',
4551
aztecEpochDuration: 64, // stable committee
@@ -170,6 +176,28 @@ export async function runReqrespTxTest(params: {
170176

171177
t.logger.info('All transactions mined');
172178

179+
// Assert that multiple blocks were built for at least one slot
180+
t.logger.info('Verifying multiple blocks for at least one checkpoint');
181+
const checkpoints = await nodes[0].getCheckpoints(CheckpointNumber(1), 50);
182+
expect(checkpoints.length).toBeGreaterThan(0);
183+
184+
let mbpsFound = false;
185+
let expectedBlockNumber = checkpoints[0].checkpoint.blocks[0].number;
186+
187+
for (const published of checkpoints) {
188+
const blockCount = published.checkpoint.blocks.length;
189+
mbpsFound = mbpsFound || blockCount >= 2;
190+
191+
for (let i = 0; i < blockCount; i++) {
192+
const block = published.checkpoint.blocks[i];
193+
expect(block.indexWithinCheckpoint).toBe(i);
194+
expect(block.checkpointNumber).toBe(published.checkpoint.number);
195+
expect(block.number).toBe(expectedBlockNumber);
196+
expectedBlockNumber++;
197+
}
198+
}
199+
200+
expect(mbpsFound).toBe(true);
173201
return nodes;
174202
}
175203

yarn-project/end-to-end/src/fixtures/fixtures.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ export const shouldCollectMetrics = () => {
77
return undefined;
88
};
99

10+
/** Returns the boot node UDP port from environment variable or default value. */
11+
export function getBootNodeUdpPort(): number {
12+
return process.env.BOOT_NODE_UDP_PORT ? parseInt(process.env.BOOT_NODE_UDP_PORT, 10) : 4500;
13+
}
14+
15+
/** Returns the anvil port from environment variable or default value. */
16+
export function getAnvilPort(): number {
17+
return process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT, 10) : 8545;
18+
}
19+
1020
export const TEST_PEER_CHECK_INTERVAL_MS = 1000;
1121
export const TEST_MAX_PENDING_TX_POOL_COUNT = 10_000; // Number of max pending TXs ~ 1.56GB
1222

yarn-project/prover-node/src/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,5 +231,6 @@ export async function createProverNode(
231231
proverNodeConfig,
232232
telemetry,
233233
delayer,
234+
dateProvider,
234235
);
235236
}

yarn-project/prover-node/src/prover-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ type DataStoreOptions = Pick<DataStoreConfig, 'dataDirectory'> & Pick<ChainConfi
5656
*/
5757
export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable {
5858
private log = createLogger('prover-node');
59-
private dateProvider = new DateProvider();
6059

6160
private jobs: Map<string, EpochProvingJob> = new Map();
6261
private config: ProverNodeOptions;
@@ -81,6 +80,7 @@ export class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable
8180
config: Partial<ProverNodeOptions> = {},
8281
protected readonly telemetryClient: TelemetryClient = getTelemetryClient(),
8382
private delayer?: Delayer,
83+
private readonly dateProvider: DateProvider = new DateProvider(),
8484
) {
8585
this.config = {
8686
proverNodePollingIntervalMs: 1_000,

yarn-project/sequencer-client/src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
205205
description: 'Skip pushing proposed blocks to archiver (default: true)',
206206
...booleanConfigHelper(DefaultSequencerConfig.skipPushProposedBlocksToArchiver),
207207
},
208+
minBlocksForCheckpoint: {
209+
description: 'Minimum number of blocks required for a checkpoint proposal (test only)',
210+
},
208211
...pickConfigMappings(p2pConfigMappings, ['txPublicSetupAllowList']),
209212
};
210213

yarn-project/sequencer-client/src/sequencer/checkpoint_proposal_job.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ export class CheckpointProposalJob implements Traceable {
249249
return undefined;
250250
}
251251

252+
const minBlocksForCheckpoint = this.config.minBlocksForCheckpoint;
253+
if (minBlocksForCheckpoint !== undefined && blocksInCheckpoint.length < minBlocksForCheckpoint) {
254+
this.log.warn(
255+
`Checkpoint has fewer blocks than minimum (${blocksInCheckpoint.length} < ${minBlocksForCheckpoint}), skipping proposal`,
256+
{ slot: this.slot, blocksBuilt: blocksInCheckpoint.length, minBlocksForCheckpoint },
257+
);
258+
return undefined;
259+
}
260+
252261
// Assemble and broadcast the checkpoint proposal, including the last block that was not
253262
// broadcasted yet, and wait to collect the committee attestations.
254263
this.setStateFn(SequencerState.ASSEMBLING_CHECKPOINT, this.slot);

0 commit comments

Comments
 (0)