reth_optimism_storage/
lib.rs

1//! Standalone crate for Optimism-Storage Reth.
2
3#![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#![cfg_attr(not(test), warn(unused_crate_dependencies))]
11
12extern crate alloc;
13
14mod chain;
15pub use chain::OptStorage;
16
17#[cfg(test)]
18mod tests {
19    use reth_codecs::{test_utils::UnusedBits, validate_bitflag_backwards_compat};
20    use reth_db_api::models::{
21        CompactClientVersion, CompactU256, CompactU64, StoredBlockBodyIndices,
22        StoredBlockWithdrawals,
23    };
24    use reth_primitives_traits::Account;
25    use reth_prune_types::{PruneCheckpoint, PruneMode, PruneSegment};
26    use reth_stages_types::{
27        AccountHashingCheckpoint, CheckpointBlockRange, EntitiesCheckpoint, ExecutionCheckpoint,
28        HeadersCheckpoint, IndexHistoryCheckpoint, StageCheckpoint, StageUnitCheckpoint,
29        StorageHashingCheckpoint,
30    };
31
32    #[test]
33    fn test_ensure_backwards_compatibility() {
34        assert_eq!(Account::bitflag_encoded_bytes(), 2);
35        assert_eq!(AccountHashingCheckpoint::bitflag_encoded_bytes(), 1);
36        assert_eq!(CheckpointBlockRange::bitflag_encoded_bytes(), 1);
37        assert_eq!(CompactClientVersion::bitflag_encoded_bytes(), 0);
38        assert_eq!(CompactU256::bitflag_encoded_bytes(), 1);
39        assert_eq!(CompactU64::bitflag_encoded_bytes(), 1);
40        assert_eq!(EntitiesCheckpoint::bitflag_encoded_bytes(), 1);
41        assert_eq!(ExecutionCheckpoint::bitflag_encoded_bytes(), 0);
42        assert_eq!(HeadersCheckpoint::bitflag_encoded_bytes(), 0);
43        assert_eq!(IndexHistoryCheckpoint::bitflag_encoded_bytes(), 0);
44        assert_eq!(PruneCheckpoint::bitflag_encoded_bytes(), 1);
45        assert_eq!(PruneMode::bitflag_encoded_bytes(), 1);
46        assert_eq!(PruneSegment::bitflag_encoded_bytes(), 1);
47        assert_eq!(StageCheckpoint::bitflag_encoded_bytes(), 1);
48        assert_eq!(StageUnitCheckpoint::bitflag_encoded_bytes(), 1);
49        assert_eq!(StoredBlockBodyIndices::bitflag_encoded_bytes(), 1);
50        assert_eq!(StoredBlockWithdrawals::bitflag_encoded_bytes(), 0);
51        assert_eq!(StorageHashingCheckpoint::bitflag_encoded_bytes(), 1);
52
53        // In case of failure, refer to the documentation of the
54        // [`validate_bitflag_backwards_compat`] macro for detailed instructions on handling
55        // it.
56        validate_bitflag_backwards_compat!(Account, UnusedBits::NotZero);
57        validate_bitflag_backwards_compat!(AccountHashingCheckpoint, UnusedBits::NotZero);
58        validate_bitflag_backwards_compat!(CheckpointBlockRange, UnusedBits::Zero);
59        validate_bitflag_backwards_compat!(CompactClientVersion, UnusedBits::Zero);
60        validate_bitflag_backwards_compat!(CompactU256, UnusedBits::NotZero);
61        validate_bitflag_backwards_compat!(CompactU64, UnusedBits::NotZero);
62        validate_bitflag_backwards_compat!(EntitiesCheckpoint, UnusedBits::Zero);
63        validate_bitflag_backwards_compat!(ExecutionCheckpoint, UnusedBits::Zero);
64        validate_bitflag_backwards_compat!(HeadersCheckpoint, UnusedBits::Zero);
65        validate_bitflag_backwards_compat!(IndexHistoryCheckpoint, UnusedBits::Zero);
66        validate_bitflag_backwards_compat!(PruneCheckpoint, UnusedBits::NotZero);
67        validate_bitflag_backwards_compat!(PruneMode, UnusedBits::Zero);
68        validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::Zero);
69        validate_bitflag_backwards_compat!(StageCheckpoint, UnusedBits::NotZero);
70        validate_bitflag_backwards_compat!(StageUnitCheckpoint, UnusedBits::Zero);
71        validate_bitflag_backwards_compat!(StoredBlockBodyIndices, UnusedBits::Zero);
72        validate_bitflag_backwards_compat!(StoredBlockWithdrawals, UnusedBits::Zero);
73        validate_bitflag_backwards_compat!(StorageHashingCheckpoint, UnusedBits::NotZero);
74    }
75}