Update Substrate & Polkadot (#519)

* Update Substrate & Polkadot

* Basti improvements

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Sergei Shulepov
2021-06-28 22:38:28 +02:00
committed by GitHub
parent f878c49de5
commit 3d636b9820
5 changed files with 304 additions and 336 deletions
Generated
+281 -318
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -208,7 +208,9 @@ where
let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header); let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header);
block_import_params.body = Some(extrinsics); block_import_params.body = Some(extrinsics);
block_import_params.storage_changes = Some(storage_changes); block_import_params.state_action = sp_consensus::StateAction::ApplyChanges(
sp_consensus::StorageChanges::Changes(storage_changes)
);
if let Err(err) = self if let Err(err) = self
.block_import .block_import
+2
View File
@@ -352,6 +352,8 @@ where
allow_missing_state: false, allow_missing_state: false,
justifications: None, justifications: None,
origin: None, origin: None,
skip_execution: false,
state: None,
}); });
if let Some(waiting) = self.waiting_for_parent.remove(&block_hash) { if let Some(waiting) = self.waiting_for_parent.remove(&block_hash) {
-1
View File
@@ -44,7 +44,6 @@ lazy_static = "1.4"
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Cumulus dependencies # Cumulus dependencies
@@ -19,12 +19,11 @@ use cumulus_primitives_core::{ParachainBlockData, PersistedValidationData};
use cumulus_test_client::{ use cumulus_test_client::{
runtime::{Block, Hash, Header, UncheckedExtrinsic, WASM_BINARY}, runtime::{Block, Hash, Header, UncheckedExtrinsic, WASM_BINARY},
transfer, BlockData, BuildParachainBlockData, Client, DefaultTestClientBuilderExt, HeadData, transfer, BlockData, BuildParachainBlockData, Client, DefaultTestClientBuilderExt, HeadData,
InitBlockBuilder, LongestChain, TestClientBuilder, TestClientBuilderExt, ValidationParams, InitBlockBuilder, TestClientBuilder, TestClientBuilderExt, ValidationParams,
}; };
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use sp_consensus::SelectChain;
use sp_keyring::AccountKeyring::*; use sp_keyring::AccountKeyring::*;
use sp_runtime::traits::Header as HeaderT; use sp_runtime::{generic::BlockId, traits::Header as HeaderT};
use std::{env, process::Command}; use std::{env, process::Command};
fn call_validate_block( fn call_validate_block(
@@ -44,11 +43,19 @@ fn call_validate_block(
.map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decodes `Header`.")) .map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decodes `Header`."))
} }
fn create_test_client() -> (Client, LongestChain) { fn create_test_client() -> (Client, Header) {
TestClientBuilder::new() let client = TestClientBuilder::new()
// NOTE: this allows easier debugging // NOTE: this allows easier debugging
.set_execution_strategy(sc_client_api::ExecutionStrategy::NativeWhenPossible) .set_execution_strategy(sc_client_api::ExecutionStrategy::NativeWhenPossible)
.build_with_longest_chain() .build();
let genesis_header = client
.header(&BlockId::number(0))
.ok()
.flatten()
.expect("Genesis header exists; qed");
(client, genesis_header)
} }
struct TestBlockData { struct TestBlockData {
@@ -88,8 +95,7 @@ fn build_block_with_witness(
fn validate_block_no_extra_extrinsics() { fn validate_block_no_extra_extrinsics() {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
let (client, longest_chain) = create_test_client(); let (client, parent_head) = create_test_client();
let parent_head = longest_chain.best_chain().expect("Best block exists");
let TestBlockData { let TestBlockData {
block, block,
validation_data, validation_data,
@@ -109,8 +115,7 @@ fn validate_block_no_extra_extrinsics() {
fn validate_block_with_extra_extrinsics() { fn validate_block_with_extra_extrinsics() {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
let (client, longest_chain) = create_test_client(); let (client, parent_head) = create_test_client();
let parent_head = longest_chain.best_chain().expect("Best block exists");
let extra_extrinsics = vec![ let extra_extrinsics = vec![
transfer(&client, Alice, Bob, 69), transfer(&client, Alice, Bob, 69),
transfer(&client, Bob, Charlie, 100), transfer(&client, Bob, Charlie, 100),
@@ -142,8 +147,7 @@ fn validate_block_invalid_parent_hash() {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
if env::var("RUN_TEST").is_ok() { if env::var("RUN_TEST").is_ok() {
let (client, longest_chain) = create_test_client(); let (client, parent_head) = create_test_client();
let parent_head = longest_chain.best_chain().expect("Best block exists");
let TestBlockData { let TestBlockData {
block, block,
validation_data, validation_data,
@@ -175,8 +179,7 @@ fn validate_block_fails_on_invalid_validation_data() {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
if env::var("RUN_TEST").is_ok() { if env::var("RUN_TEST").is_ok() {
let (client, longest_chain) = create_test_client(); let (client, parent_head) = create_test_client();
let parent_head = longest_chain.best_chain().expect("Best block exists");
let TestBlockData { block, .. } = let TestBlockData { block, .. } =
build_block_with_witness(&client, vec![], parent_head.clone(), Default::default()); build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
@@ -203,8 +206,7 @@ fn check_inherent_fails_on_validate_block_as_expected() {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
if env::var("RUN_TEST").is_ok() { if env::var("RUN_TEST").is_ok() {
let (client, longest_chain) = create_test_client(); let (client, parent_head) = create_test_client();
let parent_head = longest_chain.best_chain().expect("Best block exists");
let TestBlockData { let TestBlockData {
block, block,