diff --git a/Cargo.lock b/Cargo.lock index ded071c5dc27..56f2864c5fa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,9 +182,9 @@ dependencies = [ [[package]] name = "alloy-eip7702" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69fb9fd842fdf10a524bbf2c4de6942ad869c1c8c3d128a1b09e67ed5f7cedbd" +checksum = "5f6cee6a35793f3db8a5ffe60e86c695f321d081a567211245f503e8c498fce8" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -776,9 +776,9 @@ dependencies = [ [[package]] name = "alloy-trie" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40d8e28db02c006f7abb20f345ffb3cc99c465e36f676ba262534e654ae76042" +checksum = "b6b2e366c0debf0af77766c23694a3f863b02633050e71e096e257ffbd395e50" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -1525,9 +1525,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" dependencies = [ "memchr", "regex-automata 0.4.9", @@ -1651,9 +1651,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -1752,9 +1752,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -1762,9 +1762,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -1786,9 +1786,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "coins-bip32" @@ -1859,14 +1859,14 @@ dependencies = [ [[package]] name = "comfy-table" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" +checksum = "24f165e7b643266ea80cb858aed492ad9280e3e05ce24d4a99d7d7b889b6a4d9" dependencies = [ - "crossterm 0.27.0", + "crossterm", "strum", "strum_macros", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] @@ -2107,19 +2107,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crossterm" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" -dependencies = [ - "bitflags 2.6.0", - "crossterm_winapi", - "libc", - "parking_lot", - "winapi", -] - [[package]] name = "crossterm" version = "0.28.1" @@ -3198,9 +3185,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -6165,7 +6152,7 @@ dependencies = [ "bitflags 2.6.0", "cassowary", "compact_str", - "crossterm 0.28.1", + "crossterm", "instability", "itertools 0.13.0", "lru", @@ -6174,7 +6161,7 @@ dependencies = [ "strum_macros", "unicode-segmentation", "unicode-truncate", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -6665,7 +6652,7 @@ dependencies = [ "backon", "clap", "comfy-table", - "crossterm 0.28.1", + "crossterm", "eyre", "fdlimit", "futures", @@ -8397,6 +8384,7 @@ dependencies = [ "reth-primitives", "reth-primitives-traits", "rstest", + "serde", ] [[package]] @@ -9629,6 +9617,7 @@ checksum = "8f4b84ba6e838ceb47b41de5194a60244fac43d9fe03b71dbe8c5a201081d6d1" dependencies = [ "bytemuck", "byteorder", + "serde", ] [[package]] @@ -9903,9 +9892,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.4" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" +checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" dependencies = [ "sdd", ] @@ -11349,7 +11338,7 @@ checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" dependencies = [ "itertools 0.13.0", "unicode-segmentation", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -11358,6 +11347,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" diff --git a/crates/evm/execution-types/Cargo.toml b/crates/evm/execution-types/Cargo.toml index 13b0aef8ad45..4d2d8214ff98 100644 --- a/crates/evm/execution-types/Cargo.toml +++ b/crates/evm/execution-types/Cargo.toml @@ -40,7 +40,8 @@ serde = [ "revm/serde", "alloy-eips/serde", "alloy-primitives/serde", - "rand/serde" + "rand/serde", + "reth-primitives-traits/serde", ] serde-bincode-compat = [ "reth-primitives/serde-bincode-compat", diff --git a/crates/exex/exex/Cargo.toml b/crates/exex/exex/Cargo.toml index f7ab4fce5df0..3cbeb115b066 100644 --- a/crates/exex/exex/Cargo.toml +++ b/crates/exex/exex/Cargo.toml @@ -78,5 +78,6 @@ serde = [ "alloy-primitives/serde", "parking_lot/serde", "rand/serde", - "secp256k1/serde" + "secp256k1/serde", + "reth-primitives-traits/serde", ] diff --git a/crates/net/eth-wire-types/Cargo.toml b/crates/net/eth-wire-types/Cargo.toml index f9759ffc25af..8b89603167d4 100644 --- a/crates/net/eth-wire-types/Cargo.toml +++ b/crates/net/eth-wire-types/Cargo.toml @@ -65,4 +65,5 @@ serde = [ "alloy-primitives/serde", "bytes/serde", "rand/serde", + "reth-primitives-traits/serde", ] diff --git a/crates/net/eth-wire/Cargo.toml b/crates/net/eth-wire/Cargo.toml index 3999f658e0a6..ffbd3017fa62 100644 --- a/crates/net/eth-wire/Cargo.toml +++ b/crates/net/eth-wire/Cargo.toml @@ -87,7 +87,8 @@ serde = [ "rand/serde", "secp256k1/serde", "reth-codecs/serde", - "alloy-chains/serde" + "alloy-chains/serde", + "reth-primitives-traits/serde", ] [[test]] diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index dde0b4a0b230..ad8e65dffc69 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -121,6 +121,7 @@ serde = [ "rand/serde", "smallvec/serde", "url/serde", + "reth-primitives-traits/serde", ] test-utils = [ "dep:reth-provider", diff --git a/crates/optimism/cli/Cargo.toml b/crates/optimism/cli/Cargo.toml index 198e5377ec4d..d090075927aa 100644 --- a/crates/optimism/cli/Cargo.toml +++ b/crates/optimism/cli/Cargo.toml @@ -119,5 +119,6 @@ serde = [ "alloy-primitives/serde", "op-alloy-consensus?/serde", "reth-execution-types/serde", - "reth-provider/serde" + "reth-provider/serde", + "reth-optimism-primitives/serde", ] diff --git a/crates/optimism/primitives/Cargo.toml b/crates/optimism/primitives/Cargo.toml index 216e559a201e..4c6d9f51406f 100644 --- a/crates/optimism/primitives/Cargo.toml +++ b/crates/optimism/primitives/Cargo.toml @@ -12,21 +12,44 @@ description = "OP primitive types" workspace = true [dependencies] +# reth +reth-primitives-traits.workspace = true +reth-codecs = { workspace = true, optional = true } +reth-primitives = { workspace = true, features = ["reth-codec"], optional = true } + +# ethereum alloy-primitives.workspace = true alloy-consensus.workspace = true -op-alloy-consensus.workspace = true alloy-eips.workspace = true alloy-rlp.workspace = true -derive_more.workspace = true + +# op +op-alloy-consensus.workspace = true + +# codec bytes.workspace = true -reth-primitives-traits.workspace = true -reth-codecs = { workspace = true, optional = true } -reth-primitives = { workspace = true, features = ["reth-codec"], optional = true } +serde = { workspace = true, optional = true } -[features] -default = ["reth-codec"] -reth-codec = ["dep:reth-codecs", "dep:reth-primitives"] +# misc +derive_more.workspace = true [dev-dependencies] reth-codecs = { workspace = true, features = ["test-utils"] } -rstest.workspace = true \ No newline at end of file +rstest.workspace = true + +[features] +default = ["reth-codec"] +reth-codec = [ + "dep:reth-codecs", + "dep:reth-primitives" +] +serde = [ + "dep:serde", + "reth-primitives-traits/serde", + "alloy-primitives/serde", + "alloy-consensus/serde", + "alloy-eips/serde", + "bytes/serde", + "reth-codecs/serde", + "op-alloy-consensus/serde", +] diff --git a/crates/optimism/primitives/src/tx_type.rs b/crates/optimism/primitives/src/tx_type.rs index 70f5fd32d8e5..9ddfe77b192f 100644 --- a/crates/optimism/primitives/src/tx_type.rs +++ b/crates/optimism/primitives/src/tx_type.rs @@ -3,8 +3,9 @@ //! This type is required because a `Compact` impl is needed on the deposit tx type. use core::fmt::Debug; -use std::convert::TryFrom; +#[cfg(feature = "reth-codec")] +use alloy_consensus::constants::EIP7702_TX_TYPE_ID; use alloy_primitives::{U64, U8}; use alloy_rlp::{Decodable, Encodable, Error}; use bytes::BufMut; @@ -13,10 +14,6 @@ use derive_more::{ Display, }; use op_alloy_consensus::OpTxType as AlloyOpTxType; -use reth_primitives_traits::{InMemorySize, TxType}; - -#[cfg(feature = "reth-codec")] -use alloy_consensus::constants::EIP7702_TX_TYPE_ID; #[cfg(feature = "reth-codec")] use op_alloy_consensus::DEPOSIT_TX_TYPE_ID; #[cfg(feature = "reth-codec")] @@ -24,8 +21,9 @@ use reth_primitives::transaction::{ COMPACT_EXTENDED_IDENTIFIER_FLAG, COMPACT_IDENTIFIER_EIP1559, COMPACT_IDENTIFIER_EIP2930, COMPACT_IDENTIFIER_LEGACY, }; +use reth_primitives_traits::{InMemorySize, TxType}; -/// Wrapper type for `AlloyOpTxType` to implement `TxType` trait. +/// Wrapper type for [`op_alloy_consensus::OpTxType`] to implement [`TxType`] trait. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Display, Ord, Hash, From, Into)] #[into(u8)] pub struct OpTxType(AlloyOpTxType); diff --git a/crates/primitives-traits/Cargo.toml b/crates/primitives-traits/Cargo.toml index 651583f8e4d0..20430fbc8829 100644 --- a/crates/primitives-traits/Cargo.toml +++ b/crates/primitives-traits/Cargo.toml @@ -12,15 +12,16 @@ description = "Common types in reth." workspace = true [dependencies] +# reth reth-codecs.workspace = true -alloy-consensus = { workspace = true, features = ["serde"] } +# ethereum +alloy-consensus.workspace = true alloy-eips.workspace = true alloy-genesis.workspace = true alloy-primitives.workspace = true alloy-rlp.workspace = true - -revm-primitives = { workspace = true, features = ["serde"] } +revm-primitives.workspace = true # misc byteorder = "1" @@ -76,7 +77,19 @@ arbitrary = [ "reth-codecs/arbitrary" ] serde-bincode-compat = [ + "serde", "serde_with", "alloy-consensus/serde-bincode-compat", "alloy-eips/serde-bincode-compat" ] +serde = [ + "alloy-consensus/serde", + "alloy-eips/serde", + "alloy-primitives/serde", + "bytes/serde", + "rand/serde", + "reth-codecs/serde", + "revm-primitives/serde", + "roaring/serde", + "revm-primitives/serde", +] \ No newline at end of file diff --git a/crates/primitives-traits/src/account.rs b/crates/primitives-traits/src/account.rs index ae58973edd71..927e39a52e17 100644 --- a/crates/primitives-traits/src/account.rs +++ b/crates/primitives-traits/src/account.rs @@ -6,7 +6,6 @@ use bytes::Buf; use derive_more::Deref; use reth_codecs::{add_arbitrary_tests, Compact}; use revm_primitives::{AccountInfo, Bytecode as RevmBytecode, BytecodeDecodeError, JumpTable}; -use serde::{Deserialize, Serialize}; /// Identifier for [`LegacyRaw`](RevmBytecode::LegacyRaw). const LEGACY_RAW_BYTECODE_ID: u8 = 0; @@ -24,7 +23,8 @@ const EOF_BYTECODE_ID: u8 = 3; const EIP7702_BYTECODE_ID: u8 = 4; /// An Ethereum account. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Serialize, Deserialize, Compact)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default, Compact)] #[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[add_arbitrary_tests(compact)] pub struct Account { @@ -60,7 +60,8 @@ impl Account { /// Bytecode for an account. /// /// A wrapper around [`revm::primitives::Bytecode`][RevmBytecode] with encoding/decoding support. -#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, Deref)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Debug, Clone, Default, PartialEq, Eq, Deref)] pub struct Bytecode(pub RevmBytecode); impl Bytecode { diff --git a/crates/primitives-traits/src/block/body.rs b/crates/primitives-traits/src/block/body.rs index e9aadf409571..074efc4d5141 100644 --- a/crates/primitives-traits/src/block/body.rs +++ b/crates/primitives-traits/src/block/body.rs @@ -1,6 +1,6 @@ //! Block body abstraction. -use crate::InMemorySize; +use crate::{InMemorySize, MaybeSerde}; use alloc::fmt; use alloy_consensus::Transaction; @@ -15,11 +15,10 @@ pub trait BlockBody: + fmt::Debug + PartialEq + Eq - + serde::Serialize - + for<'de> serde::Deserialize<'de> + alloy_rlp::Encodable + alloy_rlp::Decodable + InMemorySize + + MaybeSerde { /// Ordered list of signed transactions as committed in block. // todo: requires trait for signed transaction diff --git a/crates/primitives-traits/src/block/header.rs b/crates/primitives-traits/src/block/header.rs index 779df4425388..524835879f31 100644 --- a/crates/primitives-traits/src/block/header.rs +++ b/crates/primitives-traits/src/block/header.rs @@ -1,10 +1,12 @@ //! Block header data primitive. -use crate::InMemorySize; -use alloy_primitives::Sealable; use core::fmt; + +use alloy_primitives::Sealable; use reth_codecs::Compact; +use crate::{InMemorySize, MaybeSerde}; + /// Helper trait that unifies all behaviour required by block header to support full node /// operations. pub trait FullBlockHeader: BlockHeader + Compact {} @@ -26,6 +28,7 @@ pub trait BlockHeader: + alloy_consensus::BlockHeader + Sealable + InMemorySize + + MaybeSerde { } @@ -38,12 +41,11 @@ impl BlockHeader for T where + fmt::Debug + PartialEq + Eq - + serde::Serialize - + for<'de> serde::Deserialize<'de> + alloy_rlp::Encodable + alloy_rlp::Decodable + alloy_consensus::BlockHeader + Sealable + InMemorySize + + MaybeSerde { } diff --git a/crates/primitives-traits/src/block/mod.rs b/crates/primitives-traits/src/block/mod.rs index 6bef9ea167fd..5b1faeafbb72 100644 --- a/crates/primitives-traits/src/block/mod.rs +++ b/crates/primitives-traits/src/block/mod.rs @@ -7,7 +7,7 @@ use alloc::fmt; use reth_codecs::Compact; -use crate::{BlockHeader, FullBlockHeader, InMemorySize}; +use crate::{BlockHeader, FullBlockHeader, InMemorySize, MaybeSerde}; /// Helper trait that unifies all behaviour required by block to support full node operations. pub trait FullBlock: Block + Compact {} @@ -20,17 +20,7 @@ impl FullBlock for T where T: Block + Compact {} // senders #[auto_impl::auto_impl(&, Arc)] pub trait Block: - Send - + Sync - + Unpin - + Clone - + Default - + fmt::Debug - + PartialEq - + Eq - + serde::Serialize - + for<'a> serde::Deserialize<'a> - + InMemorySize + Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + InMemorySize + MaybeSerde { /// Header part of the block. type Header: BlockHeader + 'static; diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index 584181f2c95b..1c848b814137 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -92,3 +92,16 @@ pub trait MaybeArbitrary {} impl MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {} #[cfg(not(any(feature = "test-utils", feature = "arbitrary")))] impl MaybeArbitrary for T {} + +/// Helper trait that requires de-/serialize implementation since `serde` feature is enabled. +#[cfg(feature = "serde")] +pub trait MaybeSerde: serde::Serialize + for<'de> serde::Deserialize<'de> {} +/// Noop. Helper trait that would require de-/serialize implementation if `serde` feature were +/// enabled. +#[cfg(not(feature = "serde"))] +pub trait MaybeSerde {} + +#[cfg(feature = "serde")] +impl MaybeSerde for T where T: serde::Serialize + for<'de> serde::Deserialize<'de> {} +#[cfg(not(feature = "serde"))] +impl MaybeSerde for T {} diff --git a/crates/primitives-traits/src/node.rs b/crates/primitives-traits/src/node.rs index ca490ac15aa8..35c8ea0f6937 100644 --- a/crates/primitives-traits/src/node.rs +++ b/crates/primitives-traits/src/node.rs @@ -1,17 +1,17 @@ use core::fmt; -use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType}; +use crate::{BlockBody, FullBlock, FullReceipt, FullSignedTx, FullTxType, MaybeSerde}; /// Configures all the primitive types of the node. pub trait NodePrimitives: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static { /// Block primitive. - type Block: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static; + type Block: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static; /// Signed version of the transaction type. - type SignedTx: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static; + type SignedTx: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static; /// Transaction envelope type ID. type TxType: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static; /// A receipt. - type Receipt: Send + Sync + Unpin + Clone + Default + fmt::Debug + 'static; + type Receipt: Send + Sync + Unpin + Clone + Default + fmt::Debug + MaybeSerde + 'static; } impl NodePrimitives for () { diff --git a/crates/primitives-traits/src/receipt.rs b/crates/primitives-traits/src/receipt.rs index b34590dff0e9..64839ecb8b4b 100644 --- a/crates/primitives-traits/src/receipt.rs +++ b/crates/primitives-traits/src/receipt.rs @@ -1,13 +1,11 @@ //! Receipt abstraction +use crate::{InMemorySize, MaybeSerde}; use alloc::vec::Vec; use alloy_consensus::TxReceipt; use alloy_primitives::B256; use core::fmt; use reth_codecs::Compact; -use serde::{Deserialize, Serialize}; - -use crate::InMemorySize; /// Helper trait that unifies all behaviour required by receipt to support full node operations. pub trait FullReceipt: Receipt + Compact {} @@ -26,9 +24,8 @@ pub trait Receipt: + TxReceipt + alloy_rlp::Encodable + alloy_rlp::Decodable - + Serialize + + MaybeSerde + InMemorySize - + for<'de> Deserialize<'de> { /// Returns transaction type. fn tx_type(&self) -> u8; diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 33ee36090acb..9d60be0c32e5 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -6,9 +6,8 @@ use core::{fmt, hash::Hash}; use alloy_primitives::B256; use reth_codecs::Compact; -use serde::{Deserialize, Serialize}; -use crate::{FullTxType, InMemorySize, MaybeArbitrary, TxType}; +use crate::{FullTxType, InMemorySize, MaybeArbitrary, MaybeSerde, TxType}; /// Helper trait that unifies all behaviour required by transaction to support full node operations. pub trait FullTransaction: Transaction + Compact {} @@ -26,10 +25,9 @@ pub trait Transaction: + Eq + PartialEq + Hash - + Serialize - + for<'de> Deserialize<'de> + TransactionExt + InMemorySize + + MaybeSerde + MaybeArbitrary { } @@ -44,10 +42,9 @@ impl Transaction for T where + Eq + PartialEq + Hash - + Serialize - + for<'de> Deserialize<'de> + TransactionExt + InMemorySize + + MaybeSerde + MaybeArbitrary { } diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index 7b6abbaec0f3..d860dbb92fca 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -8,7 +8,7 @@ use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256}; use reth_codecs::Compact; use revm_primitives::TxEnv; -use crate::{FullTransaction, InMemorySize, MaybeArbitrary, Transaction}; +use crate::{FullTransaction, InMemorySize, MaybeArbitrary, MaybeSerde, Transaction}; /// Helper trait that unifies all behaviour required by block to support full node operations. pub trait FullSignedTx: SignedTransaction + Compact {} @@ -27,13 +27,12 @@ pub trait SignedTransaction: + PartialEq + Eq + Hash - + serde::Serialize - + for<'a> serde::Deserialize<'a> + alloy_rlp::Encodable + alloy_rlp::Decodable + Encodable2718 + Decodable2718 + alloy_consensus::Transaction + + MaybeSerde + MaybeArbitrary + InMemorySize { diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index c9043a2bd11e..89282c8f93d7 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -13,7 +13,7 @@ workspace = true [dependencies] # reth -reth-primitives-traits.workspace = true +reth-primitives-traits = { workspace = true, features = ["serde"] } reth-ethereum-forks.workspace = true reth-static-file-types.workspace = true revm-primitives = { workspace = true, features = ["serde"] } diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index d1202cd8b2cf..4bc78b7b0562 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -59,4 +59,5 @@ serde = [ "alloy-eips/serde", "alloy-primitives/serde", "alloy-consensus/serde", + "reth-primitives-traits/serde", ] diff --git a/crates/storage/codecs/Cargo.toml b/crates/storage/codecs/Cargo.toml index 20a0673dff62..57fe9f726c7b 100644 --- a/crates/storage/codecs/Cargo.toml +++ b/crates/storage/codecs/Cargo.toml @@ -81,7 +81,7 @@ serde = [ "alloy-primitives/serde", "alloy-trie?/serde", "bytes/serde", - "op-alloy-consensus?/serde" + "op-alloy-consensus?/serde", ] arbitrary = [ "alloy-consensus?/arbitrary", diff --git a/crates/storage/db-api/Cargo.toml b/crates/storage/db-api/Cargo.toml index 9b8589cb6aa8..bcc3e7789847 100644 --- a/crates/storage/db-api/Cargo.toml +++ b/crates/storage/db-api/Cargo.toml @@ -16,7 +16,7 @@ workspace = true reth-codecs.workspace = true reth-db-models.workspace = true reth-primitives = { workspace = true, features = ["reth-codec"] } -reth-primitives-traits.workspace = true +reth-primitives-traits = { workspace = true, features = ["serde"] } reth-prune-types.workspace = true reth-stages-types.workspace = true reth-storage-errors.workspace = true diff --git a/crates/storage/db-models/Cargo.toml b/crates/storage/db-models/Cargo.toml index 59d95c2263d0..44c0c3d962a5 100644 --- a/crates/storage/db-models/Cargo.toml +++ b/crates/storage/db-models/Cargo.toml @@ -14,7 +14,7 @@ workspace = true [dependencies] # reth reth-codecs.workspace = true -reth-primitives-traits.workspace = true +reth-primitives-traits = { workspace = true, features = ["serde"] } # ethereum alloy-primitives.workspace = true diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index 6042b5faa815..7dca8aa84752 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -15,7 +15,7 @@ workspace = true # reth reth-db-api.workspace = true reth-primitives = { workspace = true, features = ["reth-codec"] } -reth-primitives-traits.workspace = true +reth-primitives-traits = { workspace = true, features = ["serde"] } reth-fs-util.workspace = true reth-storage-errors.workspace = true reth-nippy-jar.workspace = true diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 399e3e000b99..eff0540638a5 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -110,6 +110,7 @@ serde = [ "rand/serde", "revm/serde", "reth-codecs/serde", + "reth-optimism-primitives?/serde", ] test-utils = [ "reth-db/test-utils", diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index 22df82536826..7c0f34765591 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -88,6 +88,7 @@ serde = [ "rand?/serde", "revm/serde", "smallvec/serde", + "reth-primitives-traits/serde", ] test-utils = [ "rand", diff --git a/crates/trie/common/Cargo.toml b/crates/trie/common/Cargo.toml index 0616e2597109..49d09d6f39bc 100644 --- a/crates/trie/common/Cargo.toml +++ b/crates/trie/common/Cargo.toml @@ -12,7 +12,7 @@ description = "Commonly used types for trie usage in reth." workspace = true [dependencies] -reth-primitives-traits.workspace = true +reth-primitives-traits = { workspace = true, features = ["serde"] } reth-codecs.workspace = true alloy-primitives.workspace = true