This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Implements try_state hook in elections and EPM pallets
#13718
Closed
Closed
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
0402ecc
Adds try_state to elections pallet
gpestana af0e6a5
Finishes elections try-state hook; starts EPM hook impl
gpestana 788ddf4
Adds scaffolding for EPM try_state checks
gpestana b721463
implements checks for EPM
gpestana 3103262
Update frame/election-provider-multi-phase/src/lib.rs
gpestana 6cbf9ab
Update frame/elections-phragmen/src/lib.rs
gpestana a483470
chore(sc-cli): improve runner and signals (#13688)
yjhmelody 8077b19
add a new ci job to fuzz sp-arithmetic (#13673)
19e9edc
sc-slots: Forward block size limit (#13716)
bkchr 322d31b
FRAME: Fix the Referenda confirming alarm (#13704)
gavofyork c04f812
Update pallet licenses to Apache-2.0 (#13467)
aaronbassett f0bcd0d
Reward pool migration fix (#13715)
f94fce0
contracts: Add host function tracing (#13648)
pgherveou 67e1cab
Change license of node-template and FRAME examples to MIT-0 (#13465)
aaronbassett 08e037a
updating labels descriptions (#13557)
the-right-joyce 9522b75
CI: Investigate why `RUSTFLAGS` differs on `master` and PRs (#13686)
rcny 998d768
Remove HeaderBackend requirement from AuthorityDiscovery and NetworkW…
skunert f34444b
CI: rephrase `RUSTFLAGS` (#13735)
rcny f799177
contracts: proper event link in docs (#13729)
kziemianek 9bc5215
Support stable rust for compiling the runtime (#13580)
bkchr 6618041
provide a default value for RELENG_SCRIPTS_BRANCH (#13743)
42ee907
roll out new debian 11 ci image (#13744)
2482f20
Swap 'base58' with 'bs58' (#13739)
davxy 204296a
proc-macro: check for non-args runtime calls added (#13742)
michalkucharczyk 08a35e1
Clean up after debian 11 rollout (#13762)
17a5d9e
[Fix] Bump tuple element number in frame-support. (#13760)
ruseinov 57dddd2
Generic keystore internals (#13749)
davxy 8929804
Application Crypto cleanup (#13746)
davxy cb3869d
Attempt to relieve pressure on `mpsc_network_worker` (#13725)
altonen daf303f
[Enhancement] Throw an error when there are too many pallets (#13763)
ruseinov 6e4e5f5
Build wasm for mvp cpu (#13758)
athei 2fbf914
BEEFY: gossip finality proofs (#13727)
acatangiu 6c1b1ad
Fix nomiantion pools doc render (#13748)
kianenigma e070908
sp-runtime-interface-test: Fix flaky test (#13770)
bkchr 83d9516
bump zombienet version (#13772)
pepoviola 7756bb1
[Contracts] Overflowing bounded `DeletionQueue` allows DoS against co…
pgherveou 668d61b
Refactor: extract most aura logic out to standalone module, make use …
rphmeier c9a1ff0
contracts: make test work with debugger (#13776)
pgherveou 19fe15a
add claim_commission weight (#13774)
76adcec
FRAME: Minor fix for failsafe. (#13741)
gavofyork 81ea064
Adjustments to RPC-query docstrings. (#13698)
DamianStraszak e1b12eb
Force upgrade snow to 0.9.2 (#13806)
bkchr a066028
Scheduler pre block limit note (#13231)
muharem 6d38833
Disable `sign-ext` WASM feature when building runtimes (#13804)
koute 71eaef9
refactor: inconsistent BalanceConversion fn (#13610)
wischli fae245d
Remove deprecated batch verification (#13799)
bkchr d5ddea6
Uniform pallet warnings (#13798)
ggwpez cc3f56a
Update documentation for uniques (This PR renames classes and instanc…
simonsso ee40229
Implement #[pallet::composite_enum] (#13722)
KiChjang f6f7ced
Expose WASM extensions in executor semantics (#13811)
s0me0ne-unkn0wn 6c45413
Deprecate V1 Weights (#13699)
ggwpez 32f601b
update links to ink! (#13819)
agryaznov d1e309f
Move registration of `ReadRuntimeVersionExt` to `ExecutionExtension` …
bkchr 5b508e9
Mention `on_idle` round-robin logic to `trait Hooks` cargo doc (#13797)
gpestana a930258
ProofRecorder: Implement transactional support (#13769)
bkchr a98e3c2
remove duplicate sync option documentation (#13828)
liamaharon 74c0cf6
Add HoldReason to the NIS pallet (#13823)
KiChjang 3c139bc
Fix `try-runtime follow-chain`, try-runtime upgrade tuple tests, cli …
liamaharon 37479ad
Use proper weights in the `pallet-template` (#13817)
AlexD10S 359d86d
Addresses PR review comments
gpestana c6633c8
Merge branch 'master' into gpestana/try_state_elections
gpestana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
implements checks for EPM
- Loading branch information
commit b7214631afa57d0400c966bb9125513255c76e29
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1580,30 +1580,73 @@ impl<T: Config> Pallet<T> { | |
| #[cfg(any(feature = "try-runtime", test))] | ||
| impl<T: Config> Pallet<T> { | ||
| fn do_try_state() -> Result<(), &'static str> { | ||
| Self::try_state_solution_queue()?; | ||
| Self::try_state_snapshot()?; | ||
| Self::try_state_signed_submissions_map() | ||
| } | ||
|
|
||
| // [`QueuedSolution`] state check. Invariants: | ||
| // - Queued solutions must be sorted by score (highest first). | ||
| fn try_state_solution_queue() -> Result<(), &'static str> { | ||
| todo!() | ||
| Self::try_state_signed_submissions_map()?; | ||
| Self::try_state_phase_off() | ||
| } | ||
|
|
||
| // [`Snapshot`] state check. Invariants: | ||
| // - Does not exist if in `Phase::Off`; | ||
| // - [`DesiredTargets`] exist IFF [`Snapshot`] is present. | ||
| // - [`SnapshotMetadata`] exist IFF [`Snapshot`] is present. | ||
| fn try_state_snapshot() -> Result<(), &'static str> { | ||
| todo!() | ||
| let set = <DesiredTargets<T>>::get().is_some() && <DesiredTargets<T>>::get().is_some(); | ||
|
|
||
| match <Snapshot<T>>::take().is_some() { | ||
| true if !set => Err("If the snapshot exists, the desired targets and snapshot metadata must also exist."), | ||
| _ => Ok(()), | ||
| } | ||
| } | ||
|
|
||
| // [`SignedSubmissionsMap`] state check. Invariants: | ||
| // - All [`SignedSubmissionIndices`] are present in [`SignedSubmissionsMap`], and no more; | ||
| // - [`SignedSubmissionNextIndex`] points at an existing (and best) submissoin in the map. | ||
| // - [`SignedSubmissionNextIndex`] is not present in [`SignedSubmissionsMap`]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we can be more specific with this invariant. Should
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not necessarily, that is the reason why we keep the index in storage (also to avoid iterating over the map). |
||
| // - [`SignedSubmissionIndices`] is sorted by election score. | ||
| fn try_state_signed_submissions_map() -> Result<(), &'static str> { | ||
| todo!() | ||
| let mut best_score: ElectionScore = Default::default(); | ||
| let indices = <SignedSubmissionIndices<T>>::get(); | ||
|
|
||
| for (i, indice) in indices.iter().enumerate() { | ||
| let submission = <SignedSubmissionsMap<T>>::get(indice.2); | ||
| if submission.is_none() { | ||
| return Err("All signed submissions indices must be part of the submissions map") | ||
| } | ||
|
|
||
| if i == 0 { | ||
| best_score = indice.0 | ||
| } else { | ||
| if best_score.strict_threshold_better(indice.0, Perbill::zero()) { | ||
| return Err("Signed submission indices vector must be ordered by election score") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if <SignedSubmissionsMap<T>>::iter().nth(indices.len()).is_some() { | ||
| return Err("Signed submissions map length should be the same as the indices vec length") | ||
| } | ||
|
|
||
| match <SignedSubmissionNextIndex<T>>::get() { | ||
| 0 => Ok(()), | ||
| next => | ||
| if <SignedSubmissionsMap<T>>::get(next).is_none() { | ||
| Ok(()) | ||
| } else { | ||
| Err("The next submissions index should not be in the submissions maps already") | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| // [`Phase::Off`] state check. Invariants: | ||
| // - If phase is `Phase::Off`, [`Snapshot`] must be none. | ||
| fn try_state_phase_off() -> Result<(), &'static str> { | ||
| match Self::current_phase().is_off() { | ||
| false => Ok(()), | ||
| true => | ||
| if <Snapshot<T>>::take().is_some() { | ||
| Err("Snapshot must be none when in Phase::Off") | ||
| } else { | ||
| Ok(()) | ||
| }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.