Skip to content

Commit 2a2932e

Browse files
authored
chore: Fix flake in e2e-block-build (#11002)
1 parent 2d3805a commit 2a2932e

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

yarn-project/end-to-end/src/e2e_block_building.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ describe('e2e_block_building', () => {
193193
logger.info(`Updating aztec node config`);
194194
await aztecNode.setConfig({ minTxsPerBlock: 1, maxTxsPerBlock: TX_COUNT, enforceTimeTable: true });
195195

196-
// We tweak the sequencer so it uses a fake simulator that adds a 200ms delay to every public tx.
196+
// We tweak the sequencer so it uses a fake simulator that adds a delay to every public tx.
197197
const archiver = (aztecNode as AztecNodeService).getContractDataSource();
198198
sequencer.sequencer.publicProcessorFactory = new TestPublicProcessorFactory(
199199
archiver,
@@ -202,11 +202,13 @@ describe('e2e_block_building', () => {
202202
);
203203

204204
// We also cheat the sequencer's timetable so it allocates little time to processing.
205-
// This will leave the sequencer with just 2s to build the block, so it shouldn't be
206-
// able to squeeze in more than 10 txs in each. This is sensitive to the time it takes
207-
// to pick up and validate the txs, so we may need to bump it to work on CI.
208-
sequencer.sequencer.timeTable[SequencerState.WAITING_FOR_TXS] = 2;
209-
sequencer.sequencer.timeTable[SequencerState.CREATING_BLOCK] = 2;
205+
// This will leave the sequencer with just a few seconds to build the block, so it shouldn't
206+
// be able to squeeze in more than ~12 txs in each. This is sensitive to the time it takes
207+
// to pick up and validate the txs, so we may need to bump it to work on CI. Note that we need
208+
// at least 3s here so the archiver has time to loop once and sync, and the sequencer has at
209+
// least 1s to loop.
210+
sequencer.sequencer.timeTable[SequencerState.WAITING_FOR_TXS] = 4;
211+
sequencer.sequencer.timeTable[SequencerState.CREATING_BLOCK] = 4;
210212
sequencer.sequencer.processTxTime = 1;
211213

212214
// Flood the mempool with TX_COUNT simultaneous txs
@@ -615,9 +617,11 @@ type TestSequencer = Omit<Sequencer, 'publicProcessorFactory' | 'timeTable'> & {
615617
};
616618
type TestSequencerClient = Omit<SequencerClient, 'sequencer'> & { sequencer: TestSequencer };
617619

620+
const TEST_PUBLIC_TX_SIMULATION_DELAY_MS = 300;
621+
618622
class TestPublicTxSimulator extends PublicTxSimulator {
619623
public override async simulate(tx: Tx): Promise<PublicTxResult> {
620-
await sleep(200);
624+
await sleep(TEST_PUBLIC_TX_SIMULATION_DELAY_MS);
621625
return super.simulate(tx);
622626
}
623627
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ describe('sequencer', () => {
257257
await expect(sequencer.doRealWork()).rejects.toThrow(
258258
expect.objectContaining({
259259
name: 'SequencerTooSlowError',
260-
message: expect.stringContaining(`Too far into slot to transition to ${delayedState}.`),
260+
message: expect.stringContaining(`Too far into slot to transition to ${delayedState}`),
261261
}),
262262
);
263263

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class SequencerTooSlowError extends Error {
6060
public readonly currentTime: number,
6161
) {
6262
super(
63-
`Too far into slot to transition to ${proposedState}. max allowed: ${maxAllowedTime}s, time into slot: ${currentTime}s`,
63+
`Too far into slot to transition to ${proposedState} (max allowed: ${maxAllowedTime}s, time into slot: ${currentTime}s)`,
6464
);
6565
this.name = 'SequencerTooSlowError';
6666
}
@@ -172,10 +172,10 @@ export class Sequencer {
172172

173173
private setTimeTable() {
174174
// How late into the slot can we be to start working
175-
const initialTime = 1;
175+
const initialTime = 2;
176176

177177
// How long it takes to validate the txs collected and get ready to start building
178-
const blockPrepareTime = 2;
178+
const blockPrepareTime = 1;
179179

180180
// How long it takes to for attestations to travel across the p2p layer.
181181
const attestationPropagationTime = 2;
@@ -430,7 +430,7 @@ export class Sequencer {
430430
const bufferSeconds = maxAllowedTime - secondsIntoSlot;
431431

432432
if (bufferSeconds < 0) {
433-
this.log.warn(`Too far into slot to transition to ${proposedState}`, { maxAllowedTime, secondsIntoSlot });
433+
this.log.debug(`Too far into slot to transition to ${proposedState}`, { maxAllowedTime, secondsIntoSlot });
434434
return false;
435435
}
436436

0 commit comments

Comments
 (0)