diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index a186b8407..0232aecc6 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -14,7 +14,7 @@ workspace = true # reth reth-network-types = { workspace = true, features = ["serde"] } reth-prune-types.workspace = true -reth-stages-types.workspace = true +reth-stages-types = { workspace = true, features = ["serde"] } # serde serde.workspace = true diff --git a/crates/stages/types/Cargo.toml b/crates/stages/types/Cargo.toml index 8e880dfc7..5a1cd489d 100644 --- a/crates/stages/types/Cargo.toml +++ b/crates/stages/types/Cargo.toml @@ -16,7 +16,7 @@ reth-codecs = { workspace = true, optional = true } reth-trie-common.workspace = true alloy-primitives.workspace = true -serde.workspace = true +serde = { workspace = true, optional = true } arbitrary = { workspace = true, features = ["derive"], optional = true } bytes = { workspace = true, optional = true } @@ -50,3 +50,11 @@ arbitrary = [ "reth-codecs?/arbitrary", "reth-trie-common/arbitrary", ] +serde = [ + "dep:serde", + "alloy-primitives/serde", + "bytes?/serde", + "rand/serde", + "reth-codecs?/serde", + "reth-trie-common/serde", +] diff --git a/crates/stages/types/src/checkpoints.rs b/crates/stages/types/src/checkpoints.rs index 160c901e1..bd03a5ba6 100644 --- a/crates/stages/types/src/checkpoints.rs +++ b/crates/stages/types/src/checkpoints.rs @@ -3,7 +3,6 @@ use alloc::vec::Vec; use alloy_primitives::{Address, BlockNumber, B256}; use core::ops::RangeInclusive; use reth_trie_common::{hash_builder::HashBuilderState, StoredSubNode}; -use serde::{Deserialize, Serialize}; /// Saves the progress of Merkle stage. #[derive(Default, Debug, Clone, PartialEq, Eq)] @@ -75,10 +74,11 @@ impl reth_codecs::Compact for MerkleCheckpoint { } /// Saves the progress of AccountHashing stage. -#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AccountHashingCheckpoint { /// The next account to start hashing from. pub address: Option
, @@ -89,10 +89,11 @@ pub struct AccountHashingCheckpoint { } /// Saves the progress of StorageHashing stage. -#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StorageHashingCheckpoint { /// The next account to start hashing from. pub address: Option
, @@ -105,10 +106,11 @@ pub struct StorageHashingCheckpoint { } /// Saves the progress of Execution stage. -#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ExecutionCheckpoint { /// Block range which this checkpoint is valid for. pub block_range: CheckpointBlockRange, @@ -117,10 +119,11 @@ pub struct ExecutionCheckpoint { } /// Saves the progress of Headers stage. -#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct HeadersCheckpoint { /// Block range which this checkpoint is valid for. pub block_range: CheckpointBlockRange, @@ -129,10 +132,11 @@ pub struct HeadersCheckpoint { } /// Saves the progress of Index History stages. -#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IndexHistoryCheckpoint { /// Block range which this checkpoint is valid for. pub block_range: CheckpointBlockRange, @@ -141,10 +145,11 @@ pub struct IndexHistoryCheckpoint { } /// Saves the progress of abstract stage iterating over or downloading entities. -#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EntitiesCheckpoint { /// Number of entities already processed. pub processed: u64, @@ -171,10 +176,11 @@ impl EntitiesCheckpoint { /// Saves the block range. Usually, it's used to check the validity of some stage checkpoint across /// multiple executions. -#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CheckpointBlockRange { /// The first block of the range, inclusive. pub from: BlockNumber, @@ -195,10 +201,11 @@ impl From<&RangeInclusive> for CheckpointBlockRange { } /// Saves the progress of a stage. -#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StageCheckpoint { /// The maximum block processed by the stage. pub block_number: BlockNumber, @@ -263,10 +270,11 @@ impl StageCheckpoint { // TODO(alexey): add a merkle checkpoint. Currently it's hard because [`MerkleCheckpoint`] // is not a Copy type. /// Stage-specific checkpoint metrics. -#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(any(test, feature = "test-utils"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), derive(reth_codecs::Compact))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum StageUnitCheckpoint { /// Saves the progress of AccountHashing stage. Account(AccountHashingCheckpoint), diff --git a/crates/storage/db-api/Cargo.toml b/crates/storage/db-api/Cargo.toml index 4e777d310..94248c838 100644 --- a/crates/storage/db-api/Cargo.toml +++ b/crates/storage/db-api/Cargo.toml @@ -18,7 +18,7 @@ reth-db-models.workspace = true reth-primitives = { workspace = true, features = ["reth-codec"] } reth-primitives-traits = { workspace = true, features = ["serde", "reth-codec"] } reth-prune-types.workspace = true -reth-stages-types = { workspace = true, features = ["reth-codec"] } +reth-stages-types = { workspace = true, features = ["serde", "reth-codec"] } reth-storage-errors.workspace = true reth-trie-common.workspace = true diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 21e712c33..2e2113671 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -99,6 +99,7 @@ serde = [ "reth-execution-types/serde", "reth-trie-db/serde", "reth-trie/serde", + "reth-stages-types/serde", ] test-utils = [ "reth-db/test-utils", diff --git a/crates/trie/trie/Cargo.toml b/crates/trie/trie/Cargo.toml index bc55ddcbe..71b486152 100644 --- a/crates/trie/trie/Cargo.toml +++ b/crates/trie/trie/Cargo.toml @@ -68,6 +68,7 @@ serde = [ "revm/serde", "reth-trie-common/serde", "reth-primitives-traits/serde", + "reth-stages-types/serde", ] test-utils = [ "triehash",