Skip to content

Commit

Permalink
fix: flaky e2e_prover_node test (#8116)
Browse files Browse the repository at this point in the history
Fix for the flakiness in e2e_prover_node caused by halting the default
prover node while it was building a proof.

Later edit: alternatively we could refactor the test to start proving
from the first unproven block instead of from the block the first tx
landed in.
  • Loading branch information
alexghr authored Aug 22, 2024
1 parent a1127aa commit 9d97bd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions yarn-project/end-to-end/src/e2e_prover_node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
SignerlessWallet,
computeSecretHash,
createDebugLogger,
retryUntil,
sleep,
} from '@aztec/aztec.js';
import { StatefulTestContract, TestContract } from '@aztec/noir-contracts.js';
Expand All @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
);
}

0 comments on commit 9d97bd4

Please sign in to comment.