diff --git a/Cargo.lock b/Cargo.lock index f36e16c32..613716d98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6210,6 +6210,7 @@ dependencies = [ "reth-payload-validator", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-revm", "reth-rpc", "reth-rpc-api", @@ -6306,6 +6307,7 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-prune", + "reth-prune-types", "reth-revm", "reth-rpc", "reth-rpc-types", @@ -6344,6 +6346,7 @@ dependencies = [ "reth-network", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-revm", "reth-stages-api", "reth-storage-errors", @@ -6411,7 +6414,7 @@ dependencies = [ "confy", "humantime-serde", "reth-network", - "reth-primitives", + "reth-prune-types", "serde", "tempfile", "toml", @@ -6460,6 +6463,7 @@ dependencies = [ "reth-metrics", "reth-nippy-jar", "reth-primitives", + "reth-prune-types", "reth-storage-errors", "reth-tracing", "rustc-hash", @@ -6492,6 +6496,7 @@ dependencies = [ "rand 0.8.5", "reth-codecs", "reth-primitives", + "reth-prune-types", "reth-storage-errors", "serde", "serde_json", @@ -6838,6 +6843,7 @@ dependencies = [ "parking_lot 0.12.3", "reth-execution-errors", "reth-primitives", + "reth-prune-types", "reth-storage-errors", "revm", "revm-primitives", @@ -6852,6 +6858,7 @@ dependencies = [ "reth-ethereum-consensus", "reth-evm", "reth-primitives", + "reth-prune-types", "reth-revm", "reth-testing-utils", "revm-primitives", @@ -6869,6 +6876,7 @@ dependencies = [ "reth-optimism-consensus", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-revm", "revm", "revm-primitives", @@ -6882,6 +6890,7 @@ version = "0.2.0-beta.9" dependencies = [ "reth-consensus", "reth-primitives", + "reth-prune-types", "reth-storage-errors", "thiserror", ] @@ -7275,6 +7284,7 @@ dependencies = [ "reth-network-types", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-rpc", "reth-rpc-api", "reth-rpc-builder", @@ -7543,6 +7553,7 @@ dependencies = [ "reth-network-p2p", "reth-nippy-jar", "reth-primitives", + "reth-prune-types", "reth-storage-api", "reth-storage-errors", "reth-testing-utils", @@ -7559,6 +7570,7 @@ dependencies = [ name = "reth-prune" version = "0.2.0-beta.9" dependencies = [ + "alloy-primitives", "assert_matches", "itertools 0.12.1", "metrics", @@ -7570,6 +7582,7 @@ dependencies = [ "reth-metrics", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-stages", "reth-testing-utils", "reth-tokio-util", @@ -7579,6 +7592,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "reth-prune-types" +version = "0.2.0-beta.9" +dependencies = [ + "alloy-primitives", + "arbitrary", + "assert_matches", + "bytes", + "derive_more", + "modular-bitfield", + "proptest", + "proptest-derive", + "reth-codecs", + "serde", + "serde_json", + "test-fuzz", + "thiserror", + "toml", +] + [[package]] name = "reth-revm" version = "0.2.0-beta.9" @@ -7588,6 +7621,7 @@ dependencies = [ "reth-consensus-common", "reth-execution-errors", "reth-primitives", + "reth-prune-types", "reth-storage-api", "reth-storage-errors", "reth-trie", @@ -7836,6 +7870,7 @@ dependencies = [ "reth-network-types", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-revm", "reth-stages-api", "reth-static-file", @@ -7887,6 +7922,7 @@ dependencies = [ "reth-nippy-jar", "reth-primitives", "reth-provider", + "reth-prune-types", "reth-stages", "reth-storage-errors", "reth-testing-utils", @@ -7914,6 +7950,7 @@ dependencies = [ "reth-db-api", "reth-execution-types", "reth-primitives", + "reth-prune-types", "reth-storage-errors", "reth-trie", "revm", diff --git a/Cargo.toml b/Cargo.toml index f2ec883d0..1d69e5644 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,8 @@ members = [ "crates/payload/primitives/", "crates/payload/validator/", "crates/primitives/", - "crates/prune/", + "crates/prune/prune", + "crates/prune/types", "crates/revm/", "crates/rpc/ipc/", "crates/rpc/rpc-api/", @@ -295,7 +296,8 @@ reth-payload-primitives = { path = "crates/payload/primitives" } reth-payload-validator = { path = "crates/payload/validator" } reth-primitives = { path = "crates/primitives" } reth-provider = { path = "crates/storage/provider" } -reth-prune = { path = "crates/prune" } +reth-prune = { path = "crates/prune/prune" } +reth-prune-types = { path = "crates/prune/types" } reth-revm = { path = "crates/revm" } reth-rpc = { path = "crates/rpc/rpc" } reth-rpc-api = { path = "crates/rpc/rpc-api" } diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 6d003cf09..38410737e 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -63,6 +63,7 @@ reth-node-builder.workspace = true reth-node-events.workspace = true reth-consensus.workspace = true reth-optimism-primitives.workspace = true +reth-prune-types.workspace = true # crypto alloy-rlp.workspace = true diff --git a/bin/reth/src/commands/debug_cmd/execution.rs b/bin/reth/src/commands/debug_cmd/execution.rs index 5b7295b32..a68716ff7 100644 --- a/bin/reth/src/commands/debug_cmd/execution.rs +++ b/bin/reth/src/commands/debug_cmd/execution.rs @@ -22,10 +22,11 @@ use reth_exex::ExExManagerHandle; use reth_network::{NetworkEvents, NetworkHandle}; use reth_network_api::NetworkInfo; use reth_network_p2p::{bodies::client::BodiesClient, headers::client::HeadersClient}; -use reth_primitives::{stage::StageId, BlockHashOrNumber, BlockNumber, PruneModes, B256}; +use reth_primitives::{stage::StageId, BlockHashOrNumber, BlockNumber, B256}; use reth_provider::{ BlockExecutionWriter, ChainSpecProvider, HeaderSyncMode, ProviderFactory, StageCheckpointReader, }; +use reth_prune_types::PruneModes; use reth_stages::{ sets::DefaultStages, stages::{ExecutionStage, ExecutionStageThresholds}, diff --git a/bin/reth/src/commands/debug_cmd/merkle.rs b/bin/reth/src/commands/debug_cmd/merkle.rs index 6be38c267..cbc6f84aa 100644 --- a/bin/reth/src/commands/debug_cmd/merkle.rs +++ b/bin/reth/src/commands/debug_cmd/merkle.rs @@ -18,11 +18,12 @@ use reth_evm::execute::{BatchBlockExecutionOutput, BatchExecutor, BlockExecutorP use reth_network::NetworkHandle; use reth_network_api::NetworkInfo; use reth_network_p2p::full_block::FullBlockClient; -use reth_primitives::{stage::StageCheckpoint, BlockHashOrNumber, PruneModes}; +use reth_primitives::{stage::StageCheckpoint, BlockHashOrNumber}; use reth_provider::{ BlockNumReader, BlockWriter, BundleStateWithReceipts, ChainSpecProvider, HeaderProvider, LatestStateProviderRef, OriginalValuesKnown, ProviderError, ProviderFactory, StateWriter, }; +use reth_prune_types::PruneModes; use reth_revm::database::StateProviderDatabase; use reth_stages::{ stages::{AccountHashingStage, MerkleStage, StorageHashingStage}, diff --git a/bin/reth/src/commands/debug_cmd/replay_engine.rs b/bin/reth/src/commands/debug_cmd/replay_engine.rs index 942071b0d..7d8e179d2 100644 --- a/bin/reth/src/commands/debug_cmd/replay_engine.rs +++ b/bin/reth/src/commands/debug_cmd/replay_engine.rs @@ -19,10 +19,10 @@ use reth_network::NetworkHandle; use reth_network_api::NetworkInfo; use reth_node_core::engine::engine_store::{EngineMessageStore, StoredEngineApiMessage}; use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService}; -use reth_primitives::PruneModes; use reth_provider::{ providers::BlockchainProvider, CanonStateSubscriptions, ChainSpecProvider, ProviderFactory, }; +use reth_prune_types::PruneModes; use reth_stages::Pipeline; use reth_static_file::StaticFileProducer; use reth_tasks::TaskExecutor; diff --git a/bin/reth/src/commands/import.rs b/bin/reth/src/commands/import.rs index dd07084c4..201adf53e 100644 --- a/bin/reth/src/commands/import.rs +++ b/bin/reth/src/commands/import.rs @@ -22,11 +22,12 @@ use reth_network_p2p::{ headers::downloader::{HeaderDownloader, SyncTarget}, }; use reth_node_events::node::NodeEvent; -use reth_primitives::{stage::StageId, PruneModes, B256}; +use reth_primitives::{stage::StageId, B256}; use reth_provider::{ BlockNumReader, ChainSpecProvider, HeaderProvider, HeaderSyncMode, ProviderError, ProviderFactory, StageCheckpointReader, }; +use reth_prune_types::PruneModes; use reth_stages::{prelude::*, Pipeline, StageSet}; use reth_static_file::StaticFileProducer; use std::{path::PathBuf, sync::Arc}; diff --git a/bin/reth/src/commands/import_op.rs b/bin/reth/src/commands/import_op.rs index 5260c3fe7..206643b65 100644 --- a/bin/reth/src/commands/import_op.rs +++ b/bin/reth/src/commands/import_op.rs @@ -16,8 +16,9 @@ use reth_downloaders::file_client::{ ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE, }; use reth_optimism_primitives::bedrock_import::is_dup_tx; -use reth_primitives::{stage::StageId, PruneModes}; +use reth_primitives::stage::StageId; use reth_provider::StageCheckpointReader; +use reth_prune_types::PruneModes; use reth_static_file::StaticFileProducer; use std::{path::PathBuf, sync::Arc}; use tracing::{debug, error, info}; diff --git a/bin/reth/src/commands/stage/dump/merkle.rs b/bin/reth/src/commands/stage/dump/merkle.rs index e6c16783b..349a06b50 100644 --- a/bin/reth/src/commands/stage/dump/merkle.rs +++ b/bin/reth/src/commands/stage/dump/merkle.rs @@ -6,8 +6,9 @@ use reth_db::{tables, DatabaseEnv}; use reth_db_api::{database::Database, table::TableImporter}; use reth_exex::ExExManagerHandle; use reth_node_core::dirs::{ChainPath, DataDirPath}; -use reth_primitives::{stage::StageCheckpoint, BlockNumber, PruneModes}; +use reth_primitives::{stage::StageCheckpoint, BlockNumber}; use reth_provider::{providers::StaticFileProvider, ProviderFactory}; +use reth_prune_types::PruneModes; use reth_stages::{ stages::{ AccountHashingStage, ExecutionStage, ExecutionStageThresholds, MerkleStage, diff --git a/bin/reth/src/commands/stage/unwind.rs b/bin/reth/src/commands/stage/unwind.rs index feb93378e..89131e5aa 100644 --- a/bin/reth/src/commands/stage/unwind.rs +++ b/bin/reth/src/commands/stage/unwind.rs @@ -8,11 +8,12 @@ use reth_db_api::database::Database; use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader}; use reth_exex::ExExManagerHandle; use reth_node_core::args::NetworkArgs; -use reth_primitives::{BlockHashOrNumber, BlockNumber, PruneModes, B256}; +use reth_primitives::{BlockHashOrNumber, BlockNumber, B256}; use reth_provider::{ BlockExecutionWriter, BlockNumReader, ChainSpecProvider, FinalizedBlockReader, FinalizedBlockWriter, HeaderSyncMode, ProviderFactory, StaticFileProviderFactory, }; +use reth_prune_types::PruneModes; use reth_stages::{ sets::DefaultStages, stages::{ExecutionStage, ExecutionStageThresholds}, diff --git a/crates/blockchain-tree/Cargo.toml b/crates/blockchain-tree/Cargo.toml index a59858577..647969396 100644 --- a/crates/blockchain-tree/Cargo.toml +++ b/crates/blockchain-tree/Cargo.toml @@ -21,6 +21,7 @@ reth-db-api.workspace = true reth-evm.workspace = true reth-revm.workspace = true reth-provider.workspace = true +reth-prune-types.workspace = true reth-stages-api.workspace = true reth-trie = { workspace = true, features = ["metrics"] } reth-trie-parallel = { workspace = true, features = ["parallel"] } diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index e01b11b37..5fd4af084 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -14,8 +14,8 @@ use reth_db_api::database::Database; use reth_evm::execute::BlockExecutorProvider; use reth_execution_errors::{BlockExecutionError, BlockValidationError}; use reth_primitives::{ - BlockHash, BlockNumHash, BlockNumber, ForkBlock, GotExpected, Hardfork, PruneModes, Receipt, - SealedBlock, SealedBlockWithSenders, SealedHeader, StaticFileSegment, B256, U256, + BlockHash, BlockNumHash, BlockNumber, ForkBlock, GotExpected, Hardfork, Receipt, SealedBlock, + SealedBlockWithSenders, SealedHeader, StaticFileSegment, B256, U256, }; use reth_provider::{ BlockExecutionWriter, BlockNumReader, BlockWriter, BundleStateWithReceipts, @@ -23,6 +23,7 @@ use reth_provider::{ ChainSpecProvider, ChainSplit, ChainSplitTarget, DisplayBlocksChain, HeaderProvider, ProviderError, StaticFileProviderFactory, }; +use reth_prune_types::PruneModes; use reth_stages_api::{MetricEvent, MetricEventsSender}; use reth_storage_errors::provider::{ProviderResult, RootMismatch}; use std::{ diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 9e9aa4806..527f5b153 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] # reth reth-network.workspace = true -reth-primitives.workspace = true +reth-prune-types.workspace = true # serde serde.workspace = true diff --git a/crates/config/src/config.rs b/crates/config/src/config.rs index d18f6ae8d..f458ef416 100644 --- a/crates/config/src/config.rs +++ b/crates/config/src/config.rs @@ -1,7 +1,7 @@ //! Configuration files. use reth_network::{PeersConfig, SessionsConfig}; -use reth_primitives::PruneModes; +use reth_prune_types::PruneModes; use serde::{Deserialize, Deserializer, Serialize}; use std::{ ffi::OsStr, diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index 3f6043807..01a705d5c 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -66,6 +66,7 @@ reth-evm-ethereum.workspace = true reth-ethereum-engine-primitives.workspace = true reth-config.workspace = true reth-testing-utils.workspace = true +reth-prune-types.workspace = true assert_matches.workspace = true diff --git a/crates/consensus/beacon/src/engine/sync.rs b/crates/consensus/beacon/src/engine/sync.rs index 8d6ab09ba..74c6ea118 100644 --- a/crates/consensus/beacon/src/engine/sync.rs +++ b/crates/consensus/beacon/src/engine/sync.rs @@ -432,11 +432,12 @@ mod tests { use reth_network_p2p::{either::Either, test_utils::TestFullBlockClient}; use reth_primitives::{ constants::ETHEREUM_BLOCK_GAS_LIMIT, stage::StageCheckpoint, BlockBody, ChainSpecBuilder, - Header, PruneModes, SealedHeader, MAINNET, + Header, SealedHeader, MAINNET, }; use reth_provider::{ test_utils::create_test_provider_factory_with_chain_spec, BundleStateWithReceipts, }; + use reth_prune_types::PruneModes; use reth_stages::{test_utils::TestStages, ExecOutput, StageError}; use reth_static_file::StaticFileProducer; use reth_tasks::TokioTaskExecutor; diff --git a/crates/consensus/beacon/src/engine/test_utils.rs b/crates/consensus/beacon/src/engine/test_utils.rs index d97a626bf..173828f5c 100644 --- a/crates/consensus/beacon/src/engine/test_utils.rs +++ b/crates/consensus/beacon/src/engine/test_utils.rs @@ -21,12 +21,13 @@ use reth_network_p2p::{ test_utils::NoopFullBlockClient, }; use reth_payload_builder::test_utils::spawn_test_payload_service; -use reth_primitives::{BlockNumber, ChainSpec, FinishedExExHeight, PruneModes, B256}; +use reth_primitives::{BlockNumber, ChainSpec, FinishedExExHeight, B256}; use reth_provider::{ providers::BlockchainProvider, test_utils::create_test_provider_factory_with_chain_spec, BundleStateWithReceipts, HeaderSyncMode, }; use reth_prune::Pruner; +use reth_prune_types::PruneModes; use reth_rpc_types::engine::{ CancunPayloadFields, ExecutionPayload, ForkchoiceState, ForkchoiceUpdated, PayloadStatus, }; diff --git a/crates/ethereum/evm/Cargo.toml b/crates/ethereum/evm/Cargo.toml index 17b2dbd0b..84060cd1b 100644 --- a/crates/ethereum/evm/Cargo.toml +++ b/crates/ethereum/evm/Cargo.toml @@ -16,6 +16,7 @@ reth-evm.workspace = true reth-primitives.workspace = true reth-revm.workspace = true reth-ethereum-consensus.workspace = true +reth-prune-types.workspace = true # Ethereum revm-primitives.workspace = true diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 7b1e7d455..457f15428 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -13,9 +13,10 @@ use reth_evm::{ ConfigureEvm, }; use reth_primitives::{ - BlockNumber, BlockWithSenders, ChainSpec, Hardfork, Header, PruneModes, Receipt, Request, - Withdrawals, MAINNET, U256, + BlockNumber, BlockWithSenders, ChainSpec, Hardfork, Header, Receipt, Request, Withdrawals, + MAINNET, U256, }; +use reth_prune_types::PruneModes; use reth_revm::{ batch::{BlockBatchRecord, BlockExecutorStats}, db::states::bundle_state::BundleRetention, diff --git a/crates/evm/Cargo.toml b/crates/evm/Cargo.toml index 6ac91ca8d..3de203f7c 100644 --- a/crates/evm/Cargo.toml +++ b/crates/evm/Cargo.toml @@ -15,6 +15,7 @@ workspace = true reth-execution-errors.workspace = true reth-primitives.workspace = true revm-primitives.workspace = true +reth-prune-types.workspace = true reth-storage-errors.workspace = true revm.workspace = true diff --git a/crates/evm/execution-errors/Cargo.toml b/crates/evm/execution-errors/Cargo.toml index f370f8297..4a2315684 100644 --- a/crates/evm/execution-errors/Cargo.toml +++ b/crates/evm/execution-errors/Cargo.toml @@ -15,5 +15,5 @@ workspace = true reth-consensus.workspace = true reth-primitives.workspace = true reth-storage-errors.workspace = true - +reth-prune-types.workspace = true thiserror.workspace = true diff --git a/crates/evm/execution-errors/src/lib.rs b/crates/evm/execution-errors/src/lib.rs index 31693f6ce..3c5088028 100644 --- a/crates/evm/execution-errors/src/lib.rs +++ b/crates/evm/execution-errors/src/lib.rs @@ -9,7 +9,8 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] use reth_consensus::ConsensusError; -use reth_primitives::{revm_primitives::EVMError, BlockNumHash, PruneSegmentError, B256}; +use reth_primitives::{revm_primitives::EVMError, BlockNumHash, B256}; +use reth_prune_types::PruneSegmentError; use reth_storage_errors::provider::ProviderError; use std::fmt::Display; use thiserror::Error; diff --git a/crates/evm/src/either.rs b/crates/evm/src/either.rs index 695da5d28..2d9f68c9e 100644 --- a/crates/evm/src/either.rs +++ b/crates/evm/src/either.rs @@ -5,7 +5,8 @@ use crate::execute::{ BlockExecutorProvider, Executor, }; use reth_execution_errors::BlockExecutionError; -use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt}; +use reth_primitives::{BlockNumber, BlockWithSenders, Receipt}; +use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderError; use revm_primitives::db::Database; diff --git a/crates/evm/src/execute.rs b/crates/evm/src/execute.rs index b13e286a9..f6c217299 100644 --- a/crates/evm/src/execute.rs +++ b/crates/evm/src/execute.rs @@ -1,8 +1,7 @@ //! Traits for execution. -use reth_primitives::{ - BlockNumber, BlockWithSenders, PruneModes, Receipt, Receipts, Request, Requests, U256, -}; +use reth_primitives::{BlockNumber, BlockWithSenders, Receipt, Receipts, Request, Requests, U256}; +use reth_prune_types::PruneModes; use revm::db::BundleState; use revm_primitives::db::Database; diff --git a/crates/evm/src/noop.rs b/crates/evm/src/noop.rs index 67ef964e7..d6a419bf2 100644 --- a/crates/evm/src/noop.rs +++ b/crates/evm/src/noop.rs @@ -1,7 +1,8 @@ //! A no operation block executor implementation. use reth_execution_errors::BlockExecutionError; -use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt}; +use reth_primitives::{BlockNumber, BlockWithSenders, Receipt}; +use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderError; use revm_primitives::db::Database; diff --git a/crates/evm/src/test_utils.rs b/crates/evm/src/test_utils.rs index 9199747ca..20f7282c7 100644 --- a/crates/evm/src/test_utils.rs +++ b/crates/evm/src/test_utils.rs @@ -6,7 +6,8 @@ use crate::execute::{ }; use parking_lot::Mutex; use reth_execution_errors::BlockExecutionError; -use reth_primitives::{BlockNumber, BlockWithSenders, PruneModes, Receipt}; +use reth_primitives::{BlockNumber, BlockWithSenders, Receipt}; +use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderError; use revm_primitives::db::Database; use std::sync::Arc; diff --git a/crates/node-core/Cargo.toml b/crates/node-core/Cargo.toml index af0f4c773..01c078d37 100644 --- a/crates/node-core/Cargo.toml +++ b/crates/node-core/Cargo.toml @@ -36,6 +36,7 @@ reth-engine-primitives.workspace = true reth-tasks.workspace = true reth-consensus-common.workspace = true reth-beacon-consensus.workspace = true +reth-prune-types.workspace = true # ethereum alloy-rpc-types-engine.workspace = true diff --git a/crates/node-core/src/args/pruning.rs b/crates/node-core/src/args/pruning.rs index e585a216d..390597c54 100644 --- a/crates/node-core/src/args/pruning.rs +++ b/crates/node-core/src/args/pruning.rs @@ -2,9 +2,8 @@ use clap::Args; use reth_config::config::PruneConfig; -use reth_primitives::{ - ChainSpec, PruneMode, PruneModes, ReceiptsLogPruneConfig, MINIMUM_PRUNING_DISTANCE, -}; +use reth_primitives::ChainSpec; +use reth_prune_types::{PruneMode, PruneModes, ReceiptsLogPruneConfig, MINIMUM_PRUNING_DISTANCE}; /// Parameters for pruning and full node #[derive(Debug, Clone, Args, PartialEq, Eq, Default)] diff --git a/crates/node/builder/src/launch/common.rs b/crates/node/builder/src/launch/common.rs index abc632db9..67242446e 100644 --- a/crates/node/builder/src/launch/common.rs +++ b/crates/node/builder/src/launch/common.rs @@ -16,13 +16,11 @@ use reth_node_core::{ dirs::{ChainPath, DataDirPath}, node_config::NodeConfig, }; -use reth_primitives::{ - stage::PipelineTarget, BlockNumber, Chain, ChainSpec, Head, PruneModes, B256, -}; +use reth_primitives::{stage::PipelineTarget, BlockNumber, Chain, ChainSpec, Head, B256}; use reth_provider::{ providers::StaticFileProvider, HeaderSyncMode, ProviderFactory, StaticFileProviderFactory, }; -use reth_prune::PrunerBuilder; +use reth_prune::{PruneModes, PrunerBuilder}; use reth_rpc_layer::JwtSecret; use reth_stages::{sets::DefaultStages, Pipeline}; use reth_static_file::StaticFileProducer; diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index c3f4643b2..f64a341a9 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -17,6 +17,7 @@ reth-primitives.workspace = true reth-revm.workspace = true reth-execution-errors.workspace = true reth-provider.workspace = true +reth-prune-types.workspace = true reth-consensus-common.workspace = true # Optimism diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index 5ff5e3f43..344768e6a 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -10,9 +10,10 @@ use reth_evm::{ }; use reth_optimism_consensus::validate_block_post_execution; use reth_primitives::{ - BlockNumber, BlockWithSenders, ChainSpec, Hardfork, Header, PruneModes, Receipt, Receipts, - TxType, Withdrawals, U256, + BlockNumber, BlockWithSenders, ChainSpec, Hardfork, Header, Receipt, Receipts, TxType, + Withdrawals, U256, }; +use reth_prune_types::PruneModes; use reth_revm::{ batch::{BlockBatchRecord, BlockExecutorStats}, db::states::bundle_state::BundleRetention, diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index b2ec3e886..c077c1e89 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -36,7 +36,6 @@ mod integer_list; mod log; mod net; pub mod proofs; -mod prune; mod receipt; mod request; /// Helpers for working with revm @@ -76,11 +75,6 @@ pub use net::{ NodeRecordParseError, TrustedPeer, GOERLI_BOOTNODES, HOLESKY_BOOTNODES, MAINNET_BOOTNODES, SEPOLIA_BOOTNODES, }; -pub use prune::{ - PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneModes, PruneProgress, - PrunePurpose, PruneSegment, PruneSegmentError, ReceiptsLogPruneConfig, - MINIMUM_PRUNING_DISTANCE, -}; pub use receipt::{ gas_spent_by_transactions, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts, }; diff --git a/crates/prune/Cargo.toml b/crates/prune/prune/Cargo.toml similarity index 93% rename from crates/prune/Cargo.toml rename to crates/prune/prune/Cargo.toml index 2fe34db95..274056b78 100644 --- a/crates/prune/Cargo.toml +++ b/crates/prune/prune/Cargo.toml @@ -20,10 +20,12 @@ reth-errors.workspace = true reth-provider.workspace = true reth-tokio-util.workspace = true reth-config.workspace = true +reth-prune-types.workspace = true # metrics reth-metrics.workspace = true metrics.workspace = true +alloy-primitives.workspace = true # misc tracing.workspace = true diff --git a/crates/prune/src/builder.rs b/crates/prune/prune/src/builder.rs similarity index 97% rename from crates/prune/src/builder.rs rename to crates/prune/prune/src/builder.rs index 1a052434a..83fabeb4c 100644 --- a/crates/prune/src/builder.rs +++ b/crates/prune/prune/src/builder.rs @@ -1,8 +1,9 @@ use crate::{segments::SegmentSet, Pruner}; use reth_config::PruneConfig; use reth_db_api::database::Database; -use reth_primitives::{FinishedExExHeight, PruneModes, MAINNET}; +use reth_primitives::{FinishedExExHeight, MAINNET}; use reth_provider::ProviderFactory; +use reth_prune_types::PruneModes; use std::time::Duration; use tokio::sync::watch; diff --git a/crates/prune/src/error.rs b/crates/prune/prune/src/error.rs similarity index 95% rename from crates/prune/src/error.rs rename to crates/prune/prune/src/error.rs index 6f37fff9f..a2cbaebc1 100644 --- a/crates/prune/src/error.rs +++ b/crates/prune/prune/src/error.rs @@ -1,7 +1,7 @@ use reth_db::DatabaseError; use reth_errors::RethError; -use reth_primitives::PruneSegmentError; use reth_provider::ProviderError; +use reth_prune_types::PruneSegmentError; use thiserror::Error; /// Errors that can occur during pruning. diff --git a/crates/prune/src/event.rs b/crates/prune/prune/src/event.rs similarity index 83% rename from crates/prune/src/event.rs rename to crates/prune/prune/src/event.rs index c2c3808d1..7007e3f47 100644 --- a/crates/prune/src/event.rs +++ b/crates/prune/prune/src/event.rs @@ -1,4 +1,5 @@ -use reth_primitives::{BlockNumber, PruneProgress, PruneSegment}; +use alloy_primitives::BlockNumber; +use reth_prune_types::{PruneProgress, PruneSegment}; use std::{collections::BTreeMap, time::Duration}; /// An event emitted by a [Pruner][crate::Pruner]. diff --git a/crates/prune/src/lib.rs b/crates/prune/prune/src/lib.rs similarity index 90% rename from crates/prune/src/lib.rs rename to crates/prune/prune/src/lib.rs index 3cd3730e3..38453385e 100644 --- a/crates/prune/src/lib.rs +++ b/crates/prune/prune/src/lib.rs @@ -21,3 +21,7 @@ pub use builder::PrunerBuilder; pub use error::PrunerError; pub use event::PrunerEvent; pub use pruner::{Pruner, PrunerResult, PrunerWithResult}; + +// Re-export prune types +#[doc(inline)] +pub use reth_prune_types::*; diff --git a/crates/prune/src/metrics.rs b/crates/prune/prune/src/metrics.rs similarity index 96% rename from crates/prune/src/metrics.rs rename to crates/prune/prune/src/metrics.rs index 428c1f784..246dc317b 100644 --- a/crates/prune/src/metrics.rs +++ b/crates/prune/prune/src/metrics.rs @@ -2,7 +2,7 @@ use reth_metrics::{ metrics::{Gauge, Histogram}, Metrics, }; -use reth_primitives::PruneSegment; +use reth_prune_types::PruneSegment; use std::collections::HashMap; #[derive(Metrics)] diff --git a/crates/prune/src/pruner.rs b/crates/prune/prune/src/pruner.rs similarity index 98% rename from crates/prune/src/pruner.rs rename to crates/prune/prune/src/pruner.rs index 950251c5b..dbc3bae26 100644 --- a/crates/prune/src/pruner.rs +++ b/crates/prune/prune/src/pruner.rs @@ -6,13 +6,11 @@ use crate::{ Metrics, PrunerError, PrunerEvent, }; use reth_db_api::database::Database; -use reth_primitives::{ - BlockNumber, FinishedExExHeight, PruneLimiter, PruneMode, PruneProgress, PrunePurpose, - PruneSegment, StaticFileSegment, -}; +use reth_primitives::{BlockNumber, FinishedExExHeight, StaticFileSegment}; use reth_provider::{ DatabaseProviderRW, ProviderFactory, PruneCheckpointReader, StaticFileProviderFactory, }; +use reth_prune_types::{PruneLimiter, PruneMode, PruneProgress, PrunePurpose, PruneSegment}; use reth_tokio_util::{EventSender, EventStream}; use std::{ collections::BTreeMap, diff --git a/crates/prune/src/segments/account_history.rs b/crates/prune/prune/src/segments/account_history.rs similarity index 97% rename from crates/prune/src/segments/account_history.rs rename to crates/prune/prune/src/segments/account_history.rs index b78f0bce8..78ca36219 100644 --- a/crates/prune/src/segments/account_history.rs +++ b/crates/prune/prune/src/segments/account_history.rs @@ -6,8 +6,8 @@ use crate::{ }; use reth_db::tables; use reth_db_api::{database::Database, models::ShardedKey}; -use reth_primitives::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment}; use reth_provider::DatabaseProviderRW; +use reth_prune_types::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; /// Number of account history tables to prune in one step. @@ -108,11 +108,11 @@ mod tests { }; use assert_matches::assert_matches; use reth_db::{tables, BlockNumberList}; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, - PruneSegment, B256, - }; + use reth_primitives::{BlockNumber, B256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{ + PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, PruneSegment, + }; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{ generators, diff --git a/crates/prune/src/segments/headers.rs b/crates/prune/prune/src/segments/headers.rs similarity index 97% rename from crates/prune/src/segments/headers.rs rename to crates/prune/prune/src/segments/headers.rs index 86daada08..3cf2beeba 100644 --- a/crates/prune/src/segments/headers.rs +++ b/crates/prune/prune/src/segments/headers.rs @@ -12,8 +12,9 @@ use reth_db_api::{ transaction::DbTxMut, }; -use reth_primitives::{BlockNumber, PruneLimiter, PruneMode, PruneProgress, PruneSegment}; +use alloy_primitives::BlockNumber; use reth_provider::DatabaseProviderRW; +use reth_prune_types::{PruneLimiter, PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; /// Number of header tables to prune in one step @@ -190,11 +191,11 @@ mod tests { use assert_matches::assert_matches; use reth_db::tables; use reth_db_api::transaction::DbTx; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, - PruneSegment, B256, U256, - }; + use reth_primitives::{BlockNumber, B256, U256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{ + PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, PruneSegment, + }; use reth_stages::test_utils::TestStageDB; use reth_testing_utils::{generators, generators::random_header_range}; use tracing::trace; diff --git a/crates/prune/src/segments/history.rs b/crates/prune/prune/src/segments/history.rs similarity index 100% rename from crates/prune/src/segments/history.rs rename to crates/prune/prune/src/segments/history.rs diff --git a/crates/prune/src/segments/mod.rs b/crates/prune/prune/src/segments/mod.rs similarity index 97% rename from crates/prune/src/segments/mod.rs rename to crates/prune/prune/src/segments/mod.rs index 7007bce48..9dc689265 100644 --- a/crates/prune/src/segments/mod.rs +++ b/crates/prune/prune/src/segments/mod.rs @@ -11,17 +11,17 @@ mod transactions; use crate::PrunerError; pub use account_history::AccountHistory; +use alloy_primitives::{BlockNumber, TxNumber}; pub use headers::Headers; pub use receipts::Receipts; pub use receipts_by_logs::ReceiptsByLogs; use reth_db_api::database::Database; -use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, - PruneSegment, TxNumber, -}; use reth_provider::{ errors::provider::ProviderResult, BlockReader, DatabaseProviderRW, PruneCheckpointWriter, }; +use reth_prune_types::{ + PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, PruneSegment, +}; pub use sender_recovery::SenderRecovery; pub use set::SegmentSet; use std::{fmt::Debug, ops::RangeInclusive}; diff --git a/crates/prune/src/segments/receipts.rs b/crates/prune/prune/src/segments/receipts.rs similarity index 96% rename from crates/prune/src/segments/receipts.rs rename to crates/prune/prune/src/segments/receipts.rs index b841c77ed..ef6e502c7 100644 --- a/crates/prune/src/segments/receipts.rs +++ b/crates/prune/prune/src/segments/receipts.rs @@ -4,11 +4,11 @@ use crate::{ }; use reth_db::tables; use reth_db_api::database::Database; -use reth_primitives::{PruneCheckpoint, PruneMode, PruneProgress, PruneSegment}; use reth_provider::{ errors::provider::ProviderResult, DatabaseProviderRW, PruneCheckpointWriter, TransactionsProvider, }; +use reth_prune_types::{PruneCheckpoint, PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; #[derive(Debug)] @@ -100,11 +100,11 @@ mod tests { Itertools, }; use reth_db::tables; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, - PruneSegment, TxNumber, B256, - }; + use reth_primitives::{BlockNumber, TxNumber, B256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{ + PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, PruneSegment, + }; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{ generators, diff --git a/crates/prune/src/segments/receipts_by_logs.rs b/crates/prune/prune/src/segments/receipts_by_logs.rs similarity index 98% rename from crates/prune/src/segments/receipts_by_logs.rs rename to crates/prune/prune/src/segments/receipts_by_logs.rs index 98e817978..f4ccad810 100644 --- a/crates/prune/src/segments/receipts_by_logs.rs +++ b/crates/prune/prune/src/segments/receipts_by_logs.rs @@ -4,11 +4,11 @@ use crate::{ }; use reth_db::tables; use reth_db_api::database::Database; -use reth_primitives::{ +use reth_provider::{BlockReader, DatabaseProviderRW, PruneCheckpointWriter, TransactionsProvider}; +use reth_prune_types::{ PruneCheckpoint, PruneMode, PruneProgress, PrunePurpose, PruneSegment, ReceiptsLogPruneConfig, MINIMUM_PRUNING_DISTANCE, }; -use reth_provider::{BlockReader, DatabaseProviderRW, PruneCheckpointWriter, TransactionsProvider}; use tracing::{instrument, trace}; #[derive(Debug)] @@ -219,8 +219,9 @@ mod tests { use assert_matches::assert_matches; use reth_db::tables; use reth_db_api::{cursor::DbCursorRO, transaction::DbTx}; - use reth_primitives::{PruneLimiter, PruneMode, PruneSegment, ReceiptsLogPruneConfig, B256}; + use reth_primitives::B256; use reth_provider::{PruneCheckpointReader, TransactionsProvider}; + use reth_prune_types::{PruneLimiter, PruneMode, PruneSegment, ReceiptsLogPruneConfig}; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{ generators, diff --git a/crates/prune/src/segments/sender_recovery.rs b/crates/prune/prune/src/segments/sender_recovery.rs similarity index 96% rename from crates/prune/src/segments/sender_recovery.rs rename to crates/prune/prune/src/segments/sender_recovery.rs index 23ea10970..f13dfde25 100644 --- a/crates/prune/src/segments/sender_recovery.rs +++ b/crates/prune/prune/src/segments/sender_recovery.rs @@ -4,8 +4,8 @@ use crate::{ }; use reth_db::tables; use reth_db_api::database::Database; -use reth_primitives::{PruneMode, PruneProgress, PruneSegment}; use reth_provider::{DatabaseProviderRW, TransactionsProvider}; +use reth_prune_types::{PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; #[derive(Debug)] @@ -83,11 +83,9 @@ mod tests { Itertools, }; use reth_db::tables; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneLimiter, PruneMode, PruneProgress, PruneSegment, - TxNumber, B256, - }; + use reth_primitives::{BlockNumber, TxNumber, B256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{PruneCheckpoint, PruneLimiter, PruneMode, PruneProgress, PruneSegment}; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{generators, generators::random_block_range}; use std::ops::Sub; @@ -214,7 +212,7 @@ mod tests { 6, ( PruneProgress::HasMoreData( - reth_primitives::PruneInterruptReason::DeletedEntriesLimitReached, + reth_prune_types::PruneInterruptReason::DeletedEntriesLimitReached, ), 10, ), diff --git a/crates/prune/src/segments/set.rs b/crates/prune/prune/src/segments/set.rs similarity index 98% rename from crates/prune/src/segments/set.rs rename to crates/prune/prune/src/segments/set.rs index 305cef943..7448e03ae 100644 --- a/crates/prune/src/segments/set.rs +++ b/crates/prune/prune/src/segments/set.rs @@ -3,7 +3,7 @@ use crate::segments::{ TransactionLookup, }; use reth_db_api::database::Database; -use reth_primitives::PruneModes; +use reth_prune_types::PruneModes; /// Collection of [Segment]. Thread-safe, allocated on the heap. #[derive(Debug)] diff --git a/crates/prune/src/segments/storage_history.rs b/crates/prune/prune/src/segments/storage_history.rs similarity index 97% rename from crates/prune/src/segments/storage_history.rs rename to crates/prune/prune/src/segments/storage_history.rs index 68d310ca0..18af8134c 100644 --- a/crates/prune/src/segments/storage_history.rs +++ b/crates/prune/prune/src/segments/storage_history.rs @@ -9,8 +9,8 @@ use reth_db_api::{ database::Database, models::{storage_sharded_key::StorageShardedKey, BlockNumberAddress}, }; -use reth_primitives::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment}; use reth_provider::DatabaseProviderRW; +use reth_prune_types::{PruneInterruptReason, PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; /// Number of storage history tables to prune in one step @@ -111,10 +111,9 @@ mod tests { }; use assert_matches::assert_matches; use reth_db::{tables, BlockNumberList}; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneLimiter, PruneMode, PruneProgress, PruneSegment, B256, - }; + use reth_primitives::{BlockNumber, B256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{PruneCheckpoint, PruneLimiter, PruneMode, PruneProgress, PruneSegment}; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{ generators, @@ -280,7 +279,7 @@ mod tests { 1, ( PruneProgress::HasMoreData( - reth_primitives::PruneInterruptReason::DeletedEntriesLimitReached, + reth_prune_types::PruneInterruptReason::DeletedEntriesLimitReached, ), 500, ), diff --git a/crates/prune/src/segments/transaction_lookup.rs b/crates/prune/prune/src/segments/transaction_lookup.rs similarity index 97% rename from crates/prune/src/segments/transaction_lookup.rs rename to crates/prune/prune/src/segments/transaction_lookup.rs index 6018c37fa..b77b01933 100644 --- a/crates/prune/src/segments/transaction_lookup.rs +++ b/crates/prune/prune/src/segments/transaction_lookup.rs @@ -5,8 +5,8 @@ use crate::{ use rayon::prelude::*; use reth_db::tables; use reth_db_api::database::Database; -use reth_primitives::{PruneMode, PruneProgress, PruneSegment}; use reth_provider::{DatabaseProviderRW, TransactionsProvider}; +use reth_prune_types::{PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; #[derive(Debug)] @@ -110,11 +110,11 @@ mod tests { Itertools, }; use reth_db::tables; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, - PruneSegment, TxNumber, B256, - }; + use reth_primitives::{BlockNumber, TxNumber, B256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{ + PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, PruneSegment, + }; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{generators, generators::random_block_range}; use std::ops::Sub; diff --git a/crates/prune/src/segments/transactions.rs b/crates/prune/prune/src/segments/transactions.rs similarity index 96% rename from crates/prune/src/segments/transactions.rs rename to crates/prune/prune/src/segments/transactions.rs index e8d7aa532..5a7305a1b 100644 --- a/crates/prune/src/segments/transactions.rs +++ b/crates/prune/prune/src/segments/transactions.rs @@ -4,8 +4,8 @@ use crate::{ }; use reth_db::tables; use reth_db_api::database::Database; -use reth_primitives::{PruneMode, PruneProgress, PruneSegment}; use reth_provider::{DatabaseProviderRW, TransactionsProvider}; +use reth_prune_types::{PruneMode, PruneProgress, PruneSegment}; use tracing::{instrument, trace}; #[derive(Debug)] @@ -82,11 +82,11 @@ mod tests { Itertools, }; use reth_db::tables; - use reth_primitives::{ - BlockNumber, PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, - PruneSegment, TxNumber, B256, - }; + use reth_primitives::{BlockNumber, TxNumber, B256}; use reth_provider::PruneCheckpointReader; + use reth_prune_types::{ + PruneCheckpoint, PruneInterruptReason, PruneLimiter, PruneMode, PruneProgress, PruneSegment, + }; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{generators, generators::random_block_range}; use std::ops::Sub; diff --git a/crates/prune/types/Cargo.toml b/crates/prune/types/Cargo.toml new file mode 100644 index 000000000..3895ebcd0 --- /dev/null +++ b/crates/prune/types/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "reth-prune-types" +version.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +description = "Commonly used types for prune usage in reth." + +[lints] +workspace = true + +[dependencies] +reth-codecs.workspace = true + +alloy-primitives.workspace = true +bytes.workspace = true +derive_more.workspace = true +modular-bitfield.workspace = true +serde.workspace = true +thiserror.workspace = true + +[dev-dependencies] +arbitrary = { workspace = true, features = ["derive"] } +assert_matches.workspace = true +proptest.workspace = true +proptest-derive.workspace = true +serde_json.workspace = true +test-fuzz.workspace = true +toml.workspace = true \ No newline at end of file diff --git a/crates/primitives/src/prune/checkpoint.rs b/crates/prune/types/src/checkpoint.rs similarity index 87% rename from crates/primitives/src/prune/checkpoint.rs rename to crates/prune/types/src/checkpoint.rs index 3e704dbd6..0e27dd146 100644 --- a/crates/primitives/src/prune/checkpoint.rs +++ b/crates/prune/types/src/checkpoint.rs @@ -1,4 +1,5 @@ -use crate::{prune::PruneMode, BlockNumber, TxNumber}; +use crate::PruneMode; +use alloy_primitives::{BlockNumber, TxNumber}; use reth_codecs::{main_codec, Compact}; /// Saves the pruning progress of a stage. diff --git a/crates/primitives/src/prune/mod.rs b/crates/prune/types/src/lib.rs similarity index 89% rename from crates/primitives/src/prune/mod.rs rename to crates/prune/types/src/lib.rs index 5fa5d2ab5..34d74614f 100644 --- a/crates/primitives/src/prune/mod.rs +++ b/crates/prune/types/src/lib.rs @@ -1,10 +1,21 @@ +//! Commonly used types for prune usage. + +#![doc( + html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", + html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256", + issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" +)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +// TODO: remove when https://github.com/proptest-rs/proptest/pull/427 is merged +#![allow(unknown_lints, non_local_definitions)] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + mod checkpoint; mod limiter; mod mode; mod segment; mod target; -use crate::{Address, BlockNumber}; pub use checkpoint::PruneCheckpoint; pub use limiter::PruneLimiter; pub use mode::PruneMode; @@ -13,6 +24,8 @@ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; pub use target::{PruneModes, MINIMUM_PRUNING_DISTANCE}; +use alloy_primitives::{Address, BlockNumber}; + /// Configuration for pruning receipts not associated with logs emitted by the specified contracts. #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct ReceiptsLogPruneConfig(pub BTreeMap
); diff --git a/crates/primitives/src/prune/limiter.rs b/crates/prune/types/src/limiter.rs similarity index 100% rename from crates/primitives/src/prune/limiter.rs rename to crates/prune/types/src/limiter.rs diff --git a/crates/primitives/src/prune/mode.rs b/crates/prune/types/src/mode.rs similarity index 96% rename from crates/primitives/src/prune/mode.rs rename to crates/prune/types/src/mode.rs index 3911246dc..514e96b83 100644 --- a/crates/primitives/src/prune/mode.rs +++ b/crates/prune/types/src/mode.rs @@ -1,4 +1,5 @@ -use crate::{prune::segment::PrunePurpose, BlockNumber, PruneSegment, PruneSegmentError}; +use crate::{segment::PrunePurpose, PruneSegment, PruneSegmentError}; +use alloy_primitives::BlockNumber; use reth_codecs::{main_codec, Compact}; /// Prune mode. @@ -74,7 +75,7 @@ impl Default for PruneMode { #[cfg(test)] mod tests { use crate::{ - prune::PruneMode, PrunePurpose, PruneSegment, PruneSegmentError, MINIMUM_PRUNING_DISTANCE, + PruneMode, PrunePurpose, PruneSegment, PruneSegmentError, MINIMUM_PRUNING_DISTANCE, }; use assert_matches::assert_matches; use serde::Deserialize; diff --git a/crates/primitives/src/prune/segment.rs b/crates/prune/types/src/segment.rs similarity index 100% rename from crates/primitives/src/prune/segment.rs rename to crates/prune/types/src/segment.rs diff --git a/crates/primitives/src/prune/target.rs b/crates/prune/types/src/target.rs similarity index 100% rename from crates/primitives/src/prune/target.rs rename to crates/prune/types/src/target.rs diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index cba27331f..cf7c0f5fa 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -17,6 +17,7 @@ reth-primitives.workspace = true reth-storage-errors.workspace = true reth-execution-errors.workspace = true reth-consensus-common.workspace = true +reth-prune-types.workspace = true reth-storage-api.workspace = true reth-trie = { workspace = true, optional = true } diff --git a/crates/revm/src/batch.rs b/crates/revm/src/batch.rs index 936dac185..6f1b55b21 100644 --- a/crates/revm/src/batch.rs +++ b/crates/revm/src/batch.rs @@ -2,10 +2,8 @@ use crate::{precompile::Address, primitives::alloy_primitives::BlockNumber}; use reth_execution_errors::BlockExecutionError; -use reth_primitives::{ - PruneMode, PruneModes, PruneSegmentError, Receipt, Receipts, Request, Requests, - MINIMUM_PRUNING_DISTANCE, -}; +use reth_primitives::{Receipt, Receipts, Request, Requests}; +use reth_prune_types::{PruneMode, PruneModes, PruneSegmentError, MINIMUM_PRUNING_DISTANCE}; use revm::db::states::bundle_state::BundleRetention; use std::time::Duration; use tracing::debug; diff --git a/crates/stages/api/src/error.rs b/crates/stages/api/src/error.rs index 848b2570b..ab525f8f5 100644 --- a/crates/stages/api/src/error.rs +++ b/crates/stages/api/src/error.rs @@ -68,7 +68,7 @@ pub enum StageError { Database(#[from] DatabaseError), /// Invalid pruning configuration #[error(transparent)] - PruningConfiguration(#[from] reth_primitives::PruneSegmentError), + PruningConfiguration(#[from] reth_prune::PruneSegmentError), /// Invalid checkpoint passed to the stage #[error("invalid stage checkpoint: {0}")] StageCheckpoint(u64), diff --git a/crates/stages/api/src/pipeline/mod.rs b/crates/stages/api/src/pipeline/mod.rs index 554f287a0..5bf72d11d 100644 --- a/crates/stages/api/src/pipeline/mod.rs +++ b/crates/stages/api/src/pipeline/mod.rs @@ -607,8 +607,8 @@ mod tests { use assert_matches::assert_matches; use reth_consensus::ConsensusError; use reth_errors::ProviderError; - use reth_primitives::PruneModes; use reth_provider::test_utils::create_test_provider_factory; + use reth_prune::PruneModes; use reth_testing_utils::{generators, generators::random_header}; use tokio_stream::StreamExt; diff --git a/crates/stages/stages/Cargo.toml b/crates/stages/stages/Cargo.toml index e62da2761..974d47c87 100644 --- a/crates/stages/stages/Cargo.toml +++ b/crates/stages/stages/Cargo.toml @@ -24,6 +24,7 @@ reth-exex.workspace = true reth-network-p2p.workspace = true reth-primitives.workspace = true reth-provider.workspace = true +reth-prune-types.workspace = true reth-storage-errors.workspace = true reth-revm.workspace = true reth-stages-api = { workspace = true, features = ["test-utils"] } diff --git a/crates/stages/stages/src/lib.rs b/crates/stages/stages/src/lib.rs index 1c3667d2c..dc300e684 100644 --- a/crates/stages/stages/src/lib.rs +++ b/crates/stages/stages/src/lib.rs @@ -17,7 +17,8 @@ //! # use reth_downloaders::headers::reverse_headers::ReverseHeadersDownloaderBuilder; //! # use reth_network_p2p::test_utils::{TestBodiesClient, TestHeadersClient}; //! # use reth_evm_ethereum::execute::EthExecutorProvider; -//! # use reth_primitives::{MAINNET, B256, PruneModes}; +//! # use reth_primitives::{MAINNET, B256}; +//! # use reth_prune_types::PruneModes; //! # use reth_network_types::PeerId; //! # use reth_stages::Pipeline; //! # use reth_stages::sets::DefaultStages; diff --git a/crates/stages/stages/src/sets.rs b/crates/stages/stages/src/sets.rs index 8cb9675d5..8c82902bf 100644 --- a/crates/stages/stages/src/sets.rs +++ b/crates/stages/stages/src/sets.rs @@ -12,7 +12,8 @@ //! ```no_run //! # use reth_stages::Pipeline; //! # use reth_stages::sets::{OfflineStages}; -//! # use reth_primitives::{PruneModes, MAINNET}; +//! # use reth_primitives::MAINNET; +//! # use reth_prune_types::PruneModes; //! # use reth_evm_ethereum::EthEvmConfig; //! # use reth_provider::StaticFileProviderFactory; //! # use reth_provider::test_utils::create_test_provider_factory; @@ -45,8 +46,8 @@ use reth_consensus::Consensus; use reth_db_api::database::Database; use reth_evm::execute::BlockExecutorProvider; use reth_network_p2p::{bodies::downloader::BodyDownloader, headers::downloader::HeaderDownloader}; -use reth_primitives::PruneModes; use reth_provider::{HeaderSyncGapProvider, HeaderSyncMode}; +use reth_prune_types::PruneModes; use std::sync::Arc; /// A set containing all stages to run a fully syncing instance of reth. diff --git a/crates/stages/stages/src/stages/execution.rs b/crates/stages/stages/src/stages/execution.rs index 2a6ec4037..48184b40b 100644 --- a/crates/stages/stages/src/stages/execution.rs +++ b/crates/stages/stages/src/stages/execution.rs @@ -9,7 +9,7 @@ use reth_primitives::{ stage::{ CheckpointBlockRange, EntitiesCheckpoint, ExecutionCheckpoint, StageCheckpoint, StageId, }, - BlockNumber, Header, PruneModes, StaticFileSegment, + BlockNumber, Header, StaticFileSegment, }; use reth_provider::{ providers::{StaticFileProvider, StaticFileProviderRWRefMut, StaticFileWriter}, @@ -17,6 +17,7 @@ use reth_provider::{ LatestStateProviderRef, OriginalValuesKnown, ProviderError, StateWriter, StatsReader, TransactionVariant, }; +use reth_prune_types::PruneModes; use reth_revm::database::StateProviderDatabase; use reth_stages_api::{ BlockErrorKind, ExecInput, ExecOutput, MetricEvent, MetricEventsSender, Stage, StageError, @@ -658,13 +659,13 @@ mod tests { use reth_execution_errors::BlockValidationError; use reth_primitives::{ address, hex_literal::hex, keccak256, stage::StageUnitCheckpoint, Account, Address, - Bytecode, ChainSpecBuilder, PruneMode, ReceiptsLogPruneConfig, SealedBlock, StorageEntry, - B256, U256, + Bytecode, ChainSpecBuilder, SealedBlock, StorageEntry, B256, U256, }; use reth_provider::{ test_utils::create_test_provider_factory, AccountReader, ReceiptProvider, StaticFileProviderFactory, }; + use reth_prune_types::{PruneMode, ReceiptsLogPruneConfig}; use std::collections::BTreeMap; fn stage() -> ExecutionStage