-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Bounds EPM's CurrentPhase
, SnapshotMetadata
and Snapshot
storage structs
#14543
base: master
Are you sure you want to change the base?
Conversation
…with unbounded annotation per storage item that needs to be bounded in the future
…SolutionOrSnapshotSize type
…ndencies (solved, sq_phragmen, etc)
bot rebase |
Rebased |
bot fmt |
@gpestana https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3354502 was started for your command Comment |
@gpestana Command |
The CI pipeline was cancelled due to failure one of the required jobs. |
This PR starts bounding the EPM storage structs. This is a pre-requisite for the staking parachain since the worst case PoV calculation depends on bounded storage types (the
StorageInfoTrait
must be implemented) and overall just good design even when running on the relay chain.The initial plan is to remove the pallet-level
#[pallet::without_storage_info]
annotation and replace with#[pallet::unbounded]
on the individual storage structs. From there, we selectively remove the individual#[pallet::unbounded]
annotations and refactor the code to bound the storage. This way we can break down this work in multiple PRs/releases.Design discussion
Some of the type stored in storage that require bounds are returned by primitives/traits implemented in
frame-election-provider-support
(and elsewhere).The approach we took here is that the results returned from a dependency that must be stored in storage, must be bounded with the correct bounds without the caller needing to
truncate_from
or perform checks on the returned results.For example, the
ElectionDataProvider
returns the electing voters and electable targets which need to be bounded since they will be stored in theSnapshot
storage. TheElectionDataProvider
has been refactored to return bounded vecs onelecting_voters
andelectable_targets
. Now, thetrait ElectionProviderBase
has two new associated types (MaxElectingVoters
andMaxElectableTargets
) which set the bounds for the returned bounded vecs and the EPMElectionProvider
is constraint to use the EPM limits. Note that bothElectionDataProvider::electing_voters
andElectionDataProvider::electable_targets
still accept "soft bounds" as input, which allow the caller to reduce further the amount of voters/targets returned.However, the flow the other way around (caller provides a bounded vec as input to a dependency that currently only accepts vanilla vecs) does not require bounding the inputs. The caller only calls the dependency with
bounded_vec.into_inner()
. We can do this safely since the caller is controlling the bounds andinto_inner()
will be within bound limits.Task list
CurrenPhase
SnapshotMetadata
Snapshot
for another PR(s):
QueuedSolution
SignedSubmissionsMap
Migrations
In this PR, no migrations are required, since the storage items refactored have soft bounds that are re-used when setting the new storage bound. As far as the current soft bounds don't change in lock-step with the release of this PR, there is no need for migrations. However, in the future, whenever the bounds of storage items decrease, a migration is required.
Related to paritytech/polkadot-sdk#323 and paritytech/polkadot-sdk#461