-
Notifications
You must be signed in to change notification settings - Fork 1.2k
staking-async: add missing new_session_genesis #8310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
63a0b03
epm: enhance fallback election handling at genesis block
sigurpol 0d6e254
Introduce split of asap into asap/do_asap fn
sigurpol 5f50548
Cleanup prdoc
sigurpol 3525e4f
fix from kian
kianenigma 31a9f3f
staking-async-ah-client: add missing new_session_genesis
sigurpol aae4c88
Revert changes in the election-provider-multi-phase-pallet
sigurpol a804e2b
Fix fmt
sigurpol a8cb72a
Merge branch 'master' into multi_phase_default_snapshot_as_fallback
sigurpol 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
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| title: 'epm: enhance fallback election handling at genesis block' | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: |- | ||
| Prepare the snapshot for fallback elections at block zero, ensuring successful execution even at genesis. | ||
| Modify the fallback logic to include a check for the genesis block alongside the existing runtime benchmarks feature. | ||
|
|
||
| This change improves the robustness of the election provider by ensuring that fallback elections can be executed from the very first block. | ||
| While the solution has the benefit to be limited in scope and not invasive, a better fix would be probably not to rely on the asap() method at all for genesis block but ensure that the session manager correctly calls new_session() or new_session_genesis() respectively. | ||
|
|
||
| Fix #8302 as introduced by #8127. | ||
| Note also that the regression described in #8302 does NOT affect any running chain, but mostly testing. | ||
| crates: | ||
| - name: pallet-election-provider-multi-phase | ||
| bump: patch |
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
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 |
|---|---|---|
|
|
@@ -534,6 +534,16 @@ pub mod pallet { | |
| <Self as pallet_session::SessionManager<_>>::start_session(start_index) | ||
| } | ||
|
|
||
| fn new_session_genesis( | ||
|
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. [nitpick] we also need to cleanup comment at line 530 since we now implement new_session_genesis :) |
||
| new_index: SessionIndex, | ||
| ) -> Option<Vec<(T::AccountId, sp_staking::Exposure<T::AccountId, BalanceOf<T>>)>> { | ||
| if Mode::<T>::get() == OperatingMode::Passive { | ||
| T::Fallback::new_session_genesis(new_index) | ||
| } else { | ||
| None | ||
| } | ||
| } | ||
|
|
||
| fn end_session(end_index: SessionIndex) { | ||
| <Self as pallet_session::SessionManager<_>>::end_session(end_index) | ||
| } | ||
|
|
@@ -555,6 +565,14 @@ pub mod pallet { | |
| } | ||
| } | ||
|
|
||
| fn new_session_genesis(new_index: SessionIndex) -> Option<Vec<T::AccountId>> { | ||
| if Mode::<T>::get() == OperatingMode::Passive { | ||
| T::Fallback::new_session_genesis(new_index) | ||
| } else { | ||
| None | ||
| } | ||
| } | ||
|
|
||
| fn end_session(session_index: u32) { | ||
| match Mode::<T>::get() { | ||
| OperatingMode::Passive => T::Fallback::end_session(session_index), | ||
|
|
||
Oops, something went wrong.
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.