Skip to content

Conversation

@gakonst
Copy link
Contributor

@gakonst gakonst commented Feb 10, 2026

Summary

Fixes invariant test runner hanging indefinitely when using --fork-url against a Tempo RPC.

Closes #251

Motivation

Tempo precompile addresses (0xDEc0..., 0x20C0...) are Rust-native precompiles with no real EVM bytecode on-chain. The RPC returns empty code (0x) or sentinel bytecode (0xef) for these addresses.

In fork mode, the SharedBackend sends RPC requests for every uncached account/storage access using tokio::task::block_in_place() + recv(). During invariant fuzzing — which involves many rapid executor clone + snapshot/revert cycles — the repeated cache misses for precompile addresses create a pathological RPC storm that effectively hangs the test runner.

Simple fork tests work because they only touch precompile addresses a few times and the responses are fast enough. Invariant fuzzing amplifies the problem by orders of magnitude.

Changes

  • crates/evm/evm/src/tempo.rs: add warm_tempo_precompile_accounts() which pre-populates sentinel bytecode (0xef) into the local fork cache for all known precompile (0xDEc0...) and TIP20 token (0x20C0...) addresses. Gated to known Tempo chain IDs only.
  • crates/forge/src/runner.rs: call the warm function in fork mode (else branch of the existing precompile init guard).

Testing

  • cargo check -p foundry-evm -p forge
  • cargo clippy -p foundry-evm -p forge -- -D warnings
  • Verified RPC behavior: eth_getCode returns 0x for StablecoinDEX, 0xef for TIP20 tokens
  • The fix only affects Tempo chain IDs (4217, 42429, 42431) — no impact on Ethereum/L2 fork tests

Thread: https://tempoxyz.slack.com/archives/C0A87C21805/p1770734618130419

…iant hang

In fork mode against a Tempo RPC, precompile addresses (0xDEc0..., 0x20C0...)
are Rust-native precompiles with no real EVM bytecode. The RPC returns empty
code or sentinel bytecode for these addresses, causing the fork backend to
repeatedly fetch them via RPC on every access. During invariant fuzzing, this
creates a pathological RPC storm that effectively hangs the test runner.

This fix adds warm_tempo_precompile_accounts() which pre-populates sentinel
bytecode into the local fork cache for all known precompile and TIP20 token
addresses, gated to Tempo chain IDs only.

Closes #251

Amp-Thread-ID: https://ampcode.com/threads/T-019c4802-1267-7277-8001-796209967317
Co-authored-by: Amp <amp@ampcode.com>
Copy link
Contributor

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! let's move these in a common place and reuse across all places

const PATH_USD: Address = address!("20C0000000000000000000000000000000000000");
const ALPHA_USD: Address = address!("20C0000000000000000000000000000000000001");
const BETA_USD: Address = address!("20C0000000000000000000000000000000000002");
const THETA_USD: Address = address!("20C0000000000000000000000000000000000003");

@zerosnacks zerosnacks self-assigned this Feb 10, 2026
Move PATH_USD, ALPHA_USD, BETA_USD, THETA_USD constants to
foundry-evm-core/src/tempo.rs as the shared source of truth, and
reuse them in anvil backend, anvil tests, and the fork warm function.

Also fixes rustfmt import ordering.

Amp-Thread-ID: https://ampcode.com/threads/T-019c4802-1267-7277-8001-796209967317
Co-authored-by: Amp <amp@ampcode.com>
@zerosnacks
Copy link
Contributor

nice! let's move these in a common place and reuse across all places

const PATH_USD: Address = address!("20C0000000000000000000000000000000000000");
const ALPHA_USD: Address = address!("20C0000000000000000000000000000000000001");
const BETA_USD: Address = address!("20C0000000000000000000000000000000000002");
const THETA_USD: Address = address!("20C0000000000000000000000000000000000003");

Good call, fixed in 65bff21

@zerosnacks zerosnacks merged commit 2936163 into tempo Feb 10, 2026
11 of 13 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/fix-invariant-fork-hang branch February 10, 2026 15:45
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.

bug: invariant test runner hangs indefinitely with --fork-url against Tempo RPC

3 participants