From ece09440705ec37bd7f6fbeb04aa3afe0a93a1e8 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Thu, 26 Sep 2024 15:02:10 +0800 Subject: [PATCH] reth-codec: remove unused derives from alloy compat types (#11231) --- crates/engine/tree/src/tree/mod.rs | 1 - crates/storage/codecs/Cargo.toml | 5 ++--- .../storage/codecs/src/alloy/authorization_list.rs | 5 ++--- crates/storage/codecs/src/alloy/genesis_account.rs | 13 ++++++------- crates/storage/codecs/src/alloy/header.rs | 7 ++++--- .../storage/codecs/src/alloy/transaction/eip1559.rs | 6 ++---- .../storage/codecs/src/alloy/transaction/eip2930.rs | 5 ++--- .../storage/codecs/src/alloy/transaction/eip4844.rs | 5 ++--- .../storage/codecs/src/alloy/transaction/eip7702.rs | 5 ++--- .../storage/codecs/src/alloy/transaction/legacy.rs | 5 ++--- .../codecs/src/alloy/transaction/optimism.rs | 5 ++--- crates/storage/codecs/src/alloy/withdrawal.rs | 5 ++--- 12 files changed, 28 insertions(+), 39 deletions(-) diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 6c0f5a051..542bfc086 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -2272,7 +2272,6 @@ where /// Returns `Ok(_)` if computed successfully. /// Returns `Err(_)` if error was encountered during computation. /// `Err(ProviderError::ConsistentView(_))` can be safely ignored and fallback computation - /// should be used instead. fn compute_state_root_async( &self, diff --git a/crates/storage/codecs/Cargo.toml b/crates/storage/codecs/Cargo.toml index 7a999d35f..640ec8c95 100644 --- a/crates/storage/codecs/Cargo.toml +++ b/crates/storage/codecs/Cargo.toml @@ -27,7 +27,6 @@ op-alloy-consensus = { workspace = true, optional = true } # misc bytes.workspace = true modular-bitfield = { workspace = true, optional = true } -serde = { workspace = true, optional = true } [dev-dependencies] alloy-eips = { workspace = true, default-features = false, features = [ @@ -48,17 +47,17 @@ serde_json.workspace = true arbitrary = { workspace = true, features = ["derive"] } proptest.workspace = true proptest-arbitrary-interop.workspace = true +serde.workspace = true [features] default = ["std", "alloy"] -std = ["alloy-primitives/std", "bytes/std", "serde?/std"] +std = ["alloy-primitives/std", "bytes/std"] alloy = [ "dep:alloy-consensus", "dep:alloy-eips", "dep:alloy-genesis", "dep:modular-bitfield", "dep:alloy-trie", - "dep:serde" ] optimism = ["alloy", "dep:op-alloy-consensus"] test-utils = [] diff --git a/crates/storage/codecs/src/alloy/authorization_list.rs b/crates/storage/codecs/src/alloy/authorization_list.rs index 2c1495abf..3efe13590 100644 --- a/crates/storage/codecs/src/alloy/authorization_list.rs +++ b/crates/storage/codecs/src/alloy/authorization_list.rs @@ -5,13 +5,12 @@ use alloy_eips::eip7702::{Authorization as AlloyAuthorization, SignedAuthorizati use alloy_primitives::{Address, U256}; use bytes::Buf; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// Authorization acts as bridge which simplifies Compact implementation for AlloyAuthorization. /// /// Notice: Make sure this struct is 1:1 with `alloy_eips::eip7702::Authorization` -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct Authorization { chain_id: U256, diff --git a/crates/storage/codecs/src/alloy/genesis_account.rs b/crates/storage/codecs/src/alloy/genesis_account.rs index a94f4e2ef..938ad1375 100644 --- a/crates/storage/codecs/src/alloy/genesis_account.rs +++ b/crates/storage/codecs/src/alloy/genesis_account.rs @@ -3,7 +3,6 @@ use alloc::vec::Vec; use alloy_genesis::GenesisAccount as AlloyGenesisAccount; use alloy_primitives::{Bytes, B256, U256}; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// `GenesisAccount` acts as bridge which simplifies Compact implementation for /// `AlloyGenesisAccount`. @@ -23,8 +22,8 @@ pub(crate) struct GenesisAccountRef<'a> { private_key: Option<&'a B256>, } -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct GenesisAccount { /// The nonce of the account at genesis. @@ -39,15 +38,15 @@ pub(crate) struct GenesisAccount { private_key: Option, } -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct StorageEntries { entries: Vec, } -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct StorageEntry { key: B256, diff --git a/crates/storage/codecs/src/alloy/header.rs b/crates/storage/codecs/src/alloy/header.rs index b4fc90e39..c6ef2affc 100644 --- a/crates/storage/codecs/src/alloy/header.rs +++ b/crates/storage/codecs/src/alloy/header.rs @@ -1,7 +1,6 @@ use crate::Compact; use alloy_consensus::Header as AlloyHeader; use alloy_primitives::{Address, BlockNumber, Bloom, Bytes, B256, U256}; -use serde::{Deserialize, Serialize}; /// Block header /// @@ -11,7 +10,8 @@ use serde::{Deserialize, Serialize}; /// will automatically apply to this type. /// /// Notice: Make sure this struct is 1:1 with [`alloy_consensus::Header`] -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] +#[cfg_attr(test, derive(serde::Serialize, serde::Deserialize))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] pub(crate) struct Header { parent_hash: B256, ommers_hash: B256, @@ -42,7 +42,8 @@ pub(crate) struct Header { /// used as a field of [`Header`] for backwards compatibility. /// /// More information: & [`reth_codecs_derive::Compact`]. -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] +#[cfg_attr(test, derive(serde::Serialize, serde::Deserialize))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] pub(crate) struct HeaderExt { requests_root: Option, } diff --git a/crates/storage/codecs/src/alloy/transaction/eip1559.rs b/crates/storage/codecs/src/alloy/transaction/eip1559.rs index d2113a736..9c98bf300 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip1559.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip1559.rs @@ -2,8 +2,6 @@ use crate::Compact; use alloy_consensus::TxEip1559 as AlloyTxEip1559; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Bytes, ChainId, TxKind, U256}; -use serde::{Deserialize, Serialize}; - /// [EIP-1559 Transaction](https://eips.ethereum.org/EIPS/eip-1559) /// /// This is a helper type to use derive on it instead of manually managing `bitfield`. @@ -12,8 +10,8 @@ use serde::{Deserialize, Serialize}; /// will automatically apply to this type. /// /// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip1559`] -#[derive(Debug, Clone, PartialEq, Eq, Hash, Compact, Default, Serialize, Deserialize)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Compact, Default)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[cfg_attr(test, crate::add_arbitrary_tests(compact))] pub(crate) struct TxEip1559 { chain_id: ChainId, diff --git a/crates/storage/codecs/src/alloy/transaction/eip2930.rs b/crates/storage/codecs/src/alloy/transaction/eip2930.rs index b8f24db74..4717884d9 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip2930.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip2930.rs @@ -3,7 +3,6 @@ use alloy_consensus::TxEip2930 as AlloyTxEip2930; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Bytes, ChainId, TxKind, U256}; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// Transaction with an [`AccessList`] ([EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)). /// @@ -13,8 +12,8 @@ use serde::{Deserialize, Serialize}; /// will automatically apply to this type. /// /// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip2930`] -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct TxEip2930 { chain_id: ChainId, diff --git a/crates/storage/codecs/src/alloy/transaction/eip4844.rs b/crates/storage/codecs/src/alloy/transaction/eip4844.rs index e82b9afff..9f58001fd 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip4844.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip4844.rs @@ -4,7 +4,6 @@ use alloy_consensus::TxEip4844 as AlloyTxEip4844; use alloy_eips::eip2930::AccessList; use alloy_primitives::{Address, Bytes, ChainId, B256, U256}; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// [EIP-4844 Blob Transaction](https://eips.ethereum.org/EIPS/eip-4844#blob-transaction) /// @@ -14,8 +13,8 @@ use serde::{Deserialize, Serialize}; /// will automatically apply to this type. /// /// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip4844`] -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct TxEip4844 { chain_id: ChainId, diff --git a/crates/storage/codecs/src/alloy/transaction/eip7702.rs b/crates/storage/codecs/src/alloy/transaction/eip7702.rs index 5f34ac1c2..2cc0786b1 100644 --- a/crates/storage/codecs/src/alloy/transaction/eip7702.rs +++ b/crates/storage/codecs/src/alloy/transaction/eip7702.rs @@ -4,7 +4,6 @@ use alloy_consensus::TxEip7702 as AlloyTxEip7702; use alloy_eips::{eip2930::AccessList, eip7702::SignedAuthorization}; use alloy_primitives::{Address, Bytes, ChainId, U256}; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// [EIP-7702 Set Code Transaction](https://eips.ethereum.org/EIPS/eip-7702) /// @@ -14,8 +13,8 @@ use serde::{Deserialize, Serialize}; /// will automatically apply to this type. /// /// Notice: Make sure this struct is 1:1 with [`alloy_consensus::TxEip7702`] -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct TxEip7702 { chain_id: ChainId, diff --git a/crates/storage/codecs/src/alloy/transaction/legacy.rs b/crates/storage/codecs/src/alloy/transaction/legacy.rs index 641b27bf5..6be620429 100644 --- a/crates/storage/codecs/src/alloy/transaction/legacy.rs +++ b/crates/storage/codecs/src/alloy/transaction/legacy.rs @@ -1,11 +1,10 @@ use crate::Compact; use alloy_consensus::TxLegacy as AlloyTxLegacy; use alloy_primitives::{Bytes, ChainId, TxKind, U256}; -use serde::{Deserialize, Serialize}; /// Legacy transaction. -#[derive(Debug, Clone, PartialEq, Eq, Default, Compact, Serialize, Deserialize)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[cfg_attr(test, crate::add_arbitrary_tests(compact))] pub(crate) struct TxLegacy { /// Added as EIP-155: Simple replay attack protection diff --git a/crates/storage/codecs/src/alloy/transaction/optimism.rs b/crates/storage/codecs/src/alloy/transaction/optimism.rs index c84b19559..0332c1a12 100644 --- a/crates/storage/codecs/src/alloy/transaction/optimism.rs +++ b/crates/storage/codecs/src/alloy/transaction/optimism.rs @@ -2,7 +2,6 @@ use crate::Compact; use alloy_primitives::{Address, Bytes, TxKind, B256, U256}; use op_alloy_consensus::TxDeposit as AlloyTxDeposit; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// Deposit transactions, also known as deposits are initiated on L1, and executed on L2. /// @@ -12,8 +11,8 @@ use serde::{Deserialize, Serialize}; /// will automatically apply to this type. /// /// Notice: Make sure this struct is 1:1 with [`op_alloy_consensus::TxDeposit`] -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct TxDeposit { source_hash: B256, diff --git a/crates/storage/codecs/src/alloy/withdrawal.rs b/crates/storage/codecs/src/alloy/withdrawal.rs index 0ec169321..16324c280 100644 --- a/crates/storage/codecs/src/alloy/withdrawal.rs +++ b/crates/storage/codecs/src/alloy/withdrawal.rs @@ -2,13 +2,12 @@ use crate::Compact; use alloy_eips::eip4895::Withdrawal as AlloyWithdrawal; use alloy_primitives::Address; use reth_codecs_derive::add_arbitrary_tests; -use serde::{Deserialize, Serialize}; /// Withdrawal acts as bridge which simplifies Compact implementation for AlloyWithdrawal. /// /// Notice: Make sure this struct is 1:1 with `alloy_eips::eip4895::Withdrawal` -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)] -#[cfg_attr(test, derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Eq, Default, Compact)] +#[cfg_attr(test, derive(arbitrary::Arbitrary, serde::Serialize, serde::Deserialize))] #[add_arbitrary_tests(compact)] pub(crate) struct Withdrawal { /// Monotonically increasing identifier issued by consensus layer.