Bound some storage items for pallet staking and clean up deprecated exposures#7483
Conversation
staking and clean up deprecated exposuresstaking and clean up deprecated exposures
|
/cmd prdoc --audience runtime_dev --bump patch |
|
Deferring |
| MinimumValidatorCount::<T>::put(self.minimum_validator_count); | ||
| Invulnerables::<T>::put(&self.invulnerables); | ||
| assert!( | ||
| self.invulnerables.len() as u32 <= T::MaxInvulnerables::get(), |
There was a problem hiding this comment.
self.invulnerables is already bounded, we don't need this check.
| let disabled_validators_maybe = BoundedVec::try_from(old_disabled_validators); | ||
| match disabled_validators_maybe { | ||
| Ok(disabled_validators) => { | ||
| y = y.saturating_add(1); |
There was a problem hiding this comment.
You have read the storage already no matter if the match is Ok or Err.
| match disabled_validators_maybe { | ||
| Ok(disabled_validators) => { | ||
| y = y.saturating_add(1); | ||
| DisabledValidators::<T>::set(disabled_validators); |
There was a problem hiding this comment.
The main point that might be missed here is that the encoding of a Vec<_> and BoundedVec<_> is exactly the same. So no data actually needs to be migrated.
What the migration would have to do is to check if the data won't fit into BoundedVec<_>, and in this case truncate it.
If hypothetically DisabledValidators is too large, your migration will not touch it, which means the runtime will still fail to decode it upon next access.
| log!(warn, "v17 failed to bound some storage items."); | ||
| } | ||
|
|
||
| T::DbWeight::get().reads_writes(x.into(), y.into()) |
There was a problem hiding this comment.
In any case I will temp remove this migration as we will start from a fresh state and migrate the data. So any failed bounding will be detected in the migration testing.
| <Pallet<T>>::deposit_event(super::Event::<T>::ValidatorDisabled { | ||
| stash: params.stash.clone(), | ||
| }); | ||
| if disabled.try_insert(index, (offender_idx, new_severity)).is_ok() { |
There was a problem hiding this comment.
For this you can use .defensive, worth reading up on it.
|
All GitHub workflows were cancelled due to failure one of the required jobs. |
## Multi Block Election Pallet This PR adds the first iteration of the multi-block staking pallet. From this point onwards, the staking and its election provider pallets are being customized to work in AssetHub. While usage in solo-chains is still possible, it is not longer the main focus of this pallet. For a safer usage, please fork and user an older version of this pallet. --- ## Replaces - [x] #6034 - [x] #5272 ## Related PRs: - [x] #7483 - [ ] #7357 - [ ] #7424 - [ ] paritytech/polkadot-staking-miner#955 This branch can be periodically merged into #7358 -> #6996 ## TODOs: - [x] rebase to master - Benchmarking for staking critical path - [x] snapshot - [x] election result - Benchmarking for EPMB critical path - [x] snapshot - [x] verification - [x] submission - [x] unsigned submission - [ ] election results fetching - [ ] Fix deletion weights. Either of - [ ] Garbage collector + lazy removal of all paged storage items - [ ] Confirm that deletion is small PoV footprint. - [ ] Move election prediction to be push based. @tdimitrov - [ ] integrity checks for bounds - [ ] Properly benchmark this as a part of CI -- for now I will remove them as they are too slow - [x] add try-state to all pallets - [x] Staking to allow genesis dev accounts to be created internally - [x] Decouple miner config so @niklasad1 can work on the miner 72841b7 - [x] duplicate snapshot page reported by @niklasad1 - [ ] #6520 or equivalent -- during snapshot, `VoterList` must be locked - [ ] Move target snapshot to a separate block --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: command-bot <> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Giuseppe Re <giuseppe.re@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
## Multi Block Election Pallet This PR adds the first iteration of the multi-block staking pallet. From this point onwards, the staking and its election provider pallets are being customized to work in AssetHub. While usage in solo-chains is still possible, it is not longer the main focus of this pallet. For a safer usage, please fork and user an older version of this pallet. --- ## Replaces - [x] paritytech#6034 - [x] paritytech#5272 ## Related PRs: - [x] paritytech#7483 - [ ] paritytech#7357 - [ ] paritytech#7424 - [ ] paritytech/polkadot-staking-miner#955 This branch can be periodically merged into paritytech#7358 -> paritytech#6996 ## TODOs: - [x] rebase to master - Benchmarking for staking critical path - [x] snapshot - [x] election result - Benchmarking for EPMB critical path - [x] snapshot - [x] verification - [x] submission - [x] unsigned submission - [ ] election results fetching - [ ] Fix deletion weights. Either of - [ ] Garbage collector + lazy removal of all paged storage items - [ ] Confirm that deletion is small PoV footprint. - [ ] Move election prediction to be push based. @tdimitrov - [ ] integrity checks for bounds - [ ] Properly benchmark this as a part of CI -- for now I will remove them as they are too slow - [x] add try-state to all pallets - [x] Staking to allow genesis dev accounts to be created internally - [x] Decouple miner config so @niklasad1 can work on the miner 72841b7 - [x] duplicate snapshot page reported by @niklasad1 - [ ] paritytech#6520 or equivalent -- during snapshot, `VoterList` must be locked - [ ] Move target snapshot to a separate block --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Ankan <10196091+Ank4n@users.noreply.github.com> Co-authored-by: command-bot <> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Giuseppe Re <giuseppe.re@parity.io> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Building from #6445 on top of #7282
Changes
Invulnerables, vector of validators invulnerable to slashing.MaxInvulnerablesto boundInvulnerablesVec ->BoundedVec.westend).Disabled Validators, vector of validators that have offended in a given era and have been disabled.MaxDisabledValidatorsto boundDisabledValidatorsVec ->BoundedVec.MaxValidatorsCountaccording to the current disabling strategy).ErasStakersandErasStakersClipped(see Tracker issue for cleaning up old non-paged exposure logic in staking pallet #433 ), non-paged validators exposures.Migrating pallet
stakingstorage to v17 to apply all changes.TO DO (in a follow-up PR)
ErasStakersPagedExposurePage.othersvectorBondedErasvectorClaimedRewardspages vectorErasRewardPointsEraRewardPoints.individualBTreeMapUnappliedSlashesSlashingSpansSlashingSpans.priorvector