chore: no_std for reth-execution-types (#14465)

This commit is contained in:
Arsenii Kulikov
2025-02-13 13:47:40 +04:00
committed by GitHub
parent a699ee5405
commit cfb91e94dd
25 changed files with 93 additions and 62 deletions

View File

@ -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

View File

@ -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

2
Cargo.lock generated
View File

@ -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",

View File

@ -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 }

View File

@ -61,4 +61,5 @@ std = [
"reth-primitives-traits/std",
"reth-chainspec/std",
"derive_more/std",
"reth-execution-types/std",
]

View File

@ -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",

View File

@ -29,4 +29,5 @@ std = [
"alloy-rlp/std",
"thiserror/std",
"nybbles/std",
"reth-storage-errors/std",
]

View File

@ -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",
]

View File

@ -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<N: NodePrimitives = reth_primitives::EthPrimitives> {
pub struct Chain<N: NodePrimitives = reth_ethereum_primitives::EthPrimitives> {
/// All blocks in this chain.
blocks: BTreeMap<BlockNumber, RecoveredBlock<N::Block>>,
/// The outcome of block execution for this chain.
@ -470,7 +470,7 @@ impl<B: Block> IntoIterator for ChainBlocks<'_, B> {
/// Used to hold receipts and their attachment.
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct BlockReceipts<T = reth_primitives::Receipt> {
pub struct BlockReceipts<T = reth_ethereum_primitives::Receipt> {
/// Block identifier
pub block: BlockNumHash,
/// Transaction identifier and receipt.
@ -500,7 +500,7 @@ impl From<BlockHash> for ChainSplitTarget {
/// Result of a split chain.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ChainSplit<N: NodePrimitives = reth_primitives::EthPrimitives> {
pub enum ChainSplit<N: NodePrimitives = reth_ethereum_primitives::EthPrimitives> {
/// 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<Header: SerdeBincodeCompat, Body: SerdeBincodeCompat>
+ 'static,
>(Cow<'a, BTreeMap<BlockNumber, reth_primitives::RecoveredBlock<B>>>);
>(Cow<'a, BTreeMap<BlockNumber, reth_primitives_traits::RecoveredBlock<B>>>);
impl<B> 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<reth_primitives::Block> = Default::default();
let block: RecoveredBlock<reth_ethereum_primitives::Block> = 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<reth_primitives::Block> = Default::default();
let mut block1: RecoveredBlock<reth_ethereum_primitives::Block> = 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<reth_primitives::Block> = Default::default();
let mut block2: RecoveredBlock<reth_ethereum_primitives::Block> = 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<reth_primitives::Block> = Default::default();
let block: RecoveredBlock<reth_ethereum_primitives::Block> = 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<TestPrimitives> = Chain {
let chain: Chain = Chain {
blocks: BTreeMap::from([(10, block1), (11, block2)]),
execution_outcome: execution_outcome.clone(),
..Default::default()

View File

@ -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<T = reth_primitives::Receipt> {
pub struct ExecutionOutcome<T = reth_ethereum_primitives::Receipt> {
/// 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<B256> {
self.generic_receipts_root_slow(
block_number,
reth_primitives::Receipt::calculate_receipt_root_no_memo,
reth_ethereum_primitives::Receipt::calculate_receipt_root_no_memo,
)
}
}

View File

@ -61,4 +61,5 @@ std = [
"alloy-consensus/std",
"derive_more/std",
"reth-network-peers/std",
"reth-storage-errors/std",
]

View File

@ -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",

View File

@ -62,6 +62,7 @@ std = [
"reth-ethereum-primitives/std",
"alloy-rlp/std",
"alloy-primitives/std",
"reth-static-file-types/std",
]
reth-codec = [
"std",

View File

@ -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",

View File

@ -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)]

View File

@ -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))]

View File

@ -1,4 +1,5 @@
use crate::{PruneCheckpoint, PruneMode, PruneSegment};
use alloc::vec::Vec;
use alloy_primitives::{BlockNumber, TxNumber};
use derive_more::Display;

View File

@ -99,6 +99,7 @@ fn deserialize_opt_prune_mode_with_min_blocks<
>(
deserializer: D,
) -> Result<Option<PruneMode>, D::Error> {
use alloc::format;
use serde::Deserialize;
let prune_mode = Option::<PruneMode>::deserialize(deserializer)?;

View File

@ -38,6 +38,7 @@ std = [
"revm/std",
"alloy-consensus/std",
"reth-ethereum-forks/std",
"reth-storage-errors/std",
]
witness = ["dep:reth-trie"]
test-utils = [

View File

@ -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"]

View File

@ -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)]

View File

@ -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;

View File

@ -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)
}
}

View File

@ -34,4 +34,6 @@ std = [
"derive_more/std",
"reth-primitives-traits/std",
"thiserror/std",
"reth-prune-types/std",
"reth-static-file-types/std",
]

View File

@ -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",
]