Skip to content

Commit

Permalink
rm dup
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Sep 23, 2024
1 parent e8e2865 commit 24cf975
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 50 deletions.
1 change: 1 addition & 0 deletions crates/primitives-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ proptest = { workspace = true, optional = true }
proptest-arbitrary-interop = { workspace = true, optional = true }

[dev-dependencies]
reth-codecs.workspace = true
alloy-primitives = { workspace = true, features = ["arbitrary"] }
alloy-consensus = { workspace = true, features = ["arbitrary"] }
arbitrary = { workspace = true, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ proptest = { workspace = true, optional = true }
reth-primitives-traits = { workspace = true, features = ["arbitrary"] }
revm-primitives = { workspace = true, features = ["arbitrary"] }
reth-chainspec.workspace = true
reth-codecs = { workspace = true, features = ["test-utils"] }
reth-codecs.workspace = true
alloy-eips = { workspace = true, features = ["arbitrary"] }

assert_matches.workspace = true
Expand Down
6 changes: 0 additions & 6 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,6 @@ mod tests {
use super::*;
use crate::hex_literal::hex;
use alloy_primitives::{address, b256, bytes};
use reth_codecs::{validate_bitflag_backwards_compat, test_utils::UnusedBits};

#[test]
fn validate_bitflag_backwards_compat() {
validate_bitflag_backwards_compat!(Receipt, UnusedBits::NotZero);
}

// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/prune/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde.workspace = true
thiserror.workspace = true

[dev-dependencies]
reth-codecs = { workspace = true, features = ["test-utils"] }
reth-codecs.workspace = true
arbitrary = { workspace = true, features = ["derive"] }
assert_matches.workspace = true
proptest.workspace = true
Expand Down
14 changes: 0 additions & 14 deletions crates/prune/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,3 @@ impl ReceiptsLogPruneConfig {
Ok(lowest.map(|lowest| lowest.max(pruned_block)))
}
}

#[cfg(test)]
mod tests {
use crate::{PruneCheckpoint, PruneMode, PruneSegment};
use reth_codecs::{validate_bitflag_backwards_compat, test_utils::UnusedBits};

#[test]
fn validate_bitflag_backwards_compat() {
validate_bitflag_backwards_compat!(PruneMode, UnusedBits::Zero);
validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::Zero);

validate_bitflag_backwards_compat!(PruneCheckpoint, UnusedBits::NotZero);
}
}
2 changes: 1 addition & 1 deletion crates/stages/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bytes.workspace = true
serde.workspace = true

[dev-dependencies]
reth-codecs = { workspace = true, features = ["test-utils"] }
reth-codecs.workspace = true
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-arbitrary-interop.workspace = true
Expand Down
12 changes: 0 additions & 12 deletions crates/stages/types/src/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,6 @@ stage_unit_checkpoints!(
mod tests {
use super::*;
use rand::Rng;
use reth_codecs::{validate_bitflag_backwards_compat, test_utils::UnusedBits};

#[test]
fn validate_bitflag_backwards_compat() {
validate_bitflag_backwards_compat!(EntitiesCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(CheckpointBlockRange, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StageUnitCheckpoint, UnusedBits::Zero);

validate_bitflag_backwards_compat!(AccountHashingCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(StorageHashingCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(StageCheckpoint, UnusedBits::NotZero);
}

#[test]
fn merkle_checkpoint_roundtrip() {
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/codecs/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ mod compact;
/// encoding, such as `bool`, `Option<T>`, or other small types.
///
/// ### Bit Sizes for Fields:
/// The amount of bits used to store a field size is determined by the field's type. For specific types,
/// a fixed number of bits is allocated (from `fn get_bit_size`):
/// The amount of bits used to store a field size is determined by the field's type. For specific
/// types, a fixed number of bits is allocated (from `fn get_bit_size`):
/// - `bool`, `Option<T>`, `TransactionKind`, `Signature`: **1 bit**
/// - `TxType`: **2 bits**
/// - `u64`, `BlockNumber`, `TxNumber`, `ChainId`, `NumTransactions`: **4 bits**
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/codecs/src/alloy/genesis_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ pub(crate) struct GenesisAccount {
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)]
#[cfg_attr(test, derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
struct StorageEntries {
pub(crate) struct StorageEntries {
entries: Vec<StorageEntry>,
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, Compact)]
#[cfg_attr(test, derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
struct StorageEntry {
pub(crate) struct StorageEntry {
key: B256,
value: B256,
}
Expand Down
6 changes: 4 additions & 2 deletions crates/storage/codecs/src/alloy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ mod tests {
use crate::{
alloy::{
authorization_list::Authorization,
genesis_account::{GenesisAccount, GenesisAccountRef},
genesis_account::{GenesisAccount, GenesisAccountRef, StorageEntries, StorageEntry},
header::Header,
transaction::{
eip1559::TxEip1559, eip2930::TxEip2930, eip4844::TxEip4844, eip7702::TxEip7702,
legacy::TxLegacy,
},
withdrawal::Withdrawal,
},
validate_bitflag_backwards_compat,
test_utils::UnusedBits,
validate_bitflag_backwards_compat,
};

#[test]
fn validate_bitflag_backwards_compat() {
validate_bitflag_backwards_compat!(Header, UnusedBits::Zero);
validate_bitflag_backwards_compat!(TxEip2930, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StorageEntries, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StorageEntry, UnusedBits::Zero);

validate_bitflag_backwards_compat!(Authorization, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(GenesisAccountRef<'_>, UnusedBits::NotZero);
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/codecs/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/// validate_bitflag_backwards_compat!(TExtension, UnusedBits::NotZero);
/// }
/// ```
///
///
/// ### 2. `Zero` -> `NotZero`
/// If it becomes `NotZero`, it would break backwards compatibility, so there is not an action item,
/// and should be handled with care in a case by case scenario.
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ proptest = { workspace = true, optional = true }
[dev-dependencies]
# reth libs with arbitrary
reth-primitives = { workspace = true, features = ["arbitrary"] }
reth-codecs.workspace = true
reth-codecs = { workspace = true, features = ["test-utils"] }

rand.workspace = true

Expand Down
6 changes: 6 additions & 0 deletions crates/storage/db-api/src/models/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ pub type HeaderHash = B256;
mod tests {
use super::*;
use crate::table::{Compress, Decompress};
use reth_codecs::{test_utils::UnusedBits, validate_bitflag_backwards_compat};

#[test]
fn validate_bitflag_backwards_compat() {
validate_bitflag_backwards_compat!(StoredBlockOmmers, UnusedBits::Zero);
}

#[test]
fn test_ommer() {
Expand Down
51 changes: 51 additions & 0 deletions crates/storage/db-api/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ add_wrapper_struct!((ClientVersion, CompactClientVersion));
#[cfg(test)]
mod tests {
use super::*;
use reth_codecs::{test_utils::UnusedBits, validate_bitflag_backwards_compat};
use reth_primitives::{Account, Receipt, ReceiptWithBloom, SealedHeader, Withdrawals};
use reth_prune_types::{PruneCheckpoint, PruneMode, PruneSegment};
use reth_stages_types::{
Expand Down Expand Up @@ -344,6 +345,31 @@ mod tests {
assert_eq!(StoredBlockWithdrawals::bitflag_encoded_bytes(), 0);
assert_eq!(StorageHashingCheckpoint::bitflag_encoded_bytes(), 1);
assert_eq!(Withdrawals::bitflag_encoded_bytes(), 0);

validate_bitflag_backwards_compat!(Account, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(AccountHashingCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(CheckpointBlockRange, UnusedBits::Zero);
validate_bitflag_backwards_compat!(CompactClientVersion, UnusedBits::Zero);
validate_bitflag_backwards_compat!(CompactU256, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(CompactU64, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(EntitiesCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(ExecutionCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(HeadersCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(IndexHistoryCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(PruneCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(PruneMode, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(Receipt, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(ReceiptWithBloom, UnusedBits::Zero);
validate_bitflag_backwards_compat!(SealedHeader, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StageCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(StageUnitCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StoredBlockBodyIndices, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(StoredBlockOmmers, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StoredBlockWithdrawals, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StorageHashingCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(Withdrawals, UnusedBits::Zero);
validate_bitflag_backwards_compat!(Requests, UnusedBits::Zero);
}

#[cfg(feature = "optimism")]
Expand Down Expand Up @@ -372,5 +398,30 @@ mod tests {
assert_eq!(StoredBlockWithdrawals::bitflag_encoded_bytes(), 0);
assert_eq!(StorageHashingCheckpoint::bitflag_encoded_bytes(), 1);
assert_eq!(Withdrawals::bitflag_encoded_bytes(), 0);

validate_bitflag_backwards_compat!(Account, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(AccountHashingCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(CheckpointBlockRange, UnusedBits::Zero);
validate_bitflag_backwards_compat!(CompactClientVersion, UnusedBits::Zero);
validate_bitflag_backwards_compat!(CompactU256, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(CompactU64, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(EntitiesCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(ExecutionCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(HeadersCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(IndexHistoryCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(PruneCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(PruneMode, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(Receipt, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(ReceiptWithBloom, UnusedBits::Zero);
validate_bitflag_backwards_compat!(SealedHeader, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StageCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(StageUnitCheckpoint, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StoredBlockBodyIndices, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(StoredBlockOmmers, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StoredBlockWithdrawals, UnusedBits::Zero);
validate_bitflag_backwards_compat!(StorageHashingCheckpoint, UnusedBits::NotZero);
validate_bitflag_backwards_compat!(Withdrawals, UnusedBits::Zero);
validate_bitflag_backwards_compat!(Requests, UnusedBits::Zero);
}
}
2 changes: 1 addition & 1 deletion crates/storage/db-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ proptest = { workspace = true, optional = true }
[dev-dependencies]
# reth
reth-primitives = { workspace = true, features = ["arbitrary"] }
reth-codecs = { workspace = true, features = ["test-utils"] }
reth-codecs.workspace = true

arbitrary = { workspace = true, features = ["derive"] }
proptest-arbitrary-interop.workspace = true
Expand Down
6 changes: 0 additions & 6 deletions crates/storage/db-models/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ pub struct StoredBlockWithdrawals {
#[cfg(test)]
mod tests {
use crate::StoredBlockBodyIndices;
use reth_codecs::{validate_bitflag_backwards_compat, test_utils::UnusedBits};

#[test]
fn validate_bitflag_backwards_compat() {
validate_bitflag_backwards_compat!(StoredBlockBodyIndices, UnusedBits::Zero);
}

#[test]
fn block_indices() {
Expand Down

0 comments on commit 24cf975

Please sign in to comment.