diff --git a/crates/chainspec/src/lib.rs b/crates/chainspec/src/lib.rs index 4badac6bc..62ea1aa9b 100644 --- a/crates/chainspec/src/lib.rs +++ b/crates/chainspec/src/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; /// Chain specific constants diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index d0c113f88..eb25d0e5b 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -1,9 +1,5 @@ -pub use alloy_eips::eip1559::BaseFeeParams; - -#[cfg(not(feature = "std"))] use alloc::{boxed::Box, sync::Arc, vec::Vec}; -#[cfg(feature = "std")] -use std::sync::Arc; +pub use alloy_eips::eip1559::BaseFeeParams; use alloy_chains::{Chain, ChainKind, NamedChain}; use alloy_genesis::Genesis; diff --git a/crates/consensus/consensus/src/lib.rs b/crates/consensus/consensus/src/lib.rs index 5dfe46656..91b93c8a7 100644 --- a/crates/consensus/consensus/src/lib.rs +++ b/crates/consensus/consensus/src/lib.rs @@ -9,20 +9,15 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::{fmt::Debug, vec::Vec}; use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256}; use reth_primitives::{ constants::MINIMUM_GAS_LIMIT, BlockWithSenders, GotExpected, GotExpectedBoxed, Header, InvalidTransactionError, Receipt, Request, SealedBlock, SealedHeader, }; -#[cfg(feature = "std")] -use std::fmt::Debug; - -#[cfg(not(feature = "std"))] -extern crate alloc; -#[cfg(not(feature = "std"))] -use alloc::{fmt::Debug, vec::Vec}; - /// A consensus implementation that does nothing. pub mod noop; diff --git a/crates/ethereum-forks/src/display.rs b/crates/ethereum-forks/src/display.rs index b0bc06a77..98372ea30 100644 --- a/crates/ethereum-forks/src/display.rs +++ b/crates/ethereum-forks/src/display.rs @@ -1,12 +1,10 @@ -#[cfg(not(feature = "std"))] +use crate::{hardforks::Hardforks, ForkCondition}; use alloc::{ format, string::{String, ToString}, vec::Vec, }; -use crate::{hardforks::Hardforks, ForkCondition}; - /// A container to pretty-print a hardfork. /// /// The fork is formatted depending on its fork condition: diff --git a/crates/ethereum-forks/src/forkid.rs b/crates/ethereum-forks/src/forkid.rs index 48ef778fc..8a344e2dd 100644 --- a/crates/ethereum-forks/src/forkid.rs +++ b/crates/ethereum-forks/src/forkid.rs @@ -3,7 +3,6 @@ //! Previously version of Apache licenced [`ethereum-forkid`](https://crates.io/crates/ethereum-forkid). use crate::Head; -#[cfg(not(feature = "std"))] use alloc::{ collections::{BTreeMap, BTreeSet}, vec::Vec, @@ -22,8 +21,6 @@ use crc::*; use proptest_derive::Arbitrary as PropTestArbitrary; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -#[cfg(feature = "std")] -use std::collections::{BTreeMap, BTreeSet}; const CRC_32_IEEE: Crc = Crc::::new(&CRC_32_ISO_HDLC); const TIMESTAMP_BEFORE_ETHEREUM_MAINNET: u64 = 1_300_000_000; diff --git a/crates/ethereum-forks/src/hardfork/dev.rs b/crates/ethereum-forks/src/hardfork/dev.rs index 6ba54a421..11e4f764e 100644 --- a/crates/ethereum-forks/src/hardfork/dev.rs +++ b/crates/ethereum-forks/src/hardfork/dev.rs @@ -1,10 +1,8 @@ use crate::{ChainHardforks, EthereumHardfork, ForkCondition}; +use alloc::vec; use alloy_primitives::U256; use once_cell::sync::Lazy; -#[cfg(not(feature = "std"))] -use alloc::vec; - /// Dev hardforks pub static DEV_HARDFORKS: Lazy = Lazy::new(|| { ChainHardforks::new(vec![ diff --git a/crates/ethereum-forks/src/hardfork/ethereum.rs b/crates/ethereum-forks/src/hardfork/ethereum.rs index 650e88ad0..3d85b54a9 100644 --- a/crates/ethereum-forks/src/hardfork/ethereum.rs +++ b/crates/ethereum-forks/src/hardfork/ethereum.rs @@ -1,4 +1,5 @@ use crate::{hardfork, ChainHardforks, ForkCondition, Hardfork}; +use alloc::{boxed::Box, format, string::String}; use alloy_chains::Chain; use alloy_primitives::{uint, U256}; use core::{ @@ -9,9 +10,6 @@ use core::{ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::{boxed::Box, format, string::String}; - hardfork!( /// The name of an Ethereum hardfork. EthereumHardfork { diff --git a/crates/ethereum-forks/src/hardfork/optimism.rs b/crates/ethereum-forks/src/hardfork/optimism.rs index 2d763d2d9..eccbc784d 100644 --- a/crates/ethereum-forks/src/hardfork/optimism.rs +++ b/crates/ethereum-forks/src/hardfork/optimism.rs @@ -1,4 +1,3 @@ -#[cfg(not(feature = "std"))] use alloc::{boxed::Box, format, string::String, vec}; use core::{ any::Any, diff --git a/crates/ethereum-forks/src/lib.rs b/crates/ethereum-forks/src/lib.rs index 51e619f4d..63b0fd535 100644 --- a/crates/ethereum-forks/src/lib.rs +++ b/crates/ethereum-forks/src/lib.rs @@ -15,7 +15,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; mod display; diff --git a/crates/ethereum/evm/src/eip6110.rs b/crates/ethereum/evm/src/eip6110.rs index 722c38da7..605427276 100644 --- a/crates/ethereum/evm/src/eip6110.rs +++ b/crates/ethereum/evm/src/eip6110.rs @@ -1,4 +1,5 @@ //! EIP-6110 deposit requests parsing +use alloc::{string::ToString, vec::Vec}; use alloy_eips::eip6110::{DepositRequest, MAINNET_DEPOSIT_CONTRACT_ADDRESS}; use alloy_sol_types::{sol, SolEvent}; use reth_chainspec::ChainSpec; @@ -6,9 +7,6 @@ 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 cdac05ac4..483cce9f0 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -4,6 +4,7 @@ use crate::{ dao_fork::{DAO_HARDFORK_BENEFICIARY, DAO_HARDKFORK_ACCOUNTS}, EthEvmConfig, }; +use alloc::{boxed::Box, sync::Arc, vec, vec::Vec}; use core::fmt::Display; use reth_chainspec::{ChainSpec, EthereumHardforks, MAINNET}; use reth_ethereum_consensus::validate_block_post_execution; @@ -32,11 +33,6 @@ use revm_primitives::{ BlockEnv, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg, ResultAndState, }; -#[cfg(not(feature = "std"))] -use alloc::{boxed::Box, sync::Arc, vec, vec::Vec}; -#[cfg(feature = "std")] -use std::sync::Arc; - /// Provides executors to execute regular ethereum blocks #[derive(Debug, Clone)] pub struct EthExecutorProvider { diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index 58db911eb..b854b78ac 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -9,18 +9,14 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; -use std::sync::Arc; - +use alloc::vec::Vec; use reth_chainspec::{ChainSpec, Head}; use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; use reth_primitives::{transaction::FillTxEnv, Address, Header, TransactionSigned, U256}; use revm_primitives::{AnalysisKind, Bytes, CfgEnvWithHandlerCfg, Env, TxEnv, TxKind}; - -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; +use std::sync::Arc; mod config; pub use config::{revm_spec, revm_spec_by_timestamp_after_merge}; diff --git a/crates/evm/execution-errors/src/lib.rs b/crates/evm/execution-errors/src/lib.rs index 1c3c8fa4d..674b5168e 100644 --- a/crates/evm/execution-errors/src/lib.rs +++ b/crates/evm/execution-errors/src/lib.rs @@ -9,11 +9,9 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; -#[cfg(not(feature = "std"))] -use alloc::{boxed::Box, string::String}; +use alloc::{boxed::Box, string::String}; use alloy_eips::BlockNumHash; use alloy_primitives::B256; use derive_more::Display; diff --git a/crates/evm/execution-errors/src/trie.rs b/crates/evm/execution-errors/src/trie.rs index b95af1ef6..5396540b2 100644 --- a/crates/evm/execution-errors/src/trie.rs +++ b/crates/evm/execution-errors/src/trie.rs @@ -1,13 +1,11 @@ //! Errors when computing the state root. +use alloc::string::ToString; use alloy_primitives::B256; use derive_more::Display; use nybbles::Nibbles; use reth_storage_errors::{db::DatabaseError, provider::ProviderError}; -#[cfg(not(feature = "std"))] -use alloc::string::ToString; - /// State root errors. #[derive(Display, Debug, PartialEq, Eq, Clone)] pub enum StateRootError { diff --git a/crates/evm/execution-types/src/chain.rs b/crates/evm/execution-types/src/chain.rs index 1c24f0908..ca88fa87a 100644 --- a/crates/evm/execution-types/src/chain.rs +++ b/crates/evm/execution-types/src/chain.rs @@ -1,12 +1,8 @@ //! Contains [Chain], a chain of blocks and their final state. -#[cfg(not(feature = "std"))] +use crate::ExecutionOutcome; use alloc::{borrow::Cow, collections::BTreeMap}; use core::{fmt, ops::RangeInclusive}; -#[cfg(feature = "std")] -use std::{borrow::Cow, collections::BTreeMap}; - -use crate::ExecutionOutcome; use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError}; use reth_primitives::{ Address, BlockHash, BlockNumHash, BlockNumber, ForkBlock, Receipt, SealedBlock, diff --git a/crates/evm/execution-types/src/lib.rs b/crates/evm/execution-types/src/lib.rs index 86abd98de..8965f04d7 100644 --- a/crates/evm/execution-types/src/lib.rs +++ b/crates/evm/execution-types/src/lib.rs @@ -8,7 +8,6 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#[cfg(not(feature = "std"))] extern crate alloc; mod chain; diff --git a/crates/evm/src/builder.rs b/crates/evm/src/builder.rs index e238ba8cc..4b7511494 100644 --- a/crates/evm/src/builder.rs +++ b/crates/evm/src/builder.rs @@ -1,8 +1,6 @@ //! Builder for creating an EVM with a database and environment. -#[cfg(not(feature = "std"))] use alloc::boxed::Box; - use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector}; use revm_primitives::EnvWithHandlerCfg; diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 83e3606d8..2c8e26cd7 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; use core::ops::Deref; diff --git a/crates/evm/src/system_calls.rs b/crates/evm/src/system_calls.rs index 530ed3cfa..88cb2f901 100644 --- a/crates/evm/src/system_calls.rs +++ b/crates/evm/src/system_calls.rs @@ -1,12 +1,7 @@ //! System contract call functions. -#[cfg(feature = "std")] -use std::fmt::Display; -#[cfg(not(feature = "std"))] -use { - alloc::{boxed::Box, format, string::ToString, vec::Vec}, - core::fmt::Display, -}; +use alloc::{boxed::Box, format, string::ToString, vec::Vec}; +use core::fmt::Display; use crate::ConfigureEvm; use alloy_eips::{ diff --git a/crates/optimism/chainspec/src/base.rs b/crates/optimism/chainspec/src/base.rs index d14a6b3d6..436fdaabe 100644 --- a/crates/optimism/chainspec/src/base.rs +++ b/crates/optimism/chainspec/src/base.rs @@ -1,9 +1,6 @@ //! Chain specification for the Base Mainnet network. -#[cfg(not(feature = "std"))] use alloc::sync::Arc; -#[cfg(feature = "std")] -use std::sync::Arc; use alloy_chains::Chain; use alloy_primitives::{b256, U256}; diff --git a/crates/optimism/chainspec/src/base_sepolia.rs b/crates/optimism/chainspec/src/base_sepolia.rs index 916e47cf9..0a52c52fc 100644 --- a/crates/optimism/chainspec/src/base_sepolia.rs +++ b/crates/optimism/chainspec/src/base_sepolia.rs @@ -1,9 +1,6 @@ //! Chain specification for the Base Sepolia testnet network. -#[cfg(not(feature = "std"))] use alloc::sync::Arc; -#[cfg(feature = "std")] -use std::sync::Arc; use alloy_chains::Chain; use alloy_primitives::{b256, U256}; diff --git a/crates/optimism/chainspec/src/dev.rs b/crates/optimism/chainspec/src/dev.rs index 3351ee03b..b1d42a94c 100644 --- a/crates/optimism/chainspec/src/dev.rs +++ b/crates/optimism/chainspec/src/dev.rs @@ -1,9 +1,6 @@ //! Chain specification in dev mode for custom chain. -#[cfg(not(feature = "std"))] use alloc::sync::Arc; -#[cfg(feature = "std")] -use std::sync::Arc; use alloy_chains::Chain; use alloy_primitives::U256; diff --git a/crates/optimism/chainspec/src/lib.rs b/crates/optimism/chainspec/src/lib.rs index 952fee762..17dadd7cc 100644 --- a/crates/optimism/chainspec/src/lib.rs +++ b/crates/optimism/chainspec/src/lib.rs @@ -7,7 +7,6 @@ )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#[cfg(not(feature = "std"))] extern crate alloc; pub mod constants; diff --git a/crates/optimism/chainspec/src/op.rs b/crates/optimism/chainspec/src/op.rs index 15a952ae6..14a0b9770 100644 --- a/crates/optimism/chainspec/src/op.rs +++ b/crates/optimism/chainspec/src/op.rs @@ -1,9 +1,6 @@ //! Chain specification for the Optimism Mainnet network. -#[cfg(not(feature = "std"))] use alloc::sync::Arc; -#[cfg(feature = "std")] -use std::sync::Arc; use alloy_chains::Chain; use alloy_primitives::{b256, U256}; diff --git a/crates/optimism/chainspec/src/op_sepolia.rs b/crates/optimism/chainspec/src/op_sepolia.rs index 9f223f7e0..8c0586360 100644 --- a/crates/optimism/chainspec/src/op_sepolia.rs +++ b/crates/optimism/chainspec/src/op_sepolia.rs @@ -1,9 +1,6 @@ //! Chain specification for the Optimism Sepolia testnet network. -#[cfg(not(feature = "std"))] use alloc::sync::Arc; -#[cfg(feature = "std")] -use std::sync::Arc; use alloy_chains::{Chain, NamedChain}; use alloy_primitives::{b256, U256}; diff --git a/crates/primitives-traits/src/constants/gas_units.rs b/crates/primitives-traits/src/constants/gas_units.rs index ed287e6d2..312ae51cb 100644 --- a/crates/primitives-traits/src/constants/gas_units.rs +++ b/crates/primitives-traits/src/constants/gas_units.rs @@ -1,7 +1,5 @@ -use core::time::Duration; - -#[cfg(not(feature = "std"))] use alloc::string::String; +use core::time::Duration; /// Represents one Kilogas, or `1_000` gas. pub const KILOGAS: u64 = 1_000; diff --git a/crates/primitives-traits/src/error.rs b/crates/primitives-traits/src/error.rs index 144c210ba..ef088a920 100644 --- a/crates/primitives-traits/src/error.rs +++ b/crates/primitives-traits/src/error.rs @@ -1,13 +1,9 @@ +use alloc::boxed::Box; use core::{ fmt, ops::{Deref, DerefMut}, }; -#[cfg(not(feature = "std"))] -use alloc::boxed::Box; -#[cfg(not(feature = "std"))] -extern crate alloc; - /// A pair of values, one of which is expected and one of which is actual. #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct GotExpected { diff --git a/crates/primitives-traits/src/integer_list.rs b/crates/primitives-traits/src/integer_list.rs index df68d612a..e5c87d7a1 100644 --- a/crates/primitives-traits/src/integer_list.rs +++ b/crates/primitives-traits/src/integer_list.rs @@ -1,3 +1,4 @@ +use alloc::vec::Vec; use bytes::BufMut; use core::fmt; use derive_more::Deref; @@ -8,9 +9,6 @@ use serde::{ Deserialize, Deserializer, Serialize, Serializer, }; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Uses Roaring Bitmaps to hold a list of integers. It provides really good compression with the /// capability to access its elements without decoding it. #[derive(Clone, PartialEq, Default, Deref)] diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index c8c1cbd8d..46df75d45 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; diff --git a/crates/primitives-traits/src/request.rs b/crates/primitives-traits/src/request.rs index 53e174d14..c08af3fd6 100644 --- a/crates/primitives-traits/src/request.rs +++ b/crates/primitives-traits/src/request.rs @@ -1,5 +1,6 @@ //! EIP-7685 requests. +use alloc::vec::Vec; pub use alloy_consensus::Request; use alloy_eips::eip7685::{Decodable7685, Encodable7685}; use alloy_rlp::{Decodable, Encodable}; @@ -8,9 +9,6 @@ use reth_codecs::{add_arbitrary_tests, Compact}; use revm_primitives::Bytes; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// A list of EIP-7685 requests. #[derive( Debug, diff --git a/crates/primitives-traits/src/withdrawal.rs b/crates/primitives-traits/src/withdrawal.rs index 52e0495fc..995e60292 100644 --- a/crates/primitives-traits/src/withdrawal.rs +++ b/crates/primitives-traits/src/withdrawal.rs @@ -1,12 +1,10 @@ //! [EIP-4895](https://eips.ethereum.org/EIPS/eip-4895) Withdrawal types. +use alloc::vec::Vec; use alloy_rlp::{RlpDecodableWrapper, RlpEncodableWrapper}; use derive_more::{AsRef, Deref, DerefMut, From, IntoIterator}; use reth_codecs::{add_arbitrary_tests, Compact}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Re-export from `alloy_eips`. #[doc(inline)] pub use alloy_eips::eip4895::Withdrawal; diff --git a/crates/primitives/src/alloy_compat.rs b/crates/primitives/src/alloy_compat.rs index f8a05a0f6..37bda5535 100644 --- a/crates/primitives/src/alloy_compat.rs +++ b/crates/primitives/src/alloy_compat.rs @@ -5,14 +5,12 @@ use crate::{ TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930, TxEip4844, TxLegacy, TxType, }; +use alloc::{string::ToString, vec::Vec}; use alloy_primitives::TxKind; use alloy_rlp::Error as RlpError; use alloy_serde::WithOtherFields; use op_alloy_rpc_types as _; -#[cfg(not(feature = "std"))] -use alloc::{string::ToString, vec::Vec}; - impl TryFrom>> for Block { type Error = alloy_rpc_types::ConversionError; diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 166a43b82..d6ed39540 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -2,6 +2,7 @@ use crate::{ Address, Bytes, GotExpected, Header, SealedHeader, TransactionSigned, TransactionSignedEcRecovered, Withdrawals, B256, }; +use alloc::vec::Vec; pub use alloy_eips::eip1898::{ BlockHashOrNumber, BlockId, BlockNumHash, BlockNumberOrTag, ForkBlock, RpcBlockHash, }; @@ -14,9 +15,6 @@ pub use reth_primitives_traits::test_utils::{generate_valid_header, valid_header use reth_primitives_traits::Requests; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - // HACK(onbjerg): we need this to always set `requests` to `None` since we might otherwise generate // a block with `None` withdrawals and `Some` requests, in which case we end up trying to decode the // requests as withdrawals diff --git a/crates/primitives/src/compression/mod.rs b/crates/primitives/src/compression/mod.rs index f7af0acbe..476f5d06b 100644 --- a/crates/primitives/src/compression/mod.rs +++ b/crates/primitives/src/compression/mod.rs @@ -1,8 +1,7 @@ -use std::{cell::RefCell, thread_local}; -use zstd::bulk::{Compressor, Decompressor}; - -#[cfg(not(feature = "std"))] use alloc::vec::Vec; +use core::cell::RefCell; +use std::thread_local; +use zstd::bulk::{Compressor, Decompressor}; /// Compression/Decompression dictionary for `Receipt`. pub static RECEIPT_DICTIONARY: &[u8] = include_bytes!("./receipt_dictionary.bin"); diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 0c4f25057..1d95ad8b3 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -19,7 +19,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; #[cfg(feature = "alloy-compat")] diff --git a/crates/primitives/src/proofs.rs b/crates/primitives/src/proofs.rs index f8ed334ce..c7f34c2f2 100644 --- a/crates/primitives/src/proofs.rs +++ b/crates/primitives/src/proofs.rs @@ -4,12 +4,10 @@ use crate::{ constants::EMPTY_OMMER_ROOT_HASH, keccak256, Header, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Request, TransactionSigned, Withdrawal, B256, }; +use alloc::vec::Vec; use alloy_eips::eip7685::Encodable7685; use reth_trie_common::root::{ordered_trie_root, ordered_trie_root_with_encoder}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Calculate a transaction root. /// /// `(rlp(index), encoded(tx))` pairs. diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 5bce92c3c..6883b4f3b 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -4,6 +4,7 @@ use crate::{ logs_bloom, Bloom, Bytes, TxType, B256, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, }; +use alloc::{vec, vec::Vec}; use alloy_primitives::Log; use alloy_rlp::{length_of_length, Decodable, Encodable, RlpDecodable, RlpEncodable}; use bytes::{Buf, BufMut}; @@ -13,9 +14,6 @@ use derive_more::{DerefMut, From, IntoIterator}; use reth_codecs::{Compact, CompactZstd}; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::{vec, vec::Vec}; - /// Receipt containing result of transaction execution. #[derive( Clone, Debug, PartialEq, Eq, Default, RlpEncodable, RlpDecodable, Serialize, Deserialize, diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 012e64954..68b279241 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -58,7 +58,6 @@ pub use tx_type::DEPOSIT_TX_TYPE_ID; #[cfg(test)] use reth_codecs::Compact; -#[cfg(not(feature = "std"))] use alloc::vec::Vec; /// Either a transaction hash or number. diff --git a/crates/primitives/src/transaction/pooled.rs b/crates/primitives/src/transaction/pooled.rs index 1ef05577a..a883e739a 100644 --- a/crates/primitives/src/transaction/pooled.rs +++ b/crates/primitives/src/transaction/pooled.rs @@ -7,15 +7,13 @@ use crate::{ TransactionSigned, TransactionSignedEcRecovered, TxEip1559, TxEip2930, TxEip4844, TxHash, TxLegacy, B256, EIP4844_TX_TYPE_ID, }; +use alloc::vec::Vec; use alloy_consensus::{SignableTransaction, TxEip4844WithSidecar}; use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header, EMPTY_LIST_CODE}; use bytes::Buf; use derive_more::{AsRef, Deref}; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// A response to `GetPooledTransactions`. This can include either a blob transaction, or a /// non-4844 signed transaction. #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests)] diff --git a/crates/primitives/src/transaction/sidecar.rs b/crates/primitives/src/transaction/sidecar.rs index b9583a349..340d7662d 100644 --- a/crates/primitives/src/transaction/sidecar.rs +++ b/crates/primitives/src/transaction/sidecar.rs @@ -13,7 +13,6 @@ pub use alloy_eips::eip4844::BlobTransactionSidecar; #[cfg(feature = "c-kzg")] pub use alloy_eips::eip4844::BlobTransactionValidationError; -#[cfg(not(feature = "std"))] use alloc::vec::Vec; /// A response to `GetPooledTransactions` that includes blob data, their commitments, and their diff --git a/crates/revm/src/batch.rs b/crates/revm/src/batch.rs index ad71f38b4..4502732a4 100644 --- a/crates/revm/src/batch.rs +++ b/crates/revm/src/batch.rs @@ -4,14 +4,12 @@ use crate::{ precompile::{Address, HashSet}, primitives::alloy_primitives::BlockNumber, }; +use alloc::vec::Vec; use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError}; use reth_primitives::{Receipt, Receipts, Request, Requests}; use reth_prune_types::{PruneMode, PruneModes, PruneSegmentError, MINIMUM_PRUNING_DISTANCE}; use revm::db::states::bundle_state::BundleRetention; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Takes care of: /// - recording receipts during execution of multiple blocks. /// - pruning receipts according to the pruning configuration. @@ -183,14 +181,9 @@ impl BlockBatchRecord { #[cfg(test)] mod tests { use super::*; + use alloc::collections::BTreeMap; use reth_primitives::{Address, Log, Receipt}; use reth_prune_types::{PruneMode, ReceiptsLogPruneConfig}; - #[cfg(feature = "std")] - use std::collections::BTreeMap; - #[cfg(not(feature = "std"))] - extern crate alloc; - #[cfg(not(feature = "std"))] - use alloc::collections::BTreeMap; #[test] fn test_save_receipts_empty() { diff --git a/crates/revm/src/lib.rs b/crates/revm/src/lib.rs index 4fb6c30d1..5515357d0 100644 --- a/crates/revm/src/lib.rs +++ b/crates/revm/src/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; /// Contains glue code for integrating reth database into revm's [Database]. diff --git a/crates/revm/src/test_utils.rs b/crates/revm/src/test_utils.rs index 92f09e461..f54f10a38 100644 --- a/crates/revm/src/test_utils.rs +++ b/crates/revm/src/test_utils.rs @@ -1,4 +1,5 @@ use crate::precompile::HashMap; +use alloc::vec::Vec; use reth_primitives::{ keccak256, Account, Address, BlockNumber, Bytecode, Bytes, StorageKey, B256, U256, }; @@ -12,9 +13,6 @@ use reth_trie::{ HashedStorage, }; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Mock state for testing #[derive(Debug, Default, Clone, Eq, PartialEq)] pub struct StateProviderTest { diff --git a/crates/storage/codecs/src/alloy/access_list.rs b/crates/storage/codecs/src/alloy/access_list.rs index 306ef4f49..306b64d7e 100644 --- a/crates/storage/codecs/src/alloy/access_list.rs +++ b/crates/storage/codecs/src/alloy/access_list.rs @@ -1,10 +1,8 @@ use crate::Compact; +use alloc::vec::Vec; use alloy_eips::eip2930::{AccessList, AccessListItem}; use alloy_primitives::Address; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Implement `Compact` for `AccessListItem` and `AccessList`. impl Compact for AccessListItem { fn to_compact(&self, buf: &mut B) -> usize diff --git a/crates/storage/codecs/src/alloy/genesis_account.rs b/crates/storage/codecs/src/alloy/genesis_account.rs index 463c94fa3..84c8ee77a 100644 --- a/crates/storage/codecs/src/alloy/genesis_account.rs +++ b/crates/storage/codecs/src/alloy/genesis_account.rs @@ -1,12 +1,10 @@ use crate::Compact; +use alloc::vec::Vec; use alloy_genesis::GenesisAccount as AlloyGenesisAccount; use alloy_primitives::{Bytes, B256, U256}; use reth_codecs_derive::add_arbitrary_tests; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// `GenesisAccount` acts as bridge which simplifies Compact implementation for /// `AlloyGenesisAccount`. /// diff --git a/crates/storage/codecs/src/alloy/log.rs b/crates/storage/codecs/src/alloy/log.rs index 2a3aa07b7..7f0a0e362 100644 --- a/crates/storage/codecs/src/alloy/log.rs +++ b/crates/storage/codecs/src/alloy/log.rs @@ -1,12 +1,10 @@ //! Native Compact codec impl for primitive alloy log types. use crate::Compact; +use alloc::vec::Vec; use alloy_primitives::{Address, Bytes, Log, LogData}; use bytes::BufMut; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Implement `Compact` for `LogData` and `Log`. impl Compact for LogData { fn to_compact(&self, buf: &mut B) -> usize diff --git a/crates/storage/codecs/src/alloy/transaction/eip4844.rs b/crates/storage/codecs/src/alloy/transaction/eip4844.rs index 7ac815820..15a5f443c 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip4844.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip4844.rs @@ -1,13 +1,11 @@ use crate::{Compact, CompactPlaceholder}; +use alloc::vec::Vec; use alloy_consensus::transaction::TxEip4844 as AlloyTxEip4844; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, Bytes, ChainId, B256, U256}; use reth_codecs_derive::add_arbitrary_tests; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// [EIP-4844 Blob Transaction](https://eips.ethereum.org/EIPS/eip-4844#blob-transaction) /// /// This is a helper type to use derive on it instead of manually managing `bitfield`. diff --git a/crates/storage/codecs/src/alloy/transaction/eip7702.rs b/crates/storage/codecs/src/alloy/transaction/eip7702.rs index ecb7d66a0..a44e97ee1 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip7702.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip7702.rs @@ -1,13 +1,11 @@ use crate::Compact; +use alloc::vec::Vec; use alloy_consensus::transaction::TxEip7702 as AlloyTxEip7702; use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization}; use alloy_primitives::{Address, Bytes, ChainId, U256}; use reth_codecs_derive::add_arbitrary_tests; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// [EIP-7702 Set Code Transaction](https://eips.ethereum.org/EIPS/eip-7702) /// /// This is a helper type to use derive on it instead of manually managing `bitfield`. diff --git a/crates/storage/codecs/src/alloy/trie.rs b/crates/storage/codecs/src/alloy/trie.rs index 73e82af63..c89ef0bf6 100644 --- a/crates/storage/codecs/src/alloy/trie.rs +++ b/crates/storage/codecs/src/alloy/trie.rs @@ -1,13 +1,11 @@ //! Native Compact codec impl for EIP-7685 requests. use crate::Compact; +use alloc::vec::Vec; use alloy_primitives::B256; use alloy_trie::{hash_builder::HashBuilderValue, BranchNodeCompact, TrieMask}; use bytes::{Buf, BufMut}; -#[cfg(not(feature = "std"))] -use alloc::vec::Vec; - /// Identifier for [`HashBuilderValue::Hash`] const HASH_BUILDER_TYPE_HASH: u8 = 0; diff --git a/crates/storage/codecs/src/lib.rs b/crates/storage/codecs/src/lib.rs index 4419dbee2..b668c759e 100644 --- a/crates/storage/codecs/src/lib.rs +++ b/crates/storage/codecs/src/lib.rs @@ -22,9 +22,7 @@ pub use reth_codecs_derive::*; use alloy_primitives::{Address, Bloom, Bytes, FixedBytes, U256}; use bytes::{Buf, BufMut}; -#[cfg(not(feature = "std"))] extern crate alloc; -#[cfg(not(feature = "std"))] use alloc::vec::Vec; #[cfg(any(test, feature = "alloy"))] diff --git a/crates/storage/errors/src/db.rs b/crates/storage/errors/src/db.rs index 079a7d56f..e2c275d5a 100644 --- a/crates/storage/errors/src/db.rs +++ b/crates/storage/errors/src/db.rs @@ -1,14 +1,9 @@ -#[cfg(feature = "std")] -use std::{fmt, fmt::Display, str::FromStr, string::String}; - -#[cfg(not(feature = "std"))] use alloc::{ boxed::Box, format, string::{String, ToString}, vec::Vec, }; -#[cfg(not(feature = "std"))] use core::{ fmt, fmt::{Debug, Display}, diff --git a/crates/storage/errors/src/lib.rs b/crates/storage/errors/src/lib.rs index cf1a1a976..6abb0cd9b 100644 --- a/crates/storage/errors/src/lib.rs +++ b/crates/storage/errors/src/lib.rs @@ -9,7 +9,6 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; /// Database error diff --git a/crates/storage/errors/src/lockfile.rs b/crates/storage/errors/src/lockfile.rs index 17687cb69..667197f57 100644 --- a/crates/storage/errors/src/lockfile.rs +++ b/crates/storage/errors/src/lockfile.rs @@ -1,7 +1,5 @@ -use reth_fs_util::FsPathError; - -#[cfg(not(feature = "std"))] use alloc::string::{String, ToString}; +use reth_fs_util::FsPathError; /// Storage lock error. #[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)] diff --git a/crates/storage/errors/src/provider.rs b/crates/storage/errors/src/provider.rs index 2f20f1ab8..e478ca2eb 100644 --- a/crates/storage/errors/src/provider.rs +++ b/crates/storage/errors/src/provider.rs @@ -6,7 +6,6 @@ use reth_primitives::{BlockHashOrNumber, GotExpected, StaticFileSegment, TxHashO #[cfg(feature = "std")] use std::path::PathBuf; -#[cfg(not(feature = "std"))] use alloc::{boxed::Box, string::String}; /// Provider result type.