Set StateBackend::Transaction to PrefixedMemoryDB (#14612)

* Yep

* Try to get it working everywhere

* Make `from_raw_storage` start with an empty db

* More fixes!

* Make everything compile

* Fix `child_storage_root`

* Fix after merge

* Cleanups

* Update primitives/state-machine/src/overlayed_changes/mod.rs

Co-authored-by: Davide Galassi <davxy@datawok.net>

* Review comments

* Fix issues

* Silence warning

* FMT

* Clippy

---------

Co-authored-by: Davide Galassi <davxy@datawok.net>
This commit is contained in:
Bastian Köcher
2023-08-17 12:49:38 +02:00
committed by GitHub
parent a892fa7f92
commit ecf8035da6
67 changed files with 750 additions and 1150 deletions
@@ -29,7 +29,7 @@ use sp_core::{
Blake2Hasher,
};
use sp_externalities::{Extension, Extensions, MultiRemovalResults};
use sp_trie::{empty_child_trie_root, HashKey, LayoutV0, LayoutV1, TrieConfiguration};
use sp_trie::{empty_child_trie_root, LayoutV0, LayoutV1, TrieConfiguration};
use std::{
any::{Any, TypeId},
collections::BTreeMap,
@@ -39,7 +39,7 @@ use std::{
/// Simple Map-based Externalities impl.
#[derive(Debug)]
pub struct BasicExternalities {
overlay: OverlayedChanges,
overlay: OverlayedChanges<Blake2Hasher>,
extensions: Extensions,
}
@@ -282,7 +282,7 @@ impl Externalities for BasicExternalities {
if let Some((data, child_info)) = self.overlay.child_changes(child_info.storage_key()) {
let delta =
data.into_iter().map(|(k, v)| (k.as_ref(), v.value().map(|v| v.as_slice())));
crate::in_memory_backend::new_in_mem::<Blake2Hasher, HashKey<_>>()
crate::in_memory_backend::new_in_mem::<Blake2Hasher>()
.child_storage_root(&child_info, delta, state_version)
.0
} else {