Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
84 changes: 82 additions & 2 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ members = [
"toolkit/governed-map/primitives",
"toolkit/governed-map/pallet",
"toolkit/committee-selection/selection-simulator",
"toolkit/session_keys_registration",
]
resolver = "2"

Expand Down Expand Up @@ -198,6 +199,7 @@ pallet-aura = { default-features = false, git = "https://github.com/paritytech/p
pallet-balances = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
pallet-grandpa = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
pallet-session = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
pallet-staking = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
pallet-sudo = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
pallet-timestamp = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
pallet-transaction-payment = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2506" }
Expand Down Expand Up @@ -330,5 +332,8 @@ partner-chains-mock-data-sources = { path = "toolkit/data-sources/mock", default
sp-governed-map = { path = "toolkit/governed-map/primitives", default-features = false }
pallet-governed-map = { path = "toolkit/governed-map/pallet", default-features = false }

# Session Keys Registration
pallet-session-keys-registration = { path = "toolkit/session_keys_registration", default-features = false }

# demo node
partner-chains-demo-runtime = { path = "demo/runtime" }
3 changes: 1 addition & 2 deletions demo/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ pub fn pc_create_chain_spec(config: &CreateChainSpecConfig<SessionKeys>) -> serd
grandpa: partner_chains_demo_runtime::GrandpaConfig::default(),
sudo: partner_chains_demo_runtime::SudoConfig::default(),
transaction_payment: Default::default(),
session: config.pallet_partner_chains_session_config(),
session: Default::default(),
sidechain: config.pallet_sidechain_config(SlotsPerEpoch::default()),
pallet_session: Default::default(),
session_committee_management: config.pallet_session_validator_management_config(),
native_token_management: config.native_token_management_config(),
governed_map: config.governed_map_config(),
Expand Down
10 changes: 7 additions & 3 deletions demo/node/src/staging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,22 @@ pub fn staging_genesis(
},
transaction_payment: Default::default(),
session: SessionConfig {
initial_validators: initial_authorities
keys: initial_authorities
.iter()
.map(|authority_keys| {
(authority_keys.cross_chain.clone().into(), authority_keys.session.clone())
(
authority_keys.cross_chain.clone().into(),
authority_keys.cross_chain.clone().into(),
authority_keys.session.clone(),
)
})
.collect(),
non_authority_keys: Default::default(),
},
sidechain: SidechainConfig {
genesis_utxo: sp_sidechain::read_genesis_utxo_from_env_with_defaults()?,
..Default::default()
},
pallet_session: Default::default(),
session_committee_management: SessionCommitteeManagementConfig {
initial_authorities: initial_authorities
.into_iter()
Expand Down
4 changes: 2 additions & 2 deletions demo/node/src/template_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ pub fn chain_spec() -> Result<ChainSpec, envy::Error> {
transaction_payment: Default::default(),
session: SessionConfig {
// Initial validators are meant to be updated in the chain spec file, so it is empty here.
initial_validators: vec![],
keys: vec![],
non_authority_keys: Default::default(),
},
sidechain: SidechainConfig {
genesis_utxo: sp_sidechain::read_genesis_utxo_from_env_with_defaults()?,
..Default::default()
},
pallet_session: Default::default(),
session_committee_management: SessionCommitteeManagementConfig {
// Same as SessionConfig
initial_authorities: vec![],
Expand Down
10 changes: 7 additions & 3 deletions demo/node/src/testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,23 @@ pub fn testnet_genesis(
},
transaction_payment: Default::default(),
session: SessionConfig {
initial_validators: initial_authorities
keys: initial_authorities
.iter()
.map(|authority_keys| {
(authority_keys.cross_chain.clone().into(), authority_keys.session.clone())
(
authority_keys.cross_chain.clone().into(),
authority_keys.cross_chain.clone().into(),
authority_keys.session.clone(),
)
})
.collect(),
non_authority_keys: Default::default(),
},
sidechain: SidechainConfig {
genesis_utxo: sp_sidechain::read_genesis_utxo_from_env_with_defaults()?,
slots_per_epoch: SlotsPerEpoch::read_from_env()?,
..Default::default()
},
pallet_session: Default::default(),
session_committee_management: SessionCommitteeManagementConfig {
initial_authorities: initial_authorities
.into_iter()
Expand Down
4 changes: 3 additions & 1 deletion demo/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pallet-grandpa = { workspace = true }
pallet-partner-chains-session = { workspace = true, features = [
"pallet-session-compat",
] }
pallet-session = { workspace = true }
pallet-session = { workspace = true, features = ["historical"] }
pallet-sudo = { workspace = true }
frame-system = { workspace = true }
frame-try-runtime = { workspace = true, optional = true }
Expand Down Expand Up @@ -93,6 +93,7 @@ pallet-governed-map = { workspace = true }
sp-governed-map = { workspace = true }
sp-block-producer-fees = { workspace = true }
pallet-block-producer-fees = { workspace = true }
pallet-session-keys-registration = { workspace = true }

[dev-dependencies]
sp-io = { workspace = true }
Expand Down Expand Up @@ -139,6 +140,7 @@ std = [
"pallet-transaction-payment/std",
"pallet-address-associations/std",
"pallet-block-producer-metadata/std",
"pallet-session-keys-registration/std",
"sp-block-producer-metadata/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
1 change: 0 additions & 1 deletion demo/runtime/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ fn testnet_genesis(
transaction_payment: Default::default(),
sidechain: Default::default(),
session_committee_management: Default::default(),
pallet_session: Default::default(),
session: Default::default(),
native_token_management: Default::default(),
governed_map: GovernedMapConfig {
Expand Down
44 changes: 26 additions & 18 deletions demo/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use sp_core::ByteArray;
use sp_core::{OpaqueMetadata, crypto::KeyTypeId};
use sp_governed_map::MainChainScriptsV1;
use sp_inherents::InherentIdentifier;
use sp_runtime::traits::ConvertInto;
use sp_runtime::{
ApplyExtrinsicResult, MultiSignature, Perbill, generic, impl_opaque_keys,
traits::{
Expand Down Expand Up @@ -309,7 +310,24 @@ impl pallet_aura::Config for Runtime {
type SlotDuration = ConstU64<SLOT_DURATION>;
}

pallet_partner_chains_session::impl_pallet_session_config!(Runtime);
impl pallet_session::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ValidatorId = AccountId;
type ValidatorIdOf = ConvertInto;
type ShouldEndSession = ValidatorManagementSessionManager<Runtime>;
type NextSessionRotation = ();
type SessionManager = ValidatorManagementSessionManager<Runtime>;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type DisablingStrategy = pallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy;

type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
}

// impl pallet_session::historical::Config for Runtime {
// type FullIdentification = ();
// type FullIdentificationOf = ();
// }

impl pallet_grandpa::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
Expand Down Expand Up @@ -373,15 +391,6 @@ impl pallet_sudo::Config for Runtime {
type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
}

impl pallet_partner_chains_session::Config for Runtime {
type ValidatorId = <Self as frame_system::Config>::AccountId;
type ShouldEndSession = ValidatorManagementSessionManager<Runtime>;
type NextSessionRotation = ();
type SessionManager = ValidatorManagementSessionManager<Runtime>;
type SessionHandler = <opaque::SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = opaque::SessionKeys;
}

parameter_types! {
pub const MaxValidators: u32 = 1024;
}
Expand Down Expand Up @@ -672,6 +681,10 @@ impl pallet_governed_map::Config for Runtime {
type BenchmarkHelper = ();
}

impl pallet_session_keys_registration::Config for Runtime {
type PalletsOrigin = OriginCaller;
}

impl crate::test_helper_pallet::Config for Runtime {}

// Create the runtime by composing the FRAME pallets that were previously configured.
Expand All @@ -693,13 +706,9 @@ construct_runtime!(
BlockProducerMetadata: pallet_block_producer_metadata,
BlockProductionLog: pallet_block_production_log,
BlockParticipation: pallet_block_participation,
// pallet_grandpa reads pallet_session::pallet::CurrentIndex storage.
// Only stub implementation of pallet_session should be wired.
// Partner Chains session_manager ValidatorManagementSessionManager writes to pallet_session::pallet::CurrentIndex.
// ValidatorManagementSessionManager is wired in by pallet_partner_chains_session.
PalletSession: pallet_session,
// The order matters!! pallet_partner_chains_session needs to come last for correct initialization order
Session: pallet_partner_chains_session,
Session: pallet_session exclude_parts { Call },
SessionKeysRegistration: pallet_session_keys_registration,
// Historical: pallet_session::historical,
NativeTokenManagement: pallet_native_token_management,
GovernedMap: pallet_governed_map,
TestHelperPallet: crate::test_helper_pallet,
Expand Down Expand Up @@ -895,7 +904,6 @@ impl_runtime_apis! {
}
}


impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(account: AccountId) -> Nonce {
System::account_nonce(account)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,17 @@ echo "Generating chain-spec.json file for Partner chain Nodes..."
./partner-chains-node build-spec --disable-default-bootnode > chain-spec.json

echo "Configuring Initial Validators..."
jq '.genesis.runtimeGenesis.config.session.initialValidators = [
jq '.genesis.runtimeGenesis.config.session.keys = [
[
"5FnXTMg8UnfeGsMaGg24o3NY21VRFRDRdgxuLGmXuYLeZmin",
"5FnXTMg8UnfeGsMaGg24o3NY21VRFRDRdgxuLGmXuYLeZmin",
{
"aura": "5Cyx94iyji8namhRxvs4mAbURtPsvwjWCb68ZihNzfRysGLZ",
"grandpa": "5Cc5eQhbPw4CjwZpWqZkWWumMiuZywfWRK2Rh9guXUJ3U89s"
}
],
[
"5FJMH4MeZgd4fpiiAVLnr4uRop2EDFgzAFcvLmcduQ2cofCi",
"5FJMH4MeZgd4fpiiAVLnr4uRop2EDFgzAFcvLmcduQ2cofCi",
{
"aura": "5E4op92Z2Di1GoVS9KqnoGVKQXG2R9x1vdh3RW892YLFsLrc",
Expand Down
Loading
Loading