Unverified Commit e3a3906b authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Update Substrate (#623)

* Update to latest Substrate master (#615)

* Update to latest Substrate master

* Remove unneeded patch + warning

* Update `Cargo.lock`

* Fix tests

* Update again

* Bump Substrate (#616)

* Update lock

* Fix

* Few fixes

* Bump to latest Substrate

* Fixes

* fix pre-tx-pool compilation

* more compilation fixes

* Updates for the injection period

- Liberal slash-refunding
- Instant unbonding

* *: Enable refactored authority discovery (#624)

* *: Enable authority discovery module

* *: List authority discovery id after parachain validator id

Make sure existing key types don't change their order by appending the
authority discovery id instead of injecting it between im online id and
parachain validator id.

* *: Gate authority discovery module behind feature flag

* cli/src/lib.rs: Fix warnings

* cli/src/lib.rs: Shorten line length

* Bump Substrate

* Bump Substrate

* Line widths

* Line widths again

* Revert bump.
parent fba836e6
Pipeline #70398 passed with stages
in 27 minutes and 5 seconds
[package]
name = "polkadot-runtime"
version = "0.6.17"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......@@ -27,7 +27,7 @@ substrate-primitives = { git = "https://github.com/paritytech/substrate", defaul
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
substrate-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
tx-pool-api = { package = "substrate-transaction-pool-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
tx-pool-api = { package = "sp-transaction-pool-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
block-builder-api = { package = "substrate-block-builder-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authority-discovery = { package = "pallet-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
......
......@@ -53,6 +53,7 @@ use frame_support::{
weights::{Weight, DispatchInfo},
};
use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use system::offchain::TransactionSubmitter;
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
......@@ -96,7 +97,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 1019,
spec_version: 1020,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};
......@@ -258,6 +259,7 @@ impl_opaque_keys! {
pub babe: Babe,
pub im_online: ImOnline,
pub parachain_validator: Parachains,
pub authority_discovery: AuthorityDiscovery,
}
}
......@@ -298,7 +300,9 @@ parameter_types! {
pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (28 days).
// KUSAMA: This value is 1/4 of what we expect for the mainnet.
pub const BondingDuration: staking::EraIndex = 7;
// KUSAMA-launch: 0 for managing the spooning injection.
pub const BondingDuration: staking::EraIndex = 0;
pub const SlashDeferDuration: staking::EraIndex = 7;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
}
......@@ -311,6 +315,11 @@ impl staking::Trait for Runtime {
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type SlashDeferDuration = SlashDeferDuration;
// A super-majority of the council can cancel the slash.
// KUSAMA-launch: Any council member can remove a slash.
// type SlashCancelOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
type SlashCancelOrigin = collective::EnsureMember<AccountId, CouncilCollective>;
type SessionInterface = Self;
type Time = Timestamp;
type RewardCurve = RewardCurve;
......@@ -429,6 +438,8 @@ impl offences::Trait for Runtime {
type OnOffenceHandler = Staking;
}
impl authority_discovery::Trait for Runtime {}
type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
parameter_types! {
......@@ -568,6 +579,7 @@ construct_runtime!(
FinalityTracker: finality_tracker::{Module, Call, Inherent},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: authority_discovery::{Module, Call, Config},
// Governance stuff; uncallable initially.
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
......@@ -730,6 +742,12 @@ sr_api::impl_runtime_apis! {
}
}
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
fn authorities() -> Vec<AuthorityDiscoveryId> {
AuthorityDiscovery::authorities()
}
}
impl substrate_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
SessionKeys::generate(seed)
......
......@@ -1040,6 +1040,7 @@ mod tests {
parameter_types! {
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
pub const BondingDuration: staking::EraIndex = 28;
pub const SlashDeferDuration: staking::EraIndex = 7;
pub const AttestationPeriod: BlockNumber = 100;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
}
......@@ -1053,6 +1054,8 @@ mod tests {
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type Time = timestamp::Module<Test>;
type RewardCurve = RewardCurve;
......@@ -2035,7 +2038,7 @@ mod tests {
#[test]
fn empty_trie_root_const_is_blake2_hashed_null_node() {
let hashed_null_node = <NodeCodec<Blake2Hasher> as trie_db::NodeCodec>::hashed_null_node();
let hashed_null_node = <NodeCodec<Blake2Hasher> as trie_db::NodeCodec>::hashed_null_node();
assert_eq!(hashed_null_node, EMPTY_TRIE_ROOT.into())
}
}
[package]
name = "polkadot-service"
version = "0.6.17"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......@@ -9,6 +9,7 @@ parking_lot = "0.9.0"
lazy_static = "1.4.0"
log = "0.4.8"
futures = "0.1.29"
futures03 = { package = "futures", version = "0.3.1", features = ["compat"] }
exit-future = "0.1.4"
slog = "2.5.2"
hex-literal = "0.2.1"
......@@ -34,11 +35,13 @@ grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git =
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool = { package = "sc-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool-api = { package = "sp-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
im-online = { package = "pallet-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authority-discovery = { package = "substrate-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
......@@ -19,9 +19,9 @@
use primitives::{Pair, Public, crypto::UncheckedInto, sr25519};
use polkadot_primitives::{AccountId, AccountPublic, parachain::ValidatorId};
use polkadot_runtime::{
GenesisConfig, CouncilConfig, DemocracyConfig, SystemConfig, SessionConfig, StakingConfig,
BalancesConfig, SessionKeys, TechnicalCommitteeConfig, SudoConfig, IndicesConfig, StakerStatus,
WASM_BINARY, ClaimsConfig, ParachainsConfig, RegistrarConfig
AuthorityDiscoveryConfig, GenesisConfig, CouncilConfig, DemocracyConfig, SystemConfig,
SessionConfig, StakingConfig, BalancesConfig, SessionKeys, TechnicalCommitteeConfig, SudoConfig,
IndicesConfig, StakerStatus, WASM_BINARY, ClaimsConfig, ParachainsConfig, RegistrarConfig
};
use polkadot_runtime::constants::currency::DOTS;
use sr_primitives::{traits::IdentifyAccount, Perbill};
......@@ -30,6 +30,7 @@ use hex_literal::hex;
use babe_primitives::AuthorityId as BabeId;
use grandpa::AuthorityId as GrandpaId;
use im_online::sr25519::{AuthorityId as ImOnlineId};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use pallet_staking::Forcing;
const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
......@@ -46,15 +47,17 @@ fn session_keys(
babe: BabeId,
grandpa: GrandpaId,
im_online: ImOnlineId,
parachain_validator: ValidatorId
parachain_validator: ValidatorId,
authority_discovery: AuthorityDiscoveryId
) -> SessionKeys {
SessionKeys { babe, grandpa, im_online, parachain_validator }
SessionKeys { babe, grandpa, im_online, parachain_validator, authority_discovery }
}
fn staging_testnet_config_genesis() -> GenesisConfig {
// subkey inspect "$SECRET"
let endowed_accounts = vec![
hex!["12b782529c22032ed4694e0f6e7d486be7daa6d12088f6bc74d593b3900b8438"].into(), // 5CVFESwfkk7NmhQ6FwHCM9roBvr9BGa4vJHFYU8DnGQxrXvz
// 5CVFESwfkk7NmhQ6FwHCM9roBvr9BGa4vJHFYU8DnGQxrXvz
hex!["12b782529c22032ed4694e0f6e7d486be7daa6d12088f6bc74d593b3900b8438"].into(),
];
// for i in 1 2 3 4; do for j in stash controller; do subkey inspect "$SECRET//$i//$j"; done; done
......@@ -62,34 +65,74 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
// for i in 1 2 3 4; do for j in grandpa; do subkey --ed25519 inspect "$SECRET//$i//$j"; done; done
// for i in 1 2 3 4; do for j in im_online; do subkey --sr25519 inspect "$SECRET//$i//$j"; done; done
// for i in 1 2 3 4; do for j in parachains; do subkey --sr25519 inspect "$SECRET//$i//$j"; done; done
let initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId)> = vec![(
hex!["32a5718e87d16071756d4b1370c411bbbb947eb62f0e6e0b937d5cbfc0ea633b"].into(), // 5DD7Q4VEfPTLEdn11CnThoHT5f9xKCrnofWJL5SsvpTghaAT
hex!["bee39fe862c85c91aaf343e130d30b643c6ea0b4406a980206f1df8331f7093b"].into(), // 5GNzaEqhrZAtUQhbMe2gn9jBuNWfamWFZHULryFwBUXyd1cG
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(), // 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
hex!["76620f7c98bce8619979c2b58cf2b0aff71824126d2b039358729dad993223db"].unchecked_into(), // 5EjvdwATjyFFikdZibVvx1q5uBHhphS2Mnsq5c7yfaYK25vm
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(), // 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(), // 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId,
AuthorityDiscoveryId
)> = vec![(
// 5DD7Q4VEfPTLEdn11CnThoHT5f9xKCrnofWJL5SsvpTghaAT
hex!["32a5718e87d16071756d4b1370c411bbbb947eb62f0e6e0b937d5cbfc0ea633b"].into(),
// 5GNzaEqhrZAtUQhbMe2gn9jBuNWfamWFZHULryFwBUXyd1cG
hex!["bee39fe862c85c91aaf343e130d30b643c6ea0b4406a980206f1df8331f7093b"].into(),
// 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(),
// 5EjvdwATjyFFikdZibVvx1q5uBHhphS2Mnsq5c7yfaYK25vm
hex!["76620f7c98bce8619979c2b58cf2b0aff71824126d2b039358729dad993223db"].unchecked_into(),
// 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(),
// 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(),
// 5FpewyS2VY8Cj3tKgSckq8ECkjd1HKHvBRnWhiHqRQsWfFC1
hex!["a639b507ee1585e0b6498ff141d6153960794523226866d1b44eba3f25f36356"].unchecked_into(),
),(
hex!["b496c98a405ceab59b9e970e59ef61acd7765a19b704e02ab06c1cdfe171e40f"].into(), // 5G9VGb8ESBeS8Ca4or43RfhShzk9y7T5iTmxHk5RJsjZwsRx
hex!["86d3a7571dd60139d297e55d8238d0c977b2e208c5af088f7f0136b565b0c103"].into(), // 5F7V9Y5FcxKXe1aroqvPeRiUmmeQwTFcL3u9rrPXcMuMiCNx
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(), // 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
hex!["e2234d661bee4a04c38392c75d1566200aa9e6ae44dd98ee8765e4cc9af63cb7"].unchecked_into(), // 5HBDAaybNqjmY7ww8ZcZZY1L5LHxvpnyfqJwoB7HhR6raTmG
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(), // 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(), // 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
// 5G9VGb8ESBeS8Ca4or43RfhShzk9y7T5iTmxHk5RJsjZwsRx
hex!["b496c98a405ceab59b9e970e59ef61acd7765a19b704e02ab06c1cdfe171e40f"].into(),
// 5F7V9Y5FcxKXe1aroqvPeRiUmmeQwTFcL3u9rrPXcMuMiCNx
hex!["86d3a7571dd60139d297e55d8238d0c977b2e208c5af088f7f0136b565b0c103"].into(),
// 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(),
// 5HBDAaybNqjmY7ww8ZcZZY1L5LHxvpnyfqJwoB7HhR6raTmG
hex!["e2234d661bee4a04c38392c75d1566200aa9e6ae44dd98ee8765e4cc9af63cb7"].unchecked_into(),
// 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(),
// 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(),
// 5GvuM53k1Z4nAB5zXJFgkRSHv4Bqo4BsvgbQWNWkiWZTMwWY
hex!["765e46067adac4d1fe6c783aa2070dfa64a19f84376659e12705d1734b3eae01"].unchecked_into(),
),(
hex!["ae12f70078a22882bf5135d134468f77301927aa67c376e8c55b7ff127ace115"].into(), // 5FzwpgGvk2kk9agow6KsywLYcPzjYc8suKej2bne5G5b9YU3
hex!["7addb914ec8486bbc60643d2647685dcc06373401fa80e09813b630c5831d54b"].into(), // 5EqoZhVC2BcsM4WjvZNidu2muKAbu5THQTBKe3EjvxXkdP7A
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(), // 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
hex!["5b57ed1443c8967f461db1f6eb2ada24794d163a668f1cf9d9ce3235dfad8799"].unchecked_into(), // 5E8ULLQrDAtWhfnVfZmX41Yux86zNAwVJYguWJZVWrJvdhBe
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(), // 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(), // 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
// 5FzwpgGvk2kk9agow6KsywLYcPzjYc8suKej2bne5G5b9YU3
hex!["ae12f70078a22882bf5135d134468f77301927aa67c376e8c55b7ff127ace115"].into(),
// 5EqoZhVC2BcsM4WjvZNidu2muKAbu5THQTBKe3EjvxXkdP7A
hex!["7addb914ec8486bbc60643d2647685dcc06373401fa80e09813b630c5831d54b"].into(),
// 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(),
// 5E8ULLQrDAtWhfnVfZmX41Yux86zNAwVJYguWJZVWrJvdhBe
hex!["5b57ed1443c8967f461db1f6eb2ada24794d163a668f1cf9d9ce3235dfad8799"].unchecked_into(),
// 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(),
// 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(),
// 5CXNq1mSKJT4Sc2CbyBBdANeSkbUvdWvE4czJjKXfBHi9sX5
hex!["664eae1ca4713dd6abf8c15e6c041820cda3c60df97dc476c2cbf7cb82cb2d2e"].unchecked_into(),
),(
hex!["0867dbb49721126df589db100dda728dc3b475cbf414dad8f72a1d5e84897252"].into(), // 5CFj6Kg9rmVn1vrqpyjau2ztyBzKeVdRKwNPiA3tqhB5HPqq
hex!["26ab2b4b2eba2263b1e55ceb48f687bb0018130a88df0712fbdaf6a347d50e2a"].into(), // 5CwQXP6nvWzigFqNhh2jvCaW9zWVzkdveCJY3tz2MhXMjTon
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(), // 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
hex!["e60d23f49e93c1c1f2d7c115957df5bbd7faf5ebf138d1e9d02e8b39a1f63df0"].unchecked_into(), // 5HGLmrZsiTFTPp3QoS1W8w9NxByt8PVq79reqvdxNcQkByqK
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(), // 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(), // 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
// 5CFj6Kg9rmVn1vrqpyjau2ztyBzKeVdRKwNPiA3tqhB5HPqq
hex!["0867dbb49721126df589db100dda728dc3b475cbf414dad8f72a1d5e84897252"].into(),
// 5CwQXP6nvWzigFqNhh2jvCaW9zWVzkdveCJY3tz2MhXMjTon
hex!["26ab2b4b2eba2263b1e55ceb48f687bb0018130a88df0712fbdaf6a347d50e2a"].into(),
// 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(),
// 5HGLmrZsiTFTPp3QoS1W8w9NxByt8PVq79reqvdxNcQkByqK
hex!["e60d23f49e93c1c1f2d7c115957df5bbd7faf5ebf138d1e9d02e8b39a1f63df0"].unchecked_into(),
// 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(),
// 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(),
// 5FCd9Y7RLNyxz5wnCAErfsLbXGG34L2BaZRHzhiJcMUMd5zd
hex!["2adb17a5cafbddc7c3e00ec45b6951a8b12ce2264235b4def342513a767e5d3d"].unchecked_into(),
)];
const ENDOWMENT: u128 = 1_000_000 * DOTS;
......@@ -115,7 +158,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
session: Some(SessionConfig {
keys: initial_authorities.iter().map(|x| (
x.0.clone(),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
)).collect::<Vec<_>>(),
}),
staking: Some(StakingConfig {
......@@ -141,6 +184,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
babe: Some(Default::default()),
grandpa: Some(Default::default()),
im_online: Some(Default::default()),
authority_discovery: Some(AuthorityDiscoveryConfig {
keys: vec![],
}),
parachains: Some(ParachainsConfig {
authorities: vec![],
}),
......@@ -194,7 +240,8 @@ pub fn get_authority_keys_from_seed(seed: &str) -> (
BabeId,
GrandpaId,
ImOnlineId,
ValidatorId
ValidatorId,
AuthorityDiscoveryId
) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
......@@ -203,12 +250,13 @@ pub fn get_authority_keys_from_seed(seed: &str) -> (
get_from_seed::<GrandpaId>(seed),
get_from_seed::<ImOnlineId>(seed),
get_from_seed::<ValidatorId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
)
}
/// Helper function to create GenesisConfig for testing
pub fn testnet_genesis(
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId)>,
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> GenesisConfig {
......@@ -247,7 +295,7 @@ pub fn testnet_genesis(
session: Some(SessionConfig {
keys: initial_authorities.iter().map(|x| (
x.0.clone(),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()),
session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone(), x.6.clone()),
)).collect::<Vec<_>>(),
}),
staking: Some(StakingConfig {
......@@ -275,6 +323,9 @@ pub fn testnet_genesis(
babe: Some(Default::default()),
grandpa: Some(Default::default()),
im_online: Some(Default::default()),
authority_discovery: Some(AuthorityDiscoveryConfig {
keys: vec![],
}),
parachains: Some(ParachainsConfig {
authorities: vec![],
}),
......
......@@ -26,7 +26,6 @@ use polkadot_primitives::{parachain, Hash, BlockId};
use polkadot_runtime::GenesisConfig;
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
use transaction_pool::txpool::{Pool as TransactionPool};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use inherents::InherentDataProviders;
use log::info;
......@@ -55,6 +54,9 @@ pub struct CustomConfiguration {
/// Maximal `block_data` size.
pub max_block_data_size: Option<u64>,
/// Whether to enable or disable the authority discovery module.
pub authority_discovery_enabled: bool,
}
impl Default for CustomConfiguration {
......@@ -62,12 +64,13 @@ impl Default for CustomConfiguration {
Self {
collating_for: None,
max_block_data_size: None,
authority_discovery_enabled: false,
}
}
}
/// Chain API type for the transaction pool.
pub type TxChainApi<Backend, Executor> = transaction_pool::FullChainApi<
pub type TxChainApi<Backend, Executor> = txpool::FullChainApi<
client::Client<Backend, Executor, Block, RuntimeApi>,
Block,
>;
......@@ -86,9 +89,13 @@ macro_rules! new_full_start {
.with_select_chain(|_, backend| {
Ok(client::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client)))
)?
.with_transaction_pool(|config, client, _fetcher| {
let pool_api = txpool::FullChainApi::new(client.clone());
let pool = txpool::BasicPool::new(config, pool_api);
let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client);
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue(|_config, client, mut select_chain, _| {
let select_chain = select_chain.take()
.ok_or_else(|| service::Error::SelectChainRequired)?;
......@@ -118,8 +125,9 @@ macro_rules! new_full_start {
import_setup = Some((block_import, grandpa_link, babe_link));
Ok(import_queue)
})?
.with_rpc_extensions(|client, pool, _backend| -> polkadot_rpc::RpcExtension {
polkadot_rpc::create(client, pool)
.with_rpc_extensions(|client, pool, _backend, _fetcher, _remote_blockchain|
-> Result<polkadot_rpc::RpcExtension, _> {
Ok(polkadot_rpc::create_full(client, pool))
})?;
(builder, import_setup, inherent_data_providers)
......@@ -143,6 +151,11 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
>, ServiceError>
{
use substrate_network::DhtEvent;
use futures03::{
compat::Stream01CompatExt,
stream::StreamExt,
future::{FutureExt, TryFutureExt},
};
let is_collator = config.custom.collating_for.is_some();
let is_authority = config.roles.is_authority() && !is_collator;
......@@ -155,6 +168,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
};
let disable_grandpa = config.disable_grandpa;
let name = config.name.clone();
let authority_discovery_enabled = config.custom.authority_discovery_enabled;
// sentry nodes announce themselves as authorities to the network
// and should run the same protocols authorities do, but it should
......@@ -168,7 +182,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
// event per authority within the current authority set. This estimates the
// authority set size to be somewhere below 10 000 thereby setting the channel
// buffer size to 10 000.
let (dht_event_tx, _dht_event_rx) = mpsc::channel::<DhtEvent>(10000);
let (dht_event_tx, dht_event_rx) = mpsc::channel::<DhtEvent>(10000);
let service = builder
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
......@@ -273,6 +287,21 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
let babe = babe::start_babe(babe_config)?;
service.spawn_essential_task(babe);
if authority_discovery_enabled {
let future03_dht_event_rx = dht_event_rx.compat()
.map(|x| x.expect("<mpsc::channel::Receiver as Stream> never returns an error; qed"))
.boxed();
let authority_discovery = authority_discovery::AuthorityDiscovery::new(
service.client(),
service.network(),
service.keystore(),
future03_dht_event_rx,
);
let future01_authority_discovery = authority_discovery.map(|x| Ok(x)).compat();
service.spawn_task(future01_authority_discovery);
}
}
// if the node isn't actively participating in consensus then it doesn't
......@@ -337,9 +366,15 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
.with_select_chain(|_, backend| {
Ok(LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client|
Ok(TransactionPool::new(config, transaction_pool::FullChainApi::new(client)))
)?
.with_transaction_pool(|config, client, fetcher| {
let fetcher = fetcher
.ok_or_else(|| "Trying to start light transaction pool without active fetcher")?;
let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone());
let pool = txpool::BasicPool::new(config, pool_api);
let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher);
let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer);
Ok(maintainable_pool)
})?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _| {
let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone())
......@@ -376,8 +411,13 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
.with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)?
.with_rpc_extensions(|client, pool, _backend| -> polkadot_rpc::RpcExtension {
polkadot_rpc::create(client, pool)
.with_rpc_extensions(|client, pool, _backend, fetcher, remote_blockchain|
-> Result<polkadot_rpc::RpcExtension, _> {
let fetcher = fetcher
.ok_or_else(|| "Trying to start node RPC without active fetcher")?;
let remote_blockchain = remote_blockchain
.ok_or_else(|| "Trying to start node RPC without active remote blockchain")?;
Ok(polkadot_rpc::create_light(client, remote_blockchain, fetcher, pool))
})?
.build()
}
[package]
name = "polkadot-statement-table"
version = "0.6.17"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "adder"
version = "0.6.17"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition"
edition = "2018"
......
[package]
name = "halt"
version = "0.6.17"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever"
edition = "2018"
......
[package]
name = "polkadot-validation"
version = "0.6.17"
version = "0.7.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......@@ -25,8 +25,9 @@ grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/pa
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
txpool-api = { package = "sp-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
block-builder = { package = "substrate-block-builder", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
......
......@@ -25,9 +25,9 @@
use std::{thread, time::{Duration, Instant}, sync::Arc};
use client::{error::Result as ClientResult, BlockchainEvents, BlockBody};
use client::{BlockchainEvents, BlockBody};
use sp_blockchain::{HeaderBackend, Result as ClientResult};
use block_builder::BlockBuilderApi;
use client::blockchain::HeaderBackend;
use consensus::SelectChain;
use availability_store::Store as AvailabilityStore;
use futures::prelude::*;
......@@ -127,7 +127,7 @@ pub(crate) fn start<C, N, P, SC>(
P::Api: ParachainHost<Block> +
BlockBuilderApi<Block> +
BabeApi<Block> +
ApiExt<Block, Error = client::error::Error>,
ApiExt<Block, Error = sp_blockchain::Error>,
N: Network + Send + Sync + 'static,
N::TableRouter: Send + 'static,
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
......
......@@ -98,7 +98,7 @@ impl<C: Collators, P> CollationFetch<C, P> {
}
impl<C: Collators, P: ProvideRuntimeApi> Future for CollationFetch<C, P>
where P::Api: ParachainHost<Block, Error = client::error::Error>,
where P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
{
type Item = (Collation, OutgoingMessages);
type Error = C::Error;
......@@ -142,7 +142,7 @@ impl<C: Collators, P: ProvideRuntimeApi> Future for CollationFetch<C, P>
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
/// Client error
Client(client::error::Error),
Client(sp_blockchain::Error),
/// Wasm validation error
WasmValidation(wasm_executor::Error),
/// Collated for inactive parachain
......@@ -393,7 +393,7 @@ pub fn validate_collation<P>(
max_block_data_size: Option<u64>,
) -> Result<OutgoingMessages, Error> where
P: ProvideRuntimeApi,
P::Api: ParachainHost<Block, Error = client::error::Error>,
P::Api: ParachainHost<Block, Error = sp_blockchain::Error>,
{
use parachain::{IncomingMessage, ValidationParams};
......
......@@ -22,7 +22,7 @@ use polkadot_primitives::parachain::ValidatorId;
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
/// Client error
Client(client::error::Error),
Client(sp_blockchain::Error),
/// Consensus error
Consensus(consensus::error::Error),
#[display(fmt = "Invalid duty roster length: expected {}, got {}", expected, got)]
......
......@@ -29,7 +29,7 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
/// Client error