Skip to content

bump(revm: step 3): reintroduce precompile injection #10508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: yash/revm-alloy-bumps
Choose a base branch
from

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented May 13, 2025

Motivation

Closes: #10411

Builds on top of: #10454 which in turns builds on top of #10183

Solution

Uses alloy-evm's new dynamic precompile injection

Adds tests for OpEvm and EthEvm

Breaking changes

  • I've changed the Vec<(Address, Precompiles)> signature to be Vec<PrecompileWithAddress> as Revm uses this internally and it simplifies the carrying. For end-users the change is expected to be straightforward, they just wrap using PrecompileWithAddress::from(..)

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks zerosnacks self-assigned this May 13, 2025
@zerosnacks zerosnacks added the A-dependencies Area: dependencies label May 13, 2025
@zerosnacks zerosnacks added the T-chore Type: chore label May 13, 2025
@grandizzy grandizzy moved this to In Progress in Foundry May 13, 2025
@zerosnacks zerosnacks changed the title draft: reintroduce precompile injection bump(revm: step 3): (draft) reintroduce precompile injection May 13, 2025
@zerosnacks zerosnacks requested a review from yash-atreya May 13, 2025 17:43

/// Object-safe trait that enables injecting extra precompiles when using
/// `anvil` as a library.
pub trait PrecompileFactory: Send + Sync + Unpin + Debug {
/// Returns a set of precompiles to extend the EVM with.
fn precompiles(&self) -> Vec<(Address, Precompiles)>;
fn precompiles(&self) -> Vec<PrecompileWithAddress>;
Copy link
Member

@yash-atreya yash-atreya May 13, 2025

Choose a reason for hiding this comment

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

This is breaking but its fine. This feature is mostly geared towards anvil as a library users. There aren't many I would assume.

Copy link
Member

@yash-atreya yash-atreya left a comment

Choose a reason for hiding this comment

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

lgtm!

@zerosnacks zerosnacks added the T-likely-breaking Type: requires changes that can be breaking label May 14, 2025
@zerosnacks zerosnacks marked this pull request as ready for review May 14, 2025 07:21
@zerosnacks zerosnacks changed the title bump(revm: step 3): (draft) reintroduce precompile injection bump(revm: step 3): reintroduce precompile injection May 14, 2025
@zerosnacks zerosnacks removed A-dependencies Area: dependencies T-chore Type: chore labels May 14, 2025
@zerosnacks zerosnacks moved this from In Progress to Ready For Review in Foundry May 14, 2025
@@ -472,7 +472,7 @@ where
evm_context,
inspector,
EthInstructions::default(),
FoundryPrecompiles::new(),
PrecompilesMap::from_static(EthPrecompiles::default().precompiles),
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since tests are passing, can you suggest a test to add to avoid such regression?

Copy link
Member

Choose a reason for hiding this comment

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

one way to test it is to make sure that BLS precompile is not available before Prague as the bug is that all precompiles are always activated

it's not that important for foundry though I guess, would've been a more severe bug in reth :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! I've fixed it and added additional tests: 084c0ad

We currently pin to OpSpecId::BEDROCK for Optimism but ideally we will want to support the latest OP hardforks. Added a ticket for it here: #10521

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.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-likely-breaking Type: requires changes that can be breaking
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

4 participants