From b11fbcfbd9f761acc082361bdc642ba755f70dad Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 21 Aug 2024 16:56:07 +0000 Subject: [PATCH 1/2] fix: wait for proven chain --- yarn-project/end-to-end/src/e2e_prover_node.test.ts | 7 +++++-- yarn-project/end-to-end/src/fixtures/utils.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) 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..35469a3f6fe 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, + ); +} From 2d24210a28c3b78af94b8a7bf440b902a036c84d Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Wed, 21 Aug 2024 20:50:45 +0100 Subject: [PATCH 2/2] Update yarn-project/end-to-end/src/fixtures/utils.ts Co-authored-by: Santiago Palladino --- yarn-project/end-to-end/src/fixtures/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 35469a3f6fe..2c778054fa8 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -748,7 +748,7 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: number, targetBlock ??= await node.getBlockNumber(); await retryUntil( - async () => (await node.getProvenBlockNumber()) === targetBlock, + async () => (await node.getProvenBlockNumber()) >= targetBlock, 'proven chain status', timeoutSec, intervalSec,