Unverified Commit b3611713 authored by Fedor Sakharov's avatar Fedor Sakharov Committed by GitHub
Browse files

Parachains double vote handler initial implementation. (#840)



* Parachains double vote handler initial implementation.

* Make tests test the actual slashing.

* Implement SignedExtension validation of double vote reports.

* Fixes build after merge

* Review fixes

* Adds historical session proofs

* Review fixes.

* Bump runtime spec_version

* Get the session number from the proof

* Check that proof matches session

* Change signature type on DoubleVoteReport

* Adds docs and removes blank lines

* Removes leftover code

* Fix build

* Fix build after a merge

* Apply suggestions from code review

Co-Authored-By: asynchronous rob's avatarRobert Habermeier <rphmeier@gmail.com>

* Prune ParentToSessionIndex

* Remove a clone and a warning

Co-authored-by: asynchronous rob's avatarRobert Habermeier <rphmeier@gmail.com>
Co-authored-by: default avatarGavin Wood <gavin@parity.io>
parent 9c45e89d
Pipeline #84112 passed with stages
in 23 minutes and 14 seconds
...@@ -4043,6 +4043,7 @@ dependencies = [ ...@@ -4043,6 +4043,7 @@ dependencies = [
"pallet-authorship 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-authorship 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-babe 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-babe 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-balances 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-balances 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-offences 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-randomness-collective-flip 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-randomness-collective-flip 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-session 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-session 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-staking 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-staking 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
...@@ -4154,6 +4155,7 @@ dependencies = [ ...@@ -4154,6 +4155,7 @@ dependencies = [
"pallet-grandpa 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-grandpa 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-indices 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-indices 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-nicks 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-nicks 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-offences 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-randomness-collective-flip 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-randomness-collective-flip 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-session 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-session 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
"pallet-staking 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)", "pallet-staking 2.0.0-alpha.4 (git+https://github.com/paritytech/substrate)",
......
...@@ -580,7 +580,7 @@ pub struct Activity(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8 ...@@ -580,7 +580,7 @@ pub struct Activity(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8
/// Statements that can be made about parachain candidates. These are the /// Statements that can be made about parachain candidates. These are the
/// actual values that are signed. /// actual values that are signed.
#[derive(Clone, PartialEq, Eq, Encode)] #[derive(Clone, PartialEq, Eq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))] #[cfg_attr(feature = "std", derive(Debug))]
pub enum Statement { pub enum Statement {
/// Proposal of a parachain candidate. /// Proposal of a parachain candidate.
...@@ -596,8 +596,7 @@ pub enum Statement { ...@@ -596,8 +596,7 @@ pub enum Statement {
/// An either implicit or explicit attestation to the validity of a parachain /// An either implicit or explicit attestation to the validity of a parachain
/// candidate. /// candidate.
#[derive(Clone, PartialEq, Decode, Encode)] #[derive(Clone, Eq, PartialEq, Decode, Encode, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum ValidityAttestation { pub enum ValidityAttestation {
/// Implicit validity attestation by issuing. /// Implicit validity attestation by issuing.
/// This corresponds to issuance of a `Candidate` statement. /// This corresponds to issuance of a `Candidate` statement.
......
...@@ -28,6 +28,7 @@ staking = { package = "pallet-staking", git = "https://github.com/paritytech/sub ...@@ -28,6 +28,7 @@ staking = { package = "pallet-staking", git = "https://github.com/paritytech/sub
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
......
This diff is collapsed.
...@@ -312,7 +312,7 @@ decl_module! { ...@@ -312,7 +312,7 @@ decl_module! {
) { ) {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
T::Currency::reserve(&who, T::ParathreadDeposit::get())?; <T as Trait>::Currency::reserve(&who, T::ParathreadDeposit::get())?;
let info = ParaInfo { let info = ParaInfo {
scheduling: Scheduling::Dynamic, scheduling: Scheduling::Dynamic,
...@@ -371,7 +371,7 @@ decl_module! { ...@@ -371,7 +371,7 @@ decl_module! {
Self::force_unschedule(|i| i == id); Self::force_unschedule(|i| i == id);
let debtor = <Debtors<T>>::take(id); let debtor = <Debtors<T>>::take(id);
let _ = T::Currency::unreserve(&debtor, T::ParathreadDeposit::get()); let _ = <T as Trait>::Currency::unreserve(&debtor, T::ParathreadDeposit::get());
Self::deposit_event(Event::ParathreadRegistered(id)); Self::deposit_event(Event::ParathreadRegistered(id));
} }
...@@ -646,7 +646,7 @@ mod tests { ...@@ -646,7 +646,7 @@ mod tests {
traits::{ traits::{
BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize, Dispatchable, BlakeTwo256, IdentityLookup, OnInitialize, OnFinalize, Dispatchable,
AccountIdConversion, AccountIdConversion,
}, testing::{UintAuthorityId, Header}, Perbill }, testing::{UintAuthorityId, Header}, KeyTypeId, Perbill, curve::PiecewiseLinear,
}; };
use primitives::{ use primitives::{
parachain::{ parachain::{
...@@ -657,6 +657,7 @@ mod tests { ...@@ -657,6 +657,7 @@ mod tests {
Balance, BlockNumber, Balance, BlockNumber,
}; };
use frame_support::{ use frame_support::{
traits::KeyOwnerProofSystem,
impl_outer_origin, impl_outer_dispatch, assert_ok, parameter_types, assert_noop, impl_outer_origin, impl_outer_dispatch, assert_ok, parameter_types, assert_noop,
}; };
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
...@@ -678,6 +679,17 @@ mod tests { ...@@ -678,6 +679,17 @@ mod tests {
} }
} }
pallet_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,
);
}
#[derive(Clone, Eq, PartialEq)] #[derive(Clone, Eq, PartialEq)]
pub struct Test; pub struct Test;
parameter_types! { parameter_types! {
...@@ -735,7 +747,12 @@ mod tests { ...@@ -735,7 +747,12 @@ mod tests {
} }
parameter_types!{ parameter_types!{
pub const SlashDeferDuration: staking::EraIndex = 7;
pub const AttestationPeriod: BlockNumber = 100; pub const AttestationPeriod: BlockNumber = 100;
pub const MinimumPeriod: u64 = 3;
pub const SessionsPerEra: sp_staking::SessionIndex = 6;
pub const BondingDuration: staking::EraIndex = 28;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
} }
impl attestations::Trait for Test { impl attestations::Trait for Test {
...@@ -748,6 +765,7 @@ mod tests { ...@@ -748,6 +765,7 @@ mod tests {
pub const Period: BlockNumber = 1; pub const Period: BlockNumber = 1;
pub const Offset: BlockNumber = 0; pub const Offset: BlockNumber = 0;
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
} }
impl session::Trait for Test { impl session::Trait for Test {
...@@ -766,6 +784,34 @@ mod tests { ...@@ -766,6 +784,34 @@ mod tests {
pub const MaxCodeSize: u32 = 100; pub const MaxCodeSize: u32 = 100;
} }
impl staking::Trait for Test {
type RewardRemainder = ();
type CurrencyToVote = ();
type Event = ();
type Currency = balances::Module<Test>;
type Slash = ();
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;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
}
impl timestamp::Trait for Test {
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
}
impl session::historical::Trait for Test {
type FullIdentification = staking::Exposure<u64, Balance>;
type FullIdentificationOf = staking::ExposureOf<Self>;
}
impl parachains::Trait for Test { impl parachains::Trait for Test {
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
...@@ -775,6 +821,10 @@ mod tests { ...@@ -775,6 +821,10 @@ mod tests {
type Randomness = RandomnessCollectiveFlip; type Randomness = RandomnessCollectiveFlip;
type MaxCodeSize = MaxCodeSize; type MaxCodeSize = MaxCodeSize;
type MaxHeadDataSize = MaxHeadDataSize; type MaxHeadDataSize = MaxHeadDataSize;
type Proof = session::historical::Proof;
type KeyOwnerProofSystem = session::historical::Module<Test>;
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
type ReportOffence = ();
} }
parameter_types! { parameter_types! {
......
...@@ -34,7 +34,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots, ...@@ -34,7 +34,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, Percent, Permill, Perbill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, RuntimeDebug,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError}, transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
curve::PiecewiseLinear, curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup}, traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup},
...@@ -48,13 +48,14 @@ use version::NativeVersion; ...@@ -48,13 +48,14 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Randomness}, parameter_types, construct_runtime, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness},
weights::DispatchInfo, weights::DispatchInfo,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use system::offchain::TransactionSubmitter; use system::offchain::TransactionSubmitter;
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use session::{historical as session_historical};
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use staking::StakerStatus; pub use staking::StakerStatus;
...@@ -491,6 +492,10 @@ impl parachains::Trait for Runtime { ...@@ -491,6 +492,10 @@ impl parachains::Trait for Runtime {
type Registrar = Registrar; type Registrar = Registrar;
type MaxCodeSize = MaxCodeSize; type MaxCodeSize = MaxCodeSize;
type MaxHeadDataSize = MaxHeadDataSize; type MaxHeadDataSize = MaxHeadDataSize;
type Proof = session::historical::Proof;
type KeyOwnerProofSystem = session::historical::Module<Self>;
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
type ReportOffence = Offences;
} }
parameter_types! { parameter_types! {
...@@ -648,6 +653,7 @@ construct_runtime! { ...@@ -648,6 +653,7 @@ construct_runtime! {
Authorship: authorship::{Module, Call, Storage}, Authorship: authorship::{Module, Call, Storage},
Staking: staking::{Module, Call, Storage, Config<T>, Event<T>}, Staking: staking::{Module, Call, Storage, Config<T>, Event<T>},
Offences: offences::{Module, Call, Storage, Event}, Offences: offences::{Module, Call, Storage, Event},
Historical: session_historical::{Module},
Session: session::{Module, Call, Storage, Event, Config<T>}, Session: session::{Module, Call, Storage, Event, Config<T>},
FinalityTracker: finality_tracker::{Module, Call, Storage, Inherent}, FinalityTracker: finality_tracker::{Module, Call, Storage, Inherent},
Grandpa: grandpa::{Module, Call, Storage, Config, Event}, Grandpa: grandpa::{Module, Call, Storage, Config, Event},
...@@ -708,7 +714,8 @@ pub type SignedExtra = ( ...@@ -708,7 +714,8 @@ pub type SignedExtra = (
system::CheckNonce<Runtime>, system::CheckNonce<Runtime>,
system::CheckWeight<Runtime>, system::CheckWeight<Runtime>,
transaction_payment::ChargeTransactionPayment::<Runtime>, transaction_payment::ChargeTransactionPayment::<Runtime>,
registrar::LimitParathreadCommits<Runtime> registrar::LimitParathreadCommits<Runtime>,
parachains::ValidateDoubleVoteReports<Runtime>,
); );
/// Unchecked extrinsic type as expected by this runtime. /// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
......
...@@ -35,7 +35,7 @@ use primitives::{ ...@@ -35,7 +35,7 @@ use primitives::{
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, Percent, Permill, Perbill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, RuntimeDebug,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError}, transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
curve::PiecewiseLinear, curve::PiecewiseLinear,
traits::{ traits::{
...@@ -52,13 +52,14 @@ use version::NativeVersion; ...@@ -52,13 +52,14 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Randomness}, parameter_types, construct_runtime, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness},
weights::DispatchInfo, weights::DispatchInfo,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use system::offchain::TransactionSubmitter; use system::offchain::TransactionSubmitter;
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use session::{historical as session_historical};
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use staking::StakerStatus; pub use staking::StakerStatus;
...@@ -499,6 +500,10 @@ impl parachains::Trait for Runtime { ...@@ -499,6 +500,10 @@ impl parachains::Trait for Runtime {
type Registrar = Registrar; type Registrar = Registrar;
type MaxCodeSize = MaxCodeSize; type MaxCodeSize = MaxCodeSize;
type MaxHeadDataSize = MaxHeadDataSize; type MaxHeadDataSize = MaxHeadDataSize;
type Proof = session::historical::Proof;
type KeyOwnerProofSystem = session::historical::Module<Self>;
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
type ReportOffence = Offences;
} }
parameter_types! { parameter_types! {
...@@ -579,6 +584,7 @@ construct_runtime! { ...@@ -579,6 +584,7 @@ construct_runtime! {
Authorship: authorship::{Module, Call, Storage}, Authorship: authorship::{Module, Call, Storage},
Staking: staking::{Module, Call, Storage, Config<T>, Event<T>}, Staking: staking::{Module, Call, Storage, Config<T>, Event<T>},
Offences: offences::{Module, Call, Storage, Event}, Offences: offences::{Module, Call, Storage, Event},
Historical: session_historical::{Module},
Session: session::{Module, Call, Storage, Event, Config<T>}, Session: session::{Module, Call, Storage, Event, Config<T>},
FinalityTracker: finality_tracker::{Module, Call, Storage, Inherent}, FinalityTracker: finality_tracker::{Module, Call, Storage, Inherent},
Grandpa: grandpa::{Module, Call, Storage, Config, Event}, Grandpa: grandpa::{Module, Call, Storage, Config, Event},
...@@ -630,7 +636,8 @@ pub type SignedExtra = ( ...@@ -630,7 +636,8 @@ pub type SignedExtra = (
system::CheckNonce<Runtime>, system::CheckNonce<Runtime>,
system::CheckWeight<Runtime>, system::CheckWeight<Runtime>,
transaction_payment::ChargeTransactionPayment::<Runtime>, transaction_payment::ChargeTransactionPayment::<Runtime>,
registrar::LimitParathreadCommits<Runtime> registrar::LimitParathreadCommits<Runtime>,
parachains::ValidateDoubleVoteReports<Runtime>
); );
/// Unchecked extrinsic type as expected by this runtime. /// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
......
...@@ -36,6 +36,7 @@ finality-tracker = { package = "pallet-finality-tracker", git = "https://github. ...@@ -36,6 +36,7 @@ finality-tracker = { package = "pallet-finality-tracker", git = "https://github.
grandpa = { package = "pallet-grandpa", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } grandpa = { package = "pallet-grandpa", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
indices = { package = "pallet-indices", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } indices = { package = "pallet-indices", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
nicks = { package = "pallet-nicks", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } nicks = { package = "pallet-nicks", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
offences = { package = "pallet-offences", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } randomness-collective-flip = { package = "pallet-randomness-collective-flip", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } session = { package = "pallet-session", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
...@@ -89,6 +90,7 @@ std = [ ...@@ -89,6 +90,7 @@ std = [
"grandpa/std", "grandpa/std",
"indices/std", "indices/std",
"nicks/std", "nicks/std",
"offences/std",
"sp-runtime/std", "sp-runtime/std",
"sp-staking/std", "sp-staking/std",
"session/std", "session/std",
......
...@@ -34,7 +34,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots, ...@@ -34,7 +34,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, Perbill, RuntimeDebug, ApplyExtrinsicResult, Perbill, RuntimeDebug, KeyTypeId,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError}, transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
curve::PiecewiseLinear, curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto}, traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto},
...@@ -46,10 +46,12 @@ use version::NativeVersion; ...@@ -46,10 +46,12 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, traits::Randomness, parameter_types, construct_runtime,
traits::{KeyOwnerProofSystem, Randomness},
weights::DispatchInfo, weights::DispatchInfo,
}; };
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use session::{historical as session_historical};
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use staking::StakerStatus; pub use staking::StakerStatus;
...@@ -311,6 +313,18 @@ impl parachains::Trait for Runtime { ...@@ -311,6 +313,18 @@ impl parachains::Trait for Runtime {
type Registrar = Registrar; type Registrar = Registrar;
type MaxCodeSize = MaxCodeSize; type MaxCodeSize = MaxCodeSize;
type MaxHeadDataSize = MaxHeadDataSize; type MaxHeadDataSize = MaxHeadDataSize;
type Proof = session::historical::Proof;
type KeyOwnerProofSystem = session::historical::Module<Self>;
type IdentificationTuple = <
Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>
>::IdentificationTuple;
type ReportOffence = Offences;
}
impl offences::Trait for Runtime {
type Event = Event;
type IdentificationTuple = session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
} }
parameter_types! { parameter_types! {
...@@ -385,6 +399,8 @@ construct_runtime! { ...@@ -385,6 +399,8 @@ construct_runtime! {
// Consensus support. // Consensus support.
Authorship: authorship::{Module, Call, Storage}, Authorship: authorship::{Module, Call, Storage},
Staking: staking::{Module, Call, Storage, Config<T>, Event<T>}, Staking: staking::{Module, Call, Storage, Config<T>, Event<T>},
Offences: offences::{Module, Call, Storage, Event},
Historical: session_historical::{Module},
Session: session::{Module, Call, Storage, Event, Config<T>}, Session: session::{Module, Call, Storage, Event, Config<T>},
Grandpa: grandpa::{Module, Call, Storage, Config, Event}, Grandpa: grandpa::{Module, Call, Storage, Config, Event},
......
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