diff --git a/yarn-project/end-to-end/src/e2e_prover_node.test.ts b/yarn-project/end-to-end/src/e2e_prover_node.test.ts index 518c1ad6c39..efab32e13fd 100644 --- a/yarn-project/end-to-end/src/e2e_prover_node.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover_node.test.ts @@ -9,7 +9,6 @@ import { SignerlessWallet, computeSecretHash, createDebugLogger, - retryUntil, sleep, } from '@aztec/aztec.js'; import { StatefulTestContract, TestContract } from '@aztec/noir-contracts.js'; @@ -22,6 +21,7 @@ import { addAccounts, createSnapshotManager, } from './fixtures/snapshot_manager.js'; +import { waitForProvenChain } from './fixtures/utils.js'; // Tests simple block building with a sequencer that does not upload proofs to L1, // and then follows with a prover node run (with real proofs disabled, but @@ -85,6 +85,9 @@ describe('e2e_prover_node', () => { }); it('submits three blocks, then prover proves the first two', async () => { + // wait for the proven chain to catch up with the pending chain before we shut off the prover node + await waitForProvenChain(ctx.aztecNode); + // Stop the current prover node await ctx.proverNode.stop(); @@ -130,7 +133,7 @@ describe('e2e_prover_node', () => { await expect(proverNode.startProof(firstBlock, firstBlock)).rejects.toThrow(/behind the current world state/i); // Await until proofs get submitted - await retryUntil(async () => (await ctx.aztecNode.getProvenBlockNumber()) === secondBlock, 'proven', 60, 1); + await waitForProvenChain(ctx.aztecNode, secondBlock); expect(await ctx.aztecNode.getProvenBlockNumber()).toEqual(secondBlock); // Check that the prover id made it to the emitted event diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 5ba67dd0ab2..2c778054fa8 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -38,7 +38,7 @@ import { getContractClassFromArtifact, } from '@aztec/circuits.js'; import { bufferAsFields } from '@aztec/foundation/abi'; -import { makeBackoff, retry } from '@aztec/foundation/retry'; +import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry'; import { AvailabilityOracleAbi, AvailabilityOracleBytecode, @@ -743,3 +743,14 @@ export async function deployCanonicalAuthRegistry(deployer: Wallet) { await expect(deployer.isContractClassPubliclyRegistered(canonicalAuthRegistry.contractClass.id)).resolves.toBe(true); await expect(deployer.getContractInstance(canonicalAuthRegistry.instance.address)).resolves.toBeDefined(); } + +export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) { + targetBlock ??= await node.getBlockNumber(); + + await retryUntil( + async () => (await node.getProvenBlockNumber()) >= targetBlock, + 'proven chain status', + timeoutSec, + intervalSec, + ); +}