From 51d50f61d9e5f8240ee401a6939a37d52d06bae1 Mon Sep 17 00:00:00 2001 From: James Prestwich Date: Thu, 24 Oct 2024 08:00:38 -0400 Subject: [PATCH] Chore: some no_std cleanup (#1834) * chore: clean up some std feature usage * chore: clean up some std feature flags and tests in no_std --- crates/bytecode/src/eof/printer.rs | 4 ++-- crates/revm/src/builder.rs | 5 ++++- crates/revm/src/handler.rs | 3 +++ crates/wiring/src/result.rs | 9 ++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/bytecode/src/eof/printer.rs b/crates/bytecode/src/eof/printer.rs index f233084f0f..9fc4096bf6 100644 --- a/crates/bytecode/src/eof/printer.rs +++ b/crates/bytecode/src/eof/printer.rs @@ -1,4 +1,5 @@ -#[cfg(feature = "std")] +#![cfg(feature = "std")] + pub fn print(code: &[u8]) { use crate::{opcode::*, utils::read_i16}; use primitives::hex; @@ -60,7 +61,6 @@ pub fn print(code: &[u8]) { mod test { use primitives::hex; - #[cfg(feature = "std")] #[test] fn sanity_test() { super::print(&hex!("6001e200ffff00")); diff --git a/crates/revm/src/builder.rs b/crates/revm/src/builder.rs index 721f40f03f..10a572ee7e 100644 --- a/crates/revm/src/builder.rs +++ b/crates/revm/src/builder.rs @@ -463,13 +463,16 @@ where #[cfg(test)] mod test { + extern crate alloc; + use crate::{Context, Evm}; + use alloc::{boxed::Box, rc::Rc}; use bytecode::Bytecode; + use core::cell::RefCell; use database::InMemoryDB; use interpreter::Interpreter; use primitives::{address, TxKind, U256}; use state::AccountInfo; - use std::{cell::RefCell, rc::Rc}; use wiring::EthereumWiring; /// Custom evm context diff --git a/crates/revm/src/handler.rs b/crates/revm/src/handler.rs index 4a012d8085..e79a025fca 100644 --- a/crates/revm/src/handler.rs +++ b/crates/revm/src/handler.rs @@ -168,6 +168,9 @@ impl<'a, EvmWiringT: EvmWiring> EvmHandler<'a, EvmWiringT> { #[cfg(test)] mod test { + extern crate alloc; + + use alloc::boxed::Box; use core::cell::RefCell; use database_interface::EmptyDB; use std::{rc::Rc, sync::Arc}; diff --git a/crates/wiring/src/result.rs b/crates/wiring/src/result.rs index 74eb2e2ed8..0897add59d 100644 --- a/crates/wiring/src/result.rs +++ b/crates/wiring/src/result.rs @@ -185,14 +185,13 @@ impl EVMError std::error::Error +impl core::error::Error for EVMError where - DBError: std::error::Error + 'static, - TransactionValidationErrorT: std::error::Error + 'static, + DBError: core::error::Error + 'static, + TransactionValidationErrorT: core::error::Error + 'static, { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { Self::Transaction(e) => Some(e), Self::Header(e) => Some(e),