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
This commit is contained in:
Gavin Wood
2019-08-19 09:18:03 +02:00
committed by GitHub
parent 742730c865
commit ee630db943
9 changed files with 130 additions and 76 deletions
+2 -1
View File
@@ -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,
};
+1
View File
@@ -243,6 +243,7 @@ mod tests {
type MaximumBlockWeight = MaximumBlockWeight;
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
}
parameter_types! {
+4 -4
View File
@@ -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);
+14 -1
View File
@@ -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>,
+2 -3
View File
@@ -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();
+1
View File
@@ -834,6 +834,7 @@ mod tests {
type MaximumBlockWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
}
parameter_types! {