Skip to content

Commit

Permalink
Polkadot 0.9.1 support (#151)
Browse files Browse the repository at this point in the history
* Bump cumulus/polkadot/substrate to 0.9.1

* Fix compilation

* Updated specs

* Bump version

* Fix code formatting

* Update rococo_local_testnet spec

* Added timestamp inherent provider for parachain

* Bump to latest cumulus

* Build fixes

* Updated specs

Co-authored-by: Pavel Sheremetev <[email protected]>
  • Loading branch information
akru and Pavel Sheremetev authored May 19, 2021
1 parent 8659e2a commit 30d261b
Show file tree
Hide file tree
Showing 28 changed files with 2,798 additions and 2,365 deletions.
3,726 changes: 2,045 additions & 1,681 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "robonomics"
version = "0.28.2"
version = "0.29.0"
authors = ["Airalab <[email protected]>"]
description = "Robonomics node implementation in Rust & Substrate."
edition = "2018"
Expand Down
112 changes: 58 additions & 54 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "node-cli"
version = "0.28.2"
version = "0.29.0"
authors = ["Airalab <[email protected]>"]
description = "Robonomics node console line interface."
build = "build.rs"
Expand All @@ -19,70 +19,73 @@ log = "0.4"

# primitives
node-primitives = { path = "../primitives", default-features = false }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }

# client dependencies
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", default-features = false }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-finality-grandpa-warp-sync = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-consensus-uncles = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-informant = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", default-features = false }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-finality-grandpa-warp-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }

# frame dependencies
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", optional = true }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", optional = true }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
pallet-robonomics-lighthouse = { path = "../../../robonomics/frame/lighthouse", optional = true }

# cumulus dependencies
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1", optional = true }
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1", optional = true }
cumulus-client-collator = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1", optional = true }
cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1", optional = true }
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "rococo-v1", optional = true }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1", optional = true }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1", optional = true }
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1", optional = true }
cumulus-client-collator = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1", optional = true }
cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1", optional = true }
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.1", optional = true }

# polkadot dependencies
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", optional = true }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", optional = true }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", optional = true }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", optional = true }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.1", optional = true }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.1", optional = true }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.1", optional = true }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.1", optional = true }

# node-specific dependencies
node-rpc = { path = "../rpc", optional = true }
node-runtime = { path = "../runtime", optional = true }
parachain-runtime = { path = "../runtime/parachain", optional = true }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }

# CLI-specific dependencies
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", optional = true }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", optional = true }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", optional = true }

# Robonomics-specific dependencies
rosrust = { version = "0.9.5", optional = true }
Expand All @@ -91,11 +94,11 @@ robonomics-cli = { path = "../../../robonomics/cli", optional = true }

[build-dependencies]
node-runtime = { path = "../runtime", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", optional = true }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "rococo-v1", optional = true }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1", optional = true }
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "rococo-v1" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", optional = true }
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.1", optional = true }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1", optional = true }
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.1" }
robonomics-cli = { path = "../../../robonomics/cli", optional = true }
vergen = { version = "3.1.0", optional = true }
structopt = { version = "0.3.8", optional = true }
Expand Down Expand Up @@ -141,6 +144,7 @@ parachain = [
"parachain-runtime",
"pallet-robonomics-lighthouse",
"cumulus-primitives-core",
"cumulus-primitives-parachain-inherent",
"cumulus-client-consensus-relay-chain",
"cumulus-client-collator",
"cumulus-client-network",
Expand Down
17 changes: 7 additions & 10 deletions bin/node/cli/res/earth.json

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions bin/node/cli/res/mars.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions bin/node/cli/res/rococo.json

Large diffs are not rendered by default.

572 changes: 403 additions & 169 deletions bin/node/cli/res/rococo_local_testnet.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bin/node/cli/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ pub fn new_partial(
>,
sc_service::Error,
> {
let inherent_data_providers = sp_inherents::InherentDataProviders::new();

let telemetry = config
.telemetry_endpoints
.clone()
Expand Down Expand Up @@ -87,7 +85,10 @@ pub fn new_partial(
let import_queue = cumulus_client_consensus_relay_chain::import_queue(
client.clone(),
client.clone(),
inherent_data_providers.clone(),
|_, _| async {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
Ok(timestamp)
},
&task_manager.spawn_essential_handle(),
registry.clone(),
)?;
Expand All @@ -99,7 +100,6 @@ pub fn new_partial(
keystore_container,
task_manager,
transaction_pool,
inherent_data_providers,
select_chain: (),
other: (telemetry, telemetry_worker_handle),
};
Expand Down
57 changes: 33 additions & 24 deletions bin/node/cli/src/parachain/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use cumulus_client_network::build_block_announce_validator;
use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
};
use cumulus_primitives_parachain_inherent::ParachainInherentData;
use node_primitives::Block;
use polkadot_primitives::v0::CollatorPair;
use sc_service::{Configuration, Role, TFullClient, TaskManager};
Expand All @@ -48,13 +49,9 @@ async fn start_node_impl(
let parachain_config = prepare_node_config(parachain_config);

let params = new_partial(&parachain_config)?;
params
.inherent_data_providers
.register_provider(sp_timestamp::InherentDataProvider)
.unwrap();

let (mut telemetry, telemetry_worker_handle) = params.other;
let polkadot_full_node = cumulus_client_service::build_polkadot_full_node(
let relay_chain_full_node = cumulus_client_service::build_polkadot_full_node(
polkadot_config,
collator_key.clone(),
telemetry_worker_handle,
Expand All @@ -67,10 +64,10 @@ async fn start_node_impl(
let client = params.client.clone();
let backend = params.backend.clone();
let block_announce_validator = build_block_announce_validator(
polkadot_full_node.client.clone(),
relay_chain_full_node.client.clone(),
id,
Box::new(polkadot_full_node.network.clone()),
polkadot_full_node.backend.clone(),
Box::new(relay_chain_full_node.network.clone()),
relay_chain_full_node.backend.clone(),
);

let prometheus_registry = parachain_config.prometheus_registry().cloned();
Expand Down Expand Up @@ -110,42 +107,54 @@ async fn start_node_impl(
};

if let Some(account) = validator_account {
let account_data = Vec::from(account.as_ref());
params
.inherent_data_providers
.register_provider(pallet_robonomics_lighthouse::InherentDataProvider(
account_data,
))
.unwrap();

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry.as_ref(),
telemetry.as_ref().map(|x| x.handle()),
);
let spawner = task_manager.spawn_handle();

let relay_chain_backend = relay_chain_full_node.backend.clone();
let relay_chain_client = relay_chain_full_node.client.clone();
let parachain_consensus = build_relay_chain_consensus(BuildRelayChainConsensusParams {
para_id: id,
proposer_factory,
inherent_data_providers: params.inherent_data_providers,
block_import: client.clone(),
relay_chain_client: polkadot_full_node.client.clone(),
relay_chain_backend: polkadot_full_node.backend.clone(),
relay_chain_client: relay_chain_full_node.client.clone(),
relay_chain_backend: relay_chain_full_node.backend.clone(),
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
let parachain_inherent = ParachainInherentData::create_at_with_client(
relay_parent,
&relay_chain_client,
&*relay_chain_backend,
&validation_data,
id,
);
async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let lighthouse = pallet_robonomics_lighthouse::InherentDataProvider(Vec::from(
account.as_ref(),
));
let parachain = parachain_inherent.ok_or_else(|| {
Box::<dyn std::error::Error + Send + Sync>::from(
"Failed to create parachain inherent",
)
})?;
Ok((timestamp, lighthouse, parachain))
}
},
});

let spawner = task_manager.spawn_handle();
let params = StartCollatorParams {
para_id: id,
block_status: client.clone(),
announce_block,
client: client.clone(),
task_manager: &mut task_manager,
collator_key,
relay_chain_full_node: polkadot_full_node,
relay_chain_full_node,
spawner,
backend,
parachain_consensus,
};

Expand All @@ -156,7 +165,7 @@ async fn start_node_impl(
announce_block,
task_manager: &mut task_manager,
para_id: id,
polkadot_full_node,
polkadot_full_node: relay_chain_full_node,
};

start_full_node(params)?;
Expand Down
Loading

0 comments on commit 30d261b

Please sign in to comment.