diff --git a/crates/primitives-traits/src/account.rs b/crates/primitives-traits/src/account.rs index 21a8d199b..2a6546cc7 100644 --- a/crates/primitives-traits/src/account.rs +++ b/crates/primitives-traits/src/account.rs @@ -4,12 +4,12 @@ use alloy_primitives::{keccak256, Bytes, B256, U256}; use byteorder::{BigEndian, ReadBytesExt}; use bytes::Buf; use derive_more::Deref; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use revm_primitives::{AccountInfo, Bytecode as RevmBytecode, JumpTable}; use serde::{Deserialize, Serialize}; /// An Ethereum account. -#[main_codec] +#[reth_codec] #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub struct Account { /// Account nonce. diff --git a/crates/primitives-traits/src/header/mod.rs b/crates/primitives-traits/src/header/mod.rs index 21a596ce7..018ac5490 100644 --- a/crates/primitives-traits/src/header/mod.rs +++ b/crates/primitives-traits/src/header/mod.rs @@ -16,11 +16,11 @@ use alloy_primitives::{keccak256, Address, BlockNumber, Bloom, Bytes, B256, B64, use alloy_rlp::{length_of_length, Decodable, Encodable}; use bytes::BufMut; use core::mem; -use reth_codecs::{add_arbitrary_tests, main_codec, Compact}; +use reth_codecs::{add_arbitrary_tests, reth_codec, Compact}; use revm_primitives::{calc_blob_gasprice, calc_excess_blob_gas}; /// Block header -#[main_codec(no_arbitrary)] +#[reth_codec(no_arbitrary)] #[add_arbitrary_tests(rlp, 25)] #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Header { diff --git a/crates/primitives-traits/src/header/sealed.rs b/crates/primitives-traits/src/header/sealed.rs index 355e4a9bc..20bb30b8a 100644 --- a/crates/primitives-traits/src/header/sealed.rs +++ b/crates/primitives-traits/src/header/sealed.rs @@ -7,11 +7,11 @@ use alloy_rlp::{Decodable, Encodable}; use bytes::BufMut; use core::mem; use derive_more::{AsRef, Deref}; -use reth_codecs::{add_arbitrary_tests, main_codec, Compact}; +use reth_codecs::{add_arbitrary_tests, reth_codec, Compact}; /// A [`Header`] that is sealed at a precalculated hash, use [`SealedHeader::unseal()`] if you want /// to modify header. -#[main_codec(no_arbitrary)] +#[reth_codec(no_arbitrary)] #[add_arbitrary_tests(rlp, compact)] #[derive(Debug, Clone, PartialEq, Eq, Hash, AsRef, Deref)] pub struct SealedHeader { diff --git a/crates/primitives-traits/src/log.rs b/crates/primitives-traits/src/log.rs index aa6bc26a9..a27108810 100644 --- a/crates/primitives-traits/src/log.rs +++ b/crates/primitives-traits/src/log.rs @@ -19,11 +19,11 @@ mod tests { use alloy_rlp::{RlpDecodable, RlpEncodable}; use proptest::proptest; use proptest_arbitrary_interop::arb; - use reth_codecs::{main_codec, Compact}; + use reth_codecs::{reth_codec, Compact}; /// This type is kept for compatibility tests after the codec support was added to /// alloy-primitives Log type natively - #[main_codec(rlp)] + #[reth_codec(rlp)] #[derive(Clone, Debug, PartialEq, Eq, RlpDecodable, RlpEncodable, Default)] struct Log { /// Contract that emitted this log. diff --git a/crates/primitives-traits/src/request.rs b/crates/primitives-traits/src/request.rs index 99c2375e2..eab29736e 100644 --- a/crates/primitives-traits/src/request.rs +++ b/crates/primitives-traits/src/request.rs @@ -4,14 +4,14 @@ pub use alloy_consensus::Request; use alloy_eips::eip7685::{Decodable7685, Encodable7685}; use alloy_rlp::{Decodable, Encodable}; use derive_more::{Deref, DerefMut, From, IntoIterator}; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use revm_primitives::Bytes; #[cfg(not(feature = "std"))] use alloc::vec::Vec; /// A list of EIP-7685 requests. -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default, Hash, Deref, DerefMut, From, IntoIterator)] pub struct Requests(pub Vec); diff --git a/crates/primitives-traits/src/storage.rs b/crates/primitives-traits/src/storage.rs index 96e7ba15c..b8bd000d0 100644 --- a/crates/primitives-traits/src/storage.rs +++ b/crates/primitives-traits/src/storage.rs @@ -27,7 +27,7 @@ impl From<(B256, U256)> for StorageEntry { } } -// NOTE: Removing main_codec and manually encode subkey +// NOTE: Removing reth_codec and manually encode subkey // and compress second part of the value. If we have compression // over whole value (Even SubKey) that would mess up fetching of values with seek_by_key_subkey impl Compact for StorageEntry { diff --git a/crates/primitives-traits/src/withdrawal.rs b/crates/primitives-traits/src/withdrawal.rs index 49d4e5e31..2064627eb 100644 --- a/crates/primitives-traits/src/withdrawal.rs +++ b/crates/primitives-traits/src/withdrawal.rs @@ -2,7 +2,7 @@ use alloy_rlp::{RlpDecodableWrapper, RlpEncodableWrapper}; use derive_more::{AsRef, Deref, DerefMut, From, IntoIterator}; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; @@ -12,7 +12,7 @@ use alloc::vec::Vec; pub use alloy_eips::eip4895::Withdrawal; /// Represents a collection of Withdrawals. -#[main_codec] +#[reth_codec] #[derive( Debug, Clone, @@ -92,7 +92,7 @@ mod tests { /// This type is kept for compatibility tests after the codec support was added to alloy-eips /// Withdrawal type natively - #[main_codec] + #[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default, Hash, RlpEncodable, RlpDecodable)] struct RethWithdrawal { /// Monotonically increasing identifier issued by consensus layer. diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 90707e343..0c68967dc 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -8,15 +8,15 @@ use core::{cmp::Ordering, ops::Deref}; use derive_more::{Deref, DerefMut, From, IntoIterator}; #[cfg(feature = "zstd-codec")] use reth_codecs::CompactZstd; -use reth_codecs::{add_arbitrary_tests, main_codec, Compact}; +use reth_codecs::{add_arbitrary_tests, reth_codec, Compact}; use serde::{Deserialize, Serialize}; #[cfg(not(feature = "std"))] use alloc::{vec, vec::Vec}; /// Receipt containing result of transaction execution. -#[cfg_attr(feature = "zstd-codec", main_codec(no_arbitrary, zstd))] -#[cfg_attr(not(feature = "zstd-codec"), main_codec(no_arbitrary))] +#[cfg_attr(feature = "zstd-codec", reth_codec(no_arbitrary, zstd))] +#[cfg_attr(not(feature = "zstd-codec"), reth_codec(no_arbitrary))] #[add_arbitrary_tests] #[derive(Clone, Debug, PartialEq, Eq, Default, RlpEncodable, RlpDecodable)] #[rlp(trailing)] @@ -142,7 +142,7 @@ impl From for ReceiptWithBloom { } /// [`Receipt`] with calculated bloom filter. -#[main_codec] +#[reth_codec] #[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct ReceiptWithBloom { /// Bloom filter build from logs. diff --git a/crates/primitives/src/transaction/access_list.rs b/crates/primitives/src/transaction/access_list.rs index 22e113fbd..673a7f31a 100644 --- a/crates/primitives/src/transaction/access_list.rs +++ b/crates/primitives/src/transaction/access_list.rs @@ -11,11 +11,11 @@ mod tests { use alloy_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper}; use proptest::proptest; use proptest_arbitrary_interop::arb; - use reth_codecs::{main_codec, Compact}; + use reth_codecs::{reth_codec, Compact}; /// This type is kept for compatibility tests after the codec support was added to alloy-eips /// AccessList type natively - #[main_codec(rlp)] + #[reth_codec(rlp)] #[derive( Clone, Debug, PartialEq, Eq, Hash, Default, RlpDecodableWrapper, RlpEncodableWrapper, )] @@ -28,7 +28,7 @@ mod tests { } // This - #[main_codec(rlp)] + #[reth_codec(rlp)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Default, RlpDecodable, RlpEncodable)] #[serde(rename_all = "camelCase")] struct RethAccessListItem { diff --git a/crates/primitives/src/transaction/eip1559.rs b/crates/primitives/src/transaction/eip1559.rs index 5fadb248b..af34a5f2d 100644 --- a/crates/primitives/src/transaction/eip1559.rs +++ b/crates/primitives/src/transaction/eip1559.rs @@ -2,13 +2,13 @@ use super::access_list::AccessList; use crate::{keccak256, Bytes, ChainId, Signature, TxKind, TxType, B256, U256}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use core::mem; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; /// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)). -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct TxEip1559 { /// Added as EIP-155: Simple replay attack protection diff --git a/crates/primitives/src/transaction/eip2930.rs b/crates/primitives/src/transaction/eip2930.rs index 302ba41bb..ce8b39462 100644 --- a/crates/primitives/src/transaction/eip2930.rs +++ b/crates/primitives/src/transaction/eip2930.rs @@ -2,13 +2,13 @@ use super::access_list::AccessList; use crate::{keccak256, Bytes, ChainId, Signature, TxKind, TxType, B256, U256}; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use core::mem; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; /// Transaction with an [`AccessList`] ([EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)). -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct TxEip2930 { /// Added as EIP-155: Simple replay attack protection diff --git a/crates/primitives/src/transaction/eip4844.rs b/crates/primitives/src/transaction/eip4844.rs index 5e0c4a83f..e7685be97 100644 --- a/crates/primitives/src/transaction/eip4844.rs +++ b/crates/primitives/src/transaction/eip4844.rs @@ -5,7 +5,7 @@ use crate::{ }; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use core::mem; -use reth_codecs::{main_codec, Compact, CompactPlaceholder}; +use reth_codecs::{reth_codec, Compact, CompactPlaceholder}; #[cfg(feature = "c-kzg")] use crate::kzg::KzgSettings; @@ -16,7 +16,7 @@ use alloc::vec::Vec; /// [EIP-4844 Blob Transaction](https://eips.ethereum.org/EIPS/eip-4844#blob-transaction) /// /// A transaction with blob hashes and max blob fee -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct TxEip4844 { /// Added as EIP-155: Simple replay attack protection diff --git a/crates/primitives/src/transaction/eip7702.rs b/crates/primitives/src/transaction/eip7702.rs index e222597f5..5d53e1dfe 100644 --- a/crates/primitives/src/transaction/eip7702.rs +++ b/crates/primitives/src/transaction/eip7702.rs @@ -4,7 +4,7 @@ use crate::{ }; use alloy_rlp::{length_of_length, Decodable, Encodable, Header}; use core::mem; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; @@ -12,7 +12,7 @@ use alloc::vec::Vec; /// [EIP-7702 Set Code Transaction](https://eips.ethereum.org/EIPS/eip-7702) /// /// Set EOA account code for one transaction -#[main_codec(no_arbitrary, add_arbitrary_tests)] +#[reth_codec(no_arbitrary, add_arbitrary_tests)] #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct TxEip7702 { /// Added as EIP-155: Simple replay attack protection diff --git a/crates/primitives/src/transaction/legacy.rs b/crates/primitives/src/transaction/legacy.rs index 5d9957003..8f2acd4da 100644 --- a/crates/primitives/src/transaction/legacy.rs +++ b/crates/primitives/src/transaction/legacy.rs @@ -1,13 +1,13 @@ use crate::{keccak256, Bytes, ChainId, Signature, TxKind, TxType, B256, U256}; use alloy_rlp::{length_of_length, Encodable, Header}; use core::mem; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; /// Legacy transaction. -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct TxLegacy { /// Added as EIP-155: Simple replay attack protection diff --git a/crates/primitives/src/transaction/optimism.rs b/crates/primitives/src/transaction/optimism.rs index 6bb8ec9b8..fdb6f2a98 100644 --- a/crates/primitives/src/transaction/optimism.rs +++ b/crates/primitives/src/transaction/optimism.rs @@ -3,11 +3,11 @@ use alloy_rlp::{ length_of_length, Decodable, Encodable, Error as DecodeError, Header, EMPTY_STRING_CODE, }; use bytes::Buf; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use std::mem; /// Deposit transactions, also known as deposits are initiated on L1, and executed on L2. -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub struct TxDeposit { /// Hash that uniquely identifies the source of the deposit. diff --git a/crates/prune/types/src/checkpoint.rs b/crates/prune/types/src/checkpoint.rs index 0e27dd146..545358579 100644 --- a/crates/prune/types/src/checkpoint.rs +++ b/crates/prune/types/src/checkpoint.rs @@ -1,9 +1,9 @@ use crate::PruneMode; use alloy_primitives::{BlockNumber, TxNumber}; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; /// Saves the pruning progress of a stage. -#[main_codec] +#[reth_codec] #[derive(Debug, PartialEq, Eq, Clone, Copy)] #[cfg_attr(test, derive(Default))] pub struct PruneCheckpoint { diff --git a/crates/prune/types/src/mode.rs b/crates/prune/types/src/mode.rs index 514e96b83..fc685d999 100644 --- a/crates/prune/types/src/mode.rs +++ b/crates/prune/types/src/mode.rs @@ -1,9 +1,9 @@ use crate::{segment::PrunePurpose, PruneSegment, PruneSegmentError}; use alloy_primitives::BlockNumber; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; /// Prune mode. -#[main_codec] +#[reth_codec] #[derive(Debug, PartialEq, Eq, Clone, Copy)] #[serde(rename_all = "lowercase")] pub enum PruneMode { diff --git a/crates/prune/types/src/segment.rs b/crates/prune/types/src/segment.rs index 867fc4ca1..5611ca89c 100644 --- a/crates/prune/types/src/segment.rs +++ b/crates/prune/types/src/segment.rs @@ -1,10 +1,10 @@ use crate::MINIMUM_PRUNING_DISTANCE; use derive_more::Display; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use thiserror::Error; /// Segment of the data that can be pruned. -#[main_codec] +#[reth_codec] #[derive(Debug, Display, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum PruneSegment { /// Prune segment responsible for the `TransactionSenders` table. diff --git a/crates/stages/types/src/checkpoints.rs b/crates/stages/types/src/checkpoints.rs index d7188de1b..a9ca74958 100644 --- a/crates/stages/types/src/checkpoints.rs +++ b/crates/stages/types/src/checkpoints.rs @@ -1,6 +1,6 @@ use alloy_primitives::{Address, BlockNumber, B256}; use bytes::Buf; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use reth_trie_common::{hash_builder::HashBuilderState, StoredSubNode}; use std::ops::RangeInclusive; @@ -74,7 +74,7 @@ impl Compact for MerkleCheckpoint { } /// Saves the progress of AccountHashing stage. -#[main_codec] +#[reth_codec] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub struct AccountHashingCheckpoint { /// The next account to start hashing from. @@ -86,7 +86,7 @@ pub struct AccountHashingCheckpoint { } /// Saves the progress of StorageHashing stage. -#[main_codec] +#[reth_codec] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub struct StorageHashingCheckpoint { /// The next account to start hashing from. @@ -100,7 +100,7 @@ pub struct StorageHashingCheckpoint { } /// Saves the progress of Execution stage. -#[main_codec] +#[reth_codec] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub struct ExecutionCheckpoint { /// Block range which this checkpoint is valid for. @@ -110,7 +110,7 @@ pub struct ExecutionCheckpoint { } /// Saves the progress of Headers stage. -#[main_codec] +#[reth_codec] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub struct HeadersCheckpoint { /// Block range which this checkpoint is valid for. @@ -120,7 +120,7 @@ pub struct HeadersCheckpoint { } /// Saves the progress of Index History stages. -#[main_codec] +#[reth_codec] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub struct IndexHistoryCheckpoint { /// Block range which this checkpoint is valid for. @@ -130,7 +130,7 @@ pub struct IndexHistoryCheckpoint { } /// Saves the progress of abstract stage iterating over or downloading entities. -#[main_codec] +#[reth_codec] #[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] pub struct EntitiesCheckpoint { /// Number of entities already processed. @@ -158,7 +158,7 @@ impl EntitiesCheckpoint { /// Saves the block range. Usually, it's used to check the validity of some stage checkpoint across /// multiple executions. -#[main_codec] +#[reth_codec] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] pub struct CheckpointBlockRange { /// The first block of the range, inclusive. @@ -180,7 +180,7 @@ impl From<&RangeInclusive> for CheckpointBlockRange { } /// Saves the progress of a stage. -#[main_codec] +#[reth_codec] #[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] pub struct StageCheckpoint { /// The maximum block processed by the stage. @@ -246,7 +246,7 @@ impl StageCheckpoint { // TODO(alexey): add a merkle checkpoint. Currently it's hard because [`MerkleCheckpoint`] // is not a Copy type. /// Stage-specific checkpoint metrics. -#[main_codec] +#[reth_codec] #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum StageUnitCheckpoint { /// Saves the progress of AccountHashing stage. diff --git a/crates/storage/codecs/README.md b/crates/storage/codecs/README.md index db17103f7..1e958ff6e 100644 --- a/crates/storage/codecs/README.md +++ b/crates/storage/codecs/README.md @@ -2,18 +2,18 @@ This crate has helpers to implement the main codec used internally to save data in the different storage types. -Currently `Compact` is used when adding the derive macro `main_codec`. +Currently `Compact` is used when adding the derive macro `reth_codec`. This crate implements the main codec (`Compact`) for: * [primitive types](src/lib.rs) -* [alloy types](src/alloy/mod.rs): uses bridge types alongside `main_codec` from [derive](derive/src/lib.rs) +* [alloy types](src/alloy/mod.rs): uses bridge types alongside `reth_codec` from [derive](derive/src/lib.rs) ### reth-codecs-derive Provides derive macros that can be added and configured to stored data structs/enums -* `#[main_codec]`: Implements `Compact` as well as `#[derive_arbitrary(compact)]` -* `#[main_codec(rlp)]`: Implements `Compact` as well as `#[derive_arbitrary(compact, rlp)]` -* `#[main_codec(no_arbitrary)]`: Implements `Compact` without `derive_arbitrary`. +* `#[reth_codec]`: Implements `Compact` as well as `#[derive_arbitrary(compact)]` +* `#[reth_codec(rlp)]`: Implements `Compact` as well as `#[derive_arbitrary(compact, rlp)]` +* `#[reth_codec(no_arbitrary)]`: Implements `Compact` without `derive_arbitrary`. * `#[derive_arbitrary]`: will derive arbitrary `Arbitrary` and `proptest::Arbitrary` with no generated tests. * `#[derive_arbitrary(rlp)]`: will derive arbitrary and generate rlp roundtrip proptests. diff --git a/crates/storage/codecs/derive/src/lib.rs b/crates/storage/codecs/derive/src/lib.rs index e0022edc4..bc55b0d71 100644 --- a/crates/storage/codecs/derive/src/lib.rs +++ b/crates/storage/codecs/derive/src/lib.rs @@ -33,12 +33,12 @@ pub fn derive_zstd(input: TokenStream) -> TokenStream { /// If you prefer to manually implement the arbitrary traits, you can still use the [`add_arbitrary_tests()`] function to add arbitrary fuzz tests. /// /// Example usage: -/// * `#[main_codec(rlp)]`: will implement `derive_arbitrary(rlp)` or `derive_arbitrary(compact, rlp)`, if `compact` is the `main_codec`. -/// * `#[main_codec(no_arbitrary)]`: will skip `derive_arbitrary` (both trait implementations and tests) +/// * `#[reth_codec(rlp)]`: will implement `derive_arbitrary(rlp)` or `derive_arbitrary(compact, rlp)`, if `compact` is the `reth_codec`. +/// * `#[reth_codec(no_arbitrary)]`: will skip `derive_arbitrary` (both trait implementations and tests) #[proc_macro_attribute] #[rustfmt::skip] #[allow(unreachable_code)] -pub fn main_codec(args: TokenStream, input: TokenStream) -> TokenStream { +pub fn reth_codec(args: TokenStream, input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input as DeriveInput); let with_zstd = args.clone().into_iter().any(|tk| tk.to_string() == "zstd"); diff --git a/crates/storage/codecs/src/alloy/authorization_list.rs b/crates/storage/codecs/src/alloy/authorization_list.rs index 308c597a1..5dc983698 100644 --- a/crates/storage/codecs/src/alloy/authorization_list.rs +++ b/crates/storage/codecs/src/alloy/authorization_list.rs @@ -2,12 +2,12 @@ use crate::Compact; use alloy_eips::eip7702::{Authorization as AlloyAuthorization, SignedAuthorization}; use alloy_primitives::{Address, ChainId, U256}; use bytes::Buf; -use reth_codecs_derive::main_codec; +use reth_codecs_derive::reth_codec; /// Authorization acts as bridge which simplifies Compact implementation for AlloyAuthorization. /// /// Notice: Make sure this struct is 1:1 with `alloy_eips::eip7702::Authorization` -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default)] struct Authorization { chain_id: ChainId, diff --git a/crates/storage/codecs/src/alloy/genesis_account.rs b/crates/storage/codecs/src/alloy/genesis_account.rs index bc3843ab7..8f490d6fd 100644 --- a/crates/storage/codecs/src/alloy/genesis_account.rs +++ b/crates/storage/codecs/src/alloy/genesis_account.rs @@ -1,12 +1,12 @@ use crate::Compact; use alloy_genesis::GenesisAccount as AlloyGenesisAccount; use alloy_primitives::{Bytes, B256, U256}; -use reth_codecs_derive::main_codec; +use reth_codecs_derive::reth_codec; /// GenesisAccount acts as bridge which simplifies Compact implementation for AlloyGenesisAccount. /// /// Notice: Make sure this struct is 1:1 with `alloy_genesis::GenesisAccount` -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default)] struct GenesisAccount { /// The nonce of the account at genesis. @@ -21,13 +21,13 @@ struct GenesisAccount { private_key: Option, } -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default)] struct StorageEntries { entries: Vec, } -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default)] struct StorageEntry { key: B256, diff --git a/crates/storage/codecs/src/alloy/withdrawal.rs b/crates/storage/codecs/src/alloy/withdrawal.rs index 0f2569cef..80effd668 100644 --- a/crates/storage/codecs/src/alloy/withdrawal.rs +++ b/crates/storage/codecs/src/alloy/withdrawal.rs @@ -1,12 +1,12 @@ use crate::Compact; use alloy_eips::eip4895::Withdrawal as AlloyWithdrawal; use alloy_primitives::Address; -use reth_codecs_derive::main_codec; +use reth_codecs_derive::reth_codec; /// Withdrawal acts as bridge which simplifies Compact implementation for AlloyWithdrawal. /// /// Notice: Make sure this struct is 1:1 with `alloy_eips::eip4895::Withdrawal` -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default)] struct Withdrawal { /// Monotonically increasing identifier issued by consensus layer. diff --git a/crates/storage/codecs/src/lib.rs b/crates/storage/codecs/src/lib.rs index bea26090d..d73cc12f4 100644 --- a/crates/storage/codecs/src/lib.rs +++ b/crates/storage/codecs/src/lib.rs @@ -555,7 +555,7 @@ mod tests { }); } - #[main_codec] + #[reth_codec] #[derive(Debug, PartialEq, Clone)] struct TestStruct { f_u64: u64, @@ -607,7 +607,7 @@ mod tests { ); } - #[main_codec] + #[reth_codec] #[derive(Debug, PartialEq, Clone, Default)] enum TestEnum { #[default] diff --git a/crates/storage/db-api/src/models/accounts.rs b/crates/storage/db-api/src/models/accounts.rs index f53f29a12..e6479d8c0 100644 --- a/crates/storage/db-api/src/models/accounts.rs +++ b/crates/storage/db-api/src/models/accounts.rs @@ -23,7 +23,7 @@ pub struct AccountBeforeTx { pub info: Option, } -// NOTE: Removing main_codec and manually encode subkey +// NOTE: Removing reth_codec and manually encode subkey // and compress second part of the value. If we have compression // over whole value (Even SubKey) that would mess up fetching of values with seek_by_key_subkey impl Compact for AccountBeforeTx { diff --git a/crates/storage/db-api/src/models/blocks.rs b/crates/storage/db-api/src/models/blocks.rs index 97beccf87..7d42b6ee4 100644 --- a/crates/storage/db-api/src/models/blocks.rs +++ b/crates/storage/db-api/src/models/blocks.rs @@ -1,6 +1,6 @@ //! Block related models and types. -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use reth_primitives::{Header, TxNumber, Withdrawals, B256}; use std::ops::Range; @@ -12,7 +12,7 @@ pub type NumTransactions = u64; /// It has the pointer to the transaction Number of the first /// transaction in the block and the total number of transactions. #[derive(Debug, Default, Eq, PartialEq, Clone)] -#[main_codec] +#[reth_codec] pub struct StoredBlockBodyIndices { /// The number of the first transaction in this block /// @@ -68,7 +68,7 @@ impl StoredBlockBodyIndices { /// The storage representation of a block's ommers. /// /// It is stored as the headers of the block's uncles. -#[main_codec] +#[reth_codec] #[derive(Debug, Default, Eq, PartialEq, Clone)] pub struct StoredBlockOmmers { /// The block headers of this block's uncles. @@ -76,7 +76,7 @@ pub struct StoredBlockOmmers { } /// The storage representation of block withdrawals. -#[main_codec] +#[reth_codec] #[derive(Debug, Default, Eq, PartialEq, Clone)] pub struct StoredBlockWithdrawals { /// The block withdrawals. diff --git a/crates/storage/db-api/src/models/mod.rs b/crates/storage/db-api/src/models/mod.rs index df6467336..9f3fabea9 100644 --- a/crates/storage/db-api/src/models/mod.rs +++ b/crates/storage/db-api/src/models/mod.rs @@ -4,7 +4,7 @@ use crate::{ table::{Compress, Decode, Decompress, Encode}, DatabaseError, }; -use reth_codecs::{main_codec, Compact}; +use reth_codecs::{reth_codec, Compact}; use reth_primitives::{Address, B256, *}; use reth_prune_types::{PruneCheckpoint, PruneSegment}; use reth_stages_types::StageCheckpoint; @@ -263,7 +263,7 @@ macro_rules! add_wrapper_struct { ($(($name:tt, $wrapper:tt)),+) => { $( /// Wrapper struct so it can use StructFlags from Compact, when used as pure table values. - #[main_codec] + #[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct $wrapper(pub $name); diff --git a/crates/trie/common/src/storage.rs b/crates/trie/common/src/storage.rs index 04ff57e1f..9dd07fd72 100644 --- a/crates/trie/common/src/storage.rs +++ b/crates/trie/common/src/storage.rs @@ -11,7 +11,7 @@ pub struct StorageTrieEntry { pub node: BranchNodeCompact, } -// NOTE: Removing main_codec and manually encode subkey +// NOTE: Removing reth_codec and manually encode subkey // and compress second part of the value. If we have compression // over whole value (Even SubKey) that would mess up fetching of values with seek_by_key_subkey impl Compact for StorageTrieEntry { diff --git a/docs/crates/eth-wire.md b/docs/crates/eth-wire.md index f1997e2c1..9a8863802 100644 --- a/docs/crates/eth-wire.md +++ b/docs/crates/eth-wire.md @@ -105,7 +105,7 @@ And the corresponding trait implementations are present in the primitives crate. [File: crates/primitives/src/transaction/mod.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/primitives/src/transaction/mod.rs) ```rust, ignore -#[main_codec] +#[reth_codec] #[derive(Debug, Clone, PartialEq, Eq, Hash, AsRef, Deref, Default)] pub struct TransactionSigned { pub hash: TxHash, diff --git a/docs/design/database.md b/docs/design/database.md index 485c183e8..06ac63a05 100644 --- a/docs/design/database.md +++ b/docs/design/database.md @@ -19,7 +19,7 @@ - [Scale Encoding](https://github.com/paritytech/parity-scale-codec) - [Postcard Encoding](https://github.com/jamesmunns/postcard) - Passthrough (called `no_codec` in the codebase) -- We made implementation of these traits easy via a derive macro called [`main_codec`](https://github.com/paradigmxyz/reth/blob/0d9b9a392d4196793736522f3fc2ac804991b45d/crates/codecs/derive/src/lib.rs#L15) that delegates to one of Compact (default), Scale, Postcard or Passthrough encoding. This is [derived on every struct we need](https://github.com/search?q=repo%3Aparadigmxyz%2Freth%20%22%23%5Bmain_codec%5D%22&type=code), and lets us experiment with different encoding formats without having to modify the entire codebase each time. +- We made implementation of these traits easy via a derive macro called [`reth_codec`](https://github.com/paradigmxyz/reth/blob/0d9b9a392d4196793736522f3fc2ac804991b45d/crates/codecs/derive/src/lib.rs#L15) that delegates to one of Compact (default), Scale, Postcard or Passthrough encoding. This is [derived on every struct we need](https://github.com/search?q=repo%3Aparadigmxyz%2Freth%20%22%23%5Breth_codec%5D%22&type=code), and lets us experiment with different encoding formats without having to modify the entire codebase each time. ### Table layout