Skip to content

Commit b51c5e6

Browse files
committed
Move WithoutStorageRoot into separate crate
1 parent 08c78ac commit b51c5e6

7 files changed

Lines changed: 31 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ default-members = [
33
"fuzzers/*",
44
]
55
members = [
6+
"crates/*",
67
"fuzzers/*",
78
"fuzzers/fuzz-dancelight/fuzz",
89
"fuzzers/fuzz-dancelight/fuzz-dancelight-cli",
@@ -18,6 +19,7 @@ repository = "https://github.com/tmpolaczyk/fuzz-tanssi-runtime"
1819
[workspace.dependencies]
1920
fuzz-dancelight = { path = "fuzzers/fuzz-dancelight" }
2021
fuzz-starlight = { path = "fuzzers/fuzz-starlight" }
22+
externalities-without-storage-root = { path = "crates/externalities-without-storage-root" }
2123

2224
dancelight-runtime = { git = "https://github.com/moondance-labs/tanssi", branch = "master", default-features = false }
2325
dancelight-runtime-constants = { git = "https://github.com/moondance-labs/tanssi", branch = "master", default-features = false }
@@ -64,6 +66,7 @@ frame-metadata = "16"
6466
futures = "0.3.1"
6567
hash-db = { version = "0.16.0", default-features = false }
6668
hex = "0.4.3"
69+
hex-literal = "0.4.1"
6770
include_dir = "0.7.3"
6871
itertools = "0.10.5"
6972
lazy_static = "1.4.0"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "externalities-without-storage-root"
3+
authors = { workspace = true }
4+
edition = "2024"
5+
license = "GPL-3.0-only"
6+
version = "0.1.0"
7+
8+
[dependencies]
9+
sp-externalities = { workspace = true }
10+
sp-storage = { workspace = true }
11+
hex-literal = { workspace = true }
12+
13+
[lints]
14+
workspace = true

fuzzers/fuzz-dancelight/src/without_storage_root.rs renamed to crates/externalities-without-storage-root/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use sp_externalities::{Error, Extension, ExtensionStore, Externalities, MultiRem
22
use sp_storage::{ChildInfo, StateVersion, TrackedStorageKey};
33
use std::any::{Any, TypeId};
44

5+
/// Wrap externalities and return fake storage root based on block number
56
pub struct WithoutStorageRoot<T> {
67
inner: T,
78
}
@@ -109,8 +110,7 @@ impl<T: Externalities> Externalities for WithoutStorageRoot<T> {
109110
let block_number = self
110111
.inner
111112
.storage(
112-
&hex::decode("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
113-
.unwrap(),
113+
&hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac")
114114
)
115115
.unwrap();
116116
assert_eq!(block_number.len(), 4);

fuzzers/fuzz-dancelight/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ license = "GPL-3.0-only"
66
version = "0.1.0"
77

88
[dependencies]
9+
externalities-without-storage-root = { workspace = true }
910
bitvec = { workspace = true }
1011
cumulus-primitives-core = { workspace = true }
1112
dancelight-runtime = { workspace = true, features = [ "fast-runtime", "std", "try-runtime" ] }

fuzzers/fuzz-dancelight/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::metadata::{
1414
};
1515
use crate::simple_backend::SimpleBackend;
1616
use crate::storage_tracer::{BlockContext, ExtStorageTracer, TracingExt};
17-
use crate::without_storage_root::WithoutStorageRoot;
17+
use externalities_without_storage_root::WithoutStorageRoot;
1818
use dancelight_runtime::{AuthorNoting, EthereumInboundQueueV2, Session, System, TanssiCollatorAssignment, TimestampProvider, UseSnowbridgeV2};
1919
use frame_support::dispatch::DispatchResultWithPostInfo;
2020
use frame_support::traits::CallerTrait;
@@ -83,7 +83,6 @@ mod genesis;
8383
mod metadata;
8484
mod mutators;
8585
mod read_snapshot;
86-
mod without_storage_root;
8786
// TODO: extract to separate crate to speed up compilation
8887
mod simple_backend;
8988
mod storage_tracer;

fuzzers/fuzz-dancelight/src/read_snapshot.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::*;
22
use crate::genesis::invulnerables_from_seeds;
3-
use crate::without_storage_root::WithoutStorageRoot;
43

54
pub fn read_snapshot(
65
chain_spec_json_bytes: &[u8],

0 commit comments

Comments
 (0)