Skip to content

Commit

Permalink
chore: fix flakey e2e fees failures test (#8807)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
just-mitch authored and Rumata888 committed Sep 27, 2024
1 parent a907562 commit 2e93c65
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions yarn-project/end-to-end/scripts/deflaker.sh
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 5 additions & 5 deletions yarn-project/end-to-end/src/e2e_fees/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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({
Expand All @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions yarn-project/end-to-end/src/e2e_fees/fees_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2e93c65

Please sign in to comment.