Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
33b105b
Decouple the session validators from im-online
liuchengxu Sep 17, 2020
d5ce27f
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Sep 18, 2020
1070e51
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Sep 20, 2020
526dbd7
.
liuchengxu Sep 20, 2020
5f1ab56
Add SessionInterface trait in im-online
liuchengxu Sep 23, 2020
451179d
Merge branch 'make-im-online-validator-set-flexiable' of https://gith…
liuchengxu Sep 24, 2020
725ca92
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Sep 24, 2020
141b27b
Fix merging issue
liuchengxu Sep 24, 2020
9bed321
Make all compile
liuchengxu Sep 24, 2020
1582b7b
Fix tests
liuchengxu Sep 24, 2020
8fded12
Avoid using frame dep in primitives via pallet-session-common
liuchengxu Sep 24, 2020
db2d1a4
Merge ValidatorSet into SessionInterface trait
liuchengxu Sep 24, 2020
9f1344d
Move pallet-sesion-common into pallet-session
liuchengxu Sep 25, 2020
d5a3b4f
Move SessionInterface to sp-session and impl it in session pallet
liuchengxu Sep 25, 2020
004bde7
Split put historical::FullValidatorIdentification trait
liuchengxu Sep 26, 2020
c395c81
Fix line width
liuchengxu Sep 26, 2020
550632d
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Sep 26, 2020
4ebb2ef
Fix staking mock
liuchengxu Sep 26, 2020
5a92424
Fix session doc test
liuchengxu Sep 26, 2020
90efb67
Simplify <T as ValidatorIdentification<AccountId>>::ValidatorId as Va…
liuchengxu Sep 27, 2020
1a71e3e
Nits
liuchengxu Sep 27, 2020
e1abd33
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Oct 5, 2020
ee947a5
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Oct 18, 2020
f274541
Clean up.
tomusdrw Oct 19, 2020
c87f862
Make it compile by commenting out report_offence_im_online bench
liuchengxu Oct 22, 2020
1840186
Tests
liuchengxu Oct 22, 2020
da2d4a5
Nits
liuchengxu Oct 22, 2020
58e9fcc
Move OneSessionHandler to sp-session
liuchengxu Oct 22, 2020
7066c13
Fix tests
liuchengxu Oct 22, 2020
9eea0a3
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Oct 22, 2020
1848bd7
Add some docs
liuchengxu Oct 22, 2020
650f279
.
liuchengxu Oct 23, 2020
ee81bf1
Fix typo
liuchengxu Oct 23, 2020
e7598a3
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Oct 28, 2020
ff94e6b
Rename to ValidatorSet::session_index()
liuchengxu Oct 28, 2020
7d5cceb
Add some more docs
liuchengxu Oct 28, 2020
de08937
.
liuchengxu Oct 28, 2020
e28377b
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Oct 28, 2020
6e07546
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Oct 31, 2020
6c42cc8
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Nov 2, 2020
fe9e17a
Remove extra empty line
liuchengxu Nov 2, 2020
3fdb3c4
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Nov 3, 2020
6d8defa
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Nov 4, 2020
aef33ca
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Nov 9, 2020
b919689
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 4, 2021
516afb2
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 14, 2021
c4158d7
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 20, 2021
ea357a3
Fix line width check
liuchengxu Jan 20, 2021
6937b72
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 21, 2021
7a265af
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 24, 2021
d4787ad
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 25, 2021
2c007d0
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Jan 27, 2021
a34f75c
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Feb 1, 2021
04f247c
Merge branch 'make-im-online-validator-set-flexiable' of https://gith…
liuchengxu Feb 1, 2021
865bfd8
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Feb 2, 2021
0a39d79
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Feb 2, 2021
e8c8ce5
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Feb 2, 2021
12ff709
Apply suggestions from code review
liuchengxu Feb 2, 2021
12324f3
Cleaup Cargo.toml
liuchengxu Feb 2, 2021
3551036
Aura has migrated to Pallet now
liuchengxu Feb 2, 2021
8e392fa
Merge branch 'master' of https://github.com/paritytech/substrate into…
liuchengxu Feb 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move SessionInterface to sp-session and impl it in session pallet
  • Loading branch information
liuchengxu committed Sep 25, 2020
commit d5a3b4ff0f23e83b7f8342d1144f42762027b9e2
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
impl pallet_im_online::Trait for Runtime {
type AuthorityId = ImOnlineId;
type Event = Event;
type SessionInterface = Self;
type SessionInterface = Session;
type SessionDuration = SessionDuration;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority;
Expand Down
2 changes: 2 additions & 0 deletions frame/im-online/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pallet-session = { version = "2.0.0", default-features = false, path = "../sessi
sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" }
sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" }
sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" }
sp-session = { version = "2.0.0", default-features = false, path = "../../primitives/session" }
frame-support = { version = "2.0.0", default-features = false, path = "../support" }
frame-system = { version = "2.0.0", default-features = false, path = "../system" }

Expand All @@ -41,6 +42,7 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"sp-session/std",
"frame-support/std",
"frame-system/std",
]
Expand Down
29 changes: 1 addition & 28 deletions frame/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ use sp_staking::{
SessionIndex,
offence::{ReportOffence, Offence, Kind},
};
use sp_session::SessionInterface;
use frame_support::{
decl_module, decl_event, decl_storage, Parameter, debug, decl_error,
traits::Get,
Expand Down Expand Up @@ -231,34 +232,6 @@ pub trait WeightInfo {
fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight;
}

/// Trait for retrieving the session info needed for online node inspection.
///
/// This trait is used for decouple the pallet-session dependency from im-online
/// module so that the user of im-online & offences modules can pass any list of
/// validators that are considered to be online in each session, particularly useful
/// for the Substrate-based projects having their own staking implementation
/// instead of using pallet-staking directly.
pub trait SessionInterface<ValidatorId> {
/// Returns current session index.
fn current_index() -> SessionIndex;

/// Returns all the validators ought to be online in a session.
///
/// The returned validators are all expected to be running an authority node.
fn validators() -> Vec<ValidatorId>;
}

impl<T: pallet_session::Trait>
SessionInterface<<Self as ValidatorIdentification<<Self as frame_system::Trait>::AccountId>>::ValidatorId> for T
{
fn current_index() -> sp_staking::SessionIndex {
pallet_session::Module::<T>::current_index()
}
fn validators() -> Vec<<Self as ValidatorIdentification<<Self as frame_system::Trait>::AccountId>>::ValidatorId> {
pallet_session::Module::<T>::validators()
}
}

pub trait Trait:
SendTransactionTypes<Call<Self>>
+ ValidatorIdentification<<Self as frame_system::Trait>::AccountId>
Expand Down
2 changes: 1 addition & 1 deletion frame/im-online/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Trait for Runtime {
type AuthorityId = UintAuthorityId;
type Event = ();
type ReportUnresponsiveness = OffenceHandler;
type SessionInterface = Self;
type SessionInterface = Session;
type SessionDuration = Period;
type UnsignedPriority = UnsignedPriority;
type WeightInfo = ();
Expand Down
2 changes: 1 addition & 1 deletion frame/offences/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl pallet_staking::Trait for Test {
impl pallet_im_online::Trait for Test {
type AuthorityId = UintAuthorityId;
type Event = Event;
type SessionInterface = Self;
type SessionInterface = Session;
type SessionDuration = Period;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ();
Expand Down
13 changes: 13 additions & 0 deletions frame/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,3 +826,16 @@ impl<T: Trait> EstimateNextNewSession<T::BlockNumber> for Module<T> {
T::NextSessionRotation::weight(now)
}
}

impl<T: Trait>
sp_session::SessionInterface<
<T as ValidatorIdentification<<T as frame_system::Trait>::AccountId>>::ValidatorId
> for Module<T>
{
fn current_index() -> sp_staking::SessionIndex {
Module::<T>::current_index()
}
fn validators() -> Vec<<T as ValidatorIdentification<<T as frame_system::Trait>::AccountId>>::ValidatorId> {
Module::<T>::validators()
}
}
17 changes: 17 additions & 0 deletions primitives/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ impl GetValidatorCount for MembershipProof {
}
}

/// Trait for retrieving the session info needed for online node inspection.
///
/// This trait is used for decouple the pallet-session dependency from im-online
/// module so that the user of im-online & offences modules can pass any list of
/// validators that are considered to be online in each session, particularly useful
/// for the Substrate-based projects having their own staking implementation
/// instead of using pallet-staking directly.
pub trait SessionInterface<ValidatorId> {
/// Returns current session index.
fn current_index() -> SessionIndex;

/// Returns all the validators ought to be online in a session.
///
/// The returned validators are all expected to be running an authority node.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns all the validators ought to be online in a session.
///
/// The returned validators are all expected to be running an authority node.
/// Returns the active set of validators.

fn validators() -> Vec<ValidatorId>;
}

/// Generate the initial session keys with the given seeds, at the given block and store them in
/// the client's keystore.
#[cfg(feature = "std")]
Expand Down