Adds new execution strategy nativeElseWasm (#1546)

* fix: adds new execution strategy nativeElseWasm and replace nativeWhenPossible with it

* feat: adds cmd line params for execution strategies

* fix: uses of cmd line execution strategies

* chore: remove white spaces

* chore: remove println

* chore: remove whitespace

* fix: generating functions with context

* feat: add function to generate with_context declarations

* fix: add implementation for with_context function calls

* fix: add execution context to call_api_at function

* fix: making use of context to select strategy for block_builder

* chore: cleaning up

* fix: merging issues

* fix tests

* add wasm files

* chore: small doc for context fields

* chore: delete redundant docs

* fix: use full path for ExecutionContext

* fix: add context functions from inside fold_item_impl

* chore: remove clone

* fix: moving generative function to utils, remove unused imports

* fix: add missing full path for ExecutionContext

* fix: merge issues

* update wasm files

* fix: update to keep up with changes in master

* chore: remove unused functions, clean up

* fix test

* fix grumbles

* fix: add more tests

* fix: some refactorings

* feat: add execution strategy to call

* chore: small improvements

* fix: add message to panic

* fix tests
This commit is contained in:
Marcio Diaz
2019-02-11 15:22:44 +01:00
committed by GitHub
parent f9975af020
commit b8bd49961a
31 changed files with 837 additions and 544 deletions
+13 -6
View File
@@ -36,6 +36,7 @@ use std::collections::{HashMap, HashSet};
use std::result;
use runtime_primitives::traits::{ApiRef, ProvideRuntimeApi};
use runtime_primitives::generic::BlockId;
use runtime_primitives::ExecutionContext;
use substrate_primitives::NativeOrEncoded;
use authorities::AuthoritySet;
@@ -266,8 +267,9 @@ impl Core<Block> for RuntimeApi {
fn version_runtime_api_impl(
&self,
_: &BlockId<Block>,
_: ExecutionContext,
_: Option<()>,
_: Vec<u8>
_: Vec<u8>,
) -> Result<NativeOrEncoded<RuntimeVersion>> {
unimplemented!("Not required for testing!")
}
@@ -275,8 +277,9 @@ impl Core<Block> for RuntimeApi {
fn authorities_runtime_api_impl(
&self,
_: &BlockId<Block>,
_: ExecutionContext,
_: Option<()>,
_: Vec<u8>
_: Vec<u8>,
) -> Result<NativeOrEncoded<Vec<Ed25519AuthorityId>>> {
unimplemented!("Not required for testing!")
}
@@ -284,8 +287,9 @@ impl Core<Block> for RuntimeApi {
fn execute_block_runtime_api_impl(
&self,
_: &BlockId<Block>,
_: ExecutionContext,
_: Option<(Block)>,
_: Vec<u8>
_: Vec<u8>,
) -> Result<NativeOrEncoded<()>> {
unimplemented!("Not required for testing!")
}
@@ -293,6 +297,7 @@ impl Core<Block> for RuntimeApi {
fn initialise_block_runtime_api_impl(
&self,
_: &BlockId<Block>,
_: ExecutionContext,
_: Option<&<Block as BlockT>::Header>,
_: Vec<u8>,
) -> Result<NativeOrEncoded<()>> {
@@ -317,6 +322,7 @@ impl GrandpaApi<Block> for RuntimeApi {
fn grandpa_authorities_runtime_api_impl(
&self,
at: &BlockId<Block>,
_: ExecutionContext,
_: Option<()>,
_: Vec<u8>,
) -> Result<NativeOrEncoded<Vec<(Ed25519AuthorityId, u64)>>> {
@@ -330,8 +336,9 @@ impl GrandpaApi<Block> for RuntimeApi {
fn grandpa_pending_change_runtime_api_impl(
&self,
at: &BlockId<Block>,
_: ExecutionContext,
_: Option<(&DigestFor<Block>)>,
_: Vec<u8>
_: Vec<u8>,
) -> Result<NativeOrEncoded<Option<ScheduledChange<NumberFor<Block>>>>> {
let parent_hash = match at {
&BlockId::Hash(at) => at,
@@ -537,7 +544,7 @@ fn transition_3_voters_twice_1_observer() {
for (i, peer) in net.lock().peers().iter().enumerate() {
assert_eq!(peer.client().info().unwrap().chain.best_number, 1,
"Peer #{} failed to sync", i);
"Peer #{} failed to sync", i);
let set_raw = peer.client().backend().get_aux(::AUTHORITY_SET_KEY).unwrap().unwrap();
let set = AuthoritySet::<Hash, BlockNumber>::decode(&mut &set_raw[..]).unwrap();
@@ -694,7 +701,7 @@ fn justification_is_generated_periodically() {
let net = Arc::new(Mutex::new(net));
run_to_completion(32, net.clone(), peers);
// when block#32 (justification_period) is finalized, justification
// when block#32 (justification_period) is finalized, justification
// is required => generated
for i in 0..3 {
assert!(net.lock().peer(i).client().backend().blockchain()