update substrate (#442)

This commit is contained in:
thiolliere
2019-09-23 16:25:14 +02:00
committed by Robert Habermeier
parent 21cb1e9f45
commit 444a19ec5f
9 changed files with 250 additions and 193 deletions
+24 -6
View File
@@ -39,11 +39,11 @@ use client::{
runtime_api as client_api, impl_runtime_apis,
};
use sr_primitives::{
ApplyResult, generic,
ApplyResult, generic, Permill, Perbill, impl_opaque_keys, create_runtime_str, key_types,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
impl_opaque_keys, weights::{Weight, DispatchInfo}, create_runtime_str, key_types, traits::{
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, SignedExtension,
},
weights::{Weight, DispatchInfo},
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, SignedExtension},
curve::PiecewiseLinear,
};
use version::RuntimeVersion;
use grandpa::{AuthorityId as GrandpaId, fg_primitives::{self, ScheduledChange}};
@@ -67,7 +67,6 @@ pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
pub use parachains::{Call as ParachainsCall, NEW_HEADS_IDENTIFIER};
pub use sr_primitives::{Permill, Perbill};
pub use srml_support::StorageValue;
/// Implementations of some helper traits passed into runtime modules as associated types.
@@ -264,6 +263,10 @@ impl_opaque_keys! {
// TODO: Introduce some structure to tie these together to make it a bit less of a footgun. This
// should be easy, since OneSessionHandler trait provides the `Key` as an associated type. #2858
parameter_types! {
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
}
impl session::Trait for Runtime {
type OnSessionEnding = Staking;
type SessionHandler = SessionHandlers;
@@ -273,6 +276,7 @@ impl session::Trait for Runtime {
type SelectInitialValidators = Staking;
type ValidatorId = AccountId;
type ValidatorIdOf = staking::StashOf<Self>;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
}
impl session::historical::Trait for Runtime {
@@ -280,11 +284,23 @@ impl session::historical::Trait for Runtime {
type FullIdentificationOf = staking::ExposureOf<Self>;
}
srml_staking_reward_curve::build! {
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
max_inflation: 0_100_000,
ideal_stake: 0_500_000,
falloff: 0_050_000,
max_piece_count: 40,
test_precision: 0_005_000,
);
}
parameter_types! {
// Six sessions in an era (24 hours).
pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (28 days).
pub const BondingDuration: staking::EraIndex = 28;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
}
impl staking::Trait for Runtime {
@@ -298,6 +314,7 @@ impl staking::Trait for Runtime {
type BondingDuration = BondingDuration;
type SessionInterface = Self;
type Time = Timestamp;
type RewardCurve = RewardCurve;
}
parameter_types! {
@@ -347,6 +364,7 @@ parameter_types! {
pub const CandidacyBond: Balance = 10 * DOLLARS;
pub const VotingBond: Balance = 1 * DOLLARS;
pub const VotingFee: Balance = 2 * DOLLARS;
pub const MinimumVotingLock: Balance = 1 * DOLLARS;
pub const PresentSlashPerVoter: Balance = 1 * CENTS;
pub const CarryCount: u32 = 6;
// one additional vote should go by before an inactive voter can be reaped.
@@ -366,6 +384,7 @@ impl elections::Trait for Runtime {
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type VotingFee = VotingFee;
type MinimumVotingLock = MinimumVotingLock;
type PresentSlashPerVoter = PresentSlashPerVoter;
type CarryCount = CarryCount;
type InactiveGracePeriod = InactiveGracePeriod;
@@ -424,7 +443,6 @@ impl im_online::Trait for Runtime {
type Call = Call;
type SubmitTransaction = SubmitTransaction;
type ReportUnresponsiveness = ();
type CurrentElectedSet = staking::CurrentElectedStashAccounts<Runtime>;
}
impl grandpa::Trait for Runtime {
+16
View File
@@ -890,6 +890,7 @@ mod tests {
Perbill,
traits::{BlakeTwo256, IdentityLookup, ConvertInto},
testing::{UintAuthorityId, Header},
curve::PiecewiseLinear,
};
use primitives::{
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorId},
@@ -944,6 +945,7 @@ mod tests {
parameter_types! {
pub const Period: BlockNumber = 1;
pub const Offset: BlockNumber = 0;
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
}
impl session::Trait for Test {
@@ -955,6 +957,7 @@ mod tests {
type SelectInitialValidators = staking::Module<Self>;
type ValidatorId = u64;
type ValidatorIdOf = staking::StashOf<Self>;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
}
impl session::historical::Trait for Test {
@@ -1005,10 +1008,22 @@ mod tests {
type WeightToFee = ConvertInto;
}
srml_staking_reward_curve::build! {
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
max_inflation: 0_100_000,
ideal_stake: 0_500_000,
falloff: 0_050_000,
max_piece_count: 40,
test_precision: 0_005_000,
);
}
parameter_types! {
pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6;
pub const BondingDuration: staking::EraIndex = 28;
pub const AttestationPeriod: BlockNumber = 100;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
}
impl staking::Trait for Test {
@@ -1022,6 +1037,7 @@ mod tests {
type BondingDuration = BondingDuration;
type SessionInterface = Self;
type Time = timestamp::Module<Test>;
type RewardCurve = RewardCurve;
}
impl attestations::Trait for Test {