Commit aa725dc
authored
fix(e2e): give token_bridge_tutorial its own L1 account to avoid sequencer nonce race (#24386)
## Root cause
`e2e_token_bridge_tutorial_test` flakes with
`WaitForTransactionReceiptTimeoutError: Timed out while waiting for
transaction … to be confirmed`
([example](http://ci.aztec-labs.com/1643e817d7242e0e)). It is **not**
caused by #24378 — that PR only touches `forge_broadcast.js` (the L1
*contract deploy*), which succeeds in the failing run; the timeout is
~3.5 min later on one of the test's own L1 txs.
The test runs against `aztec start --local-network`, whose
`AutomineSequencer` continuously publishes checkpoint txs to L1. In
`local-network.ts` the sequencer-publisher and validator keys are
derived from `DefaultMnemonic` (`'test test … junk'`) at **address index
0** — `0xf39Fd6…` (visible as the publisher in the log).
The test's L1 client was created with the **same** mnemonic and the
**same** default index 0:
```ts
const l1Client = createExtendedL1Client(ETHEREUM_HOSTS.split(','), MNEMONIC); // → account index 0
```
So the test and the node's sequencer send L1 txs from one account,
sharing a single nonce sequence. Against an automining anvil they race:
a test tx can land with a nonce the sequencer just consumed (dropped /
"already known"), or with a future-nonce gap that automine won't mine
until the gap fills. Either way the tx gets a hash but never confirms,
and viem's per-tx confirmation timeout fires. This is intermittent
because it only bites when a test tx and a sequencer publish overlap.
## Fix
Derive the test's L1 client from a **different** address index so its
nonce space is independent of the sequencer's:
```ts
const l1Client = createExtendedL1Client(ETHEREUM_HOSTS.split(','), mnemonicToAccount(MNEMONIC, { addressIndex: 1 }));
```
Index 1 (`0x70997970…`) is funded by anvil's default mnemonic and is
unused by the local-network node (publisher/validator = index 0; index 2
is the prover and 3+ are attesters by the existing `setup.ts` /
`setup_p2p_test.ts` convention, none of which run in local-network). The
test is fully self-contained on its own L1 account — it deploys and owns
the `TestERC20`, `FeeAssetHandler` and `TokenPortal`, and bridges
to/from `l1Client.account.address` — so nothing requires it to be
account 0. All of the test's L1 txs (including the `L1TokenManager` /
`L1TokenPortalManager`, built from `l1Client`) now go through index 1.
## Verification
This is an `compose` e2e test that needs docker + a full network; the
container here is a source-only checkout (no `node_modules`, no docker),
so I could not run the test or `./bootstrap.sh ci` locally — flagging
that explicitly per the repo's red/green policy. The fix is verified by
analysis: the timed-out tx is one of the test's own L1 txs, the
shared-account nonce race is the established cause of this exact viem
symptom, and account index 0 vs 1 are the well-known distinct anvil
accounts (idx 0 = `0xf39Fd6…`, the publisher in the log; idx 1 =
`0x70997970…`).
## Relationship to #24385
#24385 broadened this test's `.test_patterns.yml` flake pattern to keep
CI from going red on the residual flake. This PR removes the underlying
cause. The flake entry can stay as a safety net, or be narrowed back to
the jest-timeout-only form once this has soaked — happy to follow up
either way.
---
*Created by
[claudebox](https://claudebox.work/v2/sessions/c01cbe3dd422bf00) ·
group: `slackbot`*1 parent 1ac6046 commit aa725dc
1 file changed
Lines changed: 7 additions & 1 deletion
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| |||
0 commit comments