Fetching changes proof from remote nodes (#769)

* changes_trie

* changs_trie: continue

* changes_trie: adding tests

* fixed TODO

* removed obsolete ExtrinsicChanges

* encodable ChangesTrieConfiguration

* removed polkadot fle

* fixed grumbles

* ext_storage_changes_root returns u32

* moved changes trie root to digest

* removed commented code

* read storage values from native code

* fixed grumbles

* fixed grumbles

* missing comma

* key changes proof generation + query

* fix grumbles

* check that changes trie config is not changed by block.finalize()

* fixed changes trie config check
This commit is contained in:
Svyatoslav Nikolsky
2018-09-29 11:47:29 +03:00
committed by Gav Wood
parent fdfd4672c1
commit c54350661d
20 changed files with 753 additions and 107 deletions
+3 -3
View File
@@ -38,9 +38,9 @@ pub trait TestClient {
}
impl<B, E> TestClient for Client<B, E, runtime::Block>
where
B: client::backend::Backend<runtime::Block, Blake2Hasher>,
E: client::CallExecutor<runtime::Block, Blake2Hasher>
where
B: client::backend::Backend<runtime::Block, Blake2Hasher>,
E: client::CallExecutor<runtime::Block, Blake2Hasher>
{
fn justify_and_import(&self, origin: client::BlockOrigin, block: runtime::Block) -> client::error::Result<()> {
let authorities: [ed25519::Pair; 3] = [
+15 -7
View File
@@ -68,29 +68,37 @@ pub type Executor = client::LocalCallExecutor<
/// Creates new client instance used for tests.
pub fn new() -> client::Client<Backend, Executor, runtime::Block> {
new_with_backend(Arc::new(Backend::new()))
new_with_backend(Arc::new(Backend::new()), false)
}
/// Creates new test client instance that suports changes trie creation.
pub fn new_with_changes_trie() -> client::Client<Backend, Executor, runtime::Block> {
new_with_backend(Arc::new(Backend::new()), true)
}
/// Creates new client instance used for tests with an explicitely provided backend.
/// This is useful for testing backend implementations.
pub fn new_with_backend<B>(backend: Arc<B>) -> client::Client<B, client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>, runtime::Block>
pub fn new_with_backend<B>(
backend: Arc<B>,
support_changes_trie: bool
) -> client::Client<B, client::LocalCallExecutor<B, executor::NativeExecutor<LocalExecutor>>, runtime::Block>
where
B: backend::LocalBackend<runtime::Block, Blake2Hasher>,
{
let executor = NativeExecutor::new();
client::new_with_backend(backend, executor, genesis_storage()).unwrap()
client::new_with_backend(backend, executor, genesis_storage(support_changes_trie)).unwrap()
}
fn genesis_config() -> GenesisConfig {
GenesisConfig::new_simple(vec![
fn genesis_config(support_changes_trie: bool) -> GenesisConfig {
GenesisConfig::new(support_changes_trie, vec![
Keyring::Alice.to_raw_public().into(),
Keyring::Bob.to_raw_public().into(),
Keyring::Charlie.to_raw_public().into(),
], 1000)
}
fn genesis_storage() -> StorageMap {
let mut storage = genesis_config().genesis_map();
fn genesis_storage(support_changes_trie: bool) -> StorageMap {
let mut storage = genesis_config(support_changes_trie).genesis_map();
let block: runtime::Block = client::genesis::construct_genesis_block(&storage);
storage.extend(additional_storage_with_genesis(&block));
storage
@@ -41,7 +41,7 @@ pub fn test_leaves_for_backend<B>(backend: Arc<B>) where
// B2 -> C3
// A1 -> D2
let client = ::new_with_backend(backend.clone());
let client = ::new_with_backend(backend.clone(), false);
let genesis_hash = client.info().unwrap().chain.genesis_hash;
@@ -153,7 +153,7 @@ pub fn test_blockchain_query_by_number_gets_canonical<B>(backend: Arc<B>) where
// A1 -> B2 -> B3 -> B4
// B2 -> C3
// A1 -> D2
let client = ::new_with_backend(backend);
let client = ::new_with_backend(backend, false);
// G -> A1
let a1 = client.new_block().unwrap().bake().unwrap();