From dad68e7e87c889a9232c16f3aa19f898a60458a2 Mon Sep 17 00:00:00 2001 From: clabby Date: Sat, 20 Jul 2024 14:02:04 -0400 Subject: [PATCH] chore: Bump revm --- Cargo.lock | 140 +++++++++++++++--------------- crates/fpvm/Cargo.toml | 2 +- crates/fpvm/src/page.rs | 2 +- crates/fpvm/src/test_utils/evm.rs | 43 +++++---- 4 files changed, 93 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5103e8c..a62f590 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,20 +46,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] -name = "alloy-primitives" -version = "0.4.2" +name = "alloy-eips" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0628ec0ba5b98b3370bb6be17b12f23bfce8ee4ad83823325a20546d9b03b78" +checksum = "d32a3e14fa0d152d00bd8daf605eb74ad397efb0f54bd7155585823dddb4401e" dependencies = [ + "alloy-primitives", "alloy-rlp", - "bytes", - "cfg-if", - "const-hex", - "derive_more", - "hex-literal", - "itoa", - "ruint", - "tiny-keccak", + "c-kzg", + "k256", + "once_cell", + "serde", ] [[package]] @@ -159,7 +156,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" dependencies = [ - "alloy-primitives 0.7.7", + "alloy-primitives", "alloy-sol-macro", "const-hex", "serde", @@ -355,11 +352,21 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "aurora-engine-modexp" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aef7712851e524f35fbbb74fa6599c5cd8692056a1c36f9ca0d2001b670e7e5" +dependencies = [ + "hex", + "num", +] + [[package]] name = "auto_impl" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" +checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", @@ -399,36 +406,13 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "bindgen" -version = "0.66.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" -dependencies = [ - "bitflags 2.4.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash 1.1.0", - "shlex", - "syn 2.0.48", - "which", -] - [[package]] name = "bindgen" version = "0.68.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "cexpr", "clang-sys", "lazy_static", @@ -468,9 +452,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -495,9 +479,9 @@ dependencies = [ [[package]] name = "blst" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +checksum = "62dc83a094a71d43eeadd254b1ec2d24cb6a0bb6cadce00df51f0db594711a32" dependencies = [ "cc", "glob", @@ -537,11 +521,10 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "c-kzg" -version = "0.1.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" +checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" dependencies = [ - "bindgen 0.66.1", "blst", "cc", "glob", @@ -554,7 +537,7 @@ dependencies = [ name = "cannon" version = "0.1.0" dependencies = [ - "alloy-primitives 0.7.7", + "alloy-primitives", "anyhow", "cannon-fpvm", "command-fds", @@ -571,7 +554,7 @@ dependencies = [ name = "cannon-fpvm" version = "0.1.0" dependencies = [ - "alloy-primitives 0.7.7", + "alloy-primitives", "alloy-sol-types", "anyhow", "criterion", @@ -594,7 +577,7 @@ dependencies = [ name = "cannon-rs" version = "0.1.0" dependencies = [ - "alloy-primitives 0.7.7", + "alloy-primitives", "anyhow", "cannon", "cannon-fpvm", @@ -937,6 +920,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ecdsa" version = "0.16.9" @@ -1417,7 +1406,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "cfg-if", "libc", ] @@ -1723,7 +1712,7 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" name = "preimage-oracle" version = "0.1.0" dependencies = [ - "alloy-primitives 0.7.7", + "alloy-primitives", "anyhow", "os_pipe", "rand", @@ -1803,7 +1792,7 @@ checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", @@ -1944,33 +1933,40 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "revm" -version = "3.5.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f4ca8ae0345104523b4af1a8a7ea97cfa1865cdb7a7c25d23c1a18d9b48598" +checksum = "c6cfb48bce8ca2113e157bdbddbd5eeb09daac1c903d79ec17085897c38c7c91" dependencies = [ "auto_impl", + "cfg-if", + "dyn-clone", "revm-interpreter", "revm-precompile", + "serde", + "serde_json", ] [[package]] name = "revm-interpreter" -version = "1.3.0" +version = "8.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f959cafdf64a7f89b014fa73dc2325001cf654b3d9400260b212d19a2ebe3da0" +checksum = "e6b0daddea06fc6da5346acc39b32a357bbe3579e9e3d94117d9ae125cd596fc" dependencies = [ "revm-primitives", + "serde", ] [[package]] name = "revm-precompile" -version = "2.2.0" +version = "9.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d360a88223d85709d2e95d4609eb1e19c649c47e28954bfabae5e92bb37e83e" +checksum = "ef55228211251d7b6c7707c3ee13bb70dea4d2fd81ec4034521e4fe31010b2ea" dependencies = [ + "aurora-engine-modexp", + "blst", "c-kzg", + "cfg-if", "k256", - "num", "once_cell", "revm-primitives", "ripemd", @@ -1981,20 +1977,24 @@ dependencies = [ [[package]] name = "revm-primitives" -version = "1.3.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51187b852d9e458816a2e19c81f1dd6c924077e1a8fccd16e4f044f865f299d7" +checksum = "2fc4311037ee093ec50ec734e1424fcb3e12d535c6cef683b75d1c064639630c" dependencies = [ - "alloy-primitives 0.4.2", - "alloy-rlp", + "alloy-eips", + "alloy-primitives", "auto_impl", - "bitflags 2.4.2", + "bitflags 2.6.0", "bitvec", "c-kzg", + "cfg-if", + "derive_more", + "dyn-clone", "enumn", "hashbrown", "hex", "once_cell", + "serde", ] [[package]] @@ -2113,7 +2113,7 @@ version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -2169,18 +2169,19 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" dependencies = [ + "rand", "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" dependencies = [ "cc", ] @@ -2235,6 +2236,7 @@ version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ + "indexmap", "itoa", "ryu", "serde", @@ -2962,7 +2964,7 @@ name = "xkcp-sys" version = "0.0.2" source = "git+https://github.com/DaniPopes/xkcp-rs?rev=40447a5#40447a53ea68350b5925bf1b6f9de4fc6524debd" dependencies = [ - "bindgen 0.68.1", + "bindgen", "cc", ] diff --git a/crates/fpvm/Cargo.toml b/crates/fpvm/Cargo.toml index 5d65abe..8045fad 100644 --- a/crates/fpvm/Cargo.toml +++ b/crates/fpvm/Cargo.toml @@ -22,7 +22,7 @@ alloy-sol-types = "0.7.7" # misc once_cell = "1.19.0" elf = "0.7.4" -revm = { version = "3.5.0", features = ["no_gas_measuring"] } +revm = "12.1.0" tracing = { version = "0.1.40", optional = true } # hashing diff --git a/crates/fpvm/src/page.rs b/crates/fpvm/src/page.rs index c720409..e8bd125 100644 --- a/crates/fpvm/src/page.rs +++ b/crates/fpvm/src/page.rs @@ -102,7 +102,7 @@ impl CachedPage { /// /// ### Returns /// - A [Result] containing the 32 byte merkle root hash of the subtree or an error if the - /// generalized index is too deep. + /// generalized index is too deep. #[inline(always)] pub fn merkleize_subtree(&mut self, g_index: Gindex) -> Result<[u8; 32]> { // Cast to usize to avoid `as usize` everywhere. diff --git a/crates/fpvm/src/test_utils/evm.rs b/crates/fpvm/src/test_utils/evm.rs index 34a4695..b2e9236 100644 --- a/crates/fpvm/src/test_utils/evm.rs +++ b/crates/fpvm/src/test_utils/evm.rs @@ -6,10 +6,10 @@ use anyhow::Result; use revm::{ db::{CacheDB, EmptyDB}, primitives::{ - hex, AccountInfo, Address, Bytecode, Bytes, CreateScheme, Output, ResultAndState, - TransactTo, TxEnv, B256, U256, + hex, AccountInfo, Address, Bytecode, Bytes, Output, ResultAndState, TransactTo, TxEnv, + B256, U256, }, - Database, EVM, + Database, Evm, EvmBuilder, }; /// The address of the deployed MIPS VM on the in-memory EVM. @@ -23,25 +23,23 @@ pub const MIPS_CREATION_CODE: &str = include_str!("../../bindings/mips_creation. pub const PREIMAGE_ORACLE_DEPLOYED_CODE: &str = include_str!("../../bindings/preimage_oracle_deployed.bin"); -/// A wrapper around a [revm] inspector with an in-memory backend that has the MIPS & PreimageOracle +/// A wrapper around a [revm] interpreter with an in-memory backend that has the MIPS & PreimageOracle /// smart contracts deployed at deterministic addresses. This is used for differential testing the /// implementation of the MIPS VM in this crate against the smart contract implementations. -pub struct MipsEVM { - pub inner: EVM, +pub struct MipsEVM<'a, DB: Database> { + pub inner: Evm<'a, (), DB>, } -impl Default for MipsEVM> { +impl<'a> Default for MipsEVM<'a, CacheDB> { fn default() -> Self { Self::new() } } -impl MipsEVM> { +impl<'a> MipsEVM<'a, CacheDB> { /// Creates a new MIPS EVM with an in-memory backend. pub fn new() -> Self { - let mut evm = EVM::default(); - evm.database(CacheDB::default()); - + let evm = EvmBuilder::default().with_db(CacheDB::default()).build(); Self { inner: evm } } @@ -50,7 +48,7 @@ impl MipsEVM> { /// ### Returns /// - A [Result] indicating whether the initialization was successful. pub fn try_init(&mut self) -> Result<()> { - let db = self.inner.db().ok_or(anyhow::anyhow!("Missing database"))?; + let db = self.inner.db_mut(); // Fund the zero address. db.insert_account_info( @@ -78,10 +76,7 @@ impl MipsEVM> { .into_iter() .chain(encoded_preimage_addr) .collect::>(); - self.fill_tx_env( - TransactTo::Create(CreateScheme::Create), - mips_creation_heap.into(), - ); + self.fill_tx_env(TransactTo::Create, mips_creation_heap.into()); if let Ok(ResultAndState { result: revm::primitives::ExecutionResult::Success { @@ -92,7 +87,7 @@ impl MipsEVM> { output: Output::Create(code, _), }, state: _, - }) = self.inner.transact_ref() + }) = self.inner.transact() { // Deploy the MIPS contract manually. self.deploy_contract(Address::from_slice(MIPS_ADDR.as_slice()), code) @@ -109,7 +104,7 @@ impl MipsEVM> { /// /// ### Returns /// - A [Result] containing the post-state hash of the MIPS VM or an error returned during - /// execution. + /// execution. pub fn step(&mut self, witness: StepWitness) -> Result { if witness.has_preimage() { crate::debug!( @@ -148,7 +143,7 @@ impl MipsEVM> { output: Output::Call(output), }, state: _, - }) = self.inner.transact_ref() + }) = self.inner.transact() { let output = B256::from_slice(&output); @@ -158,7 +153,7 @@ impl MipsEVM> { anyhow::bail!("Expected 1 log, got {}", logs.len()); } - let post_state: StateWitness = logs[0].data.to_vec().as_slice().try_into()?; + let post_state: StateWitness = logs[0].data.data.to_vec().as_slice().try_into()?; if post_state.state_hash().as_slice() != output.as_slice() { anyhow::bail!( @@ -187,7 +182,7 @@ impl MipsEVM> { code_hash: B256::ZERO, code: Some(Bytecode::new_raw(code)), }; - let db = self.inner.db().ok_or(anyhow::anyhow!("Missing database"))?; + let db = self.inner.db_mut(); db.insert_contract(&mut acc_info); db.insert_account_info(addr, acc_info); Ok(()) @@ -200,7 +195,8 @@ impl MipsEVM> { /// - `data`: The calldata for the transaction. /// - `to`: The address of the contract to call. pub(crate) fn fill_tx_env(&mut self, transact_to: TransactTo, data: Bytes) { - self.inner.env.tx = TxEnv { + let tx_env = self.inner.tx_mut(); + *tx_env = TxEnv { caller: Address::ZERO, gas_limit: u64::MAX, gas_price: U256::ZERO, @@ -213,6 +209,7 @@ impl MipsEVM> { access_list: Vec::default(), blob_hashes: Vec::default(), max_fee_per_blob_gas: None, + authorization_list: None, }; } } @@ -244,7 +241,7 @@ mod test { Bytes::from(SAMPLE.to_vec()), ); - let ResultAndState { result, state: _ } = mips_evm.inner.transact_ref().unwrap(); + let ResultAndState { result, state: _ } = mips_evm.inner.transact().unwrap(); assert!(result.is_success()); let ExecutionResult::Success {