From ade059235b5eb1a5d9171b7d6646d7301ff508e5 Mon Sep 17 00:00:00 2001 From: joshieDo <93316087+joshieDo@users.noreply.github.com> Date: Fri, 7 Jun 2024 17:24:39 +0200 Subject: [PATCH] chore: move `primitives/prune` to `reth-prune-types` (#8676) --- Cargo.lock | 39 ++++++++++++++++++- Cargo.toml | 6 ++- bin/reth/Cargo.toml | 1 + bin/reth/src/commands/debug_cmd/execution.rs | 3 +- bin/reth/src/commands/debug_cmd/merkle.rs | 3 +- .../src/commands/debug_cmd/replay_engine.rs | 2 +- bin/reth/src/commands/import.rs | 3 +- bin/reth/src/commands/import_op.rs | 3 +- bin/reth/src/commands/stage/dump/merkle.rs | 3 +- bin/reth/src/commands/stage/unwind.rs | 3 +- crates/blockchain-tree/Cargo.toml | 1 + crates/blockchain-tree/src/blockchain_tree.rs | 5 ++- crates/config/Cargo.toml | 2 +- crates/config/src/config.rs | 2 +- crates/consensus/beacon/Cargo.toml | 1 + crates/consensus/beacon/src/engine/sync.rs | 3 +- .../consensus/beacon/src/engine/test_utils.rs | 3 +- crates/ethereum/evm/Cargo.toml | 1 + crates/ethereum/evm/src/execute.rs | 5 ++- crates/evm/Cargo.toml | 1 + crates/evm/execution-errors/Cargo.toml | 2 +- crates/evm/execution-errors/src/lib.rs | 3 +- crates/evm/src/either.rs | 3 +- crates/evm/src/execute.rs | 5 +-- crates/evm/src/noop.rs | 3 +- crates/evm/src/test_utils.rs | 3 +- crates/node-core/Cargo.toml | 1 + crates/node-core/src/args/pruning.rs | 5 +-- crates/node/builder/src/launch/common.rs | 6 +-- crates/optimism/evm/Cargo.toml | 1 + crates/optimism/evm/src/execute.rs | 5 ++- crates/primitives/src/lib.rs | 6 --- crates/prune/{ => prune}/Cargo.toml | 2 + crates/prune/{ => prune}/src/builder.rs | 3 +- crates/prune/{ => prune}/src/error.rs | 2 +- crates/prune/{ => prune}/src/event.rs | 3 +- crates/prune/{ => prune}/src/lib.rs | 4 ++ crates/prune/{ => prune}/src/metrics.rs | 2 +- crates/prune/{ => prune}/src/pruner.rs | 6 +-- .../src/segments/account_history.rs | 10 ++--- .../prune/{ => prune}/src/segments/headers.rs | 11 +++--- .../prune/{ => prune}/src/segments/history.rs | 0 crates/prune/{ => prune}/src/segments/mod.rs | 8 ++-- .../{ => prune}/src/segments/receipts.rs | 10 ++--- .../src/segments/receipts_by_logs.rs | 7 ++-- .../src/segments/sender_recovery.rs | 10 ++--- crates/prune/{ => prune}/src/segments/set.rs | 2 +- .../src/segments/storage_history.rs | 9 ++--- .../src/segments/transaction_lookup.rs | 10 ++--- .../{ => prune}/src/segments/transactions.rs | 10 ++--- crates/prune/types/Cargo.toml | 31 +++++++++++++++ .../prune => prune/types/src}/checkpoint.rs | 3 +- .../prune/mod.rs => prune/types/src/lib.rs} | 15 ++++++- .../src/prune => prune/types/src}/limiter.rs | 0 .../src/prune => prune/types/src}/mode.rs | 5 ++- .../src/prune => prune/types/src}/segment.rs | 0 .../src/prune => prune/types/src}/target.rs | 0 crates/revm/Cargo.toml | 1 + crates/revm/src/batch.rs | 6 +-- crates/stages/api/src/error.rs | 2 +- crates/stages/api/src/pipeline/mod.rs | 2 +- crates/stages/stages/Cargo.toml | 1 + crates/stages/stages/src/lib.rs | 3 +- crates/stages/stages/src/sets.rs | 5 ++- crates/stages/stages/src/stages/execution.rs | 7 ++-- .../src/stages/index_account_history.rs | 3 +- .../src/stages/index_storage_history.rs | 6 +-- crates/stages/stages/src/stages/mod.rs | 5 ++- .../stages/src/stages/sender_recovery.rs | 7 ++-- crates/stages/stages/src/stages/tx_lookup.rs | 3 +- crates/static-file/static-file/Cargo.toml | 1 + .../static-file/src/static_file_producer.rs | 8 ++-- .../storage/codecs/src/alloy/transaction.rs | 0 crates/storage/db-api/Cargo.toml | 1 + crates/storage/db-api/src/models/mod.rs | 8 ++-- crates/storage/db/Cargo.toml | 1 + crates/storage/db/src/tables/mod.rs | 5 ++- crates/storage/provider/Cargo.toml | 1 + .../provider/src/providers/database/mod.rs | 11 +++--- .../src/providers/database/provider.rs | 10 ++--- crates/storage/provider/src/providers/mod.rs | 8 ++-- .../src/providers/state/historical.rs | 4 +- .../storage/provider/src/test_utils/noop.rs | 8 ++-- crates/storage/provider/src/traits/block.rs | 3 +- crates/storage/storage-api/Cargo.toml | 1 + .../storage-api/src/prune_checkpoint.rs | 2 +- 86 files changed, 268 insertions(+), 151 deletions(-) rename crates/prune/{ => prune}/Cargo.toml (93%) rename crates/prune/{ => prune}/src/builder.rs (97%) rename crates/prune/{ => prune}/src/error.rs (95%) rename crates/prune/{ => prune}/src/event.rs (83%) rename crates/prune/{ => prune}/src/lib.rs (90%) rename crates/prune/{ => prune}/src/metrics.rs (96%) rename crates/prune/{ => prune}/src/pruner.rs (98%) rename crates/prune/{ => prune}/src/segments/account_history.rs (97%) rename crates/prune/{ => prune}/src/segments/headers.rs (97%) rename crates/prune/{ => prune}/src/segments/history.rs (100%) rename crates/prune/{ => prune}/src/segments/mod.rs (97%) rename crates/prune/{ => prune}/src/segments/receipts.rs (96%) rename crates/prune/{ => prune}/src/segments/receipts_by_logs.rs (98%) rename crates/prune/{ => prune}/src/segments/sender_recovery.rs (96%) rename crates/prune/{ => prune}/src/segments/set.rs (98%) rename crates/prune/{ => prune}/src/segments/storage_history.rs (97%) rename crates/prune/{ => prune}/src/segments/transaction_lookup.rs (97%) rename crates/prune/{ => prune}/src/segments/transactions.rs (96%) create mode 100644 crates/prune/types/Cargo.toml rename crates/{primitives/src/prune => prune/types/src}/checkpoint.rs (87%) rename crates/{primitives/src/prune/mod.rs => prune/types/src/lib.rs} (89%) rename crates/{primitives/src/prune => prune/types/src}/limiter.rs (100%) rename crates/{primitives/src/prune => prune/types/src}/mode.rs (96%) rename crates/{primitives/src/prune => prune/types/src}/segment.rs (100%) rename crates/{primitives/src/prune => prune/types/src}/target.rs (100%) create mode 100644 crates/storage/codecs/src/alloy/transaction.rs 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 { diff --git a/crates/stages/stages/src/stages/index_account_history.rs b/crates/stages/stages/src/stages/index_account_history.rs index 3529f376d..d4c77bd24 100644 --- a/crates/stages/stages/src/stages/index_account_history.rs +++ b/crates/stages/stages/src/stages/index_account_history.rs @@ -4,11 +4,12 @@ use reth_db::tables; use reth_db_api::{database::Database, models::ShardedKey, table::Decode, transaction::DbTxMut}; use reth_primitives::{ stage::{StageCheckpoint, StageId}, - Address, PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment, + Address, }; use reth_provider::{ DatabaseProviderRW, HistoryWriter, PruneCheckpointReader, PruneCheckpointWriter, }; +use reth_prune_types::{PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment}; use reth_stages_api::{ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput}; use std::fmt::Debug; use tracing::info; diff --git a/crates/stages/stages/src/stages/index_storage_history.rs b/crates/stages/stages/src/stages/index_storage_history.rs index b086df457..5fcbe1fb4 100644 --- a/crates/stages/stages/src/stages/index_storage_history.rs +++ b/crates/stages/stages/src/stages/index_storage_history.rs @@ -7,13 +7,11 @@ use reth_db_api::{ table::Decode, transaction::DbTxMut, }; -use reth_primitives::{ - stage::{StageCheckpoint, StageId}, - PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment, -}; +use reth_primitives::stage::{StageCheckpoint, StageId}; use reth_provider::{ DatabaseProviderRW, HistoryWriter, PruneCheckpointReader, PruneCheckpointWriter, }; +use reth_prune_types::{PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment}; use reth_stages_api::{ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput}; use std::fmt::Debug; use tracing::info; diff --git a/crates/stages/stages/src/stages/mod.rs b/crates/stages/stages/src/stages/mod.rs index da3ac3432..c1a8666be 100644 --- a/crates/stages/stages/src/stages/mod.rs +++ b/crates/stages/stages/src/stages/mod.rs @@ -60,14 +60,15 @@ mod tests { hex_literal::hex, keccak256, stage::{PipelineTarget, StageCheckpoint, StageId}, - Account, BlockNumber, Bytecode, ChainSpecBuilder, PruneMode, PruneModes, SealedBlock, - StaticFileSegment, B256, U256, + Account, BlockNumber, Bytecode, ChainSpecBuilder, SealedBlock, StaticFileSegment, B256, + U256, }; use reth_provider::{ providers::StaticFileWriter, AccountExtReader, BlockReader, DatabaseProviderFactory, ProviderFactory, ProviderResult, ReceiptProvider, StageCheckpointWriter, StaticFileProviderFactory, StorageReader, }; + use reth_prune_types::{PruneMode, PruneModes}; use reth_stages_api::{ExecInput, Stage}; use reth_testing_utils::generators::{self, random_block, random_block_range, random_receipt}; use std::{io::Write, sync::Arc}; diff --git a/crates/stages/stages/src/stages/sender_recovery.rs b/crates/stages/stages/src/stages/sender_recovery.rs index 9f1500edf..a60f6bc52 100644 --- a/crates/stages/stages/src/stages/sender_recovery.rs +++ b/crates/stages/stages/src/stages/sender_recovery.rs @@ -8,12 +8,13 @@ use reth_db_api::{ }; use reth_primitives::{ stage::{EntitiesCheckpoint, StageCheckpoint, StageId}, - Address, PruneSegment, StaticFileSegment, TransactionSignedNoHash, TxNumber, + Address, StaticFileSegment, TransactionSignedNoHash, TxNumber, }; use reth_provider::{ BlockReader, DatabaseProviderRW, HeaderProvider, ProviderError, PruneCheckpointReader, StatsReader, }; +use reth_prune_types::PruneSegment; use reth_stages_api::{ BlockErrorKind, ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput, }; @@ -282,13 +283,13 @@ mod tests { use assert_matches::assert_matches; use reth_db_api::cursor::DbCursorRO; use reth_primitives::{ - stage::StageUnitCheckpoint, BlockNumber, PruneCheckpoint, PruneMode, SealedBlock, - TransactionSigned, B256, + stage::StageUnitCheckpoint, BlockNumber, SealedBlock, TransactionSigned, B256, }; use reth_provider::{ providers::StaticFileWriter, PruneCheckpointWriter, StaticFileProviderFactory, TransactionsProvider, }; + use reth_prune_types::{PruneCheckpoint, PruneMode}; use reth_testing_utils::{ generators, generators::{random_block, random_block_range}, diff --git a/crates/stages/stages/src/stages/tx_lookup.rs b/crates/stages/stages/src/stages/tx_lookup.rs index d5f8b799b..66fa76810 100644 --- a/crates/stages/stages/src/stages/tx_lookup.rs +++ b/crates/stages/stages/src/stages/tx_lookup.rs @@ -9,12 +9,13 @@ use reth_db_api::{ use reth_etl::Collector; use reth_primitives::{ stage::{EntitiesCheckpoint, StageCheckpoint, StageId}, - PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment, TxHash, TxNumber, + TxHash, TxNumber, }; use reth_provider::{ BlockReader, DatabaseProviderRW, PruneCheckpointReader, PruneCheckpointWriter, StatsReader, TransactionsProvider, TransactionsProviderExt, }; +use reth_prune_types::{PruneCheckpoint, PruneMode, PrunePurpose, PruneSegment}; use reth_stages_api::{ExecInput, ExecOutput, Stage, StageError, UnwindInput, UnwindOutput}; use reth_storage_errors::provider::ProviderError; use tracing::*; diff --git a/crates/static-file/static-file/Cargo.toml b/crates/static-file/static-file/Cargo.toml index 6c2507ad4..4d4e31509 100644 --- a/crates/static-file/static-file/Cargo.toml +++ b/crates/static-file/static-file/Cargo.toml @@ -20,6 +20,7 @@ reth-provider.workspace = true reth-storage-errors.workspace = true reth-nippy-jar.workspace = true reth-tokio-util.workspace = true +reth-prune-types.workspace = true # misc tracing.workspace = true diff --git a/crates/static-file/static-file/src/static_file_producer.rs b/crates/static-file/static-file/src/static_file_producer.rs index ae28a22e3..396fdd5ed 100644 --- a/crates/static-file/static-file/src/static_file_producer.rs +++ b/crates/static-file/static-file/src/static_file_producer.rs @@ -4,8 +4,9 @@ use crate::{segments, segments::Segment, StaticFileProducerEvent}; use parking_lot::Mutex; use rayon::prelude::*; use reth_db_api::database::Database; -use reth_primitives::{static_file::HighestStaticFiles, BlockNumber, PruneModes}; +use reth_primitives::{static_file::HighestStaticFiles, BlockNumber}; use reth_provider::{providers::StaticFileWriter, ProviderFactory, StaticFileProviderFactory}; +use reth_prune_types::PruneModes; use reth_storage_errors::provider::ProviderResult; use reth_tokio_util::{EventSender, EventStream}; use std::{ @@ -230,12 +231,11 @@ mod tests { use assert_matches::assert_matches; use reth_db::{test_utils::TempDatabase, DatabaseEnv}; use reth_db_api::{database::Database, transaction::DbTx}; - use reth_primitives::{ - static_file::HighestStaticFiles, PruneModes, StaticFileSegment, B256, U256, - }; + use reth_primitives::{static_file::HighestStaticFiles, StaticFileSegment, B256, U256}; use reth_provider::{ providers::StaticFileWriter, ProviderError, ProviderFactory, StaticFileProviderFactory, }; + use reth_prune_types::PruneModes; use reth_stages::test_utils::{StorageKind, TestStageDB}; use reth_testing_utils::{ generators, diff --git a/crates/storage/codecs/src/alloy/transaction.rs b/crates/storage/codecs/src/alloy/transaction.rs new file mode 100644 index 000000000..e69de29bb diff --git a/crates/storage/db-api/Cargo.toml b/crates/storage/db-api/Cargo.toml index 292786543..0f52c2743 100644 --- a/crates/storage/db-api/Cargo.toml +++ b/crates/storage/db-api/Cargo.toml @@ -15,6 +15,7 @@ workspace = true # reth reth-codecs.workspace = true reth-primitives.workspace = true +reth-prune-types.workspace = true reth-storage-errors.workspace = true # codecs diff --git a/crates/storage/db-api/src/models/mod.rs b/crates/storage/db-api/src/models/mod.rs index 5cb119dc6..8c62164fd 100644 --- a/crates/storage/db-api/src/models/mod.rs +++ b/crates/storage/db-api/src/models/mod.rs @@ -8,8 +8,9 @@ use reth_codecs::{main_codec, Compact}; use reth_primitives::{ stage::StageCheckpoint, trie::{StoredNibbles, StoredNibblesSubKey, *}, - Address, PruneSegment, B256, *, + Address, B256, *, }; +use reth_prune_types::{PruneCheckpoint, PruneSegment}; pub mod accounts; pub mod blocks; @@ -305,9 +306,10 @@ mod tests { ExecutionCheckpoint, HeadersCheckpoint, IndexHistoryCheckpoint, StageCheckpoint, StageUnitCheckpoint, StorageHashingCheckpoint, }, - Account, Header, PruneCheckpoint, PruneMode, PruneSegment, Receipt, ReceiptWithBloom, - SealedHeader, TxEip1559, TxEip2930, TxEip4844, TxLegacy, Withdrawals, + Account, Header, Receipt, ReceiptWithBloom, SealedHeader, TxEip1559, TxEip2930, TxEip4844, + TxLegacy, Withdrawals, }; + use reth_prune_types::{PruneCheckpoint, PruneMode, PruneSegment}; // each value in the database has an extra field named flags that encodes metadata about other // fields in the value, e.g. offset and length. diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index a032a9df0..b527b5d5b 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -22,6 +22,7 @@ reth-libmdbx = { workspace = true, optional = true, features = [ "read-tx-timeouts", ] } reth-nippy-jar.workspace = true +reth-prune-types.workspace = true reth-tracing.workspace = true # codecs diff --git a/crates/storage/db/src/tables/mod.rs b/crates/storage/db/src/tables/mod.rs index d50442e22..de1389b26 100644 --- a/crates/storage/db/src/tables/mod.rs +++ b/crates/storage/db/src/tables/mod.rs @@ -34,9 +34,10 @@ use reth_db_api::{ use reth_primitives::{ stage::StageCheckpoint, trie::{StorageTrieEntry, StoredBranchNode, StoredNibbles, StoredNibblesSubKey}, - Account, Address, BlockHash, BlockNumber, Bytecode, Header, IntegerList, PruneCheckpoint, - PruneSegment, Receipt, Requests, StorageEntry, TransactionSignedNoHash, TxHash, TxNumber, B256, + Account, Address, BlockHash, BlockNumber, Bytecode, Header, IntegerList, Receipt, Requests, + StorageEntry, TransactionSignedNoHash, TxHash, TxNumber, B256, }; +use reth_prune_types::{PruneCheckpoint, PruneSegment}; use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 834704ca2..14c45ca12 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -23,6 +23,7 @@ reth-storage-api.workspace = true reth-network-p2p.workspace = true reth-db = { workspace = true, features = ["mdbx"] } reth-db-api.workspace = true +reth-prune-types.workspace = true reth-trie = { workspace = true, features = ["metrics"] } reth-nippy-jar.workspace = true reth-codecs.workspace = true diff --git a/crates/storage/provider/src/providers/database/mod.rs b/crates/storage/provider/src/providers/database/mod.rs index a077d9e2c..0fe0eeb6d 100644 --- a/crates/storage/provider/src/providers/database/mod.rs +++ b/crates/storage/provider/src/providers/database/mod.rs @@ -15,10 +15,11 @@ use reth_evm::ConfigureEvmEnv; use reth_primitives::{ stage::{StageCheckpoint, StageId}, Address, Block, BlockHash, BlockHashOrNumber, BlockNumber, BlockWithSenders, ChainInfo, - ChainSpec, Header, PruneCheckpoint, PruneSegment, Receipt, SealedBlock, SealedBlockWithSenders, - SealedHeader, StaticFileSegment, TransactionMeta, TransactionSigned, TransactionSignedNoHash, - TxHash, TxNumber, Withdrawal, Withdrawals, B256, U256, + ChainSpec, Header, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader, + StaticFileSegment, TransactionMeta, TransactionSigned, TransactionSignedNoHash, TxHash, + TxNumber, Withdrawal, Withdrawals, B256, U256, }; +use reth_prune_types::{PruneCheckpoint, PruneSegment}; use reth_storage_errors::provider::ProviderResult; use revm::primitives::{BlockEnv, CfgEnvWithHandlerCfg}; use std::{ @@ -596,9 +597,9 @@ mod tests { test_utils::{create_test_static_files_dir, ERROR_TEMPDIR}, }; use reth_primitives::{ - hex_literal::hex, ChainSpecBuilder, PruneMode, PruneModes, SealedBlock, StaticFileSegment, - TxNumber, B256, U256, + hex_literal::hex, ChainSpecBuilder, SealedBlock, StaticFileSegment, TxNumber, B256, U256, }; + use reth_prune_types::{PruneMode, PruneModes}; use reth_storage_errors::provider::ProviderError; use reth_testing_utils::{ generators, diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 2f079780d..1983c3bfa 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -35,12 +35,12 @@ use reth_primitives::{ stage::{StageCheckpoint, StageId}, trie::Nibbles, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockNumber, BlockWithSenders, - ChainInfo, ChainSpec, GotExpected, Head, Header, PruneCheckpoint, PruneLimiter, PruneModes, - PruneSegment, Receipt, Requests, SealedBlock, SealedBlockWithSenders, SealedHeader, - StaticFileSegment, StorageEntry, TransactionMeta, TransactionSigned, - TransactionSignedEcRecovered, TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, - Withdrawals, B256, U256, + ChainInfo, ChainSpec, GotExpected, Head, Header, Receipt, Requests, SealedBlock, + SealedBlockWithSenders, SealedHeader, StaticFileSegment, StorageEntry, TransactionMeta, + TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxHash, TxNumber, + Withdrawal, Withdrawals, B256, U256, }; +use reth_prune_types::{PruneCheckpoint, PruneLimiter, PruneModes, PruneSegment}; use reth_storage_errors::provider::{ProviderResult, RootMismatch}; use reth_trie::{ prefix_set::{PrefixSet, PrefixSetMut, TriePrefixSets}, diff --git a/crates/storage/provider/src/providers/mod.rs b/crates/storage/provider/src/providers/mod.rs index 8f777a015..ede69cdf6 100644 --- a/crates/storage/provider/src/providers/mod.rs +++ b/crates/storage/provider/src/providers/mod.rs @@ -20,11 +20,11 @@ use reth_evm::ConfigureEvmEnv; use reth_primitives::{ stage::{StageCheckpoint, StageId}, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumHash, BlockNumber, - BlockNumberOrTag, BlockWithSenders, ChainInfo, ChainSpec, Header, PruneCheckpoint, - PruneSegment, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader, TransactionMeta, - TransactionSigned, TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256, - U256, + BlockNumberOrTag, BlockWithSenders, ChainInfo, ChainSpec, Header, Receipt, SealedBlock, + SealedBlockWithSenders, SealedHeader, TransactionMeta, TransactionSigned, + TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256, U256, }; +use reth_prune_types::{PruneCheckpoint, PruneSegment}; use reth_storage_errors::provider::ProviderResult; use revm::primitives::{BlockEnv, CfgEnvWithHandlerCfg}; use std::{ diff --git a/crates/storage/provider/src/providers/state/historical.rs b/crates/storage/provider/src/providers/state/historical.rs index ff0068ebc..ed906f1ad 100644 --- a/crates/storage/provider/src/providers/state/historical.rs +++ b/crates/storage/provider/src/providers/state/historical.rs @@ -375,11 +375,11 @@ delegate_provider_impls!(HistoricalStateProvider where [TX: DbTx]); #[derive(Clone, Copy, Debug, Default)] pub struct LowestAvailableBlocks { /// Lowest block number at which the account history is available. It may not be available if - /// [`reth_primitives::PruneSegment::AccountHistory`] was pruned. + /// [`reth_prune_types::PruneSegment::AccountHistory`] was pruned. /// [`Option::None`] means all history is available. pub account_history_block_number: Option, /// Lowest block number at which the storage history is available. It may not be available if - /// [`reth_primitives::PruneSegment::StorageHistory`] was pruned. + /// [`reth_prune_types::PruneSegment::StorageHistory`] was pruned. /// [`Option::None`] means all history is available. pub storage_history_block_number: Option, } diff --git a/crates/storage/provider/src/test_utils/noop.rs b/crates/storage/provider/src/test_utils/noop.rs index c104a2221..8b40fe652 100644 --- a/crates/storage/provider/src/test_utils/noop.rs +++ b/crates/storage/provider/src/test_utils/noop.rs @@ -12,11 +12,11 @@ use reth_primitives::{ stage::{StageCheckpoint, StageId}, trie::AccountProof, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumber, BlockWithSenders, - Bytecode, ChainInfo, ChainSpec, Header, PruneCheckpoint, PruneSegment, Receipt, SealedBlock, - SealedBlockWithSenders, SealedHeader, StorageKey, StorageValue, TransactionMeta, - TransactionSigned, TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256, - MAINNET, U256, + Bytecode, ChainInfo, ChainSpec, Header, Receipt, SealedBlock, SealedBlockWithSenders, + SealedHeader, StorageKey, StorageValue, TransactionMeta, TransactionSigned, + TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256, MAINNET, U256, }; +use reth_prune_types::{PruneCheckpoint, PruneSegment}; use reth_storage_errors::provider::ProviderResult; use reth_trie::updates::TrieUpdates; use revm::{ diff --git a/crates/storage/provider/src/traits/block.rs b/crates/storage/provider/src/traits/block.rs index e75b549f2..f457587e8 100644 --- a/crates/storage/provider/src/traits/block.rs +++ b/crates/storage/provider/src/traits/block.rs @@ -1,6 +1,7 @@ use crate::{BundleStateWithReceipts, Chain}; use reth_db_api::models::StoredBlockBodyIndices; -use reth_primitives::{BlockNumber, PruneModes, SealedBlockWithSenders}; +use reth_primitives::{BlockNumber, SealedBlockWithSenders}; +use reth_prune_types::PruneModes; use reth_storage_api::BlockReader; use reth_storage_errors::provider::ProviderResult; use reth_trie::{updates::TrieUpdates, HashedPostState}; diff --git a/crates/storage/storage-api/Cargo.toml b/crates/storage/storage-api/Cargo.toml index d109e0f93..d1806408f 100644 --- a/crates/storage/storage-api/Cargo.toml +++ b/crates/storage/storage-api/Cargo.toml @@ -16,6 +16,7 @@ workspace = true reth-execution-types.workspace = true reth-db-api.workspace = true reth-primitives.workspace = true +reth-prune-types.workspace = true reth-storage-errors.workspace = true reth-trie.workspace = true diff --git a/crates/storage/storage-api/src/prune_checkpoint.rs b/crates/storage/storage-api/src/prune_checkpoint.rs index a872e27b3..6a6e32bf6 100644 --- a/crates/storage/storage-api/src/prune_checkpoint.rs +++ b/crates/storage/storage-api/src/prune_checkpoint.rs @@ -1,4 +1,4 @@ -use reth_primitives::{PruneCheckpoint, PruneSegment}; +use reth_prune_types::{PruneCheckpoint, PruneSegment}; use reth_storage_errors::provider::ProviderResult; /// The trait for fetching prune checkpoint related data.