From 99bac950f3c057ee1c25ea61fa6fe4834b348e24 Mon Sep 17 00:00:00 2001 From: just-mitch <68168980+just-mitch@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:02:03 -0400 Subject: [PATCH] chore: fix flakey e2e fees failures test (#8807) If the proven chain weren't caught up before we took the measurement for coinbase's L1 balance, it could look as though the wrong amount of fees were paid out. --- yarn-project/end-to-end/Earthfile | 6 +++--- yarn-project/end-to-end/scripts/deflaker.sh | 14 ++++++++++++++ .../end-to-end/src/e2e_fees/failures.test.ts | 10 +++++----- yarn-project/end-to-end/src/e2e_fees/fees_test.ts | 8 ++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) create mode 100755 yarn-project/end-to-end/scripts/deflaker.sh diff --git a/yarn-project/end-to-end/Earthfile b/yarn-project/end-to-end/Earthfile index 2cf744c225d..83f95c3712f 100644 --- a/yarn-project/end-to-end/Earthfile +++ b/yarn-project/end-to-end/Earthfile @@ -140,9 +140,9 @@ e2e-fees-dapp-subscription: LOCALLY RUN ./scripts/e2e_test.sh ./src/e2e_fees/dapp_subscription.test.ts -# e2e-fees-failures: -# LOCALLY -# RUN ./scripts/e2e_test.sh ./src/e2e_fees/failures.test.ts +e2e-fees-failures: + LOCALLY + RUN ./scripts/e2e_test.sh ./src/e2e_fees/failures.test.ts e2e-fees-fee-juice-payments: LOCALLY diff --git a/yarn-project/end-to-end/scripts/deflaker.sh b/yarn-project/end-to-end/scripts/deflaker.sh new file mode 100755 index 00000000000..072a5f2952a --- /dev/null +++ b/yarn-project/end-to-end/scripts/deflaker.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +testname=$1 +script_dir=$(dirname "$0") + +for i in {1..100} +do + echo "Run #$i" + if ! yarn test $1 > $script_dir/deflaker.log 2>&1; then + echo "failed" + exit 1 + fi +done +echo "success" diff --git a/yarn-project/end-to-end/src/e2e_fees/failures.test.ts b/yarn-project/end-to-end/src/e2e_fees/failures.test.ts index 253cada5a31..60a418bdee6 100644 --- a/yarn-project/end-to-end/src/e2e_fees/failures.test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/failures.test.ts @@ -8,7 +8,6 @@ import { PublicFeePaymentMethod, TxStatus, computeSecretHash, - sleep, } from '@aztec/aztec.js'; import { Gas, GasSettings } from '@aztec/circuits.js'; import { FunctionType } from '@aztec/foundation/abi'; @@ -82,7 +81,11 @@ describe('e2e_fees failures', () => { // if we skip simulation, it includes the failed TX const rebateSecret = Fr.random(); + + // We wait until the proven chain is caught up so all previous fees are paid out. + await t.catchUpProvenChain(); const currentSequencerL1Gas = await t.getCoinbaseBalance(); + const txReceipt = await bananaCoin.methods .transfer_public(aliceAddress, sequencerAddress, OutrageousPublicAmountAliceDoesNotHave, 0) .send({ @@ -97,10 +100,7 @@ describe('e2e_fees failures', () => { expect(txReceipt.status).toBe(TxStatus.APP_LOGIC_REVERTED); // We wait until the block is proven since that is when the payout happens. - const bn = await t.aztecNode.getBlockNumber(); - while ((await t.aztecNode.getProvenBlockNumber()) < bn) { - await sleep(1000); - } + await t.catchUpProvenChain(); const feeAmount = txReceipt.transactionFee!; const newSequencerL1FeeAssetBalance = await t.getCoinbaseBalance(); diff --git a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts index 4beb1b07dee..aa5761aa80f 100644 --- a/yarn-project/end-to-end/src/e2e_fees/fees_test.ts +++ b/yarn-project/end-to-end/src/e2e_fees/fees_test.ts @@ -12,6 +12,7 @@ import { type TxHash, computeSecretHash, createDebugLogger, + sleep, } from '@aztec/aztec.js'; import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint'; import { EthAddress, GasSettings, computePartialAddress } from '@aztec/circuits.js'; @@ -101,6 +102,13 @@ export class FeesTest { await this.snapshotManager.teardown(); } + async catchUpProvenChain() { + const bn = await this.aztecNode.getBlockNumber(); + while ((await this.aztecNode.getProvenBlockNumber()) < bn) { + await sleep(1000); + } + } + /** Alice mints Token */ async mintToken(amount: bigint) { const balanceBefore = await this.token.methods.balance_of_private(this.aliceAddress).simulate();