Update CLI (#53)

* Initial commit

Forked at: 4a3ffe07e7
Parent branch: master

* Update substrate: more CLI improvement

* Update substrate and polkadot to cecton-cumulus-branch

* WIP

Forked at: 4a3ffe07e7
Parent branch: master

* Update Cargo.lock

* WIP

Forked at: 4a3ffe07e7
Parent branch: master

* WIP

Forked at: 4a3ffe07e7
Parent branch: master

* Update Cargo.lock

* WIP

Forked at: 4a3ffe07e7
Parent branch: master

* WIP

Forked at: 4a3ffe07e7
Parent branch: master

* Test running node and interrupts

* WIP

Forked at: 4a3ffe07e7
Parent branch: master

* Update Cargo.lock

* Update test/parachain/tests/running_the_node_and_interrupt.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Cecile Tonglet
2020-02-10 12:39:32 +01:00
committed by GitHub
parent 4a3ffe07e7
commit de4ab321f4
14 changed files with 1758 additions and 1655 deletions
+1493 -1470
View File
File diff suppressed because it is too large Load Diff
+17 -17
View File
@@ -6,20 +6,20 @@ edition = "2018"
[dependencies] [dependencies]
# Substrate dependencies # Substrate dependencies
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
# Polkadot dependencies # Polkadot dependencies
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
# Cumulus dependencies # Cumulus dependencies
cumulus-consensus = { path = "../consensus" } cumulus-consensus = { path = "../consensus" }
@@ -37,13 +37,13 @@ test-runtime = { package = "cumulus-test-runtime", path = "../test/runtime" }
test-client = { package = "cumulus-test-client", path = "../test/client" } test-client = { package = "cumulus-test-client", path = "../test/client" }
# Substrate dependencies # Substrate dependencies
substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
# Polkadot dependencies # Polkadot dependencies
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
# Other dependencies # Other dependencies
env_logger = "0.7.1" env_logger = "0.7.1"
+3 -21
View File
@@ -24,7 +24,6 @@ use sp_consensus::{
}; };
use sp_inherents::InherentDataProviders; use sp_inherents::InherentDataProviders;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sc_cli;
use polkadot_collator::{ use polkadot_collator::{
BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext, BuildParachainContext, InvalidHead, Network as CollatorNetwork, ParachainContext,
@@ -32,7 +31,7 @@ use polkadot_collator::{
}; };
use polkadot_primitives::{ use polkadot_primitives::{
parachain::{ parachain::{
self, BlockData, CollatorPair, Id as ParaId, Message, OutgoingMessages, self, BlockData, Id as ParaId, Message, OutgoingMessages,
Status as ParachainStatus, Status as ParachainStatus,
}, },
Block as PBlock, Hash as PHash, Block as PBlock, Hash as PHash,
@@ -256,14 +255,14 @@ where
} }
/// Implements `BuildParachainContext` to build a collator instance. /// Implements `BuildParachainContext` to build a collator instance.
struct CollatorBuilder<Block, SP> { pub struct CollatorBuilder<Block, SP> {
setup_parachain: SP, setup_parachain: SP,
_marker: PhantomData<Block>, _marker: PhantomData<Block>,
} }
impl<Block, SP> CollatorBuilder<Block, SP> { impl<Block, SP> CollatorBuilder<Block, SP> {
/// Create a new instance of self. /// Create a new instance of self.
fn new(setup_parachain: SP) -> Self { pub fn new(setup_parachain: SP) -> Self {
Self { Self {
setup_parachain, setup_parachain,
_marker: PhantomData, _marker: PhantomData,
@@ -345,23 +344,6 @@ pub trait SetupParachain<Block: BlockT>: Send {
SP: Spawn + Clone + Send + Sync + 'static; SP: Spawn + Clone + Send + Sync + 'static;
} }
/// Run a collator with the given proposer factory.
pub fn run_collator<Block, SP>(
setup_parachain: SP,
para_id: ParaId,
key: Arc<CollatorPair>,
configuration: polkadot_collator::Configuration,
) -> Result<(), sc_cli::error::Error>
where
Block: BlockT,
SP: SetupParachain<Block> + Send + 'static,
<<SP as SetupParachain<Block>>::ProposerFactory as Environment<Block>>::Proposer: Send,
{
let builder = CollatorBuilder::new(setup_parachain);
let exit = future::pending(); // TODO to delete
polkadot_collator::run_collator(builder, para_id, exit, key, configuration)
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
+11 -11
View File
@@ -7,19 +7,19 @@ edition = "2018"
[dependencies] [dependencies]
# substrate deps # substrate deps
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
# polkadot deps # polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
# other deps # other deps
futures = { version = "0.3.1", features = ["compat"] } futures = { version = "0.3.1", features = ["compat"] }
+8 -8
View File
@@ -7,16 +7,16 @@ edition = "2018"
[dependencies] [dependencies]
# substrate deps # substrate deps
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
# polkadot deps # polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-statement-table = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-statement-table = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-validation = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-validation = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-network = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-network = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
# other deps # other deps
codec = { package = "parity-scale-codec", version = "1.0.5", features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "1.0.5", features = [ "derive" ] }
+11 -11
View File
@@ -13,21 +13,21 @@ trie-db = { version = "0.19.2", default-features = false }
hashbrown = "0.6.1" hashbrown = "0.6.1"
# Substrate dependencies # Substrate dependencies
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
# Polkadot dependencies # Polkadot dependencies
parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch", default-features = false, features = [ "wasm-api" ] } parachain = { package = "polkadot-parachain", git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch", default-features = false, features = [ "wasm-api" ] }
[dev-dependencies] [dev-dependencies]
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
test-client = { package = "cumulus-test-client", path = "../test/client" } test-client = { package = "cumulus-test-client", path = "../test/client" }
[features] [features]
+5 -5
View File
@@ -5,10 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
test-client = { package = "substrate-test-client", git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } test-client = { package = "substrate-test-client", git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
runtime = { package = "cumulus-test-runtime", path = "../runtime" } runtime = { package = "cumulus-test-runtime", path = "../runtime" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = [ "derive" ] }
sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-test-primitives = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
+21 -22
View File
@@ -15,43 +15,42 @@ exit-future = '0.1.4'
futures = { version = "0.3.1", features = ["compat"] } futures = { version = "0.3.1", features = ["compat"] }
log = '0.4.8' log = '0.4.8'
parking_lot = '0.9.0' parking_lot = '0.9.0'
tokio = '0.1.22'
trie-root = '0.15.2' trie-root = '0.15.2'
codec = { package = 'parity-scale-codec', version = '1.0.0' } codec = { package = 'parity-scale-codec', version = '1.0.0' }
structopt = "0.3.3" structopt = "0.3.3"
ctrlc = { version = "3.1.3", features = ["termination"] }
itertools = { version = "0.8.2" }
# Parachain dependencies # Parachain dependencies
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" } parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
# Substrate dependencies # Substrate dependencies
sp-runtime = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-io = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-client = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" } sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cecton-cumulus-branch" }
# Cumulus dependencies # Cumulus dependencies
cumulus-consensus = { path = "../../consensus" } cumulus-consensus = { path = "../../consensus" }
cumulus-collator = { path = "../../collator" } cumulus-collator = { path = "../../collator" }
# Polkadot dependencies # Polkadot dependencies
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-collator = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "cumulus-branch" } polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "cecton-cumulus-branch" }
[build-dependencies] [build-dependencies]
vergen = '3.0.4' vergen = '3.0.4'
[dev-dependencies]
assert_cmd = "0.12"
nix = "0.17"
+20 -20
View File
@@ -9,27 +9,27 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] }
# Substrate dependencies # Substrate dependencies
sp-std = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-std = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-api = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-api = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-io = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-io = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-version = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-version = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-runtime = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-core = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } sp-core = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
frame-support = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } frame-support = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
frame-executive = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } frame-executive = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
frame-system = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } frame-system = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } pallet-balances = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
pallet-indices = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } pallet-indices = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cumulus-branch" } pallet-sudo = { git = "https://github.com/paritytech/substrate", default_features = false, branch = "cecton-cumulus-branch" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
# Cumulus dependencies # Cumulus dependencies
cumulus-runtime = { path = "../../../runtime", default-features = false } cumulus-runtime = { path = "../../../runtime", default-features = false }
+28 -39
View File
@@ -17,12 +17,11 @@
use crate::chain_spec; use crate::chain_spec;
use crate::cli::{Cli, PolkadotCli, Subcommand}; use crate::cli::{Cli, PolkadotCli, Subcommand};
use std::{path::PathBuf, sync::Arc}; use std::sync::Arc;
use futures::{future::Map, FutureExt};
use parachain_runtime::Block; use parachain_runtime::Block;
use sc_cli::{error::{self, Result}, VersionInfo}; use sc_cli::{error, VersionInfo};
use sc_client::genesis; use sc_client::genesis;
use sc_service::{Configuration, Roles as ServiceRoles}; use sc_service::{Configuration, Roles as ServiceRoles};
use sp_core::hexdisplay::HexDisplay; use sp_core::hexdisplay::HexDisplay;
@@ -34,14 +33,17 @@ use polkadot_service::ChainSpec as ChainSpecPolkadot;
use codec::Encode; use codec::Encode;
use log::info; use log::info;
use structopt::StructOpt;
const DEFAULT_POLKADOT_RPC_HTTP: &'static str = "127.0.0.1:9934";
const DEFAULT_POLKADOT_RPC_WS: &'static str = "127.0.0.1:9945";
const DEFAULT_POLKADOT_GRAFANA_PORT: &'static str = "127.0.0.1:9956";
/// Parse command line arguments into service configuration. /// Parse command line arguments into service configuration.
pub fn run(version: VersionInfo) -> error::Result<()> { pub fn run(version: VersionInfo) -> error::Result<()> {
let opt: Cli = sc_cli::from_args(&version); let opt: Cli = sc_cli::from_args(&version);
let mut config = sc_service::Configuration::default(); let mut config = sc_service::Configuration::new(&version);
config.impl_name = "cumulus-test-parachain-collator"; let mut polkadot_config = Configuration::new(&version);
match opt.subcommand { match opt.subcommand {
Some(Subcommand::Base(subcommand)) => sc_cli::run_subcommand( Some(Subcommand::Base(subcommand)) => sc_cli::run_subcommand(
@@ -78,7 +80,13 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
Ok(()) Ok(())
}, },
None => { None => {
sc_cli::init(&mut config, load_spec, &opt.run.shared_params, &version)?; sc_cli::init(&opt.run.shared_params, &version)?;
sc_cli::load_spec(&mut config, &opt.run.shared_params, load_spec)?;
sc_cli::update_config_for_running_node(
&mut config,
opt.run,
&version,
)?;
info!("{}", version.name); info!("{}", version.name);
info!(" version {}", config.full_version()); info!(" version {}", config.full_version());
@@ -91,43 +99,24 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
// TODO // TODO
let key = Arc::new(sp_core::Pair::from_seed(&[10; 32])); let key = Arc::new(sp_core::Pair::from_seed(&[10; 32]));
let mut polkadot_config = Configuration::default();
polkadot_config.impl_name = "cumulus-test-parachain-collator";
polkadot_config.config_dir = config.in_chain_config_dir("polkadot"); polkadot_config.config_dir = config.in_chain_config_dir("polkadot");
// TODO: parse_address is private
/*
let rpc_interface: &str = interface_str(opt.run.rpc_external, opt.run.unsafe_rpc_external, opt.run.validator)?;
config.rpc_http = Some(parse_address(&format!("{}:{}", rpc_interface, 9934), opt.run.rpc_port)?);
let ws_interface: &str = interface_str(opt.run.ws_external, opt.run.unsafe_ws_external, opt.run.validator)?;
config.rpc_ws = Some(parse_address(&format!("{}:{}", ws_interface, 9945), opt.run.ws_port)?);
let grafana_interface: &str = if opt.run.grafana_external { "0.0.0.0" } else { "127.0.0.1" };
config.grafana_port = Some(
parse_address(&format!("{}:{}", grafana_interface, 9956), opt.run.grafana_port)?
);
*/
let polkadot_opt: PolkadotCli = sc_cli::from_iter(opt.relaychain_args, &version); let polkadot_opt: PolkadotCli = sc_cli::from_iter(opt.relaychain_args, &version);
// TODO polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
polkadot_config.chain_spec = Some(sc_cli::load_spec(&polkadot_opt.run.shared_params, load_spec_polkadot)?); polkadot_config.rpc_ws = Some(DEFAULT_POLKADOT_RPC_WS.parse().unwrap());
// TODO: base_path is private polkadot_config.grafana_port = Some(DEFAULT_POLKADOT_GRAFANA_PORT.parse().unwrap());
//polkadot_config.config_dir = Some(sc_cli::base_path(&polkadot_opt.run.shared_params, &version));
polkadot_config.impl_commit = version.commit;
polkadot_config.impl_version = version.version;
// TODO sc_cli::load_spec(
if let Some(ref config_dir) = polkadot_config.config_dir { &mut polkadot_config,
polkadot_config.database = sc_service::config::DatabaseConfig::Path { &polkadot_opt.run.shared_params,
cache_size: Default::default(), load_spec_polkadot,
path: config_dir.join("db"), )?;
}; sc_cli::update_config_for_running_node(
} &mut polkadot_config,
// TODO polkadot_opt.run,
polkadot_config.network.boot_nodes = polkadot_config.network.boot_nodes.clone(); &version,
polkadot_config.telemetry_endpoints = polkadot_config.expect_chain_spec().telemetry_endpoints().clone(); )?;
sc_cli::update_config_for_running_node(&mut polkadot_config, polkadot_opt.run);
match config.roles { match config.roles {
ServiceRoles::LIGHT => unimplemented!("Light client not supported!"), ServiceRoles::LIGHT => unimplemented!("Light client not supported!"),
-1
View File
@@ -19,7 +19,6 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#![warn(unused_extern_crates)] #![warn(unused_extern_crates)]
use itertools::Itertools;
use polkadot_primitives::parachain::Id as ParaId; use polkadot_primitives::parachain::Id as ParaId;
mod chain_spec; mod chain_spec;
+63 -10
View File
@@ -23,7 +23,13 @@ use sc_network::construct_simple_protocol;
use sc_service::{AbstractService, Configuration}; use sc_service::{AbstractService, Configuration};
use sp_consensus::{BlockImport, Environment, Proposer}; use sp_consensus::{BlockImport, Environment, Proposer};
use sp_inherents::InherentDataProviders; use sp_inherents::InherentDataProviders;
use sc_cli; use sp_core::crypto::Pair;
use polkadot_collator::build_collator_service;
use polkadot_primitives::parachain::CollatorPair;
use polkadot_service::IsKusama;
use cumulus_collator::CollatorBuilder;
use futures::{future, task::Spawn, FutureExt, TryFutureExt}; use futures::{future, task::Spawn, FutureExt, TryFutureExt};
@@ -76,13 +82,21 @@ macro_rules! new_full_start {
}}; }};
} }
/// Run the collator with the given `config`. /// Run a collator node with the given parachain `Configuration` and relaychain `Configuration`
///
/// This function blocks until done.
pub fn run_collator<E: sc_service::ChainSpecExtension>( pub fn run_collator<E: sc_service::ChainSpecExtension>(
config: Configuration<GenesisConfig, E>, mut parachain_config: Configuration<GenesisConfig, E>,
key: Arc<polkadot_primitives::parachain::CollatorPair>, key: Arc<CollatorPair>,
polkadot_config: polkadot_collator::Configuration, polkadot_config: polkadot_collator::Configuration,
) -> Result<(), sc_cli::error::Error> { ) -> sc_cli::error::Result<()> {
let (builder, inherent_data_providers) = new_full_start!(config); let para_id = crate::PARA_ID;
if polkadot_config.expect_chain_spec().is_kusama() {
sc_cli::run_service_until_exit(polkadot_config, |polkadot_config| {
parachain_config.task_executor = polkadot_config.task_executor.clone();
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
inherent_data_providers inherent_data_providers
.register_provider(sp_timestamp::InherentDataProvider) .register_provider(sp_timestamp::InherentDataProvider)
.unwrap(); .unwrap();
@@ -104,12 +118,51 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
block_import, block_import,
}; };
cumulus_collator::run_collator( let builder = CollatorBuilder::new(setup_parachain);
setup_parachain,
crate::PARA_ID, build_collator_service(
polkadot_service::kusama_new_full(polkadot_config, Some((key.public(), para_id)), None, false, 6000)?,
para_id,
key, key,
polkadot_config, builder,
) )
})
} else {
sc_cli::run_service_until_exit(polkadot_config, |polkadot_config| {
parachain_config.task_executor = polkadot_config.task_executor.clone();
let (builder, inherent_data_providers) = new_full_start!(parachain_config);
inherent_data_providers
.register_provider(sp_timestamp::InherentDataProvider)
.unwrap();
let service = builder
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
.build()?;
let proposer_factory = sc_basic_authorship::ProposerFactory {
client: service.client(),
transaction_pool: service.transaction_pool(),
};
let block_import = service.client();
let setup_parachain = SetupParachain {
service,
inherent_data_providers,
proposer_factory,
block_import,
};
let builder = CollatorBuilder::new(setup_parachain);
build_collator_service(
polkadot_service::polkadot_new_full(polkadot_config, Some((key.public(), para_id)), None, false, 6000)?,
para_id,
key,
builder,
)
})
}
} }
struct SetupParachain<S, PF, BI> { struct SetupParachain<S, PF, BI> {
@@ -0,0 +1,58 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use assert_cmd::cargo::cargo_bin;
use std::convert::TryInto;
use std::process::{Child, Command, ExitStatus};
use std::thread::sleep;
use std::time::Duration;
#[test]
#[cfg(unix)]
fn running_the_node_works_and_can_be_interrupted() {
use nix::sys::signal::{kill, Signal::{self, SIGINT, SIGTERM}};
use nix::unistd::Pid;
fn wait_for(child: &mut Child, secs: usize) -> Option<ExitStatus> {
for _ in 0..secs {
match child.try_wait().unwrap() {
Some(status) => return Some(status),
None => sleep(Duration::from_secs(1)),
}
}
eprintln!("Took to long to exit. Killing...");
let _ = child.kill();
child.wait().unwrap();
None
}
fn run_command_and_kill(signal: Signal) {
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator")).args(&["--dev", "-d", "interrupt_test"]).spawn().unwrap();
sleep(Duration::from_secs(30));
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
assert_eq!(
wait_for(&mut cmd, 30).map(|x| x.success()),
Some(true),
"the pocess must exit gracefully after signal {}",
signal,
);
}
run_command_and_kill(SIGINT);
run_command_and_kill(SIGTERM);
}
+1 -1
View File
@@ -7,7 +7,7 @@ build = "build.rs"
[dependencies] [dependencies]
runtime = { package = "cumulus-runtime", path = "../../runtime", default-features = false } runtime = { package = "cumulus-runtime", path = "../../runtime", default-features = false }
substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cumulus-branch" } substrate-test-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "cecton-cumulus-branch" }
[build-dependencies] [build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.2" } wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = " 1.0.2" }