Unverified Commit 419baeb5 authored by Bastian Köcher's avatar Bastian Köcher Committed by GitHub
Browse files

Update to latest Substrate master (#863)



* Begin to update to latest Substrate master

* Fix compilation

* Remove `Balances` from `OnKilledAccount`

* Update cli/src/command.rs
Co-Authored-By: default avatarCecile Tonglet <cecile@parity.io>

* Change gossip name

* Change again
Co-authored-by: default avatarCecile Tonglet <cecile.tonglet@cecton.com>
parent 36c71740
Pipeline #80989 passed with stages
in 21 minutes and 21 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -21,33 +21,28 @@ use sp_api::ConstructRuntimeApi; ...@@ -21,33 +21,28 @@ use sp_api::ConstructRuntimeApi;
use sc_executor::NativeExecutionDispatch; use sc_executor::NativeExecutionDispatch;
use crate::chain_spec::load_spec; use crate::chain_spec::load_spec;
use crate::cli::{Cli, Subcommand}; use crate::cli::{Cli, Subcommand};
use sc_cli::{VersionInfo, display_role, error}; use sc_cli::VersionInfo;
/// Parses polkadot specific CLI arguments and run the service. /// Parses polkadot specific CLI arguments and run the service.
pub fn run(version: VersionInfo) -> error::Result<()> { pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
let opt = sc_cli::from_args::<Cli>(&version); let opt = sc_cli::from_args::<Cli>(&version);
let mut config = service::Configuration::new(&version); let mut config = service::Configuration::from_version(&version);
config.impl_name = "parity-polkadot"; config.impl_name = "parity-polkadot";
match opt.subcommand { match opt.subcommand {
None => { None => {
sc_cli::init(&opt.run.shared_params, &version)?; opt.run.init(&version)?;
sc_cli::init_config(&mut config, &opt.run.shared_params, &version, load_spec)?; opt.run.update_config(&mut config, load_spec, &version)?;
let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama()); let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama());
sc_cli::update_config_for_running_node(
&mut config,
opt.run,
)?;
info!("{}", version.name); info!("{}", version.name);
info!(" version {}", config.full_version()); info!(" version {}", config.full_version());
info!(" by {}, 2017-2020", version.author); info!(" by {}, 2017-2020", version.author);
info!("Chain specification: {}", config.expect_chain_spec().name()); info!("Chain specification: {}", config.expect_chain_spec().name());
info!("Node name: {}", config.name); info!("Node name: {}", config.name);
info!("Roles: {}", display_role(&config)); info!("Roles: {}", config.display_role());
if is_kusama { if is_kusama {
info!("Native runtime: {}", service::KusamaExecutor::native_version().runtime_version); info!("Native runtime: {}", service::KusamaExecutor::native_version().runtime_version);
...@@ -73,8 +68,8 @@ pub fn run(version: VersionInfo) -> error::Result<()> { ...@@ -73,8 +68,8 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
} }
}, },
Some(Subcommand::Base(cmd)) => { Some(Subcommand::Base(cmd)) => {
sc_cli::init(cmd.get_shared_params(), &version)?; cmd.init(&version)?;
sc_cli::init_config(&mut config, &cmd.get_shared_params(), &version, load_spec)?; cmd.update_config(&mut config, load_spec, &version)?;
let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama()); let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama());
...@@ -96,7 +91,7 @@ pub fn run(version: VersionInfo) -> error::Result<()> { ...@@ -96,7 +91,7 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
sc_cli::init_logger(""); sc_cli::init_logger("");
if cfg!(feature = "browser") { if cfg!(feature = "browser") {
Err(error::Error::Input("Cannot run validation worker in browser".into())) Err(sc_cli::Error::Input("Cannot run validation worker in browser".into()))
} else { } else {
#[cfg(not(feature = "browser"))] #[cfg(not(feature = "browser"))]
service::run_validation_worker(&args.mem_id)?; service::run_validation_worker(&args.mem_id)?;
...@@ -109,7 +104,7 @@ pub fn run(version: VersionInfo) -> error::Result<()> { ...@@ -109,7 +104,7 @@ pub fn run(version: VersionInfo) -> error::Result<()> {
fn run_service_until_exit<R, D, E>( fn run_service_until_exit<R, D, E>(
config: service::Configuration, config: service::Configuration,
authority_discovery_enabled: bool, authority_discovery_enabled: bool,
) -> error::Result<()> ) -> sc_cli::Result<()>
where where
R: ConstructRuntimeApi<Block, service::TFullClient<Block, R, D>> R: ConstructRuntimeApi<Block, service::TFullClient<Block, R, D>>
+ Send + Sync + 'static, + Send + Sync + 'static,
......
...@@ -41,4 +41,4 @@ pub use command::*; ...@@ -41,4 +41,4 @@ pub use command::*;
pub use chain_spec::*; pub use chain_spec::*;
#[cfg(feature = "cli")] #[cfg(feature = "cli")]
pub use sc_cli::{VersionInfo, error}; pub use sc_cli::{VersionInfo, Error, Result};
...@@ -444,7 +444,7 @@ pub fn run_collator<P>( ...@@ -444,7 +444,7 @@ pub fn run_collator<P>(
para_id: ParaId, para_id: ParaId,
key: Arc<CollatorPair>, key: Arc<CollatorPair>,
config: Configuration, config: Configuration,
) -> polkadot_cli::error::Result<()> where ) -> polkadot_cli::Result<()> where
P: BuildParachainContext, P: BuildParachainContext,
P::ParachainContext: Send + 'static, P::ParachainContext: Send + 'static,
<P::ParachainContext as ParachainContext>::ProduceCandidate: Send, <P::ParachainContext as ParachainContext>::ProduceCandidate: Send,
......
...@@ -81,6 +81,7 @@ mod attestation; ...@@ -81,6 +81,7 @@ mod attestation;
/// The engine ID of the polkadot attestation system. /// The engine ID of the polkadot attestation system.
pub const POLKADOT_ENGINE_ID: sp_runtime::ConsensusEngineId = *b"dot1"; pub const POLKADOT_ENGINE_ID: sp_runtime::ConsensusEngineId = *b"dot1";
pub const POLKADOT_PROTOCOL_NAME: &[u8] = b"/polkadot/legacy/1";
// arbitrary; in practice this should not be more than 2. // arbitrary; in practice this should not be more than 2.
pub(crate) const MAX_CHAIN_HEADS: usize = 5; pub(crate) const MAX_CHAIN_HEADS: usize = 5;
...@@ -284,6 +285,7 @@ pub fn register_validator<C: ChainContext + 'static, S: NetworkSpecialization<Bl ...@@ -284,6 +285,7 @@ pub fn register_validator<C: ChainContext + 'static, S: NetworkSpecialization<Bl
let gossip_engine = sc_network_gossip::GossipEngine::new( let gossip_engine = sc_network_gossip::GossipEngine::new(
service.clone(), service.clone(),
POLKADOT_ENGINE_ID, POLKADOT_ENGINE_ID,
POLKADOT_PROTOCOL_NAME,
gossip_side, gossip_side,
); );
......
...@@ -324,7 +324,7 @@ mod tests { ...@@ -324,7 +324,7 @@ mod tests {
type ModuleToIndex = (); type ModuleToIndex = ();
type AccountData = balances::AccountData<u64>; type AccountData = balances::AccountData<u64>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = Balances; type OnKilledAccount = Balances;
} }
parameter_types! { parameter_types! {
...@@ -421,7 +421,7 @@ mod tests { ...@@ -421,7 +421,7 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim(Origin::NONE, 42, sig(&alice(), &42u64.encode()))); assert_ok!(Claims::claim(Origin::NONE, 42, sig(&alice(), &42u64.encode())));
assert_eq!(Balances::free_balance(&42), 100); assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(Vesting::vesting_balance(&42), 50); assert_eq!(Vesting::vesting_balance(&42), Some(50));
assert_eq!(Claims::total(), 0); assert_eq!(Claims::total(), 0);
}); });
} }
...@@ -436,13 +436,13 @@ mod tests { ...@@ -436,13 +436,13 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())), Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim,
); );
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None)); assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None));
assert_eq!(Claims::total(), 300); assert_eq!(Claims::total(), 300);
assert_ok!(Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode()))); assert_ok!(Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())));
assert_eq!(Balances::free_balance(&69), 200); assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(Vesting::vesting_balance(&69), 0); assert_eq!(Vesting::vesting_balance(&69), None);
assert_eq!(Claims::total(), 100); assert_eq!(Claims::total(), 100);
}); });
} }
...@@ -462,7 +462,7 @@ mod tests { ...@@ -462,7 +462,7 @@ mod tests {
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1)))); assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1))));
assert_ok!(Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode()))); assert_ok!(Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())));
assert_eq!(Balances::free_balance(&69), 200); assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(Vesting::vesting_balance(&69), 50); assert_eq!(Vesting::vesting_balance(&69), Some(50));
}); });
} }
...@@ -509,7 +509,7 @@ mod tests { ...@@ -509,7 +509,7 @@ mod tests {
// Everything should be unchanged // Everything should be unchanged
assert_eq!(Claims::total(), 300); assert_eq!(Claims::total(), 300);
assert_eq!(Balances::free_balance(69), 1000); assert_eq!(Balances::free_balance(69), 1000);
assert_eq!(Vesting::vesting_balance(&69), 1000); assert_eq!(Vesting::vesting_balance(&69), Some(1000));
}); });
} }
......
...@@ -616,7 +616,7 @@ mod tests { ...@@ -616,7 +616,7 @@ mod tests {
type ModuleToIndex = (); type ModuleToIndex = ();
type AccountData = balances::AccountData<u64>; type AccountData = balances::AccountData<u64>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = Balances; type OnKilledAccount = Balances;
} }
parameter_types! { parameter_types! {
pub const ExistentialDeposit: u64 = 1; pub const ExistentialDeposit: u64 = 1;
......
...@@ -939,7 +939,7 @@ mod tests { ...@@ -939,7 +939,7 @@ mod tests {
type ModuleToIndex = (); type ModuleToIndex = ();
type AccountData = balances::AccountData<u128>; type AccountData = balances::AccountData<u128>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = (); type OnKilledAccount = ();
} }
parameter_types! { parameter_types! {
...@@ -1118,7 +1118,7 @@ mod tests { ...@@ -1118,7 +1118,7 @@ mod tests {
// stashes are the index. // stashes are the index.
let session_keys: Vec<_> = authority_keys.iter().enumerate() let session_keys: Vec<_> = authority_keys.iter().enumerate()
.map(|(i, _k)| (i as u64, UintAuthorityId(i as u64))) .map(|(i, _k)| (i as u64, i as u64, UintAuthorityId(i as u64)))
.collect(); .collect();
let authorities: Vec<_> = authority_keys.iter().map(|k| ValidatorId::from(k.public())).collect(); let authorities: Vec<_> = authority_keys.iter().map(|k| ValidatorId::from(k.public())).collect();
......
...@@ -705,7 +705,7 @@ mod tests { ...@@ -705,7 +705,7 @@ mod tests {
type ModuleToIndex = (); type ModuleToIndex = ();
type AccountData = balances::AccountData<u128>; type AccountData = balances::AccountData<u128>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = Balances; type OnKilledAccount = Balances;
} }
parameter_types! { parameter_types! {
...@@ -827,7 +827,7 @@ mod tests { ...@@ -827,7 +827,7 @@ mod tests {
// stashes are the index. // stashes are the index.
let session_keys: Vec<_> = authority_keys.iter().enumerate() let session_keys: Vec<_> = authority_keys.iter().enumerate()
.map(|(i, _k)| (i as u64, UintAuthorityId(i as u64))) .map(|(i, _k)| (i as u64, i as u64, UintAuthorityId(i as u64)))
.collect(); .collect();
let authorities: Vec<_> = authority_keys.iter().map(|k| ValidatorId::from(k.public())).collect(); let authorities: Vec<_> = authority_keys.iter().map(|k| ValidatorId::from(k.public())).collect();
......
...@@ -917,7 +917,7 @@ mod tests { ...@@ -917,7 +917,7 @@ mod tests {
type ModuleToIndex = (); type ModuleToIndex = ();
type AccountData = balances::AccountData<u64>; type AccountData = balances::AccountData<u64>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = Balances; type OnKilledAccount = Balances;
} }
parameter_types! { parameter_types! {
......
...@@ -137,7 +137,7 @@ impl system::Trait for Runtime { ...@@ -137,7 +137,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ModuleToIndex; type ModuleToIndex = ModuleToIndex;
type AccountData = balances::AccountData<Balance>; type AccountData = balances::AccountData<Balance>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = (Balances, Staking, Session, Recovery, Democracy); type OnKilledAccount = ();
} }
parameter_types! { parameter_types! {
......
...@@ -145,7 +145,7 @@ impl system::Trait for Runtime { ...@@ -145,7 +145,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ModuleToIndex; type ModuleToIndex = ModuleToIndex;
type AccountData = balances::AccountData<Balance>; type AccountData = balances::AccountData<Balance>;
type OnNewAccount = (); type OnNewAccount = ();
type OnReapAccount = (Balances, Staking, Session, Democracy); type OnKilledAccount = ();
} }
parameter_types! { parameter_types! {
......
...@@ -175,6 +175,7 @@ fn staging_testnet_config_genesis() -> polkadot::GenesisConfig { ...@@ -175,6 +175,7 @@ fn staging_testnet_config_genesis() -> polkadot::GenesisConfig {
}), }),
session: Some(polkadot::SessionConfig { session: Some(polkadot::SessionConfig {
keys: initial_authorities.iter().map(|x| ( keys: initial_authorities.iter().map(|x| (
x.0.clone(),
x.0.clone(), x.0.clone(),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
)).collect::<Vec<_>>(), )).collect::<Vec<_>>(),
...@@ -318,6 +319,7 @@ pub fn testnet_genesis( ...@@ -318,6 +319,7 @@ pub fn testnet_genesis(
}), }),
session: Some(polkadot::SessionConfig { session: Some(polkadot::SessionConfig {
keys: initial_authorities.iter().map(|x| ( keys: initial_authorities.iter().map(|x| (
x.0.clone(),
x.0.clone(), x.0.clone(),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
)).collect::<Vec<_>>(), )).collect::<Vec<_>>(),
......
...@@ -161,7 +161,6 @@ macro_rules! new_full_start { ...@@ -161,7 +161,6 @@ macro_rules! new_full_start {
babe::Config::get_or_compute(&*client)?, babe::Config::get_or_compute(&*client)?,
grandpa_block_import, grandpa_block_import,
client.clone(), client.clone(),
client.clone(),
)?; )?;
let import_queue = babe::import_queue( let import_queue = babe::import_queue(
...@@ -169,7 +168,6 @@ macro_rules! new_full_start { ...@@ -169,7 +168,6 @@ macro_rules! new_full_start {
block_import.clone(), block_import.clone(),
Some(Box::new(justification_import)), Some(Box::new(justification_import)),
None, None,
client.clone(),
client, client,
inherent_data_providers.clone(), inherent_data_providers.clone(),
)?; )?;
...@@ -344,15 +342,14 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>( ...@@ -344,15 +342,14 @@ pub fn new_full<Runtime, Dispatch, Extrinsic>(
let mut path = PathBuf::from(db_path); let mut path = PathBuf::from(db_path);
path.push("availability"); path.push("availability");
let gossip = polkadot_network::legacy let gossip = polkadot_network::legacy::AvailabilityNetworkShim(gossip_validator.clone());
::AvailabilityNetworkShim(gossip_validator.clone());
#[cfg(not(target_os = "unknown"))] #[cfg(not(target_os = "unknown"))]
{ {
av_store::Store::new(::av_store::Config { av_store::Store::new(
cache_size: None, av_store::Config { cache_size: None, path },
path, gossip,
}, gossip)? )?
} }
#[cfg(target_os = "unknown")] #[cfg(target_os = "unknown")]
...@@ -604,7 +601,6 @@ where ...@@ -604,7 +601,6 @@ where
babe::Config::get_or_compute(&*client)?, babe::Config::get_or_compute(&*client)?,
grandpa_block_import, grandpa_block_import,
client.clone(), client.clone(),
client.clone(),
)?; )?;
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`. // FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
...@@ -613,7 +609,6 @@ where ...@@ -613,7 +609,6 @@ where
babe_block_import, babe_block_import,
None, None,
Some(Box::new(finality_proof_import)), Some(Box::new(finality_proof_import)),
client.clone(),
client, client,
inherent_data_providers.clone(), inherent_data_providers.clone(),
)?; )?;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
use cli::VersionInfo; use cli::VersionInfo;
fn main() -> Result<(), cli::error::Error> { fn main() -> Result<(), cli::Error> {
let version = VersionInfo { let version = VersionInfo {
name: "Parity Polkadot", name: "Parity Polkadot",
commit: env!("VERGEN_SHA_SHORT"), commit: env!("VERGEN_SHA_SHORT"),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment