Skip to content

fix: stabilize e2e_bot test fees and fix L1 nonce races (backport #20962 #20992 #21148)#21465

Merged
ludamad merged 1 commit intobackport-to-v4-next-stagingfrom
claudebox/fix-bot-fee-v4-next
Mar 13, 2026
Merged

fix: stabilize e2e_bot test fees and fix L1 nonce races (backport #20962 #20992 #21148)#21465
ludamad merged 1 commit intobackport-to-v4-next-stagingfrom
claudebox/fix-bot-fee-v4-next

Conversation

@AztecBot
Copy link
Collaborator

Summary

Backports three fixes from next and adds a fourth to stabilize the flaky e2e_bot test on v4-next.

Root cause: The BotFactory was snapshotting maxFeesPerGas once during account setup, then using that stale value for subsequent transactions. L1 baseFee escalation on anvil (from rapid block building) caused fees to exceed the stale cap.

Changes

  1. BotFactory constructor sets wallet fee padding (backport of fix: set wallet minFeePadding in BotFactory constructor #20992)

    • Calls wallet.setMinFeePadding(config.minFeePadding) so all setup transactions use the configured padding instead of the wallet default (0.5x)
  2. GasFees.mul() precision fix (backport of fix: increase minFeePadding in e2e_bot bridge resume tests and harden GasFees.mul() #20962)

    • Uses bigint arithmetic for integer scalars to avoid precision loss
    • Uses Math.ceil for non-integer scalars to ensure fees always round up
  3. Dedicated L1 account for bridge resume tests (backport of fix: use dedicated L1 account for bot bridge resume tests to avoid nonce race #21148)

    • Uses private key index 7 instead of the default mnemonic (shared with the sequencer)
    • Avoids nonce races on approve/deposit calls in bridgeL1FeeJuice
    • Uses getPrivateKey() helper with auto-incrementing index for other tests
  4. Remove stale fee snapshot (new, also in fix: remove stale fee snapshot from BotFactory and reduce minFeePadding to 10x #21464 on next)

    • Removes explicit maxFeesPerGas snapshot from setupAccountWithPrivateKey
    • Lets the wallet re-estimate fees at send() time via completeFeeOptions()
    • Fresh estimation + 10x padding is sufficient since fee change within 1 block is minimal

Related: A-648, #21453

ClaudeBox log: https://claudebox.work/s/c64a6207b95c4a16?run=4

 #20992 #21148)

BEGIN_COMMIT_OVERRIDE
fix: set wallet minFeePadding in BotFactory constructor (#20992)
fix: increase minFeePadding in e2e_bot bridge resume tests and harden GasFees.mul() (#20962)
fix: use dedicated L1 account for bot bridge resume tests to avoid nonce race (#21148)
fix: remove stale fee snapshot from BotFactory account deployment
END_COMMIT_OVERRIDE

Backports three fixes from next and adds a fourth:

1. BotFactory constructor now calls wallet.setMinFeePadding() so all
   setup transactions (token deploy, minting) use the configured padding
   instead of the wallet default (0.5x). (#20992)

2. GasFees.mul() uses bigint arithmetic for integer scalars to avoid
   precision loss, and Math.ceil for non-integer scalars. (#20962)

3. Bridge resume tests use a dedicated L1 private key (index 7) instead
   of the default mnemonic shared with the sequencer, avoiding nonce
   races on approve/deposit calls. (#21148)

4. Remove explicit maxFeesPerGas snapshot from setupAccountWithPrivateKey.
   Let the wallet re-estimate fees at send() time via completeFeeOptions(),
   making the fee estimate fresh and 10x padding sufficient.
@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Mar 13, 2026
@ludamad ludamad marked this pull request as ready for review March 13, 2026 12:30
@ludamad ludamad enabled auto-merge March 13, 2026 12:30
@ludamad ludamad merged commit ee729f2 into backport-to-v4-next-staging Mar 13, 2026
21 checks passed
@ludamad ludamad deleted the claudebox/fix-bot-fee-v4-next branch March 13, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants