From 8572544f48328cc93db144560a4f4163b1632274 Mon Sep 17 00:00:00 2001 From: AztecBot Date: Fri, 5 Jun 2026 17:12:39 +0000 Subject: [PATCH] fix(cli-wallet): wait for checkpointed in serial sandbox flow tests The cli-wallet send/deploy/create-account/deploy-account commands default to waiting for PROPOSED. In the serial single-block local-network sandbox a proposed block can be orphaned and pruned before its checkpoint is published, dropping a tx the caller already moved on from ("Tx dropped by P2P node"), which flaked cli-wallet/test/flows/private_transfer.sh. Make the default wait-for-status overridable via WALLET_TX_WAIT_FOR_STATUS and set it to 'checkpointed' in the flow-test harness so each tx is durably included before the next is sent. Mirrors the same fix already applied to the local-network internal setup txs. --- yarn-project/cli-wallet/src/cmds/index.ts | 30 ++++++++++++++++--- .../cli-wallet/test/flows/shared/setup.sh | 6 ++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/yarn-project/cli-wallet/src/cmds/index.ts b/yarn-project/cli-wallet/src/cmds/index.ts index d6ca67c97ecb..24e64aaac6c1 100644 --- a/yarn-project/cli-wallet/src/cmds/index.ts +++ b/yarn-project/cli-wallet/src/cmds/index.ts @@ -52,6 +52,12 @@ function parseWaitForStatus(status: string): TxStatus { } } +// Default tx status to wait for, overridable via env var. The serial sandbox flow tests set this to +// 'checkpointed' so each tx is durably included before the next is sent: waiting only for 'proposed' +// is racy there, since a proposed block can be orphaned and pruned before its checkpoint is published, +// dropping a tx we already moved on from ("Tx dropped by P2P node"). +const DEFAULT_WAIT_FOR_STATUS = process.env.WALLET_TX_WAIT_FOR_STATUS ?? 'proposed'; + // TODO: This function is only used in 1 place so we could just inline this export function injectCommands( program: Command, @@ -115,7 +121,11 @@ export function injectCommands( // `options.wait` is default true. Passing `--no-wait` will set it to false. // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction') - .option('--wait-for-status ', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed') + .option( + '--wait-for-status ', + "Tx status to wait for: 'proposed' or 'checkpointed'", + DEFAULT_WAIT_FOR_STATUS, + ) .addOption(createVerboseOption()); addOptions(createAccountCommand, CLIFeeArgs.getOptions()).action(async (_options, command) => { @@ -202,7 +212,11 @@ export function injectCommands( '--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.', ) - .option('--wait-for-status ', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed') + .option( + '--wait-for-status ', + "Tx status to wait for: 'proposed' or 'checkpointed'", + DEFAULT_WAIT_FOR_STATUS, + ) .addOption(createVerboseOption()); addOptions(deployAccountCommand, CLIFeeArgs.getOptions()).action(async (parsedAccount, _options, command) => { @@ -271,7 +285,11 @@ export function injectCommands( 'The amount of time in seconds to wait for the deployment to post to L2', ).conflicts('wait'), ) - .option('--wait-for-status ', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed') + .option( + '--wait-for-status ', + "Tx status to wait for: 'proposed' or 'checkpointed'", + DEFAULT_WAIT_FOR_STATUS, + ) .addOption(createVerboseOption()); addOptions(deployCommand, CLIFeeArgs.getOptions()).action(async (artifactPathPromise, _options, command) => { @@ -345,7 +363,11 @@ export function injectCommands( ) .addOption(createAccountOption('Alias or address of the account to send the transaction from', !db, db)) .option('--no-wait', 'Print transaction hash without waiting for it to be mined') - .option('--wait-for-status ', "Tx status to wait for: 'proposed' or 'checkpointed'", 'proposed') + .option( + '--wait-for-status ', + "Tx status to wait for: 'proposed' or 'checkpointed'", + DEFAULT_WAIT_FOR_STATUS, + ) .addOption(createVerboseOption()); addOptions(sendCommand, CLIFeeArgs.getOptions()).action(async (functionName, _options, command) => { diff --git a/yarn-project/cli-wallet/test/flows/shared/setup.sh b/yarn-project/cli-wallet/test/flows/shared/setup.sh index 28a9b48efd51..16a99b3b0f5f 100644 --- a/yarn-project/cli-wallet/test/flows/shared/setup.sh +++ b/yarn-project/cli-wallet/test/flows/shared/setup.sh @@ -16,6 +16,12 @@ cd $root/noir-projects/noir-contracts export PXE_PROVER="none" +# These flows run serially against the single-block local-network sandbox, where a proposed block can +# be orphaned and pruned before its checkpoint is published, dropping a tx we already moved on from +# ("Tx dropped by P2P node"). Wait for each tx to be checkpointed so it is durably included before the +# next is sent. +export WALLET_TX_WAIT_FOR_STATUS="${WALLET_TX_WAIT_FOR_STATUS:-checkpointed}" + function aztec-wallet { echo_header aztec-wallet "$@" $command "$@"