From d91e5b38ddef700f8e08a7f22d07dc19704875fd Mon Sep 17 00:00:00 2001 From: "Bill.W" Date: Fri, 10 Jan 2025 13:55:41 +0800 Subject: [PATCH 1/3] chore: upgrade the versions of `primitive-types` to `0.13` and `rlp` to `0.6` --- Cargo.toml | 8 ++++---- benches/loop.rs | 4 ++-- core/Cargo.toml | 2 +- core/src/eval/macros.rs | 3 +-- gasometer/Cargo.toml | 2 +- runtime/Cargo.toml | 2 +- runtime/src/eval/macros.rs | 3 +-- runtime/src/eval/mod.rs | 3 +-- runtime/src/eval/system.rs | 15 ++++++--------- 9 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c9ec32a02..d04183619 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ edition = "2018" [dependencies] auto_impl = "1.0" -ethereum = { version = "0.15", default-features = false } +ethereum = { git = "https://github.com/rust-ethereum/ethereum.git", rev = "3be0d8f", default-features = false } log = { version = "0.4", default-features = false } -primitive-types = { version = "0.12", default-features = false, features = ["rlp"] } -rlp = { version = "0.5", default-features = false } +primitive-types = { version = "0.13", default-features = false, features = ["rlp"] } +rlp = { version = "0.6", default-features = false } sha3 = { version = "0.10", default-features = false } # Optional dependencies @@ -55,7 +55,7 @@ with-codec = [ "scale-info", "primitive-types/codec", "primitive-types/scale-info", - "ethereum/with-codec", + "ethereum/with-scale", "evm-core/with-codec", ] with-serde = [ diff --git a/benches/loop.rs b/benches/loop.rs index b9ca7ae78..840170847 100644 --- a/benches/loop.rs +++ b/benches/loop.rs @@ -42,9 +42,9 @@ fn run_loop_contract() { }, ); - let backend = MemoryBackend::new(&vicinity, state); + let mut backend = MemoryBackend::new(&vicinity, state); let metadata = StackSubstateMetadata::new(u64::MAX, &config); - let state = MemoryStackState::new(metadata, &backend); + let state = MemoryStackState::new(metadata, &mut backend); let precompiles = BTreeMap::new(); let mut executor = StackExecutor::new_with_precompiles(state, &config, &precompiles); diff --git a/core/Cargo.toml b/core/Cargo.toml index c3e2287c2..cc65ca3bb 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [dependencies] log = { version = "0.4", optional = true } -primitive-types = { version = "0.12", default-features = false } +primitive-types = { version = "0.13", default-features = false } scale-codec = { package = "parity-scale-codec", version = "3.2", default-features = false, features = ["derive", "full"], optional = true } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } diff --git a/core/src/eval/macros.rs b/core/src/eval/macros.rs index 1e1533a93..c2b413aef 100644 --- a/core/src/eval/macros.rs +++ b/core/src/eval/macros.rs @@ -53,8 +53,7 @@ macro_rules! push { macro_rules! push_u256 { ( $machine:expr, $( $x:expr ),* ) => ( $( - let mut value = H256::default(); - $x.to_big_endian(&mut value[..]); + let value = H256::from($x.to_big_endian()); match $machine.stack.push(value) { Ok(()) => (), Err(e) => return Control::Exit(e.into()), diff --git a/gasometer/Cargo.toml b/gasometer/Cargo.toml index be47d7843..e411b9470 100644 --- a/gasometer/Cargo.toml +++ b/gasometer/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" [dependencies] environmental = { version = "1.1.2", default-features = false, optional = true } log = { version = "0.4", optional = true } -primitive-types = { version = "0.12", default-features = false } +primitive-types = { version = "0.13", default-features = false } evm-core = { version = "0.42", path = "../core", default-features = false } evm-runtime = { version = "0.42", path = "../runtime", default-features = false } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 393379cf1..001fe47ba 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" [dependencies] auto_impl = "1.0" environmental = { version = "1.1.2", default-features = false, optional = true } -primitive-types = { version = "0.12", default-features = false } +primitive-types = { version = "0.13", default-features = false } sha3 = { version = "0.10", default-features = false } evm-core = { version = "0.42", path = "../core", default-features = false } diff --git a/runtime/src/eval/macros.rs b/runtime/src/eval/macros.rs index 076866fba..1b081bfda 100644 --- a/runtime/src/eval/macros.rs +++ b/runtime/src/eval/macros.rs @@ -43,8 +43,7 @@ macro_rules! push { macro_rules! push_u256 { ( $machine:expr, $( $x:expr ),* ) => ( $( - let mut value = H256::default(); - $x.to_big_endian(&mut value[..]); + let value = H256::from($x.to_big_endian()); match $machine.machine.stack_mut().push(value) { Ok(()) => (), Err(e) => return Control::Exit(e.into()), diff --git a/runtime/src/eval/mod.rs b/runtime/src/eval/mod.rs index f26a7def3..fc8797a0c 100644 --- a/runtime/src/eval/mod.rs +++ b/runtime/src/eval/mod.rs @@ -113,8 +113,7 @@ pub fn finish_call( &runtime.return_data_buffer[..], ) { Ok(()) => { - let mut value = H256::default(); - U256::one().to_big_endian(&mut value[..]); + let value = H256::from(U256::one().to_big_endian()); runtime.machine.stack_mut().push(value)?; Ok(()) } diff --git a/runtime/src/eval/system.rs b/runtime/src/eval/system.rs index a839c2745..e75bcfd07 100644 --- a/runtime/src/eval/system.rs +++ b/runtime/src/eval/system.rs @@ -67,25 +67,22 @@ pub fn caller(runtime: &mut Runtime) -> Control { } pub fn callvalue(runtime: &mut Runtime) -> Control { - let mut ret = H256::default(); - runtime.context.apparent_value.to_big_endian(&mut ret[..]); - push!(runtime, ret); + let ret = runtime.context.apparent_value.to_big_endian(); + push!(runtime, H256::from(ret)); Control::Continue } pub fn gasprice(runtime: &mut Runtime, handler: &H) -> Control { - let mut ret = H256::default(); - handler.gas_price().to_big_endian(&mut ret[..]); - push!(runtime, ret); + let ret = handler.gas_price().to_big_endian(); + push!(runtime, H256::from(ret)); Control::Continue } pub fn base_fee(runtime: &mut Runtime, handler: &H) -> Control { - let mut ret = H256::default(); - handler.block_base_fee_per_gas().to_big_endian(&mut ret[..]); - push!(runtime, ret); + let ret = handler.block_base_fee_per_gas().to_big_endian(); + push!(runtime, H256::from(ret)); Control::Continue } From 0d6f8660bfd12663ecc1732eb23e365137816455 Mon Sep 17 00:00:00 2001 From: "Bill.W" Date: Sat, 18 Jan 2025 17:30:02 +0800 Subject: [PATCH 2/3] chore: for security reasons, the `rev` field uses the full hash value --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d04183619..b35ee27d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [dependencies] auto_impl = "1.0" -ethereum = { git = "https://github.com/rust-ethereum/ethereum.git", rev = "3be0d8f", default-features = false } +ethereum = { git = "https://github.com/rust-ethereum/ethereum.git", rev = "3be0d8fd4c2ad1ba216b69ef65b9382612efc8ba", default-features = false } log = { version = "0.4", default-features = false } primitive-types = { version = "0.13", default-features = false, features = ["rlp"] } rlp = { version = "0.6", default-features = false } From 86a1443a6fe5e463d91014554c48ab779b1ee56a Mon Sep 17 00:00:00 2001 From: "Bill.W" Date: Sat, 18 Jan 2025 22:25:22 +0800 Subject: [PATCH 3/3] remove the jsontests job from CI workflow --- .github/workflows/rust.yml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 02dfe32a8..c71936d92 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,20 +32,23 @@ jobs: run: cargo build --features tracing --verbose - name: Run tests run: cargo test --verbose - jsontests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - repository: "rust-blockchain/evm-tests" - submodules: recursive - - name: Submodules - run: | - cd evm - git remote set-url origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" - git fetch origin $GITHUB_SHA - git checkout $GITHUB_SHA - - name: Run tests - run: | - cd jsontests - cargo test --release --verbose + # FIXME: Due to the evm-tests repository used by the jsontests job being archived, the tests cannot be run, + # so this jsontests job has been temporarily removed. The jsontests job will be improved later, + # see issue #182 + # jsontests: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # with: + # repository: "rust-blockchain/evm-tests" + # submodules: recursive + # - name: Submodules + # run: | + # cd evm + # git remote set-url origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" + # git fetch origin $GITHUB_SHA + # git checkout $GITHUB_SHA + # - name: Run tests + # run: | + # cd jsontests + # cargo test --release --verbose