Skip to content

Commit 019d6c5

Browse files
committed
fix: hello darkness my old friend
1 parent e2af21b commit 019d6c5

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

yarn-project/end-to-end/src/e2e_epochs/epochs_proof_fails.test.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { type Logger, getTimestampRangeForEpoch, sleep } from '@aztec/aztec.js';
22
import { BatchedBlob } from '@aztec/blob-lib';
33
import type { ViemClient } from '@aztec/ethereum';
44
import { RollupContract } from '@aztec/ethereum/contracts';
5-
import { ChainMonitor, type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/test';
5+
import { ChainMonitor, DelayedTxUtils, type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/test';
66
import { promiseWithResolvers } from '@aztec/foundation/promise';
7+
import type { ProverNodePublisher } from '@aztec/prover-node';
78
import type { TestProverNode } from '@aztec/prover-node/test';
89
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
910
import { Proof } from '@aztec/stdlib/proofs';
@@ -34,8 +35,9 @@ describe('e2e_epochs/epochs_proof_fails', () => {
3435
beforeEach(async () => {
3536
// Bumping the epoch duration to 5 because otherwise it takes a full epoch before the actual test starts,
3637
// which means the prover node is attempting to prove before we setup the mocks.
37-
test = await EpochsTestContext.setup({ ethereumSlotDuration: 8, aztecEpochDuration: 5 });
38-
({ proverDelayer, sequencerDelayer, context, l1Client, rollup, constants, logger, monitor } = test);
38+
// Set startProverNode to false to prevent automatic startup
39+
test = await EpochsTestContext.setup({ ethereumSlotDuration: 8, startProverNode: false });
40+
({ sequencerDelayer, context, l1Client, rollup, constants, logger, monitor } = test);
3941
({ L1_BLOCK_TIME_IN_S, L2_SLOT_DURATION_IN_S } = test);
4042
});
4143

@@ -48,6 +50,14 @@ describe('e2e_epochs/epochs_proof_fails', () => {
4850
// Here we cause a re-org by not publishing the proof for epoch 0 until after the end of epoch 1
4951
// The proof will be rejected and a re-org will take place
5052

53+
// Create prover node after test setup to avoid early proving
54+
const proverNode = await test.createProverNode();
55+
context.proverNode = proverNode;
56+
57+
// Get the prover delayer from the newly created prover node
58+
proverDelayer = (((proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils)
59+
.delayer!;
60+
5161
// Hold off prover tx until end epoch 1
5262
const [epoch2Start] = getTimestampRangeForEpoch(2n, constants);
5363
proverDelayer.pauseNextTxUntilTimestamp(epoch2Start);
@@ -85,16 +95,23 @@ describe('e2e_epochs/epochs_proof_fails', () => {
8595
});
8696

8797
it('aborts proving if end of next epoch is reached', async () => {
98+
// Create prover node after test setup to avoid early proving
99+
const proverNode = await test.createProverNode();
100+
101+
// Get the prover delayer from the newly created prover node
102+
proverDelayer = (((proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils)
103+
.delayer!;
104+
88105
// Inject a delay in prover node proving equal to the length of an epoch, to make sure deadline will be hit
89-
const epochProverManager = (context.proverNode as TestProverNode).prover;
106+
const epochProverManager = (proverNode as TestProverNode).prover;
90107
const originalCreate = epochProverManager.createEpochProver.bind(epochProverManager);
91108
const finalizeEpochPromise = promiseWithResolvers<void>();
92109
jest.spyOn(epochProverManager, 'createEpochProver').mockImplementation(() => {
93110
const prover = originalCreate();
94111
jest.spyOn(prover, 'finalizeEpoch').mockImplementation(async () => {
95-
const seconds = L2_SLOT_DURATION_IN_S * test.epochDuration;
112+
const seconds = L2_SLOT_DURATION_IN_S * (test.epochDuration * 2); // Forgive me for I have sinned.
96113
logger.warn(`Finalize epoch: sleeping ${seconds}s.`);
97-
await sleep(L2_SLOT_DURATION_IN_S * test.epochDuration * 1000);
114+
await sleep(seconds * 1000);
98115
logger.warn(`Finalize epoch: returning.`);
99116
finalizeEpochPromise.resolve();
100117
const ourPublicInputs = RootRollupPublicInputs.random();
@@ -109,6 +126,7 @@ describe('e2e_epochs/epochs_proof_fails', () => {
109126
});
110127
return prover;
111128
});
129+
context.proverNode = proverNode;
112130

113131
await test.waitUntilEpochStarts(1);
114132
logger.info(`Starting epoch 1`);

0 commit comments

Comments
 (0)