reth_optimism_storage/
lib.rs
1#![doc(
4 html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
5 html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
6 issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
7)]
8#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
9#![cfg_attr(not(feature = "std"), no_std)]
10
11extern crate alloc;
12
13mod chain;
14pub use chain::OptStorage;
15
16#[cfg(test)]
17mod tests {
18 use reth_codecs::{test_utils::UnusedBits, validate_bitflag_backwards_compat};
19 use reth_db_api::models::{
20 CompactClientVersion, CompactU256, CompactU64, StoredBlockBodyIndices,
21 StoredBlockWithdrawals,
22 };
23 use reth_primitives_traits::Account;
24 use reth_prune_types::{PruneCheckpoint, PruneMode, PruneSegment};
25 use reth_stages_types::{
26 AccountHashingCheckpoint, CheckpointBlockRange, EntitiesCheckpoint, ExecutionCheckpoint,
27 HeadersCheckpoint, IndexHistoryCheckpoint, StageCheckpoint, StageUnitCheckpoint,
28 StorageHashingCheckpoint,
29 };
30
31 #[test]
32 fn test_ensure_backwards_compatibility() {
33 assert_eq!(Account::bitflag_encoded_bytes(), 2);
34 assert_eq!(AccountHashingCheckpoint::bitflag_encoded_bytes(), 1);
35 assert_eq!(CheckpointBlockRange::bitflag_encoded_bytes(), 1);
36 assert_eq!(CompactClientVersion::bitflag_encoded_bytes(), 0);
37 assert_eq!(CompactU256::bitflag_encoded_bytes(), 1);
38 assert_eq!(CompactU64::bitflag_encoded_bytes(), 1);
39 assert_eq!(EntitiesCheckpoint::bitflag_encoded_bytes(), 1);
40 assert_eq!(ExecutionCheckpoint::bitflag_encoded_bytes(), 0);
41 assert_eq!(HeadersCheckpoint::bitflag_encoded_bytes(), 0);
42 assert_eq!(IndexHistoryCheckpoint::bitflag_encoded_bytes(), 0);
43 assert_eq!(PruneCheckpoint::bitflag_encoded_bytes(), 1);
44 assert_eq!(PruneMode::bitflag_encoded_bytes(), 1);
45 assert_eq!(PruneSegment::bitflag_encoded_bytes(), 1);
46 assert_eq!(StageCheckpoint::bitflag_encoded_bytes(), 1);
47 assert_eq!(StageUnitCheckpoint::bitflag_encoded_bytes(), 1);
48 assert_eq!(StoredBlockBodyIndices::bitflag_encoded_bytes(), 1);
49 assert_eq!(StoredBlockWithdrawals::bitflag_encoded_bytes(), 0);
50 assert_eq!(StorageHashingCheckpoint::bitflag_encoded_bytes(), 1);
51
52 validate_bitflag_backwards_compat!(Account, UnusedBits::NotZero);
56 validate_bitflag_backwards_compat!(AccountHashingCheckpoint, UnusedBits::NotZero);
57 validate_bitflag_backwards_compat!(CheckpointBlockRange, UnusedBits::Zero);
58 validate_bitflag_backwards_compat!(CompactClientVersion, UnusedBits::Zero);
59 validate_bitflag_backwards_compat!(CompactU256, UnusedBits::NotZero);
60 validate_bitflag_backwards_compat!(CompactU64, UnusedBits::NotZero);
61 validate_bitflag_backwards_compat!(EntitiesCheckpoint, UnusedBits::Zero);
62 validate_bitflag_backwards_compat!(ExecutionCheckpoint, UnusedBits::Zero);
63 validate_bitflag_backwards_compat!(HeadersCheckpoint, UnusedBits::Zero);
64 validate_bitflag_backwards_compat!(IndexHistoryCheckpoint, UnusedBits::Zero);
65 validate_bitflag_backwards_compat!(PruneCheckpoint, UnusedBits::NotZero);
66 validate_bitflag_backwards_compat!(PruneMode, UnusedBits::Zero);
67 validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::Zero);
68 validate_bitflag_backwards_compat!(StageCheckpoint, UnusedBits::NotZero);
69 validate_bitflag_backwards_compat!(StageUnitCheckpoint, UnusedBits::Zero);
70 validate_bitflag_backwards_compat!(StoredBlockBodyIndices, UnusedBits::Zero);
71 validate_bitflag_backwards_compat!(StoredBlockWithdrawals, UnusedBits::Zero);
72 validate_bitflag_backwards_compat!(StorageHashingCheckpoint, UnusedBits::NotZero);
73 }
74}