Upgrade Substrate & Polkadot (#612)

This commit is contained in:
Bastian Köcher
2021-09-16 06:57:29 +02:00
committed by GitHub
parent b48592ac8b
commit 7364a773ef
9 changed files with 309 additions and 366 deletions
+246 -292
View File
File diff suppressed because it is too large Load Diff
-4
View File
@@ -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)
}
+7 -7
View File
@@ -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
@@ -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])
@@ -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.
@@ -27,16 +26,17 @@ 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![],
@@ -44,7 +44,7 @@ async fn pov_recovery(task_executor: TaskExecutor) {
// Start bob
let bob = cumulus_test_service::run_relay_chain_validator_node(
task_executor.clone(),
tokio_handle.clone(),
Bob,
|| {},
vec![alice.addr.clone()],
@@ -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(|_| {
@@ -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)
+26 -33
View File
@@ -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;
@@ -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))?;
@@ -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);
@@ -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
@@ -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)
}
+1 -1
View File
@@ -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" }
@@ -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" }
+10 -11
View File
@@ -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;
@@ -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>,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
+7 -6
View File
@@ -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
@@ -49,7 +50,7 @@ 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()
@@ -57,7 +58,7 @@ async fn test_collating_and_non_collator_mode_catching_up(task_executor: TaskExe
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()
@@ -17,25 +17,25 @@
use cumulus_primitives_core::ParaId;
use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*};
use futures::{join, StreamExt};
use sc_service::TaskExecutor;
use sp_runtime::generic::BlockId;
use sc_client_api::BlockchainEvents;
#[substrate_test_utils::test]
#[ignore]
async fn test_runtime_upgrade(task_executor: TaskExecutor) {
async fn test_runtime_upgrade() {
let mut builder = sc_cli::LoggerBuilder::new("runtime=debug");
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
@@ -51,14 +51,14 @@ async fn test_runtime_upgrade(task_executor: TaskExecutor) {
// 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;
// run cumulus dave (a 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, Dave)
.connect_to_parachain_node(&charlie)
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.build()