Trait pallet_staking::Config
source · pub trait Config: Config {
Show 27 associated items
type Currency: LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>, Balance = Self::CurrencyBalance>;
type CurrencyBalance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + From<u64> + TypeInfo + MaxEncodedLen;
type UnixTime: UnixTime;
type CurrencyToVote: CurrencyToVote<BalanceOf<Self>>;
type ElectionProvider: ElectionProvider<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>, DataProvider = Pallet<Self>>;
type GenesisElectionProvider: ElectionProvider<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>, DataProvider = Pallet<Self>>;
type NominationsQuota: NominationsQuota<BalanceOf<Self>>;
type HistoryDepth: Get<u32>;
type RewardRemainder: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::NegativeImbalance>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>;
type Slash: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::NegativeImbalance>;
type Reward: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::PositiveImbalance>;
type SessionsPerEra: Get<SessionIndex>;
type BondingDuration: Get<EraIndex>;
type SlashDeferDuration: Get<EraIndex>;
type AdminOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type SessionInterface: SessionInterface<Self::AccountId>;
type EraPayout: EraPayout<BalanceOf<Self>>;
type NextNewSession: EstimateNextNewSession<BlockNumberFor<Self>>;
type MaxNominatorRewardedPerValidator: Get<u32>;
type OffendingValidatorsThreshold: Get<Perbill>;
type VoterList: SortedListProvider<Self::AccountId, Score = VoteWeight>;
type TargetList: SortedListProvider<Self::AccountId, Score = BalanceOf<Self>>;
type MaxUnlockingChunks: Get<u32>;
type EventListeners: OnStakingUpdate<Self::AccountId, BalanceOf<Self>>;
type BenchmarkingConfig: BenchmarkingConfig;
type WeightInfo: WeightInfo;
}
Expand description
Configuration trait of this pallet.
The main purpose of this trait is to act as an interface between this pallet and the runtime in which it is embedded in. A type, function, or constant in this trait is essentially left to be configured by the runtime that includes this pallet.
Consequently, a runtime that wants to include this pallet must implement this trait.
Required Associated Types§
sourcetype Currency: LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>, Balance = Self::CurrencyBalance>
type Currency: LockableCurrency<Self::AccountId, Moment = BlockNumberFor<Self>, Balance = Self::CurrencyBalance>
The staking balance.
sourcetype CurrencyBalance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + From<u64> + TypeInfo + MaxEncodedLen
type CurrencyBalance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + From<u64> + TypeInfo + MaxEncodedLen
Just the Currency::Balance
type; we have this item to allow us to constrain it to
From<u64>
.
sourcetype UnixTime: UnixTime
type UnixTime: UnixTime
Time used for computing era duration.
It is guaranteed to start being called from the first on_finalize
. Thus value at
genesis is not used.
sourcetype CurrencyToVote: CurrencyToVote<BalanceOf<Self>>
type CurrencyToVote: CurrencyToVote<BalanceOf<Self>>
Convert a balance into a number used for election calculation. This must fit into a
u64
but is allowed to be sensibly lossy. The u64
is used to communicate with the
[frame_election_provider_support
] crate which accepts u64 numbers and does operations
in 128.
Consequently, the backward convert is used convert the u128s from sp-elections back to a
BalanceOf
.
sourcetype ElectionProvider: ElectionProvider<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>, DataProvider = Pallet<Self>>
type ElectionProvider: ElectionProvider<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>, DataProvider = Pallet<Self>>
Something that provides the election functionality.
sourcetype GenesisElectionProvider: ElectionProvider<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>, DataProvider = Pallet<Self>>
type GenesisElectionProvider: ElectionProvider<AccountId = Self::AccountId, BlockNumber = BlockNumberFor<Self>, DataProvider = Pallet<Self>>
Something that provides the election functionality at genesis.
sourcetype NominationsQuota: NominationsQuota<BalanceOf<Self>>
type NominationsQuota: NominationsQuota<BalanceOf<Self>>
Something that defines the maximum number of nominations per nominator.
sourcetype HistoryDepth: Get<u32>
type HistoryDepth: Get<u32>
Number of eras to keep in history.
Following information is kept for eras in [current_era - HistoryDepth, current_era]
: ErasStakers
, ErasStakersClipped
,
ErasValidatorPrefs
, ErasValidatorReward
, ErasRewardPoints
,
ErasTotalStake
, ErasStartSessionIndex
,
StakingLedger.claimed_rewards
.
Must be more than the number of eras delayed by session.
I.e. active era must always be in history. I.e. active_era > current_era - history_depth
must be guaranteed.
If migrating an existing pallet from storage value to config value, this should be set to same value or greater as in storage.
Note: HistoryDepth
is used as the upper bound for the BoundedVec
item StakingLedger.claimed_rewards
. Setting this value lower than
the existing value can lead to inconsistencies in the
StakingLedger
and will need to be handled properly in a migration.
The test reducing_history_depth_abrupt
shows this effect.
sourcetype RewardRemainder: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::NegativeImbalance>
type RewardRemainder: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::NegativeImbalance>
Tokens have been minted and are unused for validator-reward. See Era payout.
sourcetype RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>
The overarching event type.
sourcetype Slash: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::NegativeImbalance>
type Slash: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::NegativeImbalance>
Handler for the unbalanced reduction when slashing a staker.
sourcetype Reward: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::PositiveImbalance>
type Reward: OnUnbalanced<<<Self as Config>::Currency as Currency<<Self as Config>::AccountId>>::PositiveImbalance>
Handler for the unbalanced increment when rewarding a staker.
NOTE: in most cases, the implementation of OnUnbalanced
should modify the total
issuance.
sourcetype SessionsPerEra: Get<SessionIndex>
type SessionsPerEra: Get<SessionIndex>
Number of sessions per era.
sourcetype BondingDuration: Get<EraIndex>
type BondingDuration: Get<EraIndex>
Number of eras that staked funds must remain bonded for.
sourcetype SlashDeferDuration: Get<EraIndex>
type SlashDeferDuration: Get<EraIndex>
Number of eras that slashes are deferred by, after computation.
This should be less than the bonding duration. Set to 0 if slashes should be applied immediately, without opportunity for intervention.
sourcetype AdminOrigin: EnsureOrigin<Self::RuntimeOrigin>
type AdminOrigin: EnsureOrigin<Self::RuntimeOrigin>
The origin which can manage less critical staking parameters that does not require root.
Supported actions: (1) cancel deferred slash, (2) set minimum commission.
sourcetype SessionInterface: SessionInterface<Self::AccountId>
type SessionInterface: SessionInterface<Self::AccountId>
Interface for interacting with a session pallet.
sourcetype EraPayout: EraPayout<BalanceOf<Self>>
type EraPayout: EraPayout<BalanceOf<Self>>
The payout for validators and the system for the current era. See Era payout.
sourcetype NextNewSession: EstimateNextNewSession<BlockNumberFor<Self>>
type NextNewSession: EstimateNextNewSession<BlockNumberFor<Self>>
Something that can estimate the next session change, accurately or as a best effort guess.
sourcetype MaxNominatorRewardedPerValidator: Get<u32>
type MaxNominatorRewardedPerValidator: Get<u32>
The maximum number of nominators rewarded for each validator.
For each validator only the $MaxNominatorRewardedPerValidator
biggest stakers can
claim their reward. This used to limit the i/o cost for the nominator payout.
sourcetype OffendingValidatorsThreshold: Get<Perbill>
type OffendingValidatorsThreshold: Get<Perbill>
The fraction of the validator set that is safe to be offending. After the threshold is reached a new era will be forced.
sourcetype VoterList: SortedListProvider<Self::AccountId, Score = VoteWeight>
type VoterList: SortedListProvider<Self::AccountId, Score = VoteWeight>
Something that provides a best-effort sorted list of voters aka electing nominators, used for NPoS election.
The changes to nominators are reported to this. Moreover, each validator’s self-vote is also reported as one independent vote.
To keep the load off the chain as much as possible, changes made to the staked amount
via rewards and slashes are not reported and thus need to be manually fixed by the
staker. In case of bags-list
, this always means using rebag
and putInFrontOf
.
Invariant: what comes out of this list will always be a nominator.
sourcetype TargetList: SortedListProvider<Self::AccountId, Score = BalanceOf<Self>>
type TargetList: SortedListProvider<Self::AccountId, Score = BalanceOf<Self>>
WIP: This is a noop as of now, the actual business logic that’s described below is going to be introduced in a follow-up PR.
Something that provides a best-effort sorted list of targets aka electable validators, used for NPoS election.
The changes to the approval stake of each validator are reported to this. This means any change to:
- The stake of any validator or nominator.
- The targets of any nominator
- The role of any staker (e.g. validator -> chilled, nominator -> validator, etc)
Unlike VoterList
, the values in this list are always kept up to date with reward and
slash as well, and thus represent the accurate approval stake of all account being
nominated by nominators.
Note that while at the time of nomination, all targets are checked to be real validators, they can chill at any point, and their approval stakes will still be recorded. This implies that what comes out of iterating this list MIGHT NOT BE AN ACTIVE VALIDATOR.
sourcetype MaxUnlockingChunks: Get<u32>
type MaxUnlockingChunks: Get<u32>
The maximum number of unlocking
chunks a StakingLedger
can
have. Effectively determines how many unique eras a staker may be
unbonding in.
Note: MaxUnlockingChunks
is used as the upper bound for the
BoundedVec
item StakingLedger.unlocking
. Setting this value
lower than the existing value can lead to inconsistencies in the
StakingLedger
and will need to be handled properly in a runtime
migration. The test reducing_max_unlocking_chunks_abrupt
shows
this effect.
sourcetype EventListeners: OnStakingUpdate<Self::AccountId, BalanceOf<Self>>
type EventListeners: OnStakingUpdate<Self::AccountId, BalanceOf<Self>>
Something that listens to staking updates and performs actions based on the data it receives.
WARNING: this only reports slashing events for the time being.
sourcetype BenchmarkingConfig: BenchmarkingConfig
type BenchmarkingConfig: BenchmarkingConfig
Some parameters of the benchmarking.
sourcetype WeightInfo: WeightInfo
type WeightInfo: WeightInfo
Weight information for extrinsics in this pallet.