-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,022 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,44 @@ | ||
[package] | ||
name = "module-aleph" | ||
version = "0.9.81-dev" | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
parity-scale-codec = { workspace = true } | ||
scale-info = { workspace = true } | ||
log = { workspace = true } | ||
|
||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
pallet-session = { workspace = true } | ||
sp-std = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
|
||
primitives = { workspace = true } | ||
|
||
[dev-dependencies] | ||
pallet-balances = { workspace = true } | ||
pallet-timestamp = { workspace = true } | ||
sp-core = { workspace = true } | ||
sp-io = { workspace = true } | ||
[features] | ||
default = ["std"] | ||
std = [ | ||
"parity-scale-codec/std", | ||
"scale-info/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"pallet-session/std", | ||
"sp-std/std", | ||
"primitives/std", | ||
"pallet-balances/std", | ||
"sp-runtime/std", | ||
"sp-io/std", | ||
"log/std" | ||
] | ||
try-runtime = [ | ||
"frame-support/try-runtime", | ||
] |
This file contains 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,17 @@ | ||
# Aleph Module | ||
|
||
This module is the runtime companion of the Aleph finality gadget. | ||
|
||
Currently, it only provides support for changing sessions but in the future | ||
it will allow reporting equivocation in AlephBFT. | ||
|
||
This module relies on an extension of the `AlephSessionApi` Runtime API to handle the finality | ||
version. The scheduled version change is persisted as `FinalityScheduledVersionChange`. This | ||
value stores the information about a scheduled finality version change, where `version_incoming` | ||
is the version to be set and `session` is the session on which the new version will be set. | ||
A `pallet_session::Session_Manager` checks whether a scheduled version change has moved into | ||
the past and, if so, records it as the current version represented as `FinalityVersion`, | ||
and clears `FinalityScheduledVersionChange`. | ||
It is always possible to reschedule a version change. In order to cancel a scheduled version | ||
change rather than reschedule it, a new version change should be scheduled with | ||
`version_incoming` set to the current value of `FinalityVersion`. |
This file contains 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,54 @@ | ||
# To-Do List | ||
|
||
This list contains all TODOs in the Repo | ||
|
||
<!-- TOC --> | ||
- [To-Do List](#to-do-list) | ||
- [1. Guidelines](#1-guidelines) | ||
- [2. Contribution](#2-contribution) | ||
- [3. Lists](#3-lists) | ||
- [4. Tasks](#4-tasks) | ||
<!-- /TOC --> | ||
|
||
## 1. Guidelines | ||
|
||
Note: Before you write a ToDo in this repo, please read the below guidelines carefully. | ||
|
||
Whenever you write a ToDo, you need to follow this standard syntax | ||
|
||
```rust | ||
//TODO:[file_name:task_number] - task_details | ||
``` | ||
|
||
for example: | ||
|
||
```rust | ||
//TODO:[TODO.md:0] - Add Todo Guidelines | ||
``` | ||
|
||
Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`. | ||
|
||
Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\. | ||
|
||
Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task. | ||
|
||
Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example: | ||
|
||
```rust | ||
//TODO:[TODO.md-C:0] - Add Todo Guidelines | ||
``` | ||
|
||
## 2. Contribution | ||
|
||
You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard. | ||
|
||
## 3. Lists | ||
|
||
Each package/module/directory has its own `TODO.md`. | ||
|
||
## 4. Tasks | ||
|
||
These tasks are just for this file specifically. | ||
|
||
- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo. | ||
- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`. |
This file contains 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,80 @@ | ||
// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم | ||
|
||
// This file is part of Setheum. | ||
|
||
// Copyright (C) 2019-Present Setheum Labs. | ||
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use primitives::{FinalityCommitteeManager, SessionIndex}; | ||
use sp_std::vec::Vec; | ||
|
||
use crate::{ | ||
Config, Event, FinalityScheduledVersionChange, FinalityVersion, NextFinalityCommittee, 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)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl<T: Config> FinalityCommitteeManager<T::AccountId> for Pallet<T> { | ||
fn on_next_session_finality_committee(committee: Vec<T::AccountId>) { | ||
NextFinalityCommittee::<T>::put(committee); | ||
} | ||
} |
Oops, something went wrong.