Skip to content

Conversation

@gakonst
Copy link
Contributor

@gakonst gakonst commented Feb 9, 2026

Summary

Fix flaky ANVIL FORK: FORGE SCRIPT BROADCAST failures caused by fee token exhaustion.

Motivation

The anvil fork tests reused $PK — the same wallet drained by 27+ prior devnet transactions (liquidity additions, DEX swaps, sponsor tests, batch tests). By the time the fork snapshot was taken, the account had insufficient PathUSD to pay gas, causing intermittent Out of gas: gas required exceeds allowance: 0 and Insufficient funds for gas * price + value errors.

Failing workflow: tempo-tests-wmj9p

Thread: https://tempoxyz.slack.com/archives/C0A6PD3BQ3F/p1770616527072009

Changes

  • Generate a fresh wallet (FORK_PK/FORK_ADDR) and fund it via tempo_fundAddress before starting the forked anvil
  • Replace all $PK references in the anvil fork section with $FORK_PK
  • Wait for funding to settle before forking

Testing

N/A — CI script change, will be validated by the next tempo-tests workflow run.

The anvil fork tests reused the same wallet ($PK) that was drained by
prior devnet tests (liquidity, swaps, sponsors, batches). By the time
the fork tests ran, the account had insufficient fee token balance,
causing flaky 'Insufficient funds' / 'Out of gas' errors.

Generate a new wallet and fund it via tempo_fundAddress before forking,
so the fork snapshot always has a fully-funded account.

Amp-Thread-ID: https://ampcode.com/threads/T-019c40f9-c790-771a-a1d5-5524db9edb2d
Co-authored-by: Amp <amp@ampcode.com>
gakonst and others added 4 commits February 9, 2026 06:16
The sleep 5 was not reliable — funding txs could still be pending when
anvil forked. Poll the fee token balance instead to confirm the funding
is actually mined before taking the fork snapshot.

Amp-Thread-ID: https://ampcode.com/threads/T-019c40f9-c790-771a-a1d5-5524db9edb2d
Co-authored-by: Amp <amp@ampcode.com>
Extract fund_and_wait() helper that calls tempo_fundAddress then polls
the fee token balanceOf until non-zero. Replaces unreliable sleep 3/5
after funding the main wallet, access key, sponsor, and fork wallet.

All four funding sites had the same race: the funding txs could still
be pending when the next step ran, causing 'insufficient funds' errors.

Amp-Thread-ID: https://ampcode.com/threads/T-019c40f9-c790-771a-a1d5-5524db9edb2d
Co-authored-by: Amp <amp@ampcode.com>
The fresh fork wallet had fee token balance but never had setUserToken()
called, so the fee controller didn't know which token to charge for gas.
The first broadcast tx (setUserToken itself) failed because gas allowance
was 0 — a chicken-and-egg problem.

Call setUserToken on the devnet before starting the fork so the snapshot
includes the fee token configuration.

Amp-Thread-ID: https://ampcode.com/threads/T-019c40f9-c790-771a-a1d5-5524db9edb2d
Co-authored-by: Amp <amp@ampcode.com>
The fork wallet has no native ETH balance — only fee tokens from
tempo_fundAddress. When FEE_TOKEN_ARG is empty (default PathUSD),
forge script doesn't include feeToken in eth_estimateGas requests,
causing anvil to check ETH balance instead of fee token balance.
Gas allowance computes to 0 and the tx is rejected.

Always pass --tempo.fee-token explicitly for fork forge script
commands so anvil knows to check fee token balance.

Amp-Thread-ID: https://ampcode.com/threads/T-019c40f9-c790-771a-a1d5-5524db9edb2d
Co-authored-by: Amp <amp@ampcode.com>
@grandizzy grandizzy merged commit 3058e54 into tempo Feb 9, 2026
11 of 16 checks passed
@grandizzy grandizzy deleted the georgios/fix-anvil-fork-wallet branch February 9, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants