From 76969f80e60233687590be1265baf68d22d592a8 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Thu, 2 Jan 2025 10:34:56 -0300 Subject: [PATCH] chore: Fix flake in e2e-block-build The test 'processes txs until hitting timetable' was failing sometimes (see [here](https://github.com/AztecProtocol/aztec-packages/actions/runs/12582242725/job/35068125404#step:3:1132)) since the sequencer may need at least 4s to start processing a block. This should change when #10921 lands, but in the meantime, this should handle the flake. --- .../end-to-end/src/e2e_block_building.test.ts | 18 +++++++++++------- .../src/sequencer/sequencer.ts | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index 4385c888c12..6a2ed021376 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -193,7 +193,7 @@ describe('e2e_block_building', () => { logger.info(`Updating aztec node config`); await aztecNode.setConfig({ minTxsPerBlock: 1, maxTxsPerBlock: TX_COUNT, enforceTimeTable: true }); - // We tweak the sequencer so it uses a fake simulator that adds a 200ms delay to every public tx. + // We tweak the sequencer so it uses a fake simulator that adds a delay to every public tx. const archiver = (aztecNode as AztecNodeService).getContractDataSource(); sequencer.sequencer.publicProcessorFactory = new TestPublicProcessorFactory( archiver, @@ -202,11 +202,13 @@ describe('e2e_block_building', () => { ); // We also cheat the sequencer's timetable so it allocates little time to processing. - // This will leave the sequencer with just 2s to build the block, so it shouldn't be - // able to squeeze in more than 10 txs in each. This is sensitive to the time it takes - // to pick up and validate the txs, so we may need to bump it to work on CI. - sequencer.sequencer.timeTable[SequencerState.WAITING_FOR_TXS] = 2; - sequencer.sequencer.timeTable[SequencerState.CREATING_BLOCK] = 2; + // This will leave the sequencer with just a few seconds to build the block, so it shouldn't + // be able to squeeze in more than ~12 txs in each. This is sensitive to the time it takes + // to pick up and validate the txs, so we may need to bump it to work on CI. Note that we need + // at least 3s here so the archiver has time to loop once and sync, and the sequencer has at + // least 1s to loop. + sequencer.sequencer.timeTable[SequencerState.WAITING_FOR_TXS] = 4; + sequencer.sequencer.timeTable[SequencerState.CREATING_BLOCK] = 4; sequencer.sequencer.processTxTime = 1; // Flood the mempool with TX_COUNT simultaneous txs @@ -615,9 +617,11 @@ type TestSequencer = Omit & { }; type TestSequencerClient = Omit & { sequencer: TestSequencer }; +const TEST_PUBLIC_TX_SIMULATION_DELAY_MS = 300; + class TestPublicTxSimulator extends PublicTxSimulator { public override async simulate(tx: Tx): Promise { - await sleep(200); + await sleep(TEST_PUBLIC_TX_SIMULATION_DELAY_MS); return super.simulate(tx); } } diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 9f758c456cc..65102d214a6 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -60,7 +60,7 @@ export class SequencerTooSlowError extends Error { public readonly currentTime: number, ) { super( - `Too far into slot to transition to ${proposedState}. max allowed: ${maxAllowedTime}s, time into slot: ${currentTime}s`, + `Too far into slot to transition to ${proposedState} (max allowed: ${maxAllowedTime}s, time into slot: ${currentTime}s)`, ); this.name = 'SequencerTooSlowError'; } @@ -430,7 +430,7 @@ export class Sequencer { const bufferSeconds = maxAllowedTime - secondsIntoSlot; if (bufferSeconds < 0) { - this.log.warn(`Too far into slot to transition to ${proposedState}`, { maxAllowedTime, secondsIntoSlot }); + this.log.debug(`Too far into slot to transition to ${proposedState}`, { maxAllowedTime, secondsIntoSlot }); return false; }