Skip to content

Conversation

@gakonst
Copy link
Member

@gakonst gakonst commented Jan 23, 2026

Summary

Adds revmc-reth crate for automatic JIT compilation of hot contracts in reth, OP-reth, and Tempo.

Features

  • Hot contract detection: Tracks cumulative gas per bytecode hash, queues for compilation when threshold exceeded
  • Background compilation: Worker threads compile contracts asynchronously (default: 2 threads)
  • LRU cache: Configurable cache size (default: 1024 contracts)
  • Thread-safe: Uses parking_lot and channels, no unsafe statics
  • Zero-config fallback: Always falls back to interpreter for uncompiled bytecode

Configuration

// Presets
RevmcConfig::default()        // Standard config
RevmcConfig::low_memory()     // Smaller cache, single worker
RevmcConfig::high_performance() // Larger cache, more workers

// Custom
RevmcConfig::default()
    .with_enabled(true)           // CLI flag support
    .with_hot_threshold(500_000)  // Gas threshold
    .with_cache_size(2048)        // Max cached functions

Integration

Works with all three targets via revm's handler system:

  • reth/OP-reth: Hook execute_frame handler
  • Tempo: Each call in AA multi-call batch tracked independently

Closes

Replaces PR #73 (revmc-worker) with a cleaner, safer implementation.


Stacked on main (post #80 merge).

This crate provides automatic JIT compilation for frequently-executed EVM bytecode:

- Hot contract detection based on cumulative gas usage
- Background compilation workers (configurable thread count)
- LRU cache for compiled functions (configurable size)
- Thread-safe implementation (no unsafe statics)
- CLI flag support (--jit / --no-jit)
- Works with standard txs and Tempo AA multi-call batches

Integration points:
- reth: register handler on execute_frame
- OP-reth: same as reth
- Tempo: track each call target in AA batches independently

Amp-Thread-ID: https://ampcode.com/threads/T-019bec02-ab99-77dc-89fb-73ef7c9f5381
Co-authored-by: Amp <[email protected]>
@gakonst gakonst requested a review from DaniPopes as a code owner January 23, 2026 18:51
gakonst and others added 2 commits January 23, 2026 10:59
Demonstrates:
- Creating RevmcRuntime with custom config
- Hot detection triggering compilation at gas threshold
- Background compilation by worker threads
- Statistics output (hit rate, cache usage, pending)

Amp-Thread-ID: https://ampcode.com/threads/T-019bec36-0d47-7393-a66b-2b0f41e4ffd7
Co-authored-by: Amp <[email protected]>
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.

2 participants