Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9ccf26e
In progress, runtime io must switch to future proof root +
cheme Nov 18, 2019
a0f3818
Switch interface, sr-io seems ok, rpc could use similar interface to
cheme Nov 19, 2019
41c5020
test from previous implementation.
cheme Nov 20, 2019
6eb0414
fix proving test.
cheme Nov 20, 2019
e8e72fc
Restore Keyspacedb from other branch, only apply to child trie.
cheme Nov 20, 2019
88ffbc4
Removing unneeded child_info from child root (child info are stored
cheme Nov 20, 2019
435fcb2
Switch rpc to use same format as ext: more future proof.
cheme Nov 20, 2019
b8c7e37
use root from child info for trie backend essence.
cheme Nov 20, 2019
ee43955
Breaking long lines.
cheme Nov 20, 2019
fe285ae
Merge branch 'master' into child_uuid_step1
cheme Nov 21, 2019
a8818d9
Update doc and clean pr a bit.
cheme Nov 21, 2019
9873dcb
Merge branch 'master' into child_uuid_step1
cheme Nov 23, 2019
609a847
Merge branch 'master' into child_uuid_step1
cheme Nov 25, 2019
7254f6c
Merge branch 'master' into child_uuid_step1
cheme Nov 27, 2019
cac9330
fix error type
cheme Nov 27, 2019
c3b943c
Merge branch 'master' into child_uuid_step1
cheme Nov 28, 2019
c05bc80
Restore removed doc on merge and update sr-io doc.
cheme Nov 28, 2019
cd1e343
Merge branch 'master' into child_uuid_step1
cheme Nov 29, 2019
bdff843
Switch child storage api to use directly unique id, if managed id
cheme Nov 29, 2019
9ce77bb
Clean deprecated host interface from child.
cheme Nov 29, 2019
92c7864
Removing assertion on child info (can fail depending on root
cheme Nov 29, 2019
fc91068
merging child info in the overlay when possible.
cheme Nov 29, 2019
cdabca3
child iteration by prefix using child_info.
cheme Nov 29, 2019
783f389
Merge branch 'master' into child_uuid_step1
cheme Dec 2, 2019
d4c7334
Using ChainInfo in frame support. ChainInfo gets redesign to avoid
cheme Dec 2, 2019
64f4084
Add length of root to the data of child info.
cheme Dec 2, 2019
a87bd48
comments
cheme Dec 2, 2019
68712f9
Encode compact.
cheme Dec 2, 2019
3db467e
Remove child info with root.
cheme Dec 3, 2019
a7425cc
Merge branch 'master' into child_uuid_step1
cheme Dec 3, 2019
8e2b8b9
Fix try_update condition.
cheme Dec 3, 2019
5d74151
Comment Ext child root caching.
cheme Dec 3, 2019
0ba3da5
Replace tuples by struct with field
cheme Dec 5, 2019
d924187
remove StorageTuple alias.
cheme Dec 5, 2019
43da346
Merge branch 'master' into child_uuid_step1
cheme Dec 5, 2019
ead5856
Fix doc tests, and remove StorageOverlay and ChildStorageOverlay
cheme Dec 6, 2019
9e05542
Merge branch 'master' into child_uuid_step1
cheme Dec 8, 2019
6f107d0
Merge branch 'master' into child_uuid_step1
cheme Dec 10, 2019
17dd44d
Merge branch 'master' into child_uuid_step1
cheme Dec 11, 2019
0aaeefa
Merge branch 'master' into child_uuid_step1
cheme Dec 11, 2019
489c9f9
Merge branch 'master' into child_uuid_step1
cheme Dec 11, 2019
c58b539
Merge branch 'master' into child_uuid_step1
cheme Dec 13, 2019
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
185 changes: 103 additions & 82 deletions bin/node/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod tests {
use state_machine::TestExternalities as CoreTestExternalities;
use primitives::{
Blake2Hasher, NeverNativeValue, NativeOrEncoded, map,
traits::{CodeExecutor, Externalities}, storage::well_known_keys,
traits::{CodeExecutor, Externalities}, storage::{well_known_keys, Storage},
};
use sp_runtime::{
Fixed64, traits::{Header as HeaderT, Hash as HashT, Convert}, ApplyExtrinsicResult,
Expand Down Expand Up @@ -143,20 +143,23 @@ mod tests {

#[test]
fn panic_execution_with_foreign_code_gives_error() {
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
69_u128.encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
69_u128.encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
0_u128.encode()
},
<system::BlockHash<Runtime>>::hashed_key_for(0) => {
vec![0u8; 32]
}
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
69_u128.encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
69_u128.encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
0_u128.encode()
},
<system::BlockHash<Runtime>>::hashed_key_for(0) => {
vec![0u8; 32]
}
],
children: map![],
});

let r = executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand All @@ -179,20 +182,23 @@ mod tests {

#[test]
fn bad_extrinsic_with_native_equivalent_code_gives_error() {
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
69_u128.encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
69_u128.encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
0_u128.encode()
},
<system::BlockHash<Runtime>>::hashed_key_for(0) => {
vec![0u8; 32]
}
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
69_u128.encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
69_u128.encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => {
0_u128.encode()
},
<system::BlockHash<Runtime>>::hashed_key_for(0) => {
vec![0u8; 32]
}
],
children: map![],
});

let r = executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand All @@ -215,16 +221,19 @@ mod tests {

#[test]
fn successful_execution_with_native_equivalent_code_gives_ok() {
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(111 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(111 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(111 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(111 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
],
children: map![],
});

let r = executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand Down Expand Up @@ -254,16 +263,19 @@ mod tests {

#[test]
fn successful_execution_with_foreign_code_gives_ok() {
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(111 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(111 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(111 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(111 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
],
children: map![],
});

let r = executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand Down Expand Up @@ -828,16 +840,19 @@ mod tests {

#[test]
fn panic_execution_gives_error() {
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
0_u128.encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
0_u128.encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(BLOATY_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
0_u128.encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
0_u128.encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
],
children: map![],
});

let r = executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand All @@ -860,16 +875,19 @@ mod tests {

#[test]
fn successful_execution_gives_ok() {
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(111 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(111 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(111 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(111 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
],
children: map![],
});

let r = executor_call::<NeverNativeValue, fn() -> _>(
&mut t,
Expand Down Expand Up @@ -1037,19 +1055,22 @@ mod tests {
// - 1 MILLICENTS in substrate node.
// - 1 milli-dot based on current polkadot runtime.
// (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`)
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, (map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(100 * DOLLARS).encode()
},
<balances::FreeBalance<Runtime>>::hashed_key_for(bob()) => {
(10 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(110 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
], map![]));
let mut t = TestExternalities::<Blake2Hasher>::new_with_code(COMPACT_CODE, Storage {
top: map![
<balances::FreeBalance<Runtime>>::hashed_key_for(alice()) => {
(100 * DOLLARS).encode()
},
<balances::FreeBalance<Runtime>>::hashed_key_for(bob()) => {
(10 * DOLLARS).encode()
},
<balances::TotalIssuance<Runtime>>::hashed_key().to_vec() => {
(110 * DOLLARS).encode()
},
<indices::NextEnumSet<Runtime>>::hashed_key().to_vec() => vec![0u8; 16],
<system::BlockHash<Runtime>>::hashed_key_for(0) => vec![0u8; 32]
],
children: map![],
});

let tip = 1_000_000;
let xt = sign(CheckedExtrinsic {
Expand Down
2 changes: 1 addition & 1 deletion bin/node/testing/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct GenesisParameters {
}

impl test_client::GenesisInit for GenesisParameters {
fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) {
fn genesis_storage(&self) -> Storage {
crate::genesis::config(self.support_changes_trie, None).build_storage().unwrap()
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/api/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;
use std::collections::HashMap;
use primitives::ChangesTrieConfiguration;
use primitives::offchain::OffchainStorage;
use sp_runtime::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay};
use sp_runtime::{generic::BlockId, Justification, Storage};
use sp_runtime::traits::{Block as BlockT, NumberFor};
use state_machine::backend::Backend as StateBackend;
use state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction};
Expand Down Expand Up @@ -134,7 +134,7 @@ pub trait BlockImportOperation<Block, H> where
fn update_db_storage(&mut self, update: <Self::State as StateBackend<H>>::Transaction) -> sp_blockchain::Result<()>;

/// Inject storage data into the database replacing any existing data.
fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> sp_blockchain::Result<H::Out>;
fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result<H::Out>;

/// Set storage changes.
fn update_storage(
Expand Down
7 changes: 6 additions & 1 deletion client/api/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sp_runtime::{
},
generic::BlockId
};
use primitives::{ChangesTrieConfiguration};
use primitives::ChangesTrieConfiguration;
use state_machine::StorageProof;
use sp_blockchain::{
HeaderMetadata, well_known_cache_keys, HeaderBackend, Cache as BlockchainCache,
Expand Down Expand Up @@ -81,6 +81,11 @@ pub struct RemoteReadChildRequest<Header: HeaderT> {
pub header: Header,
/// Storage key for child.
pub storage_key: Vec<u8>,
/// Child trie source information.
pub child_info: Vec<u8>,
/// Child type, its required to resolve `child_info`
/// content and choose child implementation.
pub child_type: u32,
/// Child storage key to read.
pub keys: Vec<Vec<u8>>,
/// Number of times to retry request. None means that default RETRY_COUNT is used.
Expand Down
Loading