Update to latest Polkadot & Substrate (#75)

* Start fixing compilation errors

* Switch to git version of `WasmBuilder`

* Fix compilation

* More updates

* Adapt to latest Substrate/Polkadot changes
This commit is contained in:
Bastian Köcher
2020-04-06 21:55:32 +02:00
committed by GitHub
parent f54a6e8b4d
commit d4562c3a48
14 changed files with 2176 additions and 1881 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch", version = "0.8.0-alpha.5" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
fn main() {
WasmBuilder::new()
.with_current_project()
.with_wasm_builder_from_crates("1.0.9")
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "0b30207969fdde85e0dad785750757399cd0e3e4")
.export_heap_base()
.import_memory()
.build()
+8 -6
View File
@@ -24,11 +24,10 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, ConvertInto, StaticLookup, Verify,
};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, ConvertInto, StaticLookup, Verify};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, transaction_validity::TransactionValidity,
create_runtime_str, generic, impl_opaque_keys,
transaction_validity::{TransactionSource, TransactionValidity},
AnySignature, ApplyExtrinsicResult,
};
use sp_std::prelude::*;
@@ -321,8 +320,11 @@ impl_runtime_apis! {
}
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
fn validate_transaction(
source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
) -> TransactionValidity {
Executive::validate_transaction(source, tx)
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ use sc_service;
use sp_core::{Pair, Public};
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::ChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
+12 -13
View File
@@ -22,14 +22,13 @@ use std::sync::Arc;
use parachain_runtime::Block;
use sc_client::genesis;
use sc_service::{Configuration, Roles as ServiceRoles, config::PrometheusConfig};
use sc_service::{Configuration, Role as ServiceRole, config::PrometheusConfig};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
BuildStorage,
};
use sc_network::config::TransportConfig;
use polkadot_service::ChainSpec as ChainSpecPolkadot;
use codec::Encode;
use log::info;
@@ -51,7 +50,7 @@ pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
subcommand.update_config(&mut config, load_spec, &version)?;
subcommand.run(
config,
|config: Configuration<_, _>| Ok(new_full_start!(config).0),
|config: Configuration| Ok(new_full_start!(config).0),
)
},
Some(Subcommand::ExportGenesisState(params)) => {
@@ -89,7 +88,7 @@ pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
info!(" by {}, 2019", version.author);
info!("Chain specification: {}", config.expect_chain_spec().name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
info!("Roles: {:?}", config.role);
info!("Parachain id: {:?}", crate::PARA_ID);
// TODO
@@ -101,7 +100,7 @@ pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
[version.executable_name.to_string()].iter().chain(opt.relaychain_args.iter()),
&version,
);
let allow_private_ipv4 = !polkadot_opt.run.network_config.no_private_ipv4;
let allow_private_ipv4 = !polkadot_opt.run.base.network_config.no_private_ipv4;
polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
polkadot_config.rpc_ws = Some(DEFAULT_POLKADOT_RPC_WS.parse().unwrap());
@@ -111,7 +110,7 @@ pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
)
);
polkadot_opt.run.update_config(
polkadot_opt.run.base.update_config(
&mut polkadot_config,
load_spec_polkadot,
&version,
@@ -126,20 +125,20 @@ pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
use_yamux_flow_control: false,
};
match config.roles {
ServiceRoles::LIGHT => unimplemented!("Light client not supported!"),
match config.role {
ServiceRole::Light => unimplemented!("Light client not supported!"),
_ => crate::service::run_collator(config, key, polkadot_config),
}
},
}
}
fn load_spec(_: &str) -> Result<Option<chain_spec::ChainSpec>, String> {
Ok(Some(chain_spec::get_chain_spec()))
fn load_spec(_: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(Box::new(chain_spec::get_chain_spec()))
}
fn load_spec_polkadot(_: &str) -> Result<Option<ChainSpecPolkadot>, String> {
Some(polkadot_service::ChainSpec::from_json_bytes(
fn load_spec_polkadot(_: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
polkadot_service::PolkadotChainSpec::from_json_bytes(
&include_bytes!("../res/polkadot_chainspec.json")[..],
)).transpose()
).map(|r| Box::new(r) as Box<_>)
}
+2 -4
View File
@@ -16,8 +16,6 @@
use std::sync::Arc;
use parachain_runtime::{self, GenesisConfig};
use sc_executor::native_executor_instance;
use sc_service::{AbstractService, Configuration};
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
@@ -73,8 +71,8 @@ macro_rules! new_full_start {
/// 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>(
parachain_config: Configuration<GenesisConfig, E>,
pub fn run_collator(
parachain_config: Configuration,
key: Arc<CollatorPair>,
mut polkadot_config: polkadot_collator::Configuration,
) -> sc_cli::Result<()> {
@@ -15,30 +15,39 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use assert_cmd::cargo::cargo_bin;
use std::{convert::TryInto, process::Command, thread, time::Duration, fs};
use std::{convert::TryInto, fs, process::Command, thread, time::Duration};
mod common;
#[test]
#[cfg(unix)]
fn polkadot_argument_parsing() {
use nix::sys::signal::{kill, Signal::{self, SIGINT, SIGTERM}};
use nix::sys::signal::{
kill,
Signal::{self, SIGINT, SIGTERM},
};
use nix::unistd::Pid;
fn run_command_and_kill(signal: Signal) {
let _ = fs::remove_dir_all("polkadot_argument_parsing");
let mut cmd = Command::new(cargo_bin("cumulus-test-parachain-collator"))
.args(&[
"-d", "polkadot_argument_parsing", "--", "--bootnodes",
"-d",
"polkadot_argument_parsing",
"--",
"--bootnodes",
"/ip4/127.0.0.1/tcp/30333/p2p/Qmbx43psh7LVkrYTRXisUpzCubbgYojkejzAgj5mteDnxy",
"--bootnodes",
"/ip4/127.0.0.1/tcp/50500/p2p/Qma6SpS7tzfCrhtgEVKR9Uhjmuv55ovC3kY6y6rPBxpWd",
"/ip4/127.0.0.1/tcp/50500/p2p/Qma6SpS7tzfCrhtgEVKR9Uhjmuv55ovC3kY6y6rPBxpWde",
])
.spawn()
.unwrap();
thread::sleep(Duration::from_secs(20));
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
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!(
common::wait_for(&mut cmd, 30).map(|x| x.success()),