Update to Substrate master (#311)

* Best effort to bring up to date.

* Fix the executor stuff

* Update verisons.

* Finish fixing

* Final fixes and warnings.

* add some docs and bump Wasm versions

* Fix tests

* Fix final test
This commit is contained in:
Gavin Wood
2019-07-04 17:15:59 +02:00
committed by GitHub
parent 6377974ed7
commit 29ee4e8f3a
24 changed files with 808 additions and 625 deletions
+10 -48
View File
@@ -19,9 +19,9 @@
use primitives::{ed25519, sr25519, Pair, crypto::UncheckedInto};
use polkadot_primitives::{AccountId, SessionKey};
use polkadot_runtime::{
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, TreasuryConfig, SystemConfig, AuraConfig,
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, SystemConfig, AuraConfig,
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill, SessionKeys,
GrandpaConfig, SudoConfig, IndicesConfig, Permill, CuratedGrandpaConfig, StakerStatus,
GrandpaConfig, SudoConfig, IndicesConfig, CuratedGrandpaConfig, StakerStatus,
};
use telemetry::TelemetryEndpoints;
use hex_literal::hex;
@@ -78,19 +78,13 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
system: Some(SystemConfig {
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
_genesis_phantom_data: Default::default(),
changes_trie_config: Default::default(),
}),
balances: Some(BalancesConfig {
transaction_base_fee: 1 * CENTS,
transaction_byte_fee: 10 * MILLICENTS,
balances: endowed_accounts.iter()
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect(),
existential_deposit: 1 * DOLLARS,
transfer_fee: 1 * CENTS,
creation_fee: 1 * CENTS,
vesting: vec![],
}),
indices: Some(IndicesConfig {
@@ -119,33 +113,18 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
democracy: Some(Default::default()),
council_seats: Some(CouncilSeatsConfig {
active_council: vec![],
candidacy_bond: 10 * DOLLARS,
voter_bond: 1 * DOLLARS,
voting_fee: 2 * DOLLARS,
present_slash_per_voter: 1 * CENTS,
carry_count: 6,
presentation_duration: 1 * DAYS,
approval_voting_period: 2 * DAYS,
term_duration: 28 * DAYS,
desired_seats: 0,
decay_ratio: 0,
inactive_grace_period: 1, // one additional vote should go by before an inactive voter can be reaped.
}),
timestamp: Some(TimestampConfig {
minimum_period: SECS_PER_BLOCK / 2, // due to the nature of aura the slots are 2*period
}),
treasury: Some(TreasuryConfig {
proposal_bond: Permill::from_percent(5),
proposal_bond_minimum: 1 * DOLLARS,
spend_period: 1 * DAYS,
burn: Permill::from_percent(50),
}),
sudo: Some(SudoConfig {
key: endowed_accounts[0].clone(),
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
_genesis_phantom_data: Default::default(),
}),
aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
@@ -226,18 +205,12 @@ pub fn testnet_genesis(
system: Some(SystemConfig {
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
_genesis_phantom_data: Default::default(),
changes_trie_config: Default::default(),
}),
indices: Some(IndicesConfig {
ids: endowed_accounts.clone(),
}),
balances: Some(BalancesConfig {
transaction_base_fee: 1,
transaction_byte_fee: 0,
existential_deposit: 500,
transfer_fee: 0,
creation_fee: 0,
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
vesting: vec![],
}),
@@ -256,42 +229,31 @@ pub fn testnet_genesis(
session_reward: Perbill::zero(),
current_session_reward: 0,
offline_slash_grace: 0,
stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
stakers: initial_authorities.iter()
.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(),
}),
democracy: Some(DemocracyConfig::default()),
council_seats: Some(CouncilSeatsConfig {
active_council: endowed_accounts.iter()
.filter(|&endowed| initial_authorities.iter().find(|&(_, controller, _)| controller == endowed).is_none())
.map(|a| (a.clone(), 1000000)).collect(),
candidacy_bond: 10,
voter_bond: 2,
voting_fee: 5,
present_slash_per_voter: 1,
carry_count: 4,
.filter(|&endowed| initial_authorities.iter()
.find(|&(_, controller, _)| controller == endowed)
.is_none()
).map(|a| (a.clone(), 1000000)).collect(),
presentation_duration: 10,
approval_voting_period: 20,
term_duration: 1000000,
desired_seats: (endowed_accounts.len() - initial_authorities.len()) as u32,
decay_ratio: council_desired_seats / 3,
inactive_grace_period: 1,
desired_seats: council_desired_seats,
}),
parachains: Some(Default::default()),
timestamp: Some(TimestampConfig {
minimum_period: 2, // 2*2=4 second block time.
}),
treasury: Some(TreasuryConfig {
proposal_bond: Permill::from_percent(5),
proposal_bond_minimum: 1_000_000,
spend_period: 12 * 60 * 24,
burn: Permill::from_percent(50),
}),
sudo: Some(SudoConfig {
key: root_key,
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
_genesis_phantom_data: Default::default(),
}),
aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
+9 -12
View File
@@ -26,7 +26,6 @@ use polkadot_primitives::{parachain, Block, Hash, BlockId};
use polkadot_runtime::{GenesisConfig, RuntimeApi};
use polkadot_network::gossip::{self as network_gossip, Known};
use primitives::{ed25519, Pair};
use tokio::runtime::TaskExecutor;
use service::{FactoryFullConfiguration, FullBackend, LightBackend, FullExecutor, LightExecutor};
use transaction_pool::txpool::{Pool as TransactionPool};
use aura::{import_queue, start_aura, AuraImportQueue, SlotDuration};
@@ -161,10 +160,10 @@ service::construct_service_factory! {
Genesis = GenesisConfig,
Configuration = CustomConfiguration,
FullService = FullComponents<Self>
{ |config: FactoryFullConfiguration<Self>, executor: TaskExecutor| {
FullComponents::<Factory>::new(config, executor)
{ |config: FactoryFullConfiguration<Self>| {
FullComponents::<Factory>::new(config)
} },
AuthoritySetup = { |mut service: Self::FullService, executor: TaskExecutor, key: Option<Arc<ed25519::Pair>>| {
AuthoritySetup = { |mut service: Self::FullService, key: Option<Arc<ed25519::Pair>>| {
use polkadot_network::validation::ValidationNetwork;
let (block_import, link_half) = service.config.custom.grandpa_import_setup.take()
@@ -188,7 +187,7 @@ service::construct_service_factory! {
match config.local_key {
None => {
executor.spawn(grandpa::run_grandpa_observer(
service.spawn_task(grandpa::run_grandpa_observer(
config,
link_half,
service.network(),
@@ -199,9 +198,7 @@ service::construct_service_factory! {
use service::TelemetryOnConnect;
let telemetry_on_connect = TelemetryOnConnect {
on_exit: Box::new(service.on_exit()),
telemetry_connection_sinks: service.telemetry_on_connect_stream(),
executor: &executor,
};
let grandpa_config = grandpa::GrandpaParams {
@@ -212,7 +209,7 @@ service::construct_service_factory! {
on_exit: service.on_exit(),
telemetry_on_connect: Some(telemetry_on_connect),
};
executor.spawn(grandpa::run_grandpa_voter(grandpa_config)?);
service.spawn_task(grandpa::run_grandpa_voter(grandpa_config)?);
},
}
}
@@ -280,7 +277,7 @@ service::construct_service_factory! {
service.on_exit(),
gossip_validator,
service.client(),
executor.clone(),
polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()),
);
let proposer_factory = ::consensus::ProposerFactory::new(
client.clone(),
@@ -288,7 +285,7 @@ service::construct_service_factory! {
validation_network.clone(),
validation_network,
service.transaction_pool(),
executor.clone(),
Arc::new(service.spawn_task_handle()),
key.clone(),
extrinsic_store,
SlotDuration::get_or_compute(&*client)?,
@@ -308,11 +305,11 @@ service::construct_service_factory! {
service.config.force_authoring,
)?;
executor.spawn(task);
service.spawn_task(task);
Ok(service)
}},
LightService = LightComponents<Self>
{ |config, executor| <LightComponents<Factory>>::new(config, executor) },
{ |config| <LightComponents<Factory>>::new(config) },
FullImportQueue = AuraImportQueue<
Self::Block,
>