Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Upgrade Substrate & Polkadot #612

Merged
merged 1 commit into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
538 changes: 246 additions & 292 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ impl sc_cli::CliConfiguration for NormalizedRunCmd {
self.base.rpc_ws_max_connections()
}

fn rpc_http_threads(&self) -> sc_cli::Result<Option<usize>> {
self.base.rpc_http_threads()
}

fn rpc_cors(&self, is_dev: bool) -> sc_cli::Result<Option<Vec<String>>> {
self.base.rpc_cors(is_dev)
}
Expand Down
14 changes: 7 additions & 7 deletions client/network/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
use cumulus_primitives_core::ParaId;
use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*};
use futures::join;
use sc_service::TaskExecutor;

#[substrate_test_utils::test]
#[ignore]
async fn sync_blocks_from_tip_without_being_connected_to_a_collator(task_executor: TaskExecutor) {
async fn sync_blocks_from_tip_without_being_connected_to_a_collator() {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
let _ = builder.init();

let para_id = ParaId::from(100);
let tokio_handle = tokio::runtime::Handle::current();

// start alice
let alice = run_relay_chain_validator_node(task_executor.clone(), Alice, || {}, vec![]);
let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, vec![]);

// start bob
let bob =
run_relay_chain_validator_node(task_executor.clone(), Bob, || {}, vec![alice.addr.clone()]);
run_relay_chain_validator_node(tokio_handle.clone(), Bob, || {}, vec![alice.addr.clone()]);

// register parachain
alice
Expand All @@ -49,21 +49,21 @@ async fn sync_blocks_from_tip_without_being_connected_to_a_collator(task_executo

// run charlie as parachain collator
let charlie =
cumulus_test_service::TestNodeBuilder::new(para_id, task_executor.clone(), Charlie)
cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Charlie)
.enable_collator()
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.build()
.await;

// run dave as parachain full node
let dave = cumulus_test_service::TestNodeBuilder::new(para_id, task_executor.clone(), Dave)
let dave = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Dave)
.connect_to_parachain_node(&charlie)
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.build()
.await;

// run eve as parachain full node that is only connected to dave
let eve = cumulus_test_service::TestNodeBuilder::new(para_id, task_executor.clone(), Eve)
let eve = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, Eve)
.connect_to_parachain_node(&dave)
.exclusively_connect_to_registered_parachain_nodes()
.connect_to_relay_chain_nodes(vec![&alice, &bob])
Expand Down
12 changes: 6 additions & 6 deletions client/pov-recovery/tests/pov_recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use cumulus_primitives_core::ParaId;
use cumulus_test_service::{initial_head_data, Keyring::*};
use futures::join;
use sc_service::TaskExecutor;
use std::sync::Arc;

/// Tests the PoV recovery.
Expand All @@ -27,24 +26,25 @@ use std::sync::Arc;
/// recover the block, import it and share it with the other nodes of the parachain network.
#[substrate_test_utils::test]
#[ignore]
async fn pov_recovery(task_executor: TaskExecutor) {
async fn pov_recovery() {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
let _ = builder.init();

let para_id = ParaId::from(100);
let tokio_handle = tokio::runtime::Handle::current();

// Start alice
let alice = cumulus_test_service::run_relay_chain_validator_node(
task_executor.clone(),
tokio_handle.clone(),
Alice,
|| {},
vec![],
);

// Start bob
let bob = cumulus_test_service::run_relay_chain_validator_node(
task_executor.clone(),
tokio_handle.clone(),
Bob,
|| {},
vec![alice.addr.clone()],
Expand All @@ -64,7 +64,7 @@ async fn pov_recovery(task_executor: TaskExecutor) {

// Run charlie as parachain collator
let charlie =
cumulus_test_service::TestNodeBuilder::new(para_id, task_executor.clone(), Charlie)
cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Charlie)
.enable_collator()
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.wrap_announce_block(|_| {
Expand All @@ -77,7 +77,7 @@ async fn pov_recovery(task_executor: TaskExecutor) {
// Run dave as parachain full node
//
// It will need to recover the pov blocks through availability recovery.
let dave = cumulus_test_service::TestNodeBuilder::new(para_id, task_executor, Dave)
let dave = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, Dave)
.enable_collator()
.use_null_consensus()
.connect_to_parachain_node(&charlie)
Expand Down
59 changes: 26 additions & 33 deletions polkadot-parachains/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{
StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor, new_partial,
RococoParachainRuntimeExecutor, ShellRuntimeExecutor, Block,
new_partial, Block, RococoParachainRuntimeExecutor, ShellRuntimeExecutor,
StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor,
},
};
use codec::Encode;
Expand Down Expand Up @@ -327,7 +327,7 @@ pub fn run() -> Result<()> {
let polkadot_config = SubstrateCli::create_configuration(
&polkadot_cli,
&polkadot_cli,
config.task_executor.clone(),
config.tokio_handle.clone(),
)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

Expand Down Expand Up @@ -423,9 +423,9 @@ pub fn run() -> Result<()> {
generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?;
let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));

let task_executor = config.task_executor.clone();
let tokio_handle = config.tokio_handle.clone();
let polkadot_config =
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)
SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, tokio_handle)
.map_err(|err| format!("Relay chain argument error: {}", err))?;

info!("Parachain id: {:?}", id);
Expand All @@ -441,32 +441,29 @@ pub fn run() -> Result<()> {
);

if config.chain_spec.is_statemint() {
crate::service::start_statemint_node::<statemint_runtime::RuntimeApi, StatemintRuntimeExecutor>(
config,
polkadot_config,
id,
)
.await
.map(|r| r.0)
.map_err(Into::into)
crate::service::start_statemint_node::<
statemint_runtime::RuntimeApi,
StatemintRuntimeExecutor,
>(config, polkadot_config, id)
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_statemine() {
crate::service::start_statemint_node::<statemine_runtime::RuntimeApi, StatemineRuntimeExecutor>(
config,
polkadot_config,
id,
)
.await
.map(|r| r.0)
.map_err(Into::into)
crate::service::start_statemint_node::<
statemine_runtime::RuntimeApi,
StatemineRuntimeExecutor,
>(config, polkadot_config, id)
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_westmint() {
crate::service::start_statemint_node::<westmint_runtime::RuntimeApi, WestmintRuntimeExecutor>(
config,
polkadot_config,
id,
)
.await
.map(|r| r.0)
.map_err(Into::into)
crate::service::start_statemint_node::<
westmint_runtime::RuntimeApi,
WestmintRuntimeExecutor,
>(config, polkadot_config, id)
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_shell() {
crate::service::start_shell_node(config, polkadot_config, id)
.await
Expand Down Expand Up @@ -575,10 +572,6 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_ws_max_connections()
}

fn rpc_http_threads(&self) -> Result<Option<usize>> {
self.base.base.rpc_http_threads()
}

fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {
self.base.base.rpc_cors(is_dev)
}
Expand Down
2 changes: 1 addition & 1 deletion test/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0" }
rand = "0.7.3"
serde = { version = "1.0.101", features = ["derive"] }
async-trait = "0.1.42"
tokio = { version = "1.10", features = ["macros"] }

# Substrate
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down Expand Up @@ -53,7 +54,6 @@ jsonrpc-core = "18.0.0"

[dev-dependencies]
futures = "0.3.5"
tokio = { version = "1.10", features = ["macros"] }

# Polkadot dependencies
polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch = "master" }
Expand Down
21 changes: 10 additions & 11 deletions test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use sc_service::{
OffchainWorkerConfig, PruningMode, TransactionStorageMode, WasmExecutionMethod,
},
BasePath, ChainSpec, Configuration, Error as ServiceError, PartialComponents, Role,
RpcHandlers, TFullBackend, TFullClient, TaskExecutor, TaskManager,
RpcHandlers, TFullBackend, TFullClient, TaskManager,
};
use sp_arithmetic::traits::SaturatedConversion;
use sp_blockchain::HeaderBackend;
Expand Down Expand Up @@ -375,7 +375,7 @@ enum Consensus {
/// A builder to create a [`TestNode`].
pub struct TestNodeBuilder {
para_id: ParaId,
task_executor: TaskExecutor,
tokio_handle: tokio::runtime::Handle,
key: Sr25519Keyring,
collator_key: Option<CollatorPair>,
parachain_nodes: Vec<MultiaddrWithPeerId>,
Expand All @@ -393,11 +393,11 @@ impl TestNodeBuilder {
/// `para_id` - The parachain id this node is running for.
/// `task_executor` - The task executor to use.
/// `key` - The key that will be used to generate the name and that will be passed as `dev_seed`.
pub fn new(para_id: ParaId, task_executor: TaskExecutor, key: Sr25519Keyring) -> Self {
pub fn new(para_id: ParaId, tokio_handle: tokio::runtime::Handle, key: Sr25519Keyring) -> Self {
TestNodeBuilder {
key,
para_id,
task_executor,
tokio_handle,
collator_key: None,
parachain_nodes: Vec::new(),
parachain_nodes_exclusive: false,
Expand Down Expand Up @@ -503,7 +503,7 @@ impl TestNodeBuilder {
let parachain_config = node_config(
self.storage_update_func_parachain
.unwrap_or_else(|| Box::new(|| ())),
self.task_executor.clone(),
self.tokio_handle.clone(),
self.key.clone(),
self.parachain_nodes,
self.parachain_nodes_exclusive,
Expand All @@ -514,7 +514,7 @@ impl TestNodeBuilder {
let mut relay_chain_config = polkadot_test_service::node_config(
self.storage_update_func_relay_chain
.unwrap_or_else(|| Box::new(|| ())),
self.task_executor,
self.tokio_handle,
self.key,
self.relay_chain_nodes,
false,
Expand Down Expand Up @@ -557,7 +557,7 @@ impl TestNodeBuilder {
/// adjustments to the runtime genesis.
pub fn node_config(
storage_update_func: impl Fn(),
task_executor: TaskExecutor,
tokio_handle: tokio::runtime::Handle,
key: Sr25519Keyring,
nodes: Vec<MultiaddrWithPeerId>,
nodes_exlusive: bool,
Expand Down Expand Up @@ -609,7 +609,7 @@ pub fn node_config(
impl_name: "cumulus-test-node".to_string(),
impl_version: "0.1".to_string(),
role,
task_executor,
tokio_handle,
transaction_pool: Default::default(),
network: network_config,
keystore: KeystoreConfig::InMemory,
Expand Down Expand Up @@ -637,7 +637,6 @@ pub fn node_config(
rpc_ws: None,
rpc_ipc: None,
rpc_ws_max_connections: None,
rpc_http_threads: None,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
Expand Down Expand Up @@ -747,13 +746,13 @@ pub fn construct_extrinsic(
/// This is essentially a wrapper around
/// [`run_validator_node`](polkadot_test_service::run_validator_node).
pub fn run_relay_chain_validator_node(
task_executor: TaskExecutor,
tokio_handle: tokio::runtime::Handle,
key: Sr25519Keyring,
storage_update_func: impl Fn(),
boot_nodes: Vec<MultiaddrWithPeerId>,
) -> polkadot_test_service::PolkadotTestNode {
polkadot_test_service::run_validator_node(
task_executor,
tokio_handle,
key,
storage_update_func,
boot_nodes,
Expand Down
13 changes: 7 additions & 6 deletions test/service/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
use cumulus_primitives_core::ParaId;
use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*};
use futures::join;
use sc_service::TaskExecutor;

#[substrate_test_utils::test]
#[ignore]
async fn test_collating_and_non_collator_mode_catching_up(task_executor: TaskExecutor) {
async fn test_collating_and_non_collator_mode_catching_up() {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
let _ = builder.init();

let para_id = ParaId::from(100);

let tokio_handle = tokio::runtime::Handle::current();

// start alice
let alice = run_relay_chain_validator_node(task_executor.clone(), Alice, || {}, vec![]);
let alice = run_relay_chain_validator_node(tokio_handle.clone(), Alice, || {}, vec![]);

// start bob
let bob =
run_relay_chain_validator_node(task_executor.clone(), Bob, || {}, vec![alice.addr.clone()]);
run_relay_chain_validator_node(tokio_handle.clone(), Bob, || {}, vec![alice.addr.clone()]);

// register parachain
alice
Expand All @@ -49,15 +50,15 @@ async fn test_collating_and_non_collator_mode_catching_up(task_executor: TaskExe

// run cumulus charlie (a parachain collator)
let charlie =
cumulus_test_service::TestNodeBuilder::new(para_id, task_executor.clone(), Charlie)
cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Charlie)
.enable_collator()
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.build()
.await;
charlie.wait_for_blocks(5).await;

// run cumulus dave (a parachain full node) and wait for it to sync some blocks
let dave = cumulus_test_service::TestNodeBuilder::new(para_id, task_executor.clone(), Dave)
let dave = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, Dave)
.connect_to_parachain_node(&charlie)
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.build()
Expand Down
Loading