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

Runtime version affinity enabled in transactions. (#384)

* Update to latest substrate

* Update lock

* Introduce tx version check

* Move to release constants

* fixes

* More updates

* More fixes
parent 3c6bb273
This diff is collapsed.
......@@ -21,7 +21,7 @@ srml-support = { git = "https://github.com/paritytech/substrate", default-featur
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offchain_primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offchain-primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authorship = { package = "srml-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
collective = { package = "srml-collective", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
......@@ -33,7 +33,9 @@ grandpa = { package = "srml-grandpa", git = "https://github.com/paritytech/subst
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
membership = { package = "srml-membership", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offences = { package = "srml-offences", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-staking-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
session = { package = "srml-session", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
staking = { package = "srml-staking", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sudo = { package = "srml-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
......@@ -68,7 +70,7 @@ std = [
"inherents/std",
"substrate-primitives/std",
"client/std",
"offchain_primitives/std",
"offchain-primitives/std",
"rstd/std",
"sr-io/std",
"srml-support/std",
......@@ -83,7 +85,9 @@ std = [
"im-online/std",
"indices/std",
"membership/std",
"offences/std",
"sr-primitives/std",
"sr-staking-primitives/std",
"session/std",
"staking/std",
"sudo/std",
......
......@@ -24,7 +24,8 @@ use codec::{Encode, Decode};
use srml_support::{decl_storage, decl_module, ensure};
use primitives::{Hash, parachain::{AttestedCandidate, CandidateReceipt, Id as ParaId}};
use {system, session::{self, SessionIndex}};
use sr_staking_primitives::SessionIndex;
use {system, session};
use srml_support::{
StorageValue, StorageMap, StorageDoubleMap, dispatch::Result, traits::Get,
};
......
......@@ -243,6 +243,7 @@ mod tests {
type MaximumBlockWeight = MaximumBlockWeight;
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
}
parameter_types! {
......
......@@ -28,14 +28,14 @@ pub mod currency {
pub mod time {
use primitives::{Moment, BlockNumber};
// Kusama & mainnet
// pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const MILLISECS_PER_BLOCK: Moment = 6000;
// Testnet
pub const MILLISECS_PER_BLOCK: Moment = 1000;
// pub const MILLISECS_PER_BLOCK: Moment = 1000;
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
// Kusama & mainnet
// pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 4 * HOURS;
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 4 * HOURS;
// Testnet
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
// pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
......
......@@ -50,6 +50,7 @@ use elections::VoteIndex;
#[cfg(any(feature = "std", test))]
use version::NativeVersion;
use substrate_primitives::OpaqueMetadata;
use sr_staking_primitives::SessionIndex;
use srml_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency}
};
......@@ -142,6 +143,7 @@ parameter_types! {
pub const MaximumBlockWeight: Weight = 1_000_000_000;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
pub const Version: RuntimeVersion = VERSION;
}
impl system::Trait for Runtime {
......@@ -160,6 +162,7 @@ impl system::Trait for Runtime {
type MaximumBlockWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version;
}
parameter_types! {
......@@ -275,7 +278,7 @@ impl session::historical::Trait for Runtime {
}
parameter_types! {
pub const SessionsPerEra: session::SessionIndex = 6;
pub const SessionsPerEra: SessionIndex = 6;
pub const BondingDuration: staking::EraIndex = 24 * 28;
}
......@@ -402,10 +405,18 @@ impl treasury::Trait for Runtime {
type Burn = Burn;
}
impl offences::Trait for Runtime {
type Event = Event;
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
}
impl im_online::Trait for Runtime {
type Call = Call;
type Event = Event;
type UncheckedExtrinsic = UncheckedExtrinsic;
type ReportUnresponsiveness = ();
type CurrentElectedSet = staking::CurrentElectedStashAccounts<Runtime>;
}
impl grandpa::Trait for Runtime {
......@@ -489,6 +500,7 @@ construct_runtime!(
// Consensus support.
Authorship: authorship::{Module, Call, Storage},
Staking: staking::{default, OfflineWorker},
Offences: offences::{Module, Call, Storage, Event},
Session: session::{Module, Call, Storage, Event, Config<T>},
FinalityTracker: finality_tracker::{Module, Call, Inherent},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
......@@ -531,6 +543,7 @@ pub type BlockId = generic::BlockId<Block>;
pub type SignedExtra = (
// RELEASE: remove this for release build.
OnlyStakingAndClaims,
system::CheckVersion<Runtime>,
system::CheckGenesis<Runtime>,
system::CheckEra<Runtime>,
system::CheckNonce<Runtime>,
......
......@@ -936,6 +936,7 @@ mod tests {
type MaximumBlockWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
}
parameter_types! {
......@@ -1003,7 +1004,7 @@ mod tests {
}
parameter_types! {
pub const SessionsPerEra: session::SessionIndex = 6;
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
pub const BondingDuration: staking::EraIndex = 24 * 28;
pub const AttestationPeriod: BlockNumber = 100;
}
......@@ -1098,8 +1099,6 @@ mod tests {
stakers,
validator_count: 10,
minimum_validator_count: 8,
offline_slash: Perbill::from_percent(5),
offline_slash_grace: 0,
invulnerables: vec![],
.. Default::default()
}.assimilate_storage(&mut t).unwrap();
......
......@@ -834,6 +834,7 @@ mod tests {
type MaximumBlockWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
}
parameter_types! {
......
......@@ -120,13 +120,13 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
}),
staking: Some(StakingConfig {
current_era: 0,
offline_slash: Perbill::from_parts(1_000_000),
validator_count: 7,
offline_slash_grace: 4,
minimum_validator_count: 4,
stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::ForceNone,
slash_reward_fraction: Perbill::from_percent(10),
.. Default::default()
}),
democracy: Some(Default::default()),
collective_Instance1: Some(CouncilConfig {
......@@ -253,13 +253,13 @@ pub fn testnet_genesis(
current_era: 0,
minimum_validator_count: 1,
validator_count: 2,
offline_slash: Perbill::zero(),
offline_slash_grace: 0,
stakers: initial_authorities.iter()
.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
.collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
force_era: Forcing::NotForcing,
slash_reward_fraction: Perbill::from_percent(10),
.. Default::default()
}),
democracy: Some(DemocracyConfig::default()),
collective_Instance1: Some(CouncilConfig {
......
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