Skip to content

Commit 25982ed

Browse files
AztecBotPhilWindle
authored andcommitted
fix(e2e): wait for checkpointed blocks in rediscovery test
## Summary - Fix flaky `e2e_p2p/rediscovery.test.ts` caused by a race between uncheckpointed block pruning and PXE transaction simulation - After `setupAccount()` deploys accounts, wait for blocks to reach `CHECKPOINTED` status before proceeding with the stop/restart cycle - Refactor `deployAccounts` in `setup.ts` to accept optional `DeployOptions`, with `from: NO_FROM` always applied as the base **Root cause**: After `setupAccount()` produces blocks, the test stops and restarts validator nodes. During the restart (~25s), the L1 clock advances past the block's slot. When restarted nodes sync, `pruneUncheckpointedBlocks()` removes the block because its slot has passed without a checkpoint. The PXE then fails simulating a transaction against the pruned block. **Fix**: Pass `wait: { waitForStatus: TxStatus.CHECKPOINTED }` to `deployAccounts`, which waits for the deploy tx's block to be checkpointed before returning. This replaces the previous manual `retryUntil` loop. CI log of the flake: http://ci.aztec-labs.com/19edb028126f87c3 Full analysis: https://gist.github.com/AztecBot/b4101abd080ebd536ac09e7c82188518 Co-authored-by: Phil Windle <philip.windle@gmail.com>
1 parent 7d1833d commit 25982ed

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { BootstrapNode } from '@aztec/p2p/bootstrap';
2020
import { createBootstrapNodeFromPrivateKey, getBootstrapNodeEnr } from '@aztec/p2p/test-helpers';
2121
import { tryStop } from '@aztec/stdlib/interfaces/server';
2222
import { TopicType } from '@aztec/stdlib/p2p';
23+
import { TxStatus } from '@aztec/stdlib/tx';
2324
import type { GenesisData } from '@aztec/stdlib/world-state';
2425
import { ZkPassportProofParams } from '@aztec/stdlib/zkpassport';
2526
import { getGenesisValues } from '@aztec/world-state/testing';
@@ -299,10 +300,11 @@ export class P2PNetworkTest {
299300

300301
async setupAccount() {
301302
this.logger.info('Setting up account');
302-
const { deployedAccounts } = await deployAccounts(
303-
1,
304-
this.logger,
305-
)({
303+
const { deployedAccounts } = await deployAccounts(1, this.logger, {
304+
wait: {
305+
waitForStatus: TxStatus.CHECKPOINTED,
306+
},
307+
})({
306308
wallet: this.context.wallet,
307309
initialFundedAccounts: this.context.initialFundedAccounts,
308310
});

yarn-project/end-to-end/src/fixtures/setup.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
BatchCall,
88
type ContractFunctionInteraction,
99
type ContractMethod,
10+
type DeployInteractionWaitOptions,
11+
type DeployOptions,
1012
getContractClassFromArtifact,
1113
waitForProven,
1214
} from '@aztec/aztec.js/contracts';
@@ -834,7 +836,7 @@ export async function ensureAccountContractsPublished(wallet: Wallet, accountsTo
834836
* Returns deployed account data that can be used by tests.
835837
*/
836838
export const deployAccounts =
837-
(numberOfAccounts: number, logger: Logger) =>
839+
(numberOfAccounts: number, logger: Logger, deployOptions?: Partial<DeployOptions<DeployInteractionWaitOptions>>) =>
838840
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
839841
if (initialFundedAccounts.length < numberOfAccounts) {
840842
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
@@ -853,6 +855,7 @@ export const deployAccounts =
853855
await deployMethod.send({
854856
from: NO_FROM,
855857
skipClassPublication: i !== 0, // Publish the contract class at most once.
858+
...deployOptions,
856859
});
857860
}
858861

0 commit comments

Comments
 (0)