-
Notifications
You must be signed in to change notification settings - Fork 66
A0-1323: Extend Runtime API to handle AlephBFT version #608
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
maciejzelaszczyk
merged 48 commits into
main
from
A0-1323-aleph-bft-version-coordination
Oct 19, 2022
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
5ac97f2
Setting up AlephBFT version
maciejzelaszczyk 27e43a9
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 62126ec
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 459d145
Changed handling to map from session to version
maciejzelaszczyk ac02944
Changed logic to handle serving last set AlephBFT version
maciejzelaszczyk fb4b788
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk c707921
Changed logic to handle setting of version in future only
maciejzelaszczyk afa232b
Reworked storage and accessors to only store one version plus session…
maciejzelaszczyk 3eea0df
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 357e2d9
Treat version change as a delimiting flag
maciejzelaszczyk b74359d
Loose coupling between pallet_aleph and pallet_session to access curr…
maciejzelaszczyk 7c900a3
Fixed trait implementation for mock
maciejzelaszczyk 4ae4f4c
Added comment to trait
maciejzelaszczyk 71c1538
Replaced panics with Results in AlephBFT version handling
maciejzelaszczyk 9ef7f8f
Changed logic to work with numbered versions
maciejzelaszczyk c781a0c
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 0fee02d
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk e0d9fb3
Changed behavior on session start and end
maciejzelaszczyk 157d49b
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 7eea19c
Fixed version change update
maciejzelaszczyk 5ff7256
Linked SessionManager in runtime
maciejzelaszczyk 08a0dc6
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk f63875b
Mock impl
maciejzelaszczyk 3f68522
Reworked SessionManage link
maciejzelaszczyk 002a2b5
Linter
maciejzelaszczyk 9b70cc4
Removed pallet_elections from mock
maciejzelaszczyk 4853d8b
Removed event
maciejzelaszczyk 706c9b1
linter
maciejzelaszczyk 66989bf
Linter
maciejzelaszczyk 23ae4a8
Reworked AlephBFT version history updates
maciejzelaszczyk f0bb79a
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk f23314e
Reworked storage to use value instead of map
maciejzelaszczyk 6416805
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk f08cb5f
Added unit test
maciejzelaszczyk f11a76c
Added version change unscheduling and next session version
maciejzelaszczyk 1ca8421
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 8c46f55
Removed explicit version unscheduling; added version default
maciejzelaszczyk b76b5d3
Extended docs for pallet aleph
maciejzelaszczyk 8f3d600
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk ab33ed1
Moved default AlephBFT version to const
maciejzelaszczyk df25289
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk cc89848
Renamed helper function
maciejzelaszczyk 5a331e7
Merge branch 'A0-1323-aleph-bft-version-coordination' of github.com:C…
maciejzelaszczyk 94519a2
Fixed test
maciejzelaszczyk 1e9daef
Changed naming
maciejzelaszczyk 27a1207
Bumped spec version
maciejzelaszczyk 6599a4e
Bumped transaction version
maciejzelaszczyk 95a7fdd
Merge branch 'main' into A0-1323-aleph-bft-version-coordination
maciejzelaszczyk 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
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| use primitives::SessionIndex; | ||
| use sp_std::vec::Vec; | ||
|
|
||
| use crate::{Config, Event, FinalityScheduledVersionChange, FinalityVersion, Pallet}; | ||
|
|
||
| impl<T> pallet_session::SessionManager<T::AccountId> for Pallet<T> | ||
| where | ||
| T: Config, | ||
| { | ||
| fn new_session(new_index: SessionIndex) -> Option<Vec<T::AccountId>> { | ||
| <T as Config>::SessionManager::new_session(new_index) | ||
| } | ||
|
|
||
| fn new_session_genesis(new_index: SessionIndex) -> Option<Vec<T::AccountId>> { | ||
| <T as Config>::SessionManager::new_session_genesis(new_index) | ||
| } | ||
|
|
||
| fn end_session(end_index: SessionIndex) { | ||
| <T as Config>::SessionManager::end_session(end_index); | ||
| } | ||
|
|
||
| fn start_session(start_index: SessionIndex) { | ||
| <T as Config>::SessionManager::start_session(start_index); | ||
| Self::update_version_change_history(); | ||
| } | ||
| } | ||
|
|
||
| impl<T> Pallet<T> | ||
| where | ||
| T: Config, | ||
| { | ||
| // Check if a schedule version change has moved into the past. Update history, even if there is | ||
| // no change. Resets the scheduled version. | ||
| fn update_version_change_history() { | ||
| let current_session = Self::current_session(); | ||
|
|
||
| if let Some(scheduled_version_change) = <FinalityScheduledVersionChange<T>>::get() { | ||
| let scheduled_session = scheduled_version_change.session; | ||
| let scheduled_version = scheduled_version_change.version_incoming; | ||
|
|
||
| // Record the scheduled version as the current version as it moves into the past. | ||
| if scheduled_session == current_session { | ||
| <FinalityVersion<T>>::put(scheduled_version); | ||
|
|
||
| // Reset the scheduled version. | ||
| <FinalityScheduledVersionChange<T>>::kill(); | ||
|
|
||
| Self::deposit_event(Event::FinalityVersionChange(scheduled_version_change)); | ||
| } | ||
| } | ||
| } | ||
| } |
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
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| use primitives::SessionIndex; | ||
|
|
||
| /// Information provider from `pallet_session`. Loose pallet coupling via traits. | ||
| pub trait SessionInfoProvider<T: frame_system::Config> { | ||
| fn current_session() -> SessionIndex; | ||
| } | ||
|
|
||
| impl<T> SessionInfoProvider<T> for pallet_session::Pallet<T> | ||
| where | ||
| T: pallet_session::Config, | ||
| { | ||
| fn current_session() -> SessionIndex { | ||
| pallet_session::CurrentIndex::<T>::get() | ||
| } | ||
| } |
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.