From 2a992040db1aa5dfd51400777e71432483379dd9 Mon Sep 17 00:00:00 2001 From: Akase Haruka Date: Wed, 17 Jul 2024 20:06:41 +0800 Subject: [PATCH] chore: upgrade revm to v40 (#1360) * upgrade revm * fix upgrade * fix * upgrade to v38 * fix * upgrade to v40 --- Cargo.lock | 60 +++++++++++++++++++++++++---------- Cargo.toml | 4 +-- bus-mapping/src/precompile.rs | 20 ++++++------ eth-types/src/l2_types.rs | 17 ++++------ 4 files changed, 63 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 699d69ef03..7010a64f7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -99,11 +99,25 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alloy-eips" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32a3e14fa0d152d00bd8daf605eb74ad397efb0f54bd7155585823dddb4401e" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "c-kzg", + "k256", + "once_cell", + "serde", +] + [[package]] name = "alloy-primitives" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8aa973e647ec336810a9356af8aea787249c9d00b1525359f3db29a68d231b" +checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" dependencies = [ "alloy-rlp", "bytes", @@ -127,10 +141,22 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" dependencies = [ + "alloy-rlp-derive", "arrayvec", "bytes", ] +[[package]] +name = "alloy-rlp-derive" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83524c1f6162fcb5b0decf775498a125066c86dda6066ed609531b0e912f85a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -484,9 +510,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitstream-io" @@ -2669,7 +2695,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -3447,7 +3473,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", @@ -3696,11 +3722,12 @@ dependencies = [ [[package]] name = "revm-precompile" -version = "7.0.0" -source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#30613ed430505b7c11f335d265dc561e485c94bf" +version = "9.2.0" +source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v40#03b072906faf3f826e4daf38ca0be69a73d90ce3" dependencies = [ "aurora-engine-modexp", "c-kzg", + "cfg-if 1.0.0", "k256", "once_cell", "revm-primitives", @@ -3712,12 +3739,13 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "4.0.0" -source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#30613ed430505b7c11f335d265dc561e485c94bf" +version = "7.1.0" +source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v40#03b072906faf3f826e4daf38ca0be69a73d90ce3" dependencies = [ + "alloy-eips", "alloy-primitives", "auto_impl", - "bitflags 2.5.0", + "bitflags 2.6.0", "bitvec", "c-kzg", "cfg-if 1.0.0", @@ -3823,9 +3851,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -3847,9 +3875,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-demangle" @@ -3893,7 +3921,7 @@ version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", diff --git a/Cargo.toml b/Cargo.toml index 19554d12ec..162fcf8bfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,8 +63,8 @@ strum_macros = "0.25" subtle = "2.4" tokio = { version = "1.13", features = ["macros", "rt-multi-thread"] } url = "2.2" -revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v36", default-features = false, features = ["std"] } # v36 -revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v36", default-features = false, features = ["std"] } # v36 +revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v40", default-features = false, features = ["std"] } # v40 +revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v40", default-features = false, features = ["std"] } # v40 c-kzg = "1.0.2" [patch.crates-io] diff --git a/bus-mapping/src/precompile.rs b/bus-mapping/src/precompile.rs index 4930cdf6c6..3c2c52bd7e 100644 --- a/bus-mapping/src/precompile.rs +++ b/bus-mapping/src/precompile.rs @@ -1,7 +1,7 @@ //! precompile helpers use eth_types::{evm_types::GasCost, Address, ToBigEndian, Word}; -use revm_precompile::{Precompile, PrecompileError, Precompiles}; +use revm_precompile::{Precompile, PrecompileError, PrecompileErrors, Precompiles}; use strum_macros::EnumIter; use crate::circuit_input_builder::{EcMulOp, EcPairingOp}; @@ -27,15 +27,15 @@ pub(crate) fn execute_precompiled( hex::encode(input) ); let (return_data, gas_cost, is_oog, is_ok) = match precompile_fn(&input.to_vec().into(), gas) { - Ok((gas_cost, return_value)) => (return_value.to_vec(), gas_cost, false, true), - Err(err) => match err { - PrecompileError::OutOfGas => (vec![], gas, true, false), - PrecompileError::NotImplemented => (vec![], gas, false, false), - _ => { - log::warn!("unknown precompile err {err:?}"); - (vec![], gas, false, false) - } - }, + Ok(output) => (output.bytes.to_vec(), output.gas_used, false, true), + Err(PrecompileErrors::Error(PrecompileError::OutOfGas)) => (vec![], gas, true, false), + Err(PrecompileErrors::Error(PrecompileError::NotImplemented)) => { + (vec![], gas, false, false) + } + Err(err) => { + log::warn!("unknown precompile err {err:?}"); + (vec![], gas, false, false) + } }; log::trace!("called precompile with is_ok {is_ok} is_oog {is_oog}, gas_cost {gas_cost}, return_data len {}, return_data {}", return_data.len(), hex::encode(&return_data)); (return_data, gas_cost, is_oog) diff --git a/eth-types/src/l2_types.rs b/eth-types/src/l2_types.rs index b9f489f838..2fb21295b2 100644 --- a/eth-types/src/l2_types.rs +++ b/eth-types/src/l2_types.rs @@ -359,16 +359,13 @@ impl From<&TransactionTrace> for revm_primitives::TxEnv { .as_ref() .map(|v| { v.iter() - .map(|e| { - ( - e.address.0.into(), - e.storage_keys - .iter() - .map(|s| { - revm_primitives::U256::from_be_bytes(s.to_fixed_bytes()) - }) - .collect(), - ) + .map(|e| revm_primitives::AccessListItem { + address: e.address.0.into(), + storage_keys: e + .storage_keys + .iter() + .map(|s| s.to_fixed_bytes().into()) + .collect(), }) .collect() })