mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +00:00
Check storage_key for validity (#2316)
* Intro `ChildStorageKey` for checked child keys * Get rid of Into in Externalities trait * Use Cow in ChildStorageKey * Fix tests for state-machine. * Clean * child_storage_root always return a value * Don't return Option from Ext::child_storage_root * Return 42 in child_storage_root * Return CHILD_STORAGE_KEY_PREFIX from trie id gen * Bump spec and impl version. * Require `:default:` in `is_child_trie_key_valid` * Add `default:` prefix. * Introduce `into_owned` for `ChildStorageKey`. * Add documentation. * Fix state-machine tests * Remove outdated TODO I check out with Emeric and he is ok with that * child_storage_root is infailable * Nit * Move assert after check. * Apply suggestions from @DemiMarie-parity Co-Authored-By: pepyakin <s.pepyakin@gmail.com> * Formatting nit in core/executor/src/wasm_executor.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * Formatting nits from @thiolliere
This commit is contained in:
@@ -23,7 +23,7 @@ use heapsize::HeapSizeOf;
|
||||
use trie::trie_root;
|
||||
use primitives::storage::well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES};
|
||||
use parity_codec::Encode;
|
||||
use super::{Externalities, OverlayedChanges};
|
||||
use super::{ChildStorageKey, Externalities, OverlayedChanges};
|
||||
use log::warn;
|
||||
|
||||
/// Simple HashMap-based Externalities impl.
|
||||
@@ -115,7 +115,7 @@ impl<H: Hasher> Externalities<H> for BasicExternalities where H::Out: Ord + Heap
|
||||
Externalities::<H>::storage(self, key)
|
||||
}
|
||||
|
||||
fn child_storage(&self, _storage_key: &[u8], _key: &[u8]) -> Option<Vec<u8>> {
|
||||
fn child_storage(&self, _storage_key: ChildStorageKey<H>, _key: &[u8]) -> Option<Vec<u8>> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -132,11 +132,10 @@ impl<H: Hasher> Externalities<H> for BasicExternalities where H::Out: Ord + Heap
|
||||
}
|
||||
}
|
||||
|
||||
fn place_child_storage(&mut self, _storage_key: Vec<u8>, _key: Vec<u8>, _value: Option<Vec<u8>>) -> bool {
|
||||
false
|
||||
fn place_child_storage(&mut self, _storage_key: ChildStorageKey<H>, _key: Vec<u8>, _value: Option<Vec<u8>>) {
|
||||
}
|
||||
|
||||
fn kill_child_storage(&mut self, _storage_key: &[u8]) { }
|
||||
fn kill_child_storage(&mut self, _storage_key: ChildStorageKey<H>) { }
|
||||
|
||||
fn clear_prefix(&mut self, prefix: &[u8]) {
|
||||
self.changes.clear_prefix(prefix);
|
||||
@@ -149,8 +148,8 @@ impl<H: Hasher> Externalities<H> for BasicExternalities where H::Out: Ord + Heap
|
||||
trie_root::<H, _, _, _>(self.inner.clone())
|
||||
}
|
||||
|
||||
fn child_storage_root(&mut self, _storage_key: &[u8]) -> Option<Vec<u8>> {
|
||||
None
|
||||
fn child_storage_root(&mut self, _storage_key: ChildStorageKey<H>) -> Vec<u8> {
|
||||
vec![42]
|
||||
}
|
||||
|
||||
fn storage_changes_root(&mut self, _parent: H::Out, _parent_num: u64) -> Option<H::Out> {
|
||||
|
||||
Reference in New Issue
Block a user