Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Inner hashing of value in state trie (runtime versioning). #9732

Merged
merged 194 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
194 commits
Select commit Hold shift + click to select a range
e026ea6
starting
cheme May 17, 2021
5b1c550
Updated from other branch.
cheme May 18, 2021
7e98291
setting flag
cheme May 18, 2021
5d3a1b2
flag in storage struct
cheme May 18, 2021
4256a40
fix flagging to access and insert.
cheme May 18, 2021
5bb0b68
added todo to fix
cheme May 18, 2021
7081864
also missing serialize meta to storage proof
cheme May 18, 2021
3f1ee83
extract meta.
cheme May 19, 2021
1bbdf35
Isolate old trie layout.
cheme May 19, 2021
e5feabf
failing test that requires storing in meta when old hash scheme is used.
cheme May 19, 2021
aa78ed6
old hash compatibility
cheme May 19, 2021
045b097
Db migrate.
cheme May 19, 2021
79a43dd
runing tests with both states when interesting.
cheme May 20, 2021
aa2e5c3
fix chain spec test with serde default.
cheme May 20, 2021
91bd0aa
export state (missing trie function).
cheme May 20, 2021
183b7b5
Pending using new branch, lacking genericity on layout resolution.
cheme May 21, 2021
8511a40
extract and set global meta
cheme May 21, 2021
270ed28
Update to branch 4
cheme May 24, 2021
b838e7e
fix iterator with root flag (no longer insert node).
cheme May 25, 2021
30742b7
fix trie root hashing of root
cheme May 25, 2021
c620869
complete basic backend.
cheme May 26, 2021
a3b1039
Remove old_hash meta from proof that do not use inner_hashing.
cheme May 26, 2021
693e38b
fix trie test for empty (force layout on empty deltas).
cheme May 26, 2021
6e89b3a
Root update fix.
cheme May 26, 2021
c14e11c
Merge branch 'master' into state-update4
cheme May 26, 2021
f568794
debug on meta
cheme May 26, 2021
fb0ea03
Use trie key iteration that do not include value in proofs.
cheme May 27, 2021
cd98390
switch default test ext to use inner hash.
cheme May 27, 2021
5ab0c01
small integration test, and fix tx cache mgmt in ext.
cheme May 27, 2021
99ef85c
Proof scenario at state-machine level.
cheme May 27, 2021
4d6aee8
trace for db upgrade
cheme May 27, 2021
791acae
try different param
cheme May 27, 2021
b51eaa4
act more like iter_from.
cheme May 28, 2021
715b1a5
Bigger batches.
cheme May 28, 2021
3cdb0ed
Update trie dependency.
cheme May 28, 2021
ae1454f
drafting codec changes and refact
cheme Jun 8, 2021
c807f44
before removing unused branch no value alt hashing.
cheme Jun 8, 2021
a70ce70
alt hashing only for branch with value.
cheme Jun 8, 2021
11f0d5a
fix trie tests
cheme Jun 8, 2021
cf0f0df
Hash of value include the encoded size.
cheme Jun 8, 2021
b721733
removing fields(broken)
cheme Jun 9, 2021
2f8360f
fix trie_stream to also include value length in inner hash.
cheme Jun 9, 2021
76b6d7a
triedbmut only using alt type if inner hashing.
cheme Jun 9, 2021
cfa0ecd
trie_stream to also only use alt hashing type when actually alt hashing.
cheme Jun 9, 2021
60f7012
Refactor meta state, logic should work with change of trie treshold.
cheme Jun 9, 2021
40ec2f7
Remove NoMeta variant.
cheme Jun 9, 2021
204f51f
Remove state_hashed trigger specific functions.
cheme Jun 9, 2021
b62cdf5
pending switching to using threshold, new storage root api does not
cheme Jun 10, 2021
74fb9c8
refactoring to use state from backend (not possible payload changes).
cheme Jun 10, 2021
97a1aa6
Applying from previous state
cheme Jun 10, 2021
f4849a2
Remove default from storage, genesis need a special build.
cheme Jun 10, 2021
4eabbde
rem empty space
cheme Jun 11, 2021
18abb6e
Merge branch 'master' into state-update4-refact
cheme Jun 11, 2021
ae627f6
Catch problem: when using triedb with default: we should not revert
cheme Jun 11, 2021
4706814
fix compilation
cheme Jun 11, 2021
09d5cf6
Right logic to avoid switch on reencode when default layout.
cheme Jun 11, 2021
906cd48
Clean up some todos
cheme Jun 14, 2021
662eabe
remove trie meta from root upstream
cheme Jun 14, 2021
17ac7cb
Merge branch 'master' into state-update4-refact
cheme Jun 15, 2021
ac0e019
update upstream and fix benches.
cheme Jun 15, 2021
7e73a70
split some long lines.
cheme Jun 15, 2021
3498d17
Merge branch 'master' into state-update4-refact
cheme Jun 15, 2021
934021c
UPdate trie crate to work with new design.
cheme Jun 18, 2021
1e40e6d
Finish update to refactored upstream.
cheme Jun 21, 2021
602723e
update to latest triedb changes.
cheme Jun 21, 2021
66ee72d
Clean up.
cheme Jun 21, 2021
23c5db3
fix executor test.
cheme Jun 21, 2021
03d93b2
rust fmt from master.
cheme Jul 22, 2021
b13ebd0
Merge branch 'master' into state-update4
cheme Jul 22, 2021
93aaa4c
rust format.
cheme Jul 22, 2021
66c832e
Merge branch 'master' into state-update4
cheme Aug 11, 2021
89eba2b
Merge branch 'master' into state-update4
cheme Aug 16, 2021
1e02c01
rustfmt
cheme Aug 16, 2021
7898e49
Merge branch 'master' into state-update4
cheme Aug 27, 2021
a48970f
fix
cheme Aug 27, 2021
92b9fcf
start host function driven versioning
cheme Aug 27, 2021
145406a
update state-machine part
cheme Aug 30, 2021
00460da
still need access to state version from runtime
cheme Aug 31, 2021
bad0723
state hash in mem: wrong
cheme Aug 31, 2021
537c04f
direction likely correct, but passing call to code exec for genesis
cheme Aug 31, 2021
b537440
state version serialize in runtime, wrong approach, just initialize it
cheme Sep 8, 2021
b717611
stateversion from runtime version (core api >= 4).
cheme Sep 8, 2021
b6a6e83
Merge branch 'master' into state-update4-host2
cheme Sep 8, 2021
846fef0
update trie, fix tests
cheme Sep 8, 2021
0a6dc15
unused import
cheme Sep 8, 2021
4e10a68
clean some TODOs
cheme Sep 8, 2021
bf31362
Require RuntimeVersionOf for executor
cheme Sep 8, 2021
8aba5dd
use RuntimeVersionOf to resolve genesis state version.
cheme Sep 8, 2021
499ab5b
update runtime version test
cheme Sep 8, 2021
27cf136
fix state-machine tests
cheme Sep 8, 2021
ac4f7dc
TODO
cheme Sep 8, 2021
1c817d6
Use runtime version from storage wasm with fast sync.
cheme Sep 9, 2021
f0d9326
rustfmt
cheme Sep 9, 2021
6d930fa
Merge branch 'master' into state-update4-host2
cheme Sep 9, 2021
877c36e
fmt
cheme Sep 9, 2021
8514d5f
fix test
cheme Sep 9, 2021
3385eae
revert useless changes.
cheme Sep 9, 2021
3be7538
clean some unused changes
cheme Sep 9, 2021
c858c28
fmt
cheme Sep 9, 2021
63265eb
removing useless trait function.
cheme Sep 10, 2021
4142b8d
remove remaining reference to state_hash
cheme Sep 14, 2021
b3c8812
Merge branch 'state-update4-host2' of github.com:cheme/substrate into…
cheme Sep 14, 2021
aaca0f8
Merge branch 'master' into state-update4-host2
cheme Oct 1, 2021
5ed824a
fix some imports
cheme Oct 1, 2021
b0b8a85
Follow chain state version management.
cheme Oct 1, 2021
e7267c0
trie update, fix and constant threshold for trie layouts.
cheme Oct 4, 2021
599714f
update deps
cheme Oct 4, 2021
6045952
Update to latest trie pr changes.
cheme Oct 5, 2021
fb8ff8e
fix benches
cheme Oct 5, 2021
af86f39
Verify proof requires right layout.
cheme Oct 5, 2021
66daec0
update trie_root
cheme Oct 7, 2021
299fea6
Merge branch 'master' into state-update4-host2
cheme Oct 12, 2021
4ff9009
Update trie deps to latest
cheme Oct 12, 2021
fa7ebaf
Merge branch 'master' into state-update4-host2
cheme Oct 18, 2021
a343138
Update to latest trie versioning
cheme Oct 18, 2021
3432668
Removing patch
cheme Oct 19, 2021
932eee7
update lock
cheme Oct 19, 2021
c86af90
Merge branch 'master' into state-update4-host2
cheme Oct 19, 2021
3299b7f
extrinsic for sc-service-test using layout v0.
cheme Oct 19, 2021
e66e40d
Merge branch 'master' into state-update4-host2
cheme Oct 20, 2021
4328973
Adding RuntimeVersionOf to CallExecutor works.
cheme Oct 20, 2021
c342bdf
fmt
cheme Oct 20, 2021
d8a9b50
error when resolving version and no wasm in storage.
cheme Oct 20, 2021
898bc13
use existing utils to instantiate runtime code.
cheme Oct 20, 2021
d35f273
Patch to delay runtime switch.
cheme Oct 21, 2021
90ceb5e
Revert "Patch to delay runtime switch."
cheme Oct 21, 2021
a327e5c
Merge branch 'master' into state-update4-host2
cheme Oct 21, 2021
ac1a80c
useless closure
cheme Oct 21, 2021
b06a90c
remove remaining state_hash variables.
cheme Oct 21, 2021
84e3ab9
Remove outdated comment
cheme Oct 21, 2021
213d648
useless inner hash
cheme Oct 21, 2021
24309cd
fmt
cheme Oct 21, 2021
0d6590d
Merge branch 'master' of github.com:paritytech/substrate into ecr-sta…
kianenigma Oct 26, 2021
182ec74
Merge branch 'master' into state-update4-host2
cheme Nov 1, 2021
3b267bf
Merge branch 'state-update4-host2' into ecr-state-update-host
cheme Nov 1, 2021
98c8467
Merge branch 'master' into ecr-state-update-host
cheme Nov 5, 2021
9b4837f
fmt and opt-in feature to apply state change.
cheme Nov 5, 2021
b3d8f62
feature gate core version, use new test feature for node and test node
cheme Nov 8, 2021
dd20a8d
Use a 'State' api version instead of Core one.
cheme Nov 8, 2021
a0ac11f
Merge branch 'master' into state-update4-host2
cheme Nov 8, 2021
c75d148
fix merge of test function
cheme Nov 8, 2021
aba8632
use blake macro.
cheme Nov 8, 2021
205db5e
Fix state api (require declaring the api in runtime).
cheme Nov 8, 2021
d493547
Merge branch 'master' into state-update4-host2
cheme Nov 8, 2021
6126ed2
Opt out feature, fix macro for io to select a given version
cheme Nov 11, 2021
610bc23
run test nodes on new state.
cheme Nov 11, 2021
c0af4f1
fix
cheme Nov 11, 2021
89b28ac
Merge branch 'master' into state-update4-host2
cheme Nov 11, 2021
8e962f2
Merge branch 'state-update4-host2' into ecr-state-update-host
cheme Nov 12, 2021
c4cf663
Apply review change (docs and error).
cheme Nov 15, 2021
b8d2d28
Merge branch 'master' into state-update4-host2
cheme Nov 15, 2021
c80bbb4
fmt
cheme Nov 15, 2021
b77287f
use explicit runtime_interface in doc test
cheme Nov 15, 2021
3ba8b77
Merge branch 'master' into state-update4-host2
cheme Nov 25, 2021
0bae05c
Merge branch 'state-update4-host2' into ecr-state-update-host
cheme Nov 25, 2021
02cfccf
fix ui test
cheme Nov 25, 2021
6e95123
fix doc test
cheme Nov 25, 2021
c1de720
fmt
cheme Nov 25, 2021
5f8b91c
Merge branch 'master' into state-update4-host2
cheme Dec 10, 2021
6801721
use default for path and specname when resolving version.
cheme Dec 10, 2021
96fef9e
Merge branch 'master' into state-update4-host2
cheme Dec 13, 2021
601d11b
small review related changes.
cheme Dec 15, 2021
7914f5f
Merge branch 'master' into state-update4-host2
cheme Dec 15, 2021
422eb63
doc value size requirement.
cheme Dec 16, 2021
dae0509
rename old_state feature
cheme Dec 16, 2021
70e1312
Remove macro changes
cheme Dec 16, 2021
9174e31
feature rename
cheme Dec 16, 2021
ba00361
state version as host function parameter
cheme Dec 16, 2021
f10d086
Merge branch 'master' into state-update4-host2
cheme Dec 16, 2021
a427125
remove flag for client api
cheme Dec 16, 2021
24d9d12
fix tests
cheme Dec 16, 2021
711a5b9
switch storage chain proof to V1
cheme Dec 17, 2021
a82019e
host functions, pass by state version enum
cheme Dec 17, 2021
be65e77
use WrappedRuntimeCode
cheme Dec 17, 2021
941f4fb
start
cheme Dec 18, 2021
bab1662
state_version in runtime version
cheme Dec 18, 2021
3d92fe9
rust fmt
cheme Dec 20, 2021
41482dd
Update storage proof of max size.
cheme Dec 20, 2021
c51adf0
fix runtime version rpc test
cheme Dec 20, 2021
b7b2fce
right intent of convert from compat
cheme Dec 20, 2021
87bf6ed
fix doc test
cheme Dec 20, 2021
75ca0ed
fix doc test
cheme Dec 20, 2021
17fd079
split proof
cheme Dec 21, 2021
067cb9c
decode without replay, and remove some reexports.
cheme Dec 21, 2021
cf875e0
Decode with compatibility by default.
cheme Dec 22, 2021
064ccbc
switch state_version to u8. And remove RuntimeVersionBasis.
cheme Dec 22, 2021
9debfc5
test
cheme Dec 23, 2021
56a3165
use api when reading embedded version
cheme Dec 23, 2021
4bf0140
fix decode with apis
cheme Dec 23, 2021
0b5820f
extract core version instead
cheme Dec 23, 2021
8e87fde
test fix
cheme Dec 23, 2021
63f9e97
unused import
cheme Dec 23, 2021
f0ba0ed
review changes.
cheme Dec 23, 2021
ad9f030
Merge branch 'master' into state-update4-host2
cheme Dec 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
};

/// This determines the average expected block time that we are targeting.
Expand Down
5 changes: 2 additions & 3 deletions bin/node/bench/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{collections::HashMap, sync::Arc};

use kvdb::KeyValueDB;
use node_primitives::Hash;
use sp_trie::{trie_types::TrieDBMut, TrieMut};
use sp_trie::{trie_types::TrieDBMutV1, TrieMut};

use crate::simple_trie::SimpleTrie;

Expand All @@ -43,8 +43,7 @@ pub fn generate_trie(
);
let mut trie = SimpleTrie { db, overlay: &mut overlay };
{
let mut trie_db = TrieDBMut::new(&mut trie, &mut root);

let mut trie_db = TrieDBMutV1::<crate::simple_trie::Hasher>::new(&mut trie, &mut root);
for (key, value) in key_values {
trie_db.insert(&key, &value).expect("trie insertion failed");
}
Expand Down
6 changes: 3 additions & 3 deletions bin/node/bench/src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use kvdb::KeyValueDB;
use lazy_static::lazy_static;
use rand::Rng;
use sp_state_machine::Backend as _;
use sp_trie::{trie_types::TrieDBMut, TrieMut as _};
use sp_trie::{trie_types::TrieDBMutV1, TrieMut as _};
use std::{borrow::Cow, collections::HashMap, sync::Arc};

use node_primitives::Hash;
Expand Down Expand Up @@ -286,8 +286,8 @@ impl core::Benchmark for TrieWriteBenchmark {

let mut overlay = HashMap::new();
let mut trie = SimpleTrie { db: kvdb.clone(), overlay: &mut overlay };
let mut trie_db_mut =
TrieDBMut::from_existing(&mut trie, &mut new_root).expect("Failed to create TrieDBMut");
let mut trie_db_mut = TrieDBMutV1::from_existing(&mut trie, &mut new_root)
.expect("Failed to create TrieDBMut");

for (warmup_key, warmup_value) in self.warmup_keys.iter() {
let value = trie_db_mut
Expand Down
4 changes: 2 additions & 2 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ fn construct_block<E: Externalities>(
parent_hash: Hash,
extrinsics: Vec<CheckedExtrinsic>,
) -> (Vec<u8>, Hash) {
use sp_trie::{trie_types::Layout, TrieConfiguration};
use sp_trie::{LayoutV0, TrieConfiguration};

// sign extrinsics.
let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();

// calculate the header fields that we can.
let extrinsics_root =
Layout::<BlakeTwo256>::ordered_trie_root(extrinsics.iter().map(Encode::encode))
LayoutV0::<BlakeTwo256>::ordered_trie_root(extrinsics.iter().map(Encode::encode))
gui1117 marked this conversation as resolved.
Show resolved Hide resolved
.to_fixed_bytes()
.into();

Expand Down
2 changes: 1 addition & 1 deletion bin/node/executor/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn construct_block(
extrinsics: Vec<CheckedExtrinsic>,
babe_slot: Slot,
) -> (Vec<u8>, Hash) {
use sp_trie::{trie_types::Layout, TrieConfiguration};
use sp_trie::{LayoutV1 as Layout, TrieConfiguration};

// sign extrinsics.
let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();
Expand Down
1 change: 1 addition & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
state_version: 1,
};

/// The BABE epoch configuration at genesis.
Expand Down
9 changes: 7 additions & 2 deletions client/api/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sp_core::offchain::OffchainStorage;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, HashFor, NumberFor},
Justification, Justifications, Storage,
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
ChildStorageCollection, IndexOperation, OffchainChangesCollection, StorageCollection,
Expand Down Expand Up @@ -166,10 +166,15 @@ pub trait BlockImportOperation<Block: BlockT> {
&mut self,
storage: Storage,
commit: bool,
state_version: StateVersion,
) -> sp_blockchain::Result<Block::Hash>;

/// Inject storage data into the database replacing any existing data.
fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result<Block::Hash>;
fn reset_storage(
&mut self,
storage: Storage,
state_version: StateVersion,
) -> sp_blockchain::Result<Block::Hash>;

/// Set storage changes.
fn update_storage(
Expand Down
4 changes: 2 additions & 2 deletions client/api/src/call_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! A method call executor interface.

use codec::{Decode, Encode};
use sc_executor::RuntimeVersion;
use sc_executor::{RuntimeVersion, RuntimeVersionOf};
use sp_core::NativeOrEncoded;
use sp_externalities::Extensions;
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
Expand All @@ -42,7 +42,7 @@ pub trait ExecutorProvider<Block: BlockT> {
}

/// Method call executor.
pub trait CallExecutor<B: BlockT> {
pub trait CallExecutor<B: BlockT>: RuntimeVersionOf {
/// Externalities error type.
type Error: sp_state_machine::Error;

Expand Down
15 changes: 11 additions & 4 deletions client/api/src/in_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sp_core::{
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, HashFor, Header as HeaderT, NumberFor, Zero},
Justification, Justifications, Storage,
Justification, Justifications, StateVersion, Storage,
};
use sp_state_machine::{
Backend as StateBackend, ChildStorageCollection, InMemoryBackend, IndexOperation,
Expand Down Expand Up @@ -506,6 +506,7 @@ where
&mut self,
storage: Storage,
commit: bool,
state_version: StateVersion,
) -> sp_blockchain::Result<Block::Hash> {
check_genesis_storage(&storage)?;

Expand All @@ -519,6 +520,7 @@ where
let (root, transaction) = self.old_state.full_storage_root(
storage.top.iter().map(|(k, v)| (k.as_ref(), Some(v.as_ref()))),
child_delta,
state_version,
);

if commit {
Expand Down Expand Up @@ -566,12 +568,17 @@ where
&mut self,
storage: Storage,
commit: bool,
state_version: StateVersion,
) -> sp_blockchain::Result<Block::Hash> {
self.apply_storage(storage, commit)
self.apply_storage(storage, commit, state_version)
}

fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result<Block::Hash> {
self.apply_storage(storage, true)
fn reset_storage(
&mut self,
storage: Storage,
state_version: StateVersion,
) -> sp_blockchain::Result<Block::Hash> {
self.apply_storage(storage, true, state_version)
}

fn insert_aux<I>(&mut self, ops: I) -> sp_blockchain::Result<()>
Expand Down
1 change: 1 addition & 0 deletions client/block-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ where
header.extrinsics_root().clone(),
HashFor::<Block>::ordered_trie_root(
self.extrinsics.iter().map(Encode::encode).collect(),
sp_runtime::StateVersion::V0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be documented somewhere. At least at the Header trait where we say that the extrinsics root is always build using V0

),
);

Expand Down
13 changes: 9 additions & 4 deletions client/db/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use sp_core::{
};
use sp_runtime::{
traits::{Block as BlockT, HashFor},
Storage,
StateVersion, Storage,
};
use sp_state_machine::{
backend::Backend as StateBackend, ChildStorageCollection, DBValue, ProofRecorder,
Expand Down Expand Up @@ -73,6 +73,7 @@ impl<Block: BlockT> sp_state_machine::Storage<HashFor<Block>> for StorageDb<Bloc
}
}
}

/// State that manages the backend database reference. Allows runtime to control the database.
pub struct BenchmarkingState<B: BlockT> {
root: Cell<B::Hash>,
Expand Down Expand Up @@ -105,9 +106,10 @@ impl<B: BlockT> BenchmarkingState<B> {
record_proof: bool,
enable_tracking: bool,
) -> Result<Self, String> {
let state_version = sp_runtime::StateVersion::default();
let mut root = B::Hash::default();
let mut mdb = MemoryDB::<HashFor<B>>::default();
sp_state_machine::TrieDBMut::<HashFor<B>>::new(&mut mdb, &mut root);
sp_state_machine::TrieDBMutV1::<HashFor<B>>::new(&mut mdb, &mut root);

let mut state = BenchmarkingState {
state: RefCell::new(None),
Expand Down Expand Up @@ -138,6 +140,7 @@ impl<B: BlockT> BenchmarkingState<B> {
state.state.borrow_mut().as_mut().unwrap().full_storage_root(
genesis.top.iter().map(|(k, v)| (k.as_ref(), Some(v.as_ref()))),
child_delta,
state_version,
);
state.genesis = transaction.clone().drain();
state.genesis_root = root.clone();
Expand Down Expand Up @@ -415,28 +418,30 @@ impl<B: BlockT> StateBackend<HashFor<B>> for BenchmarkingState<B> {
fn storage_root<'a>(
&self,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, Self::Transaction)
where
B::Hash: Ord,
{
self.state
.borrow()
.as_ref()
.map_or(Default::default(), |s| s.storage_root(delta))
.map_or(Default::default(), |s| s.storage_root(delta, state_version))
}

fn child_storage_root<'a>(
&self,
child_info: &ChildInfo,
delta: impl Iterator<Item = (&'a [u8], Option<&'a [u8]>)>,
state_version: StateVersion,
) -> (B::Hash, bool, Self::Transaction)
where
B::Hash: Ord,
{
self.state
.borrow()
.as_ref()
.map_or(Default::default(), |s| s.child_storage_root(child_info, delta))
.map_or(Default::default(), |s| s.child_storage_root(child_info, delta, state_version))
}

fn pairs(&self) -> Vec<(Vec<u8>, Vec<u8>)> {
Expand Down
Loading