From 29f4ca2a617f32ad5cebcd9a39bd04fd765e4d5c Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Tue, 18 Feb 2025 16:54:56 +0400 Subject: [PATCH] feat: `no_std` for `reth-evm` (#14561) --- .github/assets/check_rv32imac.sh | 1 + .github/assets/check_wasm.sh | 1 - Cargo.toml | 4 ++-- Makefile | 4 ++-- crates/engine/tree/Cargo.toml | 2 +- crates/ethereum/evm/Cargo.toml | 1 + crates/ethereum/reth/Cargo.toml | 1 + crates/evm/Cargo.toml | 8 ++++++-- crates/evm/src/lib.rs | 2 +- crates/evm/src/test_utils.rs | 2 +- crates/optimism/evm/Cargo.toml | 1 + crates/optimism/reth/Cargo.toml | 1 + crates/stages/stages/Cargo.toml | 2 +- crates/tasks/Cargo.toml | 2 +- 14 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/assets/check_rv32imac.sh b/.github/assets/check_rv32imac.sh index 18a260a3a..f2be927f9 100755 --- a/.github/assets/check_rv32imac.sh +++ b/.github/assets/check_rv32imac.sh @@ -16,6 +16,7 @@ crates_to_check=( reth-execution-errors reth-execution-types reth-db-models + reth-evm ## ethereum reth-ethereum-forks diff --git a/.github/assets/check_wasm.sh b/.github/assets/check_wasm.sh index e28b27ee9..01c4effb0 100755 --- a/.github/assets/check_wasm.sh +++ b/.github/assets/check_wasm.sh @@ -28,7 +28,6 @@ exclude_crates=( reth-ethereum-cli reth-ethereum-payload-builder reth-etl - reth-evm reth-exex reth-exex-test-utils reth-ipc diff --git a/Cargo.toml b/Cargo.toml index 00bbdbb86..0e788e3eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -346,7 +346,7 @@ reth-ethereum-payload-builder = { path = "crates/ethereum/payload" } reth-ethereum-primitives = { path = "crates/ethereum/primitives", default-features = false } reth-ethereum = { path = "crates/ethereum/reth" } reth-etl = { path = "crates/etl" } -reth-evm = { path = "crates/evm" } +reth-evm = { path = "crates/evm", default-features = false } reth-evm-ethereum = { path = "crates/ethereum/evm" } reth-optimism-evm = { path = "crates/optimism/evm", default-features = false } reth-execution-errors = { path = "crates/evm/execution-errors", default-features = false } @@ -559,7 +559,7 @@ async-stream = "0.3" async-trait = "0.1.68" futures = "0.3" futures-core = "0.3" -futures-util = "0.3" +futures-util = { version = "0.3", default-features = false } hyper = "1.3" hyper-util = "0.1.5" pin-project = "1.0.12" diff --git a/Makefile b/Makefile index 8d1e5180a..9fc8e5a0c 100644 --- a/Makefile +++ b/Makefile @@ -432,7 +432,7 @@ rustdocs: ## Runs `cargo docs` to generate the Rust documents in the `target/doc cargo +nightly docs \ --document-private-items -test: +cargo-test: cargo test \ --workspace \ --bin "op-reth" \ @@ -445,7 +445,7 @@ test-doc: cargo test --doc --workspace --all-features test: - make test && \ + make cargo-test && \ make test-doc pr: diff --git a/crates/engine/tree/Cargo.toml b/crates/engine/tree/Cargo.toml index a22626031..7f2e84408 100644 --- a/crates/engine/tree/Cargo.toml +++ b/crates/engine/tree/Cargo.toml @@ -18,7 +18,7 @@ reth-consensus.workspace = true reth-db.workspace = true reth-engine-primitives.workspace = true reth-errors.workspace = true -reth-evm.workspace = true +reth-evm = { workspace = true, features = ["metrics"] } reth-network-p2p.workspace = true reth-payload-builder.workspace = true reth-payload-primitives.workspace = true diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index 45618034b..d456b69e5 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -57,4 +57,5 @@ std = [ "reth-chainspec/std", "alloy-evm/std", "reth-execution-types/std", + "reth-evm/std", ] diff --git a/crates/ethereum/reth/Cargo.toml b/crates/ethereum/reth/Cargo.toml index ce3587260..28c53604c 100644 --- a/crates/ethereum/reth/Cargo.toml +++ b/crates/ethereum/reth/Cargo.toml @@ -49,6 +49,7 @@ std = [ "reth-consensus-common?/std", "alloy-rpc-types-eth?/std", "reth-storage-api?/std", + "reth-evm?/std", ] arbitrary = [ "std", diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index e78281ea9..032d92e02 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -47,8 +47,6 @@ metrics-util = { workspace = true, features = ["debugging"] } [features] default = ["std"] std = [ - "dep:metrics", - "dep:reth-metrics", "reth-consensus/std", "reth-primitives/std", "reth-primitives-traits/std", @@ -66,6 +64,12 @@ std = [ "reth-execution-errors/std", "reth-execution-types/std", "reth-storage-errors/std", + "futures-util/std", +] +metrics = [ + "std", + "dep:metrics", + "dep:reth-metrics", ] test-utils = [ "dep:parking_lot", diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 3e4a227ff..5bb93218b 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -36,7 +36,7 @@ pub mod execute; mod aliases; pub use aliases::*; -#[cfg(feature = "std")] +#[cfg(feature = "metrics")] pub mod metrics; pub mod noop; pub mod state_change; diff --git a/crates/evm/src/test_utils.rs b/crates/evm/src/test_utils.rs index 49b8cbb63..cb9645988 100644 --- a/crates/evm/src/test_utils.rs +++ b/crates/evm/src/test_utils.rs @@ -8,13 +8,13 @@ use crate::{ system_calls::OnStateHook, Database, }; +use alloc::{sync::Arc, vec::Vec}; use alloy_eips::eip7685::Requests; use parking_lot::Mutex; use reth_execution_errors::BlockExecutionError; use reth_execution_types::{BlockExecutionResult, ExecutionOutcome}; use reth_primitives::{EthPrimitives, NodePrimitives, RecoveredBlock}; use revm_database::State; -use std::sync::Arc; /// A [`BlockExecutorProvider`] that returns mocked execution results. #[derive(Clone, Debug, Default)] diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index 846e1903a..9c28a1181 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -82,4 +82,5 @@ std = [ "alloy-op-evm/std", "revm-database/std", "revm-optimism/std", + "reth-evm/std", ] diff --git a/crates/optimism/reth/Cargo.toml b/crates/optimism/reth/Cargo.toml index edc5b2546..e3437d85e 100644 --- a/crates/optimism/reth/Cargo.toml +++ b/crates/optimism/reth/Cargo.toml @@ -48,6 +48,7 @@ std = [ "reth-optimism-primitives/std", "reth-primitives-traits/std", "reth-storage-api?/std", + "reth-evm?/std", ] arbitrary = [ "std", diff --git a/crates/stages/stages/Cargo.toml b/crates/stages/stages/Cargo.toml index 4cfa59850..4f1564fd3 100644 --- a/crates/stages/stages/Cargo.toml +++ b/crates/stages/stages/Cargo.toml @@ -20,7 +20,7 @@ reth-consensus.workspace = true reth-db.workspace = true reth-db-api.workspace = true reth-etl.workspace = true -reth-evm.workspace = true +reth-evm = { workspace = true, features = ["metrics"] } reth-exex.workspace = true reth-fs-util.workspace = true reth-network-p2p.workspace = true diff --git a/crates/tasks/Cargo.toml b/crates/tasks/Cargo.toml index 78963f675..7ddc6a32f 100644 --- a/crates/tasks/Cargo.toml +++ b/crates/tasks/Cargo.toml @@ -15,7 +15,7 @@ workspace = true # async tokio = { workspace = true, features = ["sync", "rt"] } tracing-futures.workspace = true -futures-util.workspace = true +futures-util = { workspace = true, features = ["std"] } # metrics reth-metrics.workspace = true