diff --git a/src/frame/session.rs b/src/frame/session.rs index 0a9cfc02b0..de534ba7ff 100644 --- a/src/frame/session.rs +++ b/src/frame/session.rs @@ -42,7 +42,7 @@ pub trait Session: System { #[derive(Encode, Store)] pub struct ValidatorsStore { #[store(returns = Vec<::ValidatorId>)] - /// The current set of validators. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -50,8 +50,8 @@ pub struct ValidatorsStore { #[derive(Encode, Store)] pub struct CurrentIndexStore { #[store(returns = ::SessionIndex)] - /// Current index of the session. - pub _r: PhantomData, + /// Marker for the runtime + pub _runtime: PhantomData, } /// True if the underlying economic identities or weighting behind the validators @@ -59,7 +59,6 @@ pub struct CurrentIndexStore { #[derive(Encode, Store)] pub struct QueuedChangedStore { #[store(returns = bool)] - /// True if the underlying economic identities or weighting behind the validators - /// has changed in the queued validator set. - pub _r: PhantomData, + /// Marker for the runtime + pub _runtime: PhantomData, } diff --git a/src/frame/staking.rs b/src/frame/staking.rs index 9d46a51e23..97c79fc4c6 100644 --- a/src/frame/staking.rs +++ b/src/frame/staking.rs @@ -25,17 +25,14 @@ use codec::{ Encode, HasCompact, }; -use sp_runtime::{ - Perbill, - RuntimeDebug, -}; +use sp_runtime::Perbill; use std::{ fmt::Debug, marker::PhantomData, }; /// A record of the nominations made by a specific account. -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, Encode, Decode, Debug, Ord, PartialOrd, Hash)] pub struct Nominations { /// The targets of nomination. pub targets: Vec, @@ -48,7 +45,7 @@ pub struct Nominations { } /// Information regarding the active era (era in used in session). -#[derive(Encode, Decode, RuntimeDebug)] +#[derive(Encode, Decode, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct ActiveEraInfo { /// Index of era. pub index: EraIndex, @@ -56,7 +53,7 @@ pub struct ActiveEraInfo { /// /// Start can be none if start hasn't been set for the era yet, /// Start is set on the first on_finalize of the era to guarantee usage of `Time`. - start: Option, + pub start: Option, } /// Data type used to index nominators in the compact type @@ -78,7 +75,7 @@ pub type EraIndex = u32; pub type RewardPoint = u32; /// A destination account for payment. -#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, RuntimeDebug)] +#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, Debug)] pub enum RewardDestination { /// Pay into the stash account, increasing the amount at stake accordingly. Staked, @@ -95,7 +92,7 @@ impl Default for RewardDestination { } /// Preference of what happens regarding validation. -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, Encode, Decode, Debug)] pub struct ValidatorPrefs { /// Reward that validator takes up-front; only the rest is split between themselves and /// nominators. @@ -116,18 +113,18 @@ impl Default for ValidatorPrefs { pub trait Staking: System {} /// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked. -#[derive(PartialEq, Eq, Clone, Encode, Decode)] +#[derive(PartialEq, Eq, Clone, Encode, Decode, Ord, PartialOrd, Hash)] pub struct UnlockChunk { /// Amount of funds to be unlocked. #[codec(compact)] - value: Balance, + pub value: Balance, /// Era number at which point it'll be unlocked. #[codec(compact)] - era: EraIndex, + pub era: EraIndex, } /// The ledger of a (bonded) stash. -#[derive(PartialEq, Eq, Clone, Encode, Decode)] +#[derive(PartialEq, Eq, Clone, Encode, Decode, Ord, PartialOrd, Hash)] pub struct StakingLedger { /// The stash account whose balance is actually locked and at stake. pub stash: AccountId, @@ -159,13 +156,7 @@ pub struct StakingLedger { )] pub struct HistoryDepthStore { #[store(returns = u32)] - /// Number of eras to keep in history. - /// - /// Information is kept for eras in `[current_era - history_depth; current_era]`. - /// - /// Must be more than the number of eras delayed by session otherwise. - /// I.e. active era must always be in history. - /// I.e. `active_era > current_era - history_depth` must be guaranteed. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -175,7 +166,7 @@ pub struct HistoryDepthStore { )] pub struct ValidatorCountStore { #[store(returns = u32)] - /// The ideal number of staking participants. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -185,7 +176,7 @@ pub struct ValidatorCountStore { )] pub struct MinimumValidatorCountStore { #[store(returns = u32)] - /// Minimum number of staking participants before emergency conditions are imposed. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -195,17 +186,15 @@ pub struct MinimumValidatorCountStore { #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct InvulnerablesStore { #[store(returns = Vec)] - /// Any validators that may never be slashed or forcibly kicked. It's a Vec since they're - /// easy to initialize and the performance hit is minimal (we expect no more than four - /// invulnerables) and restricted to testnets. - pub _runtime: core::marker::PhantomData, + /// Marker for the runtime + pub _runtime: PhantomData, } /// Map from all locked "stash" accounts to the controller account. #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct BondedStore { #[store(returns = Vec)] - /// Map from all locked "stash" accounts to the controller account. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -213,7 +202,7 @@ pub struct BondedStore { #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct LedgerStore { #[store(returns = Option>)] - /// Map from all (unlocked) "controller" accounts to the info regarding the staking. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -221,7 +210,7 @@ pub struct LedgerStore { #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct PayeeStore { #[store(returns = RewardDestination)] - /// Where the reward payment should be made. Keyed by stash. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -229,7 +218,7 @@ pub struct PayeeStore { #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct ValidatorsStore { #[store(returns = ValidatorPrefs)] - /// The map from (wannabe) validator stash key to the preferences of that validator. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -237,7 +226,7 @@ pub struct ValidatorsStore { #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct NominatorsStore { #[store(returns = Option>)] - /// The map from nominator stash key to the set of stash keys of all validators to nominate. + /// Marker for the runtime pub _runtime: PhantomData, } @@ -262,10 +251,7 @@ pub struct CurrentEraStore { #[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)] pub struct ActiveEraStore { #[store(returns = Option)] - /// The active era information, it holds index and start. - /// - /// The active era is the era currently rewarded. - /// Validator set of this era must be equal to `SessionInterface::validators`. + /// Marker for the runtime pub _runtime: PhantomData, } diff --git a/src/runtimes.rs b/src/runtimes.rs index 0366a86abe..26f5d9bbb9 100644 --- a/src/runtimes.rs +++ b/src/runtimes.rs @@ -61,6 +61,13 @@ impl Balances for DefaultNodeRuntime { type Balance = u128; } +impl Session for DefaultNodeRuntime { + type SessionIndex = u32; + type ValidatorId = ::AccountId; +} + +impl Staking for DefaultNodeRuntime {} + impl Contracts for DefaultNodeRuntime {} /// Concrete type definitions compatible with those for kusama, v0.7