Tracking issue for bounding pallet-staking
storage items #255
Open
Description
related to #323 and paritytech/substrate#9724
If we simply remove the pallet::without_storage_info
, we get an error about the following items:
Full Errors
error[E0277]: the trait bound `std::vec::Vec<<T as frame_system::Config>::AccountId>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `std::vec::Vec<<T as frame_system::Config>::AccountId>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageInvulnerables<T>, std::vec::Vec<<T as frame_system::Config>::AccountId>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `StakingLedger<T>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `StakingLedger<T>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStorageLedger<T>, frame_support::Blake2_128Concat, <T as frame_system::Config>::AccountId, StakingLedger<T>>`
error[E0277]: the trait bound `RewardDestination<<T as frame_system::Config>::AccountId>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `RewardDestination<<T as frame_system::Config>::AccountId>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStoragePayee<T>, frame_support::Twox64Concat, <T as frame_system::Config>::AccountId, RewardDestination<<T as frame_system::Config>::AccountId>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `ValidatorPrefs: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `ValidatorPrefs`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::CountedStorageMap<pallet::pallet::_GeneratedPrefixForStorageValidators<T>, frame_support::Twox64Concat, <T as frame_system::Config>::AccountId, ValidatorPrefs, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `Nominations<T>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `Nominations<T>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::CountedStorageMap<_GeneratedPrefixForStorageNominators<T>, frame_support::Twox64Concat, <T as frame_system::Config>::AccountId, Nominations<T>>`
error[E0277]: the trait bound `ActiveEraInfo: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `ActiveEraInfo`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageActiveEra<T>, ActiveEraInfo>`
error[E0277]: the trait bound `Exposure<<T as frame_system::Config>::AccountId, <T as pallet::pallet::Config>::CurrencyBalance>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `Exposure<<T as frame_system::Config>::AccountId, <T as pallet::pallet::Config>::CurrencyBalance>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageDoubleMap<_GeneratedPrefixForStorageErasStakers<T>, frame_support::Twox64Concat, u32, frame_support::Twox64Concat, <T as frame_system::Config>::AccountId, Exposure<<T as frame_system::Config>::AccountId, <T as pallet::pallet::Config>::CurrencyBalance>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `EraRewardPoints<<T as frame_system::Config>::AccountId>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `EraRewardPoints<<T as frame_system::Config>::AccountId>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStorageErasRewardPoints<T>, frame_support::Twox64Concat, u32, EraRewardPoints<<T as frame_system::Config>::AccountId>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `Forcing: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `Forcing`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageForceEra<T>, Forcing, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `std::vec::Vec<UnappliedSlash<<T as frame_system::Config>::AccountId, <T as pallet::pallet::Config>::CurrencyBalance>>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `std::vec::Vec<UnappliedSlash<<T as frame_system::Config>::AccountId, <T as pallet::pallet::Config>::CurrencyBalance>>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStorageUnappliedSlashes<T>, frame_support::Twox64Concat, u32, std::vec::Vec<UnappliedSlash<<T as frame_system::Config>::AccountId, <T as pallet::pallet::Config>::CurrencyBalance>>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `std::vec::Vec<(u32, u32)>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `std::vec::Vec<(u32, u32)>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageBondedEras<T>, std::vec::Vec<(u32, u32)>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `slashing::SlashingSpans: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `slashing::SlashingSpans`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStorageSlashingSpans<T>, frame_support::Twox64Concat, <T as frame_system::Config>::AccountId, slashing::SlashingSpans>`
error[E0277]: the trait bound `SpanRecord<<T as pallet::pallet::Config>::CurrencyBalance>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `SpanRecord<<T as pallet::pallet::Config>::CurrencyBalance>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStorageSpanSlash<T>, frame_support::Twox64Concat, (<T as frame_system::Config>::AccountId, u32), SpanRecord<<T as pallet::pallet::Config>::CurrencyBalance>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `std::vec::Vec<(u32, bool)>: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `std::vec::Vec<(u32, bool)>`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageOffendingValidators<T>, std::vec::Vec<(u32, bool)>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `Releases: parity_scale_codec::MaxEncodedLen` is not satisfied
--> frame/staking/src/pallet/mod.rs:59:12
|
59 | #[pallet::pallet]
| ^^^^^^ the trait `parity_scale_codec::MaxEncodedLen` is not implemented for `Releases`
|
= help: the following other types implement trait `parity_scale_codec::MaxEncodedLen`:
()
(TupleElement0, TupleElement1)
(TupleElement0, TupleElement1, TupleElement2)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
(TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
and 78 others
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageStorageVersion<T>, Releases, frame_support::pallet_prelude::ValueQuery>`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `pallet-staking` due to 15 previous errors
Invulnerables
StakingLedger
Payee
Validators
/ValidatorPrefs
Nominators
/Nominations
ErasStakers
/ErasStakersClipped
/Exposure
ActiveEraInfo
ErasRewardPoints
Forcing
UnappliedSlashes
BondedEras
SlashingSpans
OffendingValidators
Releases
I categorize these into 4 groups:
- [Done] Trivial ones. These are generally 1 liner changes for the type to
derive(MaxEncodedLen)
. This list includes: - [Done] Bounded by
HistoryDepth
. This includes onlyStakingLedger
. Also, a number of storage maps and double maps have an invariant that the number of their keys should never exceedHistoryDepth
. We should detect these, and make sure they are always respected (usetry_state
). - [Done] Bounding by
MaxActiveValidators
. These are storage item who's bound is missing because we don't enforce a bound on the maximum number of active validators.
- This will eventually leak into
election-provider-mutli-phase
, and staking would express: typeElectionProvider<MaxWinners = Self::MaxActiveValidators>
- This will eventually help staking pallet bound the number of validators into session as well. In other words
- @Doordashcon started this with session, staking: introduce static limit on the number of validators substrate#11967 and Bound
RewardPoints
in pallet-staking substrate#12125, but I think we should start from scratch based on my draft in https://github.com/paritytech/substrate/tree/kiz-properly-bound-staking-validators.
- [Weakly bounded in this PR] Bounding by maximum number of active exposed nominators per validator, i.e.
MaxBackersPerWinner
. @ggwpez started doing this in Staking: IntroduceMaxBackersPerWinner
substrate#11935, we need someone to finish it. - Slashing related storage items. These are the more scary ones, and I am not sure if and how we should bound them. The slashing code needs an overhaul in any case.
So, these are the bounds we know:
MaxActiveValidators
:Invulnerables
ErasRewardPoints
MaxBackersPerWinner
ErasStakers
/ErasStakersClipped
/Exposure
HistoryDepth
StakingLedger
- Trivial
ActiveEraInfo
Forcing
Payee
Validators
/ValidatorPrefs
Nominators
/Nominations
-Releases
- Slashing, unknown
UnappliedSlashes
BondedEras
SlashingSpans
OffendingValidators
It is hard to predict all of these without actually writing the entire code. I might be wrong in some places.
- An easy action item, which I am happy to mentor for someone external is to take care of all the trivial ones.
- I am not sure about
MaxActiveValidators
. I might prefer doing it myself since it is rather important and touches a few pallets. Nonetheless, I am grateful for @Doordashcon's effort here so far and will acknowledge it. MaxBackersPerWinner
needs completion by me and @ggwpez- Slashing is a project of its own.