Update polkadot and substrate (#71)

This commit is contained in:
Cecile Tonglet
2020-03-11 17:45:44 +01:00
committed by GitHub
parent b0c9cfb580
commit 28687351df
12 changed files with 2400 additions and 2401 deletions
+1
View File
@@ -37,6 +37,7 @@ sc-network = { git = "https://github.com/paritytech/substrate", branch = "cumulu
sc-client = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "cumulus-branch" }
# Cumulus dependencies
cumulus-consensus = { path = "../../consensus" }
File diff suppressed because one or more lines are too long
+1 -5
View File
@@ -171,7 +171,7 @@ impl frame_system::Trait for Runtime {
type ModuleToIndex = ModuleToIndex;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = Balances;
type OnKilledAccount = Balances;
}
parameter_types! {
@@ -303,10 +303,6 @@ impl_runtime_apis! {
Executive::apply_extrinsic(extrinsic)
}
fn apply_trusted_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
Executive::apply_trusted_extrinsic(extrinsic)
}
fn finalize_block() -> <Block as BlockT>::Header {
Executive::finalize_block()
}
+24 -23
View File
@@ -21,9 +21,8 @@ use std::sync::Arc;
use parachain_runtime::Block;
use sc_cli::{error, VersionInfo};
use sc_client::genesis;
use sc_service::{Configuration, Roles as ServiceRoles};
use sc_service::{Configuration, Roles as ServiceRoles, config::PrometheusConfig};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::{
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
@@ -37,23 +36,24 @@ use log::info;
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";
const DEFAULT_POLKADOT_PROMETHEUS_PORT: &'static str = "127.0.0.1:9616";
/// Parse command line arguments into service configuration.
pub fn run(version: VersionInfo) -> error::Result<()> {
pub fn run(version: sc_cli::VersionInfo) -> sc_cli::Result<()> {
let opt: Cli = sc_cli::from_args(&version);
let mut config = sc_service::Configuration::new(&version);
let mut polkadot_config = Configuration::new(&version);
let mut config = sc_service::Configuration::from_version(&version);
let mut polkadot_config = Configuration::from_version(&version);
match opt.subcommand {
Some(Subcommand::Base(subcommand)) => sc_cli::run_subcommand(
config,
subcommand,
load_spec,
|config: Configuration<_, _>| Ok(new_full_start!(config).0),
&version,
),
Some(Subcommand::Base(subcommand)) => {
subcommand.init(&version)?;
subcommand.update_config(&mut config, load_spec, &version)?;
subcommand.run(
config,
|config: Configuration<_, _>| Ok(new_full_start!(config).0),
)
},
Some(Subcommand::ExportGenesisState(params)) => {
sc_cli::init_logger("");
@@ -81,9 +81,8 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
Ok(())
},
None => {
sc_cli::init(&opt.run.shared_params, &version)?;
sc_cli::init_config(&mut config, &opt.run.shared_params, &version, load_spec)?;
sc_cli::update_config_for_running_node(&mut config, opt.run)?;
opt.run.init(&version)?;
opt.run.update_config(&mut config, load_spec, &version)?;
info!("{}", version.name);
info!(" version {}", config.full_version());
@@ -106,15 +105,17 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
polkadot_config.rpc_http = Some(DEFAULT_POLKADOT_RPC_HTTP.parse().unwrap());
polkadot_config.rpc_ws = Some(DEFAULT_POLKADOT_RPC_WS.parse().unwrap());
polkadot_config.grafana_port = Some(DEFAULT_POLKADOT_GRAFANA_PORT.parse().unwrap());
polkadot_config.prometheus_config = Some(
PrometheusConfig::new_with_default_registry(
DEFAULT_POLKADOT_PROMETHEUS_PORT.parse().unwrap(),
)
);
sc_cli::init_config(
polkadot_opt.run.update_config(
&mut polkadot_config,
&polkadot_opt.run.shared_params,
&version,
load_spec_polkadot,
&version,
)?;
sc_cli::update_config_for_running_node(&mut polkadot_config, polkadot_opt.run)?;
// TODO: we disable mdns for the polkadot node because it prevents the process to exit
// properly. See https://github.com/paritytech/cumulus/issues/57
@@ -133,11 +134,11 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
}
}
fn load_spec(_: &str) -> std::result::Result<Option<chain_spec::ChainSpec>, String> {
fn load_spec(_: &str) -> Result<Option<chain_spec::ChainSpec>, String> {
Ok(Some(chain_spec::get_chain_spec()))
}
fn load_spec_polkadot(_: &str) -> std::result::Result<Option<ChainSpecPolkadot>, String> {
fn load_spec_polkadot(_: &str) -> Result<Option<ChainSpecPolkadot>, String> {
Some(polkadot_service::ChainSpec::from_json_bytes(
&include_bytes!("../res/polkadot_chainspec.json")[..],
)).transpose()
+2 -4
View File
@@ -27,8 +27,6 @@ mod service;
mod cli;
mod command;
pub use sc_cli::{error, VersionInfo};
/// The parachain id of this parachain.
pub const PARA_ID: ParaId = ParaId::new(100);
const EXECUTABLE_NAME: &'static str = "cumulus-test-parachain-collator";
@@ -38,8 +36,8 @@ const DESCRIPTION: &'static str =
to the relaychain node.\n\n\
cumulus-test-parachain-collator [parachain-args] -- [relaychain-args]";
fn main() -> Result<(), error::Error> {
let version = VersionInfo {
fn main() -> sc_cli::Result<()> {
let version = sc_cli::VersionInfo {
name: "Cumulus Test Parachain Collator",
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
+12 -13
View File
@@ -16,11 +16,11 @@
use std::sync::Arc;
use parachain_runtime::{self, opaque::Block, GenesisConfig};
use parachain_runtime::{self, GenesisConfig};
use sc_executor::native_executor_instance;
use sc_network::construct_simple_protocol;
use sc_service::{AbstractService, Configuration};
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
use polkadot_primitives::parachain::CollatorPair;
@@ -37,11 +37,6 @@ native_executor_instance!(
parachain_runtime::native_version,
);
construct_simple_protocol! {
/// Demo protocol attachment for substrate.
pub struct NodeProtocol where Block = Block { }
}
/// Starts a `ServiceBuilder` for a full service.
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
@@ -82,7 +77,7 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
parachain_config: Configuration<GenesisConfig, E>,
key: Arc<CollatorPair>,
mut polkadot_config: polkadot_collator::Configuration,
) -> sc_cli::error::Result<()> {
) -> sc_cli::Result<()> {
sc_cli::run_service_until_exit(parachain_config, move |parachain_config| {
polkadot_config.task_executor = parachain_config.task_executor.clone();
@@ -92,13 +87,17 @@ pub fn run_collator<E: sc_service::ChainSpecExtension>(
.unwrap();
let service = builder
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
.with_finality_proof_provider(|client, backend| {
// GenesisAuthoritySetProvider is implemented for StorageAndProofProvider
let provider = client as Arc<dyn StorageAndProofProvider<_, _>>;
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, provider)) as _)
})?
.build()?;
let proposer_factory = sc_basic_authorship::ProposerFactory {
client: service.client(),
transaction_pool: service.transaction_pool(),
};
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
service.client(),
service.transaction_pool(),
);
let block_import = service.client();
let client = service.client();