mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
move op storage tests into new crate reth-optimism-storage (#11233)
This commit is contained in:
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -8195,6 +8195,17 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reth-optimism-storage"
|
||||||
|
version = "1.0.7"
|
||||||
|
dependencies = [
|
||||||
|
"reth-codecs",
|
||||||
|
"reth-db-api",
|
||||||
|
"reth-primitives",
|
||||||
|
"reth-prune-types",
|
||||||
|
"reth-stages-types",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reth-payload-builder"
|
name = "reth-payload-builder"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
|||||||
@ -79,6 +79,7 @@ members = [
|
|||||||
"crates/optimism/payload/",
|
"crates/optimism/payload/",
|
||||||
"crates/optimism/primitives/",
|
"crates/optimism/primitives/",
|
||||||
"crates/optimism/rpc/",
|
"crates/optimism/rpc/",
|
||||||
|
"crates/optimism/storage",
|
||||||
"crates/payload/basic/",
|
"crates/payload/basic/",
|
||||||
"crates/payload/builder/",
|
"crates/payload/builder/",
|
||||||
"crates/payload/primitives/",
|
"crates/payload/primitives/",
|
||||||
@ -368,6 +369,7 @@ reth-optimism-forks = { path = "crates/optimism/hardforks" }
|
|||||||
reth-optimism-payload-builder = { path = "crates/optimism/payload" }
|
reth-optimism-payload-builder = { path = "crates/optimism/payload" }
|
||||||
reth-optimism-primitives = { path = "crates/optimism/primitives" }
|
reth-optimism-primitives = { path = "crates/optimism/primitives" }
|
||||||
reth-optimism-rpc = { path = "crates/optimism/rpc" }
|
reth-optimism-rpc = { path = "crates/optimism/rpc" }
|
||||||
|
reth-optimism-storage = { path = "crates/optimism/storage" }
|
||||||
reth-payload-builder = { path = "crates/payload/builder" }
|
reth-payload-builder = { path = "crates/payload/builder" }
|
||||||
reth-payload-primitives = { path = "crates/payload/primitives" }
|
reth-payload-primitives = { path = "crates/payload/primitives" }
|
||||||
reth-payload-validator = { path = "crates/payload/validator" }
|
reth-payload-validator = { path = "crates/payload/validator" }
|
||||||
|
|||||||
23
crates/optimism/storage/Cargo.toml
Normal file
23
crates/optimism/storage/Cargo.toml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[package]
|
||||||
|
name = "reth-optimism-storage"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reth-primitives.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
reth-codecs.workspace = true
|
||||||
|
reth-db-api.workspace = true
|
||||||
|
reth-prune-types.workspace = true
|
||||||
|
reth-stages-types.workspace = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
optimism = ["reth-primitives/optimism"]
|
||||||
83
crates/optimism/storage/src/lib.rs
Normal file
83
crates/optimism/storage/src/lib.rs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
//! Standalone crate for Optimism-Storage Reth.
|
||||||
|
|
||||||
|
#![doc(
|
||||||
|
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||||
|
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||||
|
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
|
||||||
|
)]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||||
|
// The `optimism` feature must be enabled to use this crate.
|
||||||
|
#![cfg(feature = "optimism")]
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use reth_codecs::{test_utils::UnusedBits, validate_bitflag_backwards_compat};
|
||||||
|
use reth_db_api::models::{
|
||||||
|
CompactClientVersion, CompactU256, CompactU64, StoredBlockBodyIndices, StoredBlockOmmers,
|
||||||
|
StoredBlockWithdrawals,
|
||||||
|
};
|
||||||
|
use reth_primitives::{
|
||||||
|
Account, Receipt, ReceiptWithBloom, Requests, SealedHeader, Withdrawals,
|
||||||
|
};
|
||||||
|
use reth_prune_types::{PruneCheckpoint, PruneMode, PruneSegment};
|
||||||
|
use reth_stages_types::{
|
||||||
|
AccountHashingCheckpoint, CheckpointBlockRange, EntitiesCheckpoint, ExecutionCheckpoint,
|
||||||
|
HeadersCheckpoint, IndexHistoryCheckpoint, StageCheckpoint, StageUnitCheckpoint,
|
||||||
|
StorageHashingCheckpoint,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_ensure_backwards_compatibility() {
|
||||||
|
assert_eq!(Account::bitflag_encoded_bytes(), 2);
|
||||||
|
assert_eq!(AccountHashingCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(CheckpointBlockRange::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(CompactClientVersion::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(CompactU256::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(CompactU64::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(EntitiesCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(ExecutionCheckpoint::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(HeadersCheckpoint::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(IndexHistoryCheckpoint::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(PruneCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(PruneMode::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(PruneSegment::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(Receipt::bitflag_encoded_bytes(), 2);
|
||||||
|
assert_eq!(ReceiptWithBloom::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(SealedHeader::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(StageCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(StageUnitCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(StoredBlockBodyIndices::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(StoredBlockOmmers::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(StoredBlockWithdrawals::bitflag_encoded_bytes(), 0);
|
||||||
|
assert_eq!(StorageHashingCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
|
assert_eq!(Withdrawals::bitflag_encoded_bytes(), 0);
|
||||||
|
|
||||||
|
// In case of failure, refer to the documentation of the
|
||||||
|
// [`validate_bitflag_backwards_compat`] macro for detailed instructions on handling
|
||||||
|
// it.
|
||||||
|
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::Zero);
|
||||||
|
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::Zero);
|
||||||
|
validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::Zero);
|
||||||
|
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::Zero);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -305,16 +305,6 @@ add_wrapper_struct!((ClientVersion, CompactClientVersion));
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
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::{
|
|
||||||
AccountHashingCheckpoint, CheckpointBlockRange, EntitiesCheckpoint, ExecutionCheckpoint,
|
|
||||||
HeadersCheckpoint, IndexHistoryCheckpoint, StageCheckpoint, StageUnitCheckpoint,
|
|
||||||
StorageHashingCheckpoint,
|
|
||||||
};
|
|
||||||
|
|
||||||
// each value in the database has an extra field named flags that encodes metadata about other
|
// each value in the database has an extra field named flags that encodes metadata about other
|
||||||
// fields in the value, e.g. offset and length.
|
// fields in the value, e.g. offset and length.
|
||||||
//
|
//
|
||||||
@ -323,6 +313,15 @@ mod tests {
|
|||||||
#[cfg(not(feature = "optimism"))]
|
#[cfg(not(feature = "optimism"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ensure_backwards_compatibility() {
|
fn test_ensure_backwards_compatibility() {
|
||||||
|
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::{
|
||||||
|
AccountHashingCheckpoint, CheckpointBlockRange, EntitiesCheckpoint,
|
||||||
|
ExecutionCheckpoint, HeadersCheckpoint, IndexHistoryCheckpoint, StageCheckpoint,
|
||||||
|
StageUnitCheckpoint, StorageHashingCheckpoint,
|
||||||
|
};
|
||||||
assert_eq!(Account::bitflag_encoded_bytes(), 2);
|
assert_eq!(Account::bitflag_encoded_bytes(), 2);
|
||||||
assert_eq!(AccountHashingCheckpoint::bitflag_encoded_bytes(), 1);
|
assert_eq!(AccountHashingCheckpoint::bitflag_encoded_bytes(), 1);
|
||||||
assert_eq!(CheckpointBlockRange::bitflag_encoded_bytes(), 1);
|
assert_eq!(CheckpointBlockRange::bitflag_encoded_bytes(), 1);
|
||||||
@ -372,60 +371,4 @@ mod tests {
|
|||||||
validate_bitflag_backwards_compat!(Withdrawals, UnusedBits::Zero);
|
validate_bitflag_backwards_compat!(Withdrawals, UnusedBits::Zero);
|
||||||
validate_bitflag_backwards_compat!(Requests, UnusedBits::Zero);
|
validate_bitflag_backwards_compat!(Requests, UnusedBits::Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "optimism")]
|
|
||||||
#[test]
|
|
||||||
fn test_ensure_backwards_compatibility() {
|
|
||||||
assert_eq!(Account::bitflag_encoded_bytes(), 2);
|
|
||||||
assert_eq!(AccountHashingCheckpoint::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(CheckpointBlockRange::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(CompactClientVersion::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(CompactU256::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(CompactU64::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(EntitiesCheckpoint::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(ExecutionCheckpoint::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(HeadersCheckpoint::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(IndexHistoryCheckpoint::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(PruneCheckpoint::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(PruneMode::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(PruneSegment::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(Receipt::bitflag_encoded_bytes(), 2);
|
|
||||||
assert_eq!(ReceiptWithBloom::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(SealedHeader::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(StageCheckpoint::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(StageUnitCheckpoint::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(StoredBlockBodyIndices::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(StoredBlockOmmers::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(StoredBlockWithdrawals::bitflag_encoded_bytes(), 0);
|
|
||||||
assert_eq!(StorageHashingCheckpoint::bitflag_encoded_bytes(), 1);
|
|
||||||
assert_eq!(Withdrawals::bitflag_encoded_bytes(), 0);
|
|
||||||
|
|
||||||
// In case of failure, refer to the documentation of the
|
|
||||||
// [`validate_bitflag_backwards_compat`] macro for detailed instructions on handling
|
|
||||||
// it.
|
|
||||||
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::Zero);
|
|
||||||
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::Zero);
|
|
||||||
validate_bitflag_backwards_compat!(PruneSegment, UnusedBits::Zero);
|
|
||||||
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::Zero);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user