diff --git a/.github/assets/check_rv32imac.sh b/.github/assets/check_rv32imac.sh index 0166f43c876a..4be9b1d7e88e 100755 --- a/.github/assets/check_rv32imac.sh +++ b/.github/assets/check_rv32imac.sh @@ -10,6 +10,11 @@ crates_to_check=( reth-chainspec reth-consensus reth-consensus-common + reth-prune-types + reth-static-file-types + reth-storage-errors + reth-execution-errors + reth-execution-types ## ethereum reth-ethereum-forks diff --git a/.github/assets/check_wasm.sh b/.github/assets/check_wasm.sh index d24f998fcdac..a86cfa51c8d4 100755 --- a/.github/assets/check_wasm.sh +++ b/.github/assets/check_wasm.sh @@ -28,6 +28,7 @@ exclude_crates=( reth-ethereum-cli reth-ethereum-payload-builder reth-etl + reth-evm reth-exex reth-exex-test-utils reth-ipc @@ -58,7 +59,7 @@ exclude_crates=( reth-invalid-block-hooks # reth-provider reth-libmdbx # mdbx reth-mdbx-sys # mdbx - reth-payload-builder # reth-metrics + reth-payload-builder # reth-metrics reth-provider # tokio reth-prune # tokio reth-stages-api # reth-provider, reth-prune diff --git a/Cargo.lock b/Cargo.lock index d0bfd3ffc9d0..fe533b7c1d83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7707,9 +7707,7 @@ dependencies = [ "rand 0.8.5", "reth-ethereum-primitives", "reth-execution-errors", - "reth-primitives", "reth-primitives-traits", - "reth-trie", "reth-trie-common", "revm", "serde", diff --git a/Cargo.toml b/Cargo.toml index 8e143ffc4153..aac8ff87b382 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -348,8 +348,8 @@ reth-etl = { path = "crates/etl" } reth-evm = { path = "crates/evm" } reth-evm-ethereum = { path = "crates/ethereum/evm" } reth-optimism-evm = { path = "crates/optimism/evm" } -reth-execution-errors = { path = "crates/evm/execution-errors" } -reth-execution-types = { path = "crates/evm/execution-types" } +reth-execution-errors = { path = "crates/evm/execution-errors", default-features = false } +reth-execution-types = { path = "crates/evm/execution-types", default-features = false } reth-exex = { path = "crates/exex/exex" } reth-exex-test-utils = { path = "crates/exex/test-utils" } reth-exex-types = { path = "crates/exex/types" } @@ -394,7 +394,7 @@ reth-primitives = { path = "crates/primitives", default-features = false } reth-primitives-traits = { path = "crates/primitives-traits", default-features = false } reth-provider = { path = "crates/storage/provider" } reth-prune = { path = "crates/prune/prune" } -reth-prune-types = { path = "crates/prune/types" } +reth-prune-types = { path = "crates/prune/types", default-features = false } reth-revm = { path = "crates/revm", default-features = false } reth-rpc = { path = "crates/rpc/rpc" } reth-rpc-api = { path = "crates/rpc/rpc-api" } @@ -410,9 +410,9 @@ reth-stages = { path = "crates/stages/stages" } reth-stages-api = { path = "crates/stages/api" } reth-stages-types = { path = "crates/stages/types", default-features = false } reth-static-file = { path = "crates/static-file/static-file" } -reth-static-file-types = { path = "crates/static-file/types" } +reth-static-file-types = { path = "crates/static-file/types", default-features = false } reth-storage-api = { path = "crates/storage/storage-api" } -reth-storage-errors = { path = "crates/storage/errors" } +reth-storage-errors = { path = "crates/storage/errors", default-features = false } reth-tasks = { path = "crates/tasks" } reth-testing-utils = { path = "testing/testing-utils" } reth-tokio-util = { path = "crates/tokio-util" } @@ -436,7 +436,7 @@ alloy-chains = { version = "0.1.32", default-features = false } alloy-dyn-abi = "0.8.20" alloy-eip2124 = { version = "0.1.0", default-features = false } alloy-primitives = { version = "0.8.20", default-features = false, features = ["map-foldhash"] } -alloy-rlp = { version = "0.3.10", default-features = false } +alloy-rlp = { version = "0.3.10", default-features = false, features = ["core-net"] } alloy-sol-types = "0.8.20" alloy-trie = { version = "0.7", default-features = false } diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index 2b41d5549450..06cba81dcb67 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -61,4 +61,5 @@ std = [ "reth-primitives-traits/std", "reth-chainspec/std", "derive_more/std", + "reth-execution-types/std", ] diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 89117b8cfccc..909261353840 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -59,6 +59,9 @@ std = [ "reth-ethereum-primitives/std", "reth-chainspec/std", "reth-consensus-common/std", + "reth-execution-errors/std", + "reth-storage-errors/std", + "reth-execution-types/std", ] test-utils = [ "dep:parking_lot", diff --git a/crates/evm/execution-errors/Cargo.toml b/crates/evm/execution-errors/Cargo.toml index b35d37b61db4..1047fdbd2022 100644 --- a/crates/evm/execution-errors/Cargo.toml +++ b/crates/evm/execution-errors/Cargo.toml @@ -29,4 +29,5 @@ std = [ "alloy-rlp/std", "thiserror/std", "nybbles/std", + "reth-storage-errors/std", ] diff --git a/crates/evm/execution-types/Cargo.toml b/crates/evm/execution-types/Cargo.toml index 5cc787554b16..de959e537c58 100644 --- a/crates/evm/execution-types/Cargo.toml +++ b/crates/evm/execution-types/Cargo.toml @@ -11,11 +11,10 @@ repository.workspace = true workspace = true [dependencies] -reth-primitives.workspace = true +reth-ethereum-primitives.workspace = true reth-primitives-traits.workspace = true reth-execution-errors.workspace = true -reth-trie-common = { workspace = true, optional = true } -reth-trie.workspace = true +reth-trie-common.workspace = true revm.workspace = true @@ -31,7 +30,6 @@ serde_with = { workspace = true, optional = true } arbitrary.workspace = true bincode.workspace = true rand.workspace = true -reth-primitives = { workspace = true, features = ["arbitrary", "test-utils"] } reth-ethereum-primitives.workspace = true [features] @@ -45,13 +43,11 @@ serde = [ "alloy-primitives/serde", "reth-primitives-traits/serde", "alloy-consensus/serde", - "reth-trie/serde", - "reth-trie-common?/serde", + "reth-trie-common/serde", ] serde-bincode-compat = [ "serde", "reth-trie-common/serde-bincode-compat", - "reth-primitives/serde-bincode-compat", "reth-primitives-traits/serde-bincode-compat", "serde_with", "alloy-eips/serde-bincode-compat", @@ -59,7 +55,6 @@ serde-bincode-compat = [ "reth-ethereum-primitives/serde-bincode-compat", ] std = [ - "reth-primitives/std", "alloy-eips/std", "alloy-primitives/std", "revm/std", @@ -67,6 +62,7 @@ std = [ "reth-primitives-traits/std", "alloy-consensus/std", "serde_with?/std", - "reth-trie-common?/std", + "reth-trie-common/std", "reth-ethereum-primitives/std", + "reth-execution-errors/std", ] diff --git a/crates/evm/execution-types/src/chain.rs b/crates/evm/execution-types/src/chain.rs index 948ccc47c722..a5c000adca02 100644 --- a/crates/evm/execution-types/src/chain.rs +++ b/crates/evm/execution-types/src/chain.rs @@ -2,16 +2,16 @@ use crate::ExecutionOutcome; use alloc::{borrow::Cow, boxed::Box, collections::BTreeMap, vec::Vec}; -use alloy_consensus::BlockHeader; +use alloy_consensus::{transaction::Recovered, BlockHeader}; use alloy_eips::{eip1898::ForkBlock, eip2718::Encodable2718, BlockNumHash}; use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash}; use core::{fmt, ops::RangeInclusive}; use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError}; -use reth_primitives::{ - transaction::SignedTransactionIntoRecoveredExt, Recovered, RecoveredBlock, SealedHeader, +use reth_primitives_traits::{ + transaction::signed::SignedTransactionIntoRecoveredExt, Block, BlockBody, NodePrimitives, + RecoveredBlock, SealedHeader, SignedTransaction, }; -use reth_primitives_traits::{Block, BlockBody, NodePrimitives, SignedTransaction}; -use reth_trie::updates::TrieUpdates; +use reth_trie_common::updates::TrieUpdates; use revm::db::BundleState; /// A chain of blocks and their final state. @@ -26,7 +26,7 @@ use revm::db::BundleState; /// A chain of blocks should not be empty. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct Chain { +pub struct Chain { /// All blocks in this chain. blocks: BTreeMap>, /// The outcome of block execution for this chain. @@ -470,7 +470,7 @@ impl IntoIterator for ChainBlocks<'_, B> { /// Used to hold receipts and their attachment. #[derive(Default, Clone, Debug, PartialEq, Eq)] -pub struct BlockReceipts { +pub struct BlockReceipts { /// Block identifier pub block: BlockNumHash, /// Transaction identifier and receipt. @@ -500,7 +500,7 @@ impl From for ChainSplitTarget { /// Result of a split chain. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum ChainSplit { +pub enum ChainSplit { /// Chain is not split. Pending chain is returned. /// Given block split is higher than last block. /// Or in case of split by hash when hash is unknown. @@ -529,8 +529,11 @@ pub(super) mod serde_bincode_compat { use crate::ExecutionOutcome; use alloc::borrow::Cow; use alloy_primitives::BlockNumber; - use reth_primitives::{serde_bincode_compat::RecoveredBlock, EthPrimitives, NodePrimitives}; - use reth_primitives_traits::{serde_bincode_compat::SerdeBincodeCompat, Block}; + use reth_ethereum_primitives::EthPrimitives; + use reth_primitives_traits::{ + serde_bincode_compat::{RecoveredBlock, SerdeBincodeCompat}, + Block, NodePrimitives, + }; use reth_trie_common::serde_bincode_compat::updates::TrieUpdates; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; use serde_with::{DeserializeAs, SerializeAs}; @@ -568,7 +571,7 @@ pub(super) mod serde_bincode_compat { 'a, B: reth_primitives_traits::Block + 'static, - >(Cow<'a, BTreeMap>>); + >(Cow<'a, BTreeMap>>); impl Serialize for RecoveredBlocks<'_, B> where @@ -666,7 +669,7 @@ pub(super) mod serde_bincode_compat { use super::super::{serde_bincode_compat, Chain}; use arbitrary::Arbitrary; use rand::Rng; - use reth_primitives::RecoveredBlock; + use reth_primitives_traits::RecoveredBlock; use serde::{Deserialize, Serialize}; use serde_with::serde_as; @@ -705,23 +708,9 @@ mod tests { use reth_ethereum_primitives::Receipt; use revm::primitives::{AccountInfo, HashMap}; - // TODO: this is temporary, until we fully switch over to `reth_ethereum_primitives` for the - // `Receipt` type in `EthPrimitives`. - #[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] - #[non_exhaustive] - struct TestPrimitives; - - impl reth_primitives_traits::NodePrimitives for TestPrimitives { - type Block = reth_primitives::Block; - type BlockHeader = alloy_consensus::Header; - type BlockBody = reth_primitives::BlockBody; - type SignedTx = reth_primitives::TransactionSigned; - type Receipt = Receipt; - } - #[test] fn chain_append() { - let block: RecoveredBlock = Default::default(); + let block: RecoveredBlock = Default::default(); let block1_hash = B256::new([0x01; 32]); let block2_hash = B256::new([0x02; 32]); let block3_hash = B256::new([0x03; 32]); @@ -785,13 +774,13 @@ mod tests { vec![], ); - let mut block1: RecoveredBlock = Default::default(); + let mut block1: RecoveredBlock = Default::default(); let block1_hash = B256::new([15; 32]); block1.set_block_number(1); block1.set_hash(block1_hash); block1.push_sender(Address::new([4; 20])); - let mut block2: RecoveredBlock = Default::default(); + let mut block2: RecoveredBlock = Default::default(); let block2_hash = B256::new([16; 32]); block2.set_block_number(2); block2.set_hash(block2_hash); @@ -852,7 +841,7 @@ mod tests { #[test] fn receipts_by_block_hash() { // Create a default RecoveredBlock object - let block: RecoveredBlock = Default::default(); + let block: RecoveredBlock = Default::default(); // Define block hashes for block1 and block2 let block1_hash = B256::new([0x01; 32]); @@ -896,7 +885,7 @@ mod tests { // Create a Chain object with a BTreeMap of blocks mapped to their block numbers, // including block1_hash and block2_hash, and the execution_outcome - let chain: Chain = Chain { + let chain: Chain = Chain { blocks: BTreeMap::from([(10, block1), (11, block2)]), execution_outcome: execution_outcome.clone(), ..Default::default() diff --git a/crates/evm/execution-types/src/execution_outcome.rs b/crates/evm/execution-types/src/execution_outcome.rs index 280cd457d8f9..123704becd60 100644 --- a/crates/evm/execution-types/src/execution_outcome.rs +++ b/crates/evm/execution-types/src/execution_outcome.rs @@ -3,7 +3,7 @@ use alloc::{vec, vec::Vec}; use alloy_eips::eip7685::Requests; use alloy_primitives::{logs_bloom, map::HashMap, Address, BlockNumber, Bloom, Log, B256, U256}; use reth_primitives_traits::{Account, Bytecode, Receipt, StorageEntry}; -use reth_trie::{HashedPostState, KeyHasher}; +use reth_trie_common::{HashedPostState, KeyHasher}; use revm::{ db::{states::BundleState, BundleAccount}, primitives::AccountInfo, @@ -33,7 +33,7 @@ impl ChangedAccount { /// blocks, capturing the resulting state, receipts, and requests following the execution. #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ExecutionOutcome { +pub struct ExecutionOutcome { /// Bundle state with reverts. pub bundle: BundleState, /// The collection of receipts. @@ -390,7 +390,7 @@ impl ExecutionOutcome { pub fn ethereum_receipts_root(&self, block_number: BlockNumber) -> Option { self.generic_receipts_root_slow( block_number, - reth_primitives::Receipt::calculate_receipt_root_no_memo, + reth_ethereum_primitives::Receipt::calculate_receipt_root_no_memo, ) } } diff --git a/crates/net/p2p/Cargo.toml b/crates/net/p2p/Cargo.toml index da208d48b8ae..161b91442119 100644 --- a/crates/net/p2p/Cargo.toml +++ b/crates/net/p2p/Cargo.toml @@ -61,4 +61,5 @@ std = [ "alloy-consensus/std", "derive_more/std", "reth-network-peers/std", + "reth-storage-errors/std", ] diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index e1d496d74d02..1579cbd1675f 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -71,6 +71,8 @@ std = [ "reth-chainspec/std", "reth-optimism-consensus/std", "reth-consensus-common/std", + "reth-execution-errors/std", + "reth-execution-types/std", ] optimism = [ "reth-execution-types/optimism", diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 99ffd7ef7fd8..2f0b5d4caeea 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -62,6 +62,7 @@ std = [ "reth-ethereum-primitives/std", "alloy-rlp/std", "alloy-primitives/std", + "reth-static-file-types/std", ] reth-codec = [ "std", diff --git a/crates/prune/types/Cargo.toml b/crates/prune/types/Cargo.toml index c6e6451585f0..42a6d7f20824 100644 --- a/crates/prune/types/Cargo.toml +++ b/crates/prune/types/Cargo.toml @@ -37,6 +37,14 @@ test-fuzz.workspace = true toml.workspace = true [features] +default = ["std"] +std = [ + "alloy-primitives/std", + "derive_more/std", + "serde?/std", + "serde_json/std", + "thiserror/std", +] test-utils = [ "dep:arbitrary", "reth-codecs?/test-utils", diff --git a/crates/prune/types/src/event.rs b/crates/prune/types/src/event.rs index bac5f0d512cc..869c19182e19 100644 --- a/crates/prune/types/src/event.rs +++ b/crates/prune/types/src/event.rs @@ -1,6 +1,7 @@ use crate::PrunedSegmentInfo; +use alloc::vec::Vec; use alloy_primitives::BlockNumber; -use std::time::Duration; +use core::time::Duration; /// An event emitted by a pruner. #[derive(Debug, PartialEq, Eq, Clone)] diff --git a/crates/prune/types/src/lib.rs b/crates/prune/types/src/lib.rs index 54c62b42d9d6..1aedce38fcef 100644 --- a/crates/prune/types/src/lib.rs +++ b/crates/prune/types/src/lib.rs @@ -7,6 +7,9 @@ )] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; mod checkpoint; mod event; @@ -15,7 +18,10 @@ mod pruner; mod segment; mod target; +use alloc::{collections::BTreeMap, vec::Vec}; +use alloy_primitives::{Address, BlockNumber}; pub use checkpoint::PruneCheckpoint; +use core::ops::Deref; pub use event::PrunerEvent; pub use mode::PruneMode; pub use pruner::{ @@ -23,12 +29,8 @@ pub use pruner::{ SegmentOutputCheckpoint, }; pub use segment::{PrunePurpose, PruneSegment, PruneSegmentError}; -use std::collections::BTreeMap; pub use target::{PruneModes, MINIMUM_PRUNING_DISTANCE}; -use alloy_primitives::{Address, BlockNumber}; -use std::ops::Deref; - /// Configuration for pruning receipts not associated with logs emitted by the specified contracts. #[derive(Debug, Clone, PartialEq, Eq, Default)] #[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))] diff --git a/crates/prune/types/src/pruner.rs b/crates/prune/types/src/pruner.rs index daf490501f3b..fcac3da139f6 100644 --- a/crates/prune/types/src/pruner.rs +++ b/crates/prune/types/src/pruner.rs @@ -1,4 +1,5 @@ use crate::{PruneCheckpoint, PruneMode, PruneSegment}; +use alloc::vec::Vec; use alloy_primitives::{BlockNumber, TxNumber}; use derive_more::Display; diff --git a/crates/prune/types/src/target.rs b/crates/prune/types/src/target.rs index 59ebd803b900..9edeb71ec97f 100644 --- a/crates/prune/types/src/target.rs +++ b/crates/prune/types/src/target.rs @@ -99,6 +99,7 @@ fn deserialize_opt_prune_mode_with_min_blocks< >( deserializer: D, ) -> Result, D::Error> { + use alloc::format; use serde::Deserialize; let prune_mode = Option::::deserialize(deserializer)?; diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 78d942bb2020..e001b138d17a 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -38,6 +38,7 @@ std = [ "revm/std", "alloy-consensus/std", "reth-ethereum-forks/std", + "reth-storage-errors/std", ] witness = ["dep:reth-trie"] test-utils = [ diff --git a/crates/static-file/types/Cargo.toml b/crates/static-file/types/Cargo.toml index f3377698b303..e2cd90c2686f 100644 --- a/crates/static-file/types/Cargo.toml +++ b/crates/static-file/types/Cargo.toml @@ -23,4 +23,11 @@ strum = { workspace = true, features = ["derive"] } reth-nippy-jar.workspace = true [features] +default = ["std"] +std = [ + "alloy-primitives/std", + "derive_more/std", + "serde/std", + "strum/std", +] clap = ["dep:clap"] diff --git a/crates/static-file/types/src/event.rs b/crates/static-file/types/src/event.rs index 1e5d2cb6032e..31492a185202 100644 --- a/crates/static-file/types/src/event.rs +++ b/crates/static-file/types/src/event.rs @@ -1,5 +1,5 @@ use crate::StaticFileTargets; -use std::time::Duration; +use core::time::Duration; /// An event emitted by the static file producer. #[derive(Debug, PartialEq, Eq, Clone)] diff --git a/crates/static-file/types/src/lib.rs b/crates/static-file/types/src/lib.rs index 1618d6443e32..ad3dca486de0 100644 --- a/crates/static-file/types/src/lib.rs +++ b/crates/static-file/types/src/lib.rs @@ -7,6 +7,9 @@ )] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; mod compression; mod event; @@ -14,9 +17,9 @@ mod segment; use alloy_primitives::BlockNumber; pub use compression::Compression; +use core::ops::RangeInclusive; pub use event::StaticFileProducerEvent; pub use segment::{SegmentConfig, SegmentHeader, SegmentRangeInclusive, StaticFileSegment}; -use std::ops::RangeInclusive; /// Default static file block count. pub const DEFAULT_BLOCKS_PER_STATIC_FILE: u64 = 500_000; diff --git a/crates/static-file/types/src/segment.rs b/crates/static-file/types/src/segment.rs index fe07f28a3185..2cf952022059 100644 --- a/crates/static-file/types/src/segment.rs +++ b/crates/static-file/types/src/segment.rs @@ -1,8 +1,12 @@ use crate::{BlockNumber, Compression}; +use alloc::{ + format, + string::{String, ToString}, +}; use alloy_primitives::TxNumber; +use core::{ops::RangeInclusive, str::FromStr}; use derive_more::Display; use serde::{Deserialize, Serialize}; -use std::{ops::RangeInclusive, str::FromStr}; use strum::{AsRefStr, EnumString}; #[derive( @@ -338,8 +342,8 @@ impl SegmentRangeInclusive { } } -impl std::fmt::Display for SegmentRangeInclusive { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { +impl core::fmt::Display for SegmentRangeInclusive { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}..={}", self.start, self.end) } } diff --git a/crates/storage/errors/Cargo.toml b/crates/storage/errors/Cargo.toml index 24e282605eaf..e9405a485a3e 100644 --- a/crates/storage/errors/Cargo.toml +++ b/crates/storage/errors/Cargo.toml @@ -34,4 +34,6 @@ std = [ "derive_more/std", "reth-primitives-traits/std", "thiserror/std", + "reth-prune-types/std", + "reth-static-file-types/std", ] diff --git a/crates/storage/storage-api/Cargo.toml b/crates/storage/storage-api/Cargo.toml index 4d8fb640a8e3..5bbe2fa87fcf 100644 --- a/crates/storage/storage-api/Cargo.toml +++ b/crates/storage/storage-api/Cargo.toml @@ -47,4 +47,7 @@ std = [ "reth-primitives-traits/std", "revm/std", "reth-stages-types/std", + "reth-prune-types/std", + "reth-storage-errors/std", + "reth-execution-types/std", ]