From 6365fe96c79935954226f60f380ff06181e1fdfe Mon Sep 17 00:00:00 2001 From: Bear Wang Date: Fri, 29 Dec 2023 11:05:35 +0800 Subject: [PATCH] Update evm to v0.41.1 (#1259) (#19) Co-authored-by: Wei Tang --- Cargo.lock | 62 +++++++++-------------- Cargo.toml | 4 +- frame/evm/precompile/dispatch/src/lib.rs | 7 ++- frame/evm/precompile/dispatch/src/mock.rs | 1 + frame/evm/src/runner/stack.rs | 3 +- frame/evm/test-vector-support/src/lib.rs | 7 ++- precompiles/src/evm/handle.rs | 3 +- precompiles/src/precompile_set.rs | 4 +- precompiles/src/substrate.rs | 2 +- precompiles/src/testing/handle.rs | 1 + precompiles/tests-external/lib.rs | 1 + 11 files changed, 49 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e1ae53ad4..212b4ec94a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2328,20 +2328,20 @@ dependencies = [ [[package]] name = "ethereum" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89fb87a9e103f71b903b80b670200b54cc67a07578f070681f1fffb7396fb7" +checksum = "2e04d24d20b8ff2235cffbf242d5092de3aa45f77c5270ddbfadd2778ca13fea" dependencies = [ "bytes", "ethereum-types", - "hash-db 0.15.2", + "hash-db", "hash256-std-hasher", "parity-scale-codec", "rlp", "scale-info", "serde", "sha3", - "triehash", + "trie-root", ] [[package]] @@ -2368,8 +2368,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" -version = "0.39.1" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767f43e9630cc36cf8ff2777cbb0121b055f0d1fd6eaaa13b46a1808f0d0e7e9" dependencies = [ "auto_impl", "environmental", @@ -2388,8 +2389,9 @@ dependencies = [ [[package]] name = "evm-core" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1da6cedc5cedb4208e59467106db0d1f50db01b920920589f8e672c02fdc04f" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2399,8 +2401,9 @@ dependencies = [ [[package]] name = "evm-gasometer" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dc0eb591abc5cd7b05bef6a036c2bb6c66ab6c5e0c5ce94bfe377ab670b1fd7" dependencies = [ "environmental", "evm-core", @@ -2410,8 +2413,9 @@ dependencies = [ [[package]] name = "evm-runtime" -version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84bbe09b64ae13a29514048c1bb6fda6374ac0b4f6a1f15a443348ab88ef42cd" dependencies = [ "auto_impl", "environmental", @@ -3630,12 +3634,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hash-db" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" - [[package]] name = "hash-db" version = "0.16.0" @@ -5116,7 +5114,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" dependencies = [ - "hash-db 0.16.0", + "hash-db", ] [[package]] @@ -5813,7 +5811,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "hash-db 0.16.0", + "hash-db", "hex", "hex-literal", "impl-trait-for-tuples", @@ -7578,7 +7576,7 @@ name = "sc-client-db" version = "0.10.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" dependencies = [ - "hash-db 0.16.0", + "hash-db", "kvdb", "kvdb-memorydb", "kvdb-rocksdb", @@ -8886,7 +8884,7 @@ name = "sp-api" version = "4.0.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", "parity-scale-codec", "scale-info", @@ -9068,7 +9066,7 @@ dependencies = [ "dyn-clonable", "ed25519-zebra", "futures", - "hash-db 0.16.0", + "hash-db", "hash256-std-hasher", "impl-serde", "lazy_static", @@ -9361,7 +9359,7 @@ name = "sp-state-machine" version = "0.28.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" dependencies = [ - "hash-db 0.16.0", + "hash-db", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -9474,7 +9472,7 @@ version = "22.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#f60318f68687e601c47de5ad5ca88e2c3f8139a7" dependencies = [ "ahash 0.8.3", - "hash-db 0.16.0", + "hash-db", "hashbrown 0.13.2", "lazy_static", "memory-db", @@ -10463,7 +10461,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ - "hash-db 0.16.0", + "hash-db", "hashbrown 0.13.2", "log", "rustc-hex", @@ -10476,17 +10474,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ - "hash-db 0.16.0", -] - -[[package]] -name = "triehash" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" -dependencies = [ - "hash-db 0.15.2", - "rlp", + "hash-db", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8a11829161..9ae4937f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,9 +49,9 @@ bn = { package = "substrate-bn", version = "0.6", default-features = false } clap = { version = "4.4.3", features = ["derive", "deprecated"] } derive_more = "0.99" environmental = { version = "1.1.4", default-features = false } -ethereum = { version = "0.14.0", default-features = false } +ethereum = { version = "0.15.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } +evm = { version = "0.41.1", default-features = false } futures = "0.3.28" hash-db = { version = "0.16.0", default-features = false } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } diff --git a/frame/evm/precompile/dispatch/src/lib.rs b/frame/evm/precompile/dispatch/src/lib.rs index 4de25ae878..715831badf 100644 --- a/frame/evm/precompile/dispatch/src/lib.rs +++ b/frame/evm/precompile/dispatch/src/lib.rs @@ -85,8 +85,11 @@ where return Err(err); } - handle - .record_external_cost(Some(info.weight.ref_time()), Some(info.weight.proof_size()))?; + handle.record_external_cost( + Some(info.weight.ref_time()), + Some(info.weight.proof_size()), + None, + )?; match call.dispatch(Some(origin).into()) { Ok(post_info) => { diff --git a/frame/evm/precompile/dispatch/src/mock.rs b/frame/evm/precompile/dispatch/src/mock.rs index cb55296bda..2221f3bc1b 100644 --- a/frame/evm/precompile/dispatch/src/mock.rs +++ b/frame/evm/precompile/dispatch/src/mock.rs @@ -183,6 +183,7 @@ impl PrecompileHandle for MockHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), ExitError> { Ok(()) } diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 255e79383e..15a96b467e 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -999,7 +999,7 @@ where ExternalOperation::IsEmpty => { weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)? } - ExternalOperation::Write => { + ExternalOperation::Write(_) => { weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)? } }; @@ -1138,6 +1138,7 @@ where &mut self, ref_time: Option, proof_size: Option, + _storage_growth: Option, ) -> Result<(), ExitError> { let weight_info = if let (Some(weight_info), _) = self.info_mut() { weight_info diff --git a/frame/evm/test-vector-support/src/lib.rs b/frame/evm/test-vector-support/src/lib.rs index dfc14f051c..5dd816b3e2 100644 --- a/frame/evm/test-vector-support/src/lib.rs +++ b/frame/evm/test-vector-support/src/lib.rs @@ -80,7 +80,12 @@ impl PrecompileHandle for MockHandle { Ok(()) } - fn record_external_cost(&mut self, _: Option, _: Option) -> Result<(), ExitError> { + fn record_external_cost( + &mut self, + _: Option, + _: Option, + _: Option, + ) -> Result<(), ExitError> { Ok(()) } diff --git a/precompiles/src/evm/handle.rs b/precompiles/src/evm/handle.rs index d3d26bbe57..74254025f6 100644 --- a/precompiles/src/evm/handle.rs +++ b/precompiles/src/evm/handle.rs @@ -60,7 +60,7 @@ impl PrecompileHandleExt for T { ) -> Result<(), evm::ExitError> { self.record_cost(crate::prelude::RuntimeHelper::::db_read_gas_cost())?; // TODO: record ref time when precompile will be benchmarked - self.record_external_cost(None, Some(data_max_encoded_len as u64)) + self.record_external_cost(None, Some(data_max_encoded_len as u64), None) } /// Record cost of a log manualy. @@ -190,6 +190,7 @@ mod tests { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), fp_evm::ExitError> { Ok(()) } diff --git a/precompiles/src/precompile_set.rs b/precompiles/src/precompile_set.rs index 2f9bb0816a..ebe2d11cfd 100644 --- a/precompiles/src/precompile_set.rs +++ b/precompiles/src/precompile_set.rs @@ -477,8 +477,10 @@ impl<'a, H: PrecompileHandle> PrecompileHandle for RestrictiveHandle<'a, H> { &mut self, ref_time: Option, proof_size: Option, + storage_growth: Option, ) -> Result<(), ExitError> { - self.handle.record_external_cost(ref_time, proof_size) + self.handle + .record_external_cost(ref_time, proof_size, storage_growth) } fn refund_external_cost(&mut self, ref_time: Option, proof_size: Option) { diff --git a/precompiles/src/substrate.rs b/precompiles/src/substrate.rs index a5604af160..4a133272bd 100644 --- a/precompiles/src/substrate.rs +++ b/precompiles/src/substrate.rs @@ -77,7 +77,7 @@ where // Make sure there is enough remaining weight // TODO: record ref time when precompile will be benchmarked - handle.record_external_cost(None, Some(weight.proof_size())) + handle.record_external_cost(None, Some(weight.proof_size()), None) } #[inline(always)] diff --git a/precompiles/src/testing/handle.rs b/precompiles/src/testing/handle.rs index f521954034..0e869700f2 100644 --- a/precompiles/src/testing/handle.rs +++ b/precompiles/src/testing/handle.rs @@ -208,6 +208,7 @@ impl PrecompileHandle for MockHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), ExitError> { Ok(()) } diff --git a/precompiles/tests-external/lib.rs b/precompiles/tests-external/lib.rs index bdf46e2932..90df26f85f 100644 --- a/precompiles/tests-external/lib.rs +++ b/precompiles/tests-external/lib.rs @@ -162,6 +162,7 @@ impl PrecompileHandle for MockPrecompileHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), fp_evm::ExitError> { Ok(()) }