Skip to content

Commit

Permalink
change: ETCM-7136 add partner-chains-session pallet (paritytech#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmbientTea authored Apr 18, 2024
1 parent 8d171c0 commit e75b2a1
Show file tree
Hide file tree
Showing 16 changed files with 803 additions and 24 deletions.
40 changes: 29 additions & 11 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ members = [
"substrate/frame/scheduler",
"substrate/frame/scored-pool",
"substrate/frame/session",
"substrate/frame/partner-chains-session",
"substrate/frame/session/benchmarking",
"substrate/frame/society",
"substrate/frame/staking",
Expand Down Expand Up @@ -461,7 +462,7 @@ members = [
"substrate/primitives/runtime-interface/test-wasm",
"substrate/primitives/runtime-interface/test-wasm-deprecated",
"substrate/primitives/session",
"substrate/primitives/sidechains-session",
"substrate/primitives/partner-chains-session",
"substrate/primitives/staking",
"substrate/primitives/state-machine",
"substrate/primitives/statement-store",
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sp-storage = { path = "../../../substrate/primitives/storage", default-features
sp-version = { path = "../../../substrate/primitives/version", default-features = false }
tx-pool-api = { package = "sp-transaction-pool", path = "../../../substrate/primitives/transaction-pool", default-features = false }
block-builder-api = { package = "sp-block-builder", path = "../../../substrate/primitives/block-builder", default-features = false }
sp-sidechains-session = { path = "../../../substrate/primitives/sidechains-session", default-features = false }
sp-partner-chains-session = { path = "../../../substrate/primitives/partner-chains-session", default-features = false }

pallet-authority-discovery = { path = "../../../substrate/frame/authority-discovery", default-features = false }
pallet-authorship = { path = "../../../substrate/frame/authorship", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl sp_runtime::traits::Convert<AccountId, Option<AccountId>> for ValidatorIdOf
}
}

impl sp_sidechains_session::CurrentSessionIndex for Runtime {
impl sp_partner_chains_session::CurrentSessionIndex for Runtime {
fn current_session_index() -> SessionIndex {
Session::current_index()
}
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sp-version = { path = "../../../substrate/primitives/version", default-features
tx-pool-api = { package = "sp-transaction-pool", path = "../../../substrate/primitives/transaction-pool", default-features = false }
block-builder-api = { package = "sp-block-builder", path = "../../../substrate/primitives/block-builder", default-features = false }
sp-npos-elections = { path = "../../../substrate/primitives/npos-elections", default-features = false }
sp-sidechains-session = { path = "../../../substrate/primitives/sidechains-session", default-features = false }
sp-partner-chains-session = { path = "../../../substrate/primitives/partner-chains-session", default-features = false }

frame-election-provider-support = { path = "../../../substrate/frame/election-provider-support", default-features = false }
frame-executive = { path = "../../../substrate/frame/executive", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ parameter_types! {
pub const MaxControllersInDeprecationBatch: u32 = 751;
}

impl sp_sidechains_session::CurrentSessionIndex for Runtime {
impl sp_partner_chains_session::CurrentSessionIndex for Runtime {
fn current_session_index() -> sp_staking::SessionIndex {
Session::current_index()
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-f
sp-statement-store = { path = "../../../primitives/statement-store", default-features = false, features = ["serde"] }
sp-version = { path = "../../../primitives/version", default-features = false, features = ["serde"] }
sp-io = { path = "../../../primitives/io", default-features = false }
sp-sidechains-session = { path = "../../../primitives/sidechains-session", default-features = false }
sp-partner-chains-session = { path = "../../../primitives/partner-chains-session", default-features = false }

# frame dependencies
frame-executive = { path = "../../../frame/executive", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ impl pallet_im_online::Config for Runtime {
type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
}

impl sp_sidechains_session::CurrentSessionIndex for Runtime {
impl sp_partner_chains_session::CurrentSessionIndex for Runtime {
fn current_session_index() -> sp_staking::SessionIndex {
Session::current_index()
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sp-core = { path = "../../primitives/core", default-features = false, features =
sp-io = { path = "../../primitives/io", default-features = false }
sp-runtime = { path = "../../primitives/runtime", default-features = false, features = ["serde"] }
sp-session = { path = "../../primitives/session", default-features = false }
sp-sidechains-session = { path = "../../primitives/sidechains-session", default-features = false }
sp-partner-chains-session = { path = "../../primitives/partner-chains-session", default-features = false }
sp-staking = { path = "../../primitives/staking", default-features = false, features = ["serde"] }
sp-std = { path = "../../primitives/std", default-features = false }

Expand Down Expand Up @@ -67,7 +67,7 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-session/std",
"sp-sidechains-session/std",
"sp-partner-chains-session/std",
"sp-staking/std",
"sp-std/std",
]
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Pallet<T> {

impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T>
where
T: sp_sidechains_session::CurrentSessionIndex,
T: sp_partner_chains_session::CurrentSessionIndex,
{
type Key = AuthorityId;

Expand Down Expand Up @@ -616,7 +616,7 @@ where

// update the mapping to note that the current set corresponds to the
// latest equivalent session (i.e. now).
let session_index = <T as sp_sidechains_session::CurrentSessionIndex>::current_session_index();
let session_index = <T as sp_partner_chains_session::CurrentSessionIndex>::current_session_index();
SetIdSession::<T>::insert(current_set_id, &session_index);
}

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ use pallet_session::historical as pallet_session_historical;
use sp_consensus_grandpa::{RoundNumber, SetId, GRANDPA_ENGINE_ID};
use sp_core::{crypto::KeyTypeId, H256};
use sp_keyring::Ed25519Keyring;
use sp_partner_chains_session::CurrentSessionIndex;
use sp_runtime::{
curve::PiecewiseLinear,
impl_opaque_keys,
testing::{TestXt, UintAuthorityId},
traits::OpaqueKeys,
BuildStorage, DigestItem, Perbill,
};
use sp_sidechains_session::CurrentSessionIndex;
use sp_staking::{EraIndex, SessionIndex};

type Block = frame_system::mocking::MockBlock<Test>;
Expand Down
42 changes: 42 additions & 0 deletions substrate/frame/partner-chains-session/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "pallet-partner-chains-session"
version = "1.0.0"
repository.workspace = true
description = "FRAME pallet for setting validators with InherentData and session management"
edition = "2021"
license = "Apache-2.0"


[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
frame-support = { path = "../support", default-features = false }
frame-system = { path = "../system", default-features = false }
impl-trait-for-tuples = "0.2.2"
log = { workspace = true }
pallet-timestamp = { path = "../timestamp", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] }
sp-core = { path = "../../primitives/core", default-features = false, features = ["serde"] }
sp-runtime = { path = "../../primitives/runtime", default-features = false, features = ["serde"] }
sp-partner-chains-session = { path = "../../primitives/partner-chains-session", default-features = false }
sp-staking = { path = "../../primitives/staking", default-features = false, features = ["serde"] }
sp-std = { path = "../../primitives/std", default-features = false }


[features]
default = ["std", "polkadot-js-compat"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"log/std",
"scale-info/std",
"sp-core/std",
"sp-runtime/std",
"sp-partner-chains-session/std",
"sp-staking/std",
"sp-std/std",
]
polkadot-js-compat = []
Loading

0 comments on commit e75b2a1

Please sign in to comment.