Skip to content

feat(rpc): implement movePrecompileToAddress for eth_simulateV1#21414

Merged
mattsse merged 1 commit intomainfrom
feat/move-precompile-to-address
Jan 26, 2026
Merged

feat(rpc): implement movePrecompileToAddress for eth_simulateV1#21414
mattsse merged 1 commit intomainfrom
feat/move-precompile-to-address

Conversation

@mattsse
Copy link
Collaborator

@mattsse mattsse commented Jan 25, 2026

Summary

This PR adds support for the movePrecompileToAddress state override in eth_simulateV1, allowing callers to move precompiles from their original addresses to new destinations.

Dependencies

⚠️ This PR depends on alloy-rs/alloy#3589 which adds the serde alias for MovePrecompileToAddress (the field uses PascalCase in the JSON-RPC spec but alloy expects camelCase).

Changes

crates/rpc/rpc-eth-types/src/simulate.rs

  • Add NotAPrecompile(Address) error variant with error code -32000 (matching other clients)
  • Add apply_precompile_overrides() function that:
    • Extracts movePrecompileToAddress entries from state overrides
    • Validates source addresses are actual precompiles before applying changes
    • Moves precompiles to new destinations, clearing the source address
    • Handles self-references (source == dest) as no-ops
    • Allows multiple precompiles to be moved to the same destination (per spec)

crates/rpc/rpc-eth-api/src/helpers/call.rs

  • Add BlockBuilder trait import to access evm_mut()
  • Modified state override handling to keep a reference after applying to database
  • Integrate apply_precompile_overrides() after EVM/builder creation, before transaction execution (in both inspector and non-inspector code paths)

Test Cases Addressed

Based on hive test analysis:

Test Expected Behavior Status
ethSimulate-move-ecrecover-and-call-old-and-new Move precompile works at new address, original becomes empty
ethSimulate-move-ecrecover-and-call Precompile works at new address after move
ethSimulate-move-ecrecover-twice-and-call Sequential moves work correctly
ethSimulate-move-two-accounts-to-same-38023 Multiple precompiles to same destination allowed
ethSimulate-move-to-address-itself-reference-38022 Non-precompile returns error -32000
ethSimulate-try-to-move-non-precompile Non-precompile returns error -32000

Related

@mattsse mattsse added the A-rpc Related to the RPC implementation label Jan 25, 2026
@mattsse mattsse added the A-rpc Related to the RPC implementation label Jan 25, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 25, 2026
This adds support for the movePrecompileToAddress state override in eth_simulateV1,
allowing callers to move precompiles from their original addresses to new destinations.

Changes:
- Add NotAPrecompile error variant with error code -32000
- Add apply_precompile_overrides function to handle precompile moves
- Integrate precompile override application after EVM creation in simulate_v1
- Validate that source addresses are actual precompiles before moving
- Support moving multiple precompiles to the same destination
- Handle self-reference (source == dest) as no-op

Amp-Thread-ID: https://ampcode.com/threads/T-019bf5d7-2b64-7619-92d4-2934b62708bd
Co-authored-by: Amp <amp@ampcode.com>
@mattsse mattsse force-pushed the feat/move-precompile-to-address branch from 04ae2cf to ff9d896 Compare January 25, 2026 16:05
Copy link
Member

@klkvr klkvr left a comment

Choose a reason for hiding this comment

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

cool

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Jan 26, 2026
@mattsse mattsse added this pull request to the merge queue Jan 26, 2026
Merged via the queue into main with commit d4f28b0 Jan 26, 2026
46 checks passed
@mattsse mattsse deleted the feat/move-precompile-to-address branch January 26, 2026 12:48
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Jan 26, 2026
rakita pushed a commit that referenced this pull request Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rpc Related to the RPC implementation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants