refactor: remove #[reth_codec] and #[derive_arbitrary] macros (#10263)

This commit is contained in:
Arsenii Kulikov
2024-08-12 22:23:50 +08:00
committed by GitHub
parent 6eae55e516
commit 330f73b7ec
45 changed files with 240 additions and 206 deletions

View File

@ -7,15 +7,16 @@ use crate::{
table::{Decode, Encode},
DatabaseError,
};
use reth_codecs::{derive_arbitrary, Compact};
use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{Account, Address, BlockNumber, Buf, StorageKey};
use serde::{Deserialize, Serialize};
/// Account as it is saved in the database.
///
/// [`Address`] is the subkey.
#[derive_arbitrary(compact)]
#[derive(Debug, Default, Clone, Eq, PartialEq, Serialize)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct AccountBeforeTx {
/// Address for the account. Acts as `DupSort::SubKey`.
pub address: Address,

View File

@ -1,6 +1,6 @@
//! Block related models and types.
use reth_codecs::{reth_codec, Compact};
use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{Header, TxNumber, Withdrawals, B256};
use serde::{Deserialize, Serialize};
use std::ops::Range;
@ -12,8 +12,9 @@ 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, Serialize, Deserialize)]
#[reth_codec]
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize, Compact)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct StoredBlockBodyIndices {
/// The number of the first transaction in this block
///
@ -69,16 +70,18 @@ impl StoredBlockBodyIndices {
/// The storage representation of a block's ommers.
///
/// It is stored as the headers of the block's uncles.
#[reth_codec]
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize, Compact)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct StoredBlockOmmers {
/// The block headers of this block's uncles.
pub ommers: Vec<Header>,
}
/// The storage representation of block withdrawals.
#[reth_codec]
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize, Compact)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct StoredBlockWithdrawals {
/// The block withdrawals.
pub withdrawals: Withdrawals,

View File

@ -1,11 +1,12 @@
//! Client version model.
use reth_codecs::{derive_arbitrary, Compact};
use reth_codecs::{add_arbitrary_tests, Compact};
use serde::{Deserialize, Serialize};
/// Client version that accessed the database.
#[derive_arbitrary(compact)]
#[derive(Clone, Eq, PartialEq, Debug, Default, Serialize, Deserialize)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct ClientVersion {
/// Client version
pub version: String,

View File

@ -4,7 +4,7 @@ use crate::{
table::{Compress, Decode, Decompress, Encode},
DatabaseError,
};
use reth_codecs::{reth_codec, Compact};
use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{Address, B256, *};
use reth_prune_types::{PruneCheckpoint, PruneSegment};
use reth_stages_types::StageCheckpoint;
@ -264,8 +264,9 @@ macro_rules! add_wrapper_struct {
($(($name:tt, $wrapper:tt)),+) => {
$(
/// Wrapper struct so it can use StructFlags from Compact, when used as pure table values.
#[reth_codec]
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct $wrapper(pub $name);
impl From<$name> for $wrapper {