Update polkadot and substrate (#71)

This commit is contained in:
Cecile Tonglet
2020-03-11 17:45:44 +01:00
committed by GitHub
parent f29b94816c
commit dd5b344274
12 changed files with 2400 additions and 2401 deletions
+5 -5
View File
@@ -18,7 +18,7 @@
use crate::WitnessData;
use frame_executive::ExecuteBlock;
use sp_runtime::traits::{Block as BlockT, HasherFor, Header as HeaderT};
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
use sp_trie::{delta_trie_root, read_trie_value, Layout, MemoryDB};
@@ -116,7 +116,7 @@ pub fn validate_block<B: BlockT, E: ExecuteBlock<B>>(params: ValidationParams) -
/// The storage implementation used when validating a block that is using the
/// witness data as source.
struct WitnessStorage<B: BlockT> {
witness_data: MemoryDB<HasherFor<B>>,
witness_data: MemoryDB<HashFor<B>>,
overlay: hashbrown::HashMap<Vec<u8>, Option<Vec<u8>>>,
storage_root: B::Hash,
}
@@ -149,7 +149,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
.get(key)
.cloned()
.or_else(|| {
read_trie_value::<Layout<HasherFor<B>>, _>(
read_trie_value::<Layout<HashFor<B>>, _>(
&self.witness_data,
&self.storage_root,
key,
@@ -168,7 +168,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
}
fn storage_root(&mut self) -> Vec<u8> {
let root = delta_trie_root::<Layout<HasherFor<B>>, _, _, _, _>(
let root = delta_trie_root::<Layout<HashFor<B>>, _, _, _, _>(
&mut self.witness_data,
self.storage_root.clone(),
self.overlay.drain(),
@@ -184,7 +184,7 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
}
});
let trie = match TrieDB::<Layout<HasherFor<B>>>::new(&self.witness_data, &self.storage_root)
let trie = match TrieDB::<Layout<HashFor<B>>>::new(&self.witness_data, &self.storage_root)
{
Ok(r) => r,
Err(_) => panic!(),
+15 -11
View File
@@ -17,9 +17,13 @@
use crate::{ParachainBlockData, WitnessData};
use parachain::{ValidationParams, ValidationResult};
use sc_executor::{call_in_wasm, error::Result, WasmExecutionMethod};
use sc_executor::{
error::Result, WasmExecutionMethod, WasmExecutor, sp_wasm_interface::HostFunctions,
};
use sc_block_builder::BlockBuilderProvider;
use sp_blockchain::HeaderBackend;
use sp_consensus::SelectChain;
use sp_core::traits::CallInWasm;
use sp_io::TestExternalities;
use sp_keyring::AccountKeyring;
use sp_runtime::{
@@ -45,22 +49,22 @@ fn call_validate_block(
}
.encode();
call_in_wasm::<
(
sp_io::SubstrateHostFunctions,
sc_executor::deprecated_host_interface::SubstrateExternals,
),
>(
let executor = WasmExecutor::new(
WasmExecutionMethod::Interpreted,
Some(1024),
sp_io::SubstrateHostFunctions::host_functions(),
false,
);
executor.call_in_wasm(
&WASM_BINARY,
"validate_block",
&params,
WasmExecutionMethod::Interpreted,
&mut ext_ext,
&WASM_BINARY,
1024,
false,
)
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
.map(|v| Header::decode(&mut &v.head_data[..]).expect("Decode `Header`."))
.map_err(|err| err.into())
}
fn create_extrinsics() -> Vec<<Block as BlockT>::Extrinsic> {