Skip to content

bump(revm: step 1): bump revm to 21.0.0 release #10183

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 211 commits into
base: master
Choose a base branch
from

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Mar 26, 2025

Stacked PRs:

Benchmarks forge test

Project Before (v1.2.0-rc) After (revm 23 @ ec4ffd3) Change %
uniswap v4-core 5.21s 4.43s –14.97%
spark-psm 17.48s 14.76s –15.56%
morpho-blue 1.81s 1.67s –7.73%
morpho-blue (invariant) 1.66s 1.57s –5.42%
morpho-blue (integration) 0.67s 0.62s –7.46%
sablier lockup 20.44s 17.45s –14.63%
solady 4.31s 3.37s –21.80%
euler evc 16.05s 13.65s –14.95%

Conclusion: on average at least 12% faster!

Notes:

  • Benchmarks only measure running of tests and are pre-build
  • Solady fuzz runs has been bumped to 1024 from 256 for all tests
  • Sablier lockup excludes forked fuzz tests for all cases due to RPC unavailability
  • Euler EVC tests were patched to constrain deadline to type(uint64).max - 1 on all cases, now enforced (see breaking changes)

Benchmarks anvil

mem and cpu

ref #7940 (comment)

Nightly 1.2.0-nightly Commit SHA: 58297d3 Pr
nightly pr
https://github.com/PhilippLgh/anvil-perf

ref #4399 (comment)

Chunk v1.1 (ms) v1.2 (ms) new revm (ms) Speedup
1 0 0 0 x0.00
2 39 39 36 x1.08
3 63 64 58 x1.10
4 86 87 77 x1.12
5 107 108 95 x1.13
6 128 129 114 x1.13
7 148 148 132 x1.12
8 168 169 149 x1.13
9 189 189 166 x1.13
10 208 209 184 x1.13
11 226 230 201 x1.14
12 245 250 219 x1.14
13 266 270 236 x1.14
14 288 290 253 x1.14
15 308 310 270 x1.14
20 423 428 368 x1.16
25 516 524 451 x1.16
30 606 621 533 x1.16
35 698 717 614 x1.16
40 795 812 692 x1.17
50 984 1003 855 x1.17
65 1263 1292 1113 x1.16
https://github.com/mshakeg/anvil-backtester

ref #6017 (comment)) - blocksToMine: 10, nullSwapsPerBlock: 2000, totalTxs: 40000, 3 runs

metric Nightly 1.2.0-nightly Commit SHA: 58297d3 Pr
executionTime run1: 4.67
run2: 4.605
run3: 4.626
run1: 4.667
run2: 4.672
run3: 4.676
averageTPS
(more is better)
run1: 8565.310492505354
run2: 8686.210640608035
run3: 8646.779074794638
run1: 8570.816370259268
run2: 8561.643835616438
run3: 8554.31993156544
averageTimePerTx
(less is better)
run1: 0.11674999999999999
run2: 0.115125
run3: 0.11565
run1: 0.116748
run2: 0.1168
run3: 0.1169
https://github.com/xmtp/xmtpd

ref #10122 (comment)

Nightly 1.2.0-nightly Commit SHA: 58297d3 Pr
29.361s
29.907s
29.856s
29.867s
29.890s
29.807s
29.988s
29.771s
30.017s
29.769s

Known breaking changes ❗ ⚠️

Revm now operates on u64 for the following fields:

  • chain id
  • tx.gas_price
  • block.basefee
  • block.number
  • block.timestamp

Thereforce we must constrain the input we accept to up u64::max for the following cheatcodes:

  • vm.chainId
  • vm.fee
  • vm.roll
  • vm.txGasPrice
  • vm.warp
  • vm.setBlockhash

These cheatcodes will raise an error if a value > u64::max is passed.

Because of these Revm fields changing the Anvil state files are known to currently break, this can possibly be handled in a follow-up where we flexibly read from old state files but write in the new form. This is not currently handled in this PR.

Closes

Closes: #10367

Follow ups that will become unlocked, to check

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks zerosnacks added A-dependencies Area: dependencies T-chore Type: chore labels Mar 26, 2025
@zerosnacks zerosnacks moved this to In Progress in Foundry Mar 26, 2025
@zerosnacks zerosnacks added this to the v1.1.0 milestone Mar 26, 2025
@klkvr klkvr force-pushed the zerosnacks/revm-bump-2 branch from ade941f to fc6b765 Compare May 11, 2025 22:30
@klkvr klkvr force-pushed the zerosnacks/revm-bump-2 branch from 4e3f71d to 7e2b0ea Compare May 12, 2025 12:32
@klkvr klkvr force-pushed the zerosnacks/revm-bump-2 branch from 7e2b0ea to 4b4da4a Compare May 12, 2025 12:34
@zerosnacks zerosnacks changed the title chore: bump revm to 21.0.0 release bump(revm: step 1): bump revm to 21.0.0 release May 13, 2025
@zerosnacks zerosnacks requested a review from klkvr May 14, 2025 07:22
@zerosnacks zerosnacks added the T-likely-breaking Type: requires changes that can be breaking label May 14, 2025
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

okiee,

some things required workarounds but overall this lgtm even though the total diff is quite large

is_system_transaction: *is_system_tx,
};

OpTransaction { base, deposit, enveloped_tx: None }
Copy link
Member

Choose a reason for hiding this comment

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

this we need to always set to the encoded2718 value

or maybe not, depdning on how this will be executed

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this is currently handled downstream

if env.is_optimism {
env.tx.enveloped_tx =
Some(alloy_rlp::encode(&tx.pending_transaction.transaction.transaction).into());
}

fn env_for(&self, tx: &PendingTransaction) -> Env {
let mut tx_env = tx.to_revm_tx_env();
if self.optimism {
tx_env.enveloped_tx = Some(alloy_rlp::encode(&tx.transaction.transaction).into());
}
Env::new(self.cfg_env.clone(), self.block_env.clone(), tx_env, self.optimism)
}

This field was also previously None

@@ -267,7 +267,7 @@ impl CallArgs {
let tx_kind = tx.inner.to.expect("set by builder");

if let Some(access_list) = tx.inner.access_list {
executor.env_mut().tx.access_list = access_list.0
executor.env_mut().tx.access_list = access_list;
Copy link
Member

Choose a reason for hiding this comment

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

maybe we also need to set the tx type here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 9a4fb2b

Copy link
Collaborator

@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.

that's great, left couple of nits and some questions if we could decouple more from op?

@zerosnacks zerosnacks requested review from grandizzy and mattsse May 15, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependencies Area: dependencies T-chore Type: chore T-likely-breaking Type: requires changes that can be breaking
Projects
Status: Ready For Review
8 participants