Update Cumulus for Parachains V1 (#224)

* Start with something

* Whatever

* Update

* MOARE

* Make cumulus-network compile and tests work

* Update more and fixes

* More stuff

* More fixes

* Make collator build

* Make test almost work

* Remove contracts runtime

* More test work

* Make service compile

* Fix test-service

* Fix test client

* More fixes

* Fix collator test

* Fix network tests (again)

* Make everything compile, finally

* Fix tests

* Update to latest masters

* Remove ignore

* Switch to different branch in polkadot for now

* Update reference

* Make it compile with latest changes

* Update collator/src/lib.rs

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>

* Update to latest upstream

* Update to latest master

* Fix test

Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
Bastian Köcher
2020-11-08 22:18:09 +01:00
committed by GitHub
parent 9512520b95
commit 76f9ecae47
87 changed files with 3815 additions and 17343 deletions
+23 -19
View File
@@ -5,25 +5,29 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
sc-service = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
test-client = { package = "substrate-test-client", git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-branch" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "rococo-branch" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "rococo-branch" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "rococo-branch" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Cumulus dependencies
# Cumulus deps
cumulus-test-runtime = { path = "../runtime" }
cumulus-test-service = { path = "../service" }
cumulus-primitives = { path = "../../primitives" }
runtime = { package = "cumulus-test-runtime", path = "../runtime" }
# Polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "bkchr-adder-collator-integration-test" }
# Other deps
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
+16 -11
View File
@@ -15,34 +15,39 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::Client;
use cumulus_primitives::{
inherents::VALIDATION_FUNCTION_PARAMS_IDENTIFIER,
validation_function_params::ValidationFunctionParams,
};
use runtime::GetLastTimestamp;
use cumulus_primitives::{inherents::VALIDATION_DATA_IDENTIFIER, ValidationData};
use cumulus_test_runtime::GetLastTimestamp;
use polkadot_primitives::v1::BlockNumber as PBlockNumber;
use sc_block_builder::BlockBuilderApi;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::ExecutionContext;
use sp_runtime::generic::BlockId;
/// Generate the inherents to a block so you don't have to.
pub fn generate_block_inherents(client: &Client) -> Vec<runtime::UncheckedExtrinsic> {
let mut inherent_data = sp_consensus::InherentData::new();
/// Generate the inherents required by the test runtime.
///
/// - `validation_data`: The [`ValidationData`] that will be passed as inherent
/// data into the runtime when building the inherents. If
/// `None` is passed, the default value will be used.
pub fn generate_block_inherents(
client: &Client,
validation_data: Option<ValidationData<PBlockNumber>>,
) -> Vec<cumulus_test_runtime::UncheckedExtrinsic> {
let mut inherent_data = sp_inherents::InherentData::new();
let block_id = BlockId::Hash(client.info().best_hash);
let last_timestamp = client
.runtime_api()
.get_last_timestamp(&block_id)
.expect("Get last timestamp");
let timestamp = last_timestamp + runtime::MinimumPeriod::get();
let timestamp = last_timestamp + cumulus_test_runtime::MinimumPeriod::get();
inherent_data
.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
.expect("Put timestamp failed");
inherent_data
.put_data(
VALIDATION_FUNCTION_PARAMS_IDENTIFIER,
&ValidationFunctionParams::default(),
VALIDATION_DATA_IDENTIFIER,
&validation_data.unwrap_or_default(),
)
.expect("Put validation function params failed");
+8 -8
View File
@@ -21,7 +21,7 @@ mod block_builder;
pub use block_builder::*;
use codec::Encode;
pub use runtime;
pub use cumulus_test_runtime as runtime;
use runtime::{
Balance, Block, BlockHashCount, Call, GenesisConfig, Runtime, Signature, SignedExtra,
SignedPayload, UncheckedExtrinsic, VERSION,
@@ -35,14 +35,14 @@ use sp_runtime::{
BuildStorage, SaturatedConversion,
};
use std::collections::BTreeMap;
pub use test_client::*;
pub use substrate_test_client::*;
mod local_executor {
use test_client::sc_executor::native_executor_instance;
use substrate_test_client::sc_executor::native_executor_instance;
native_executor_instance!(
pub LocalExecutor,
runtime::api::dispatch,
runtime::native_version,
cumulus_test_runtime::api::dispatch,
cumulus_test_runtime::native_version,
);
}
@@ -50,14 +50,14 @@ mod local_executor {
pub use local_executor::LocalExecutor;
/// Test client database backend.
pub type Backend = test_client::Backend<Block>;
pub type Backend = substrate_test_client::Backend<Block>;
/// Test client executor.
pub type Executor = client::LocalCallExecutor<Backend, sc_executor::NativeExecutor<LocalExecutor>>;
/// Test client builder for Cumulus
pub type TestClientBuilder =
test_client::TestClientBuilder<Block, Executor, Backend, GenesisParameters>;
substrate_test_client::TestClientBuilder<Block, Executor, Backend, GenesisParameters>;
/// LongestChain type for the test runtime/client.
pub type LongestChain = sc_consensus::LongestChain<Backend, Block>;
@@ -71,7 +71,7 @@ pub struct GenesisParameters {
support_changes_trie: bool,
}
impl test_client::GenesisInit for GenesisParameters {
impl substrate_test_client::GenesisInit for GenesisParameters {
fn genesis_storage(&self) -> Storage {
let changes_trie_config: Option<ChangesTrieConfiguration> = if self.support_changes_trie {
Some(sp_test_primitives::changes_trie_config())