From c24671bd6997332a44acd213242ce9ad5d2546fd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 18 Jun 2024 18:00:32 +0200 Subject: [PATCH] chore: make reth-ethereum-evm compile with no-std --- crates/ethereum/evm/Cargo.toml | 3 +++ crates/ethereum/evm/src/eip6110.rs | 3 +++ crates/ethereum/evm/src/execute.rs | 5 +++++ crates/ethereum/evm/src/lib.rs | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index f087bb210769..1d996e5d3995 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -33,3 +33,6 @@ reth-revm = { workspace = true, features = ["test-utils"] } secp256k1.workspace = true serde_json.workspace = true +[features] +default = ["std"] +std = [] \ No newline at end of file diff --git a/crates/ethereum/evm/src/eip6110.rs b/crates/ethereum/evm/src/eip6110.rs index 1552a03d3d9c..722c38da76dc 100644 --- a/crates/ethereum/evm/src/eip6110.rs +++ b/crates/ethereum/evm/src/eip6110.rs @@ -6,6 +6,9 @@ use reth_evm::execute::BlockValidationError; use reth_primitives::{Receipt, Request}; use revm_primitives::Log; +#[cfg(not(feature = "std"))] +use alloc::{string::ToString, vec::Vec}; + sol! { #[allow(missing_docs)] event DepositEvent( diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 8bc6a9e8507c..149fbc9557b9 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -31,6 +31,11 @@ use revm_primitives::{ db::{Database, DatabaseCommit}, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, }; + +#[cfg(not(feature = "std"))] +use alloc::{sync::Arc, vec, vec::Vec}; + +#[cfg(feature = "std")] use std::sync::Arc; /// Provides executors to execute regular ethereum blocks diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index da9248c2136c..4134849ea8f9 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -7,6 +7,10 @@ )] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc; use reth_chainspec::ChainSpec; use reth_evm::{ConfigureEvm, ConfigureEvmEnv};