Skip to content

Commit 308cc20

Browse files
AztecBotPhilWindle
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 4576993 commit 308cc20

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

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';
@@ -832,7 +834,7 @@ export async function ensureAccountContractsPublished(wallet: Wallet, accountsTo
832834
* Returns deployed account data that can be used by tests.
833835
*/
834836
export const deployAccounts =
835-
(numberOfAccounts: number, logger: Logger) =>
837+
(numberOfAccounts: number, logger: Logger, deployOptions?: Partial<DeployOptions<DeployInteractionWaitOptions>>) =>
836838
async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
837839
if (initialFundedAccounts.length < numberOfAccounts) {
838840
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
@@ -851,6 +853,7 @@ export const deployAccounts =
851853
await deployMethod.send({
852854
from: NO_FROM,
853855
skipClassPublication: i !== 0, // Publish the contract class at most once.
856+
...deployOptions,
854857
});
855858
}
856859

0 commit comments

Comments
 (0)