mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Add assignment keys to session keys, no separate approvals key (#2092)
* guide: merge backing and approval keys * bump substrate master & update primitives * use new SessionInfo struct in session_info * session keys upgrade for Polkadot * kusama & westend runtimes * bump westend, kusama, and polkadot versions * add session key to rococo & test-runtime * update prepare-test-net to latest subkey * update chain specs to support new para_assignment session key * get cargo.lock from master * formatting * update kill_storage based on substrate master * fix test-service * assgn -> asgn * use session info module for assignment session key
This commit is contained in:
committed by
GitHub
parent
04e9489da6
commit
15c253117d
@@ -28,13 +28,13 @@ use primitives::v1::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt,
|
||||
CoreState, GroupRotationInfo, Hash, Id, Moment, Nonce, OccupiedCoreAssumption,
|
||||
PersistedValidationData, Signature, ValidationCode, ValidationData, ValidatorId, ValidatorIndex,
|
||||
InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
|
||||
InboundDownwardMessage, InboundHrmpMessage, SessionInfo, AssignmentId,
|
||||
};
|
||||
use runtime_common::{
|
||||
SlowAdjustingFeeUpdate, CurrencyToVote,
|
||||
impls::ToAuthor,
|
||||
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit,
|
||||
ParachainSessionKeyPlaceholder,
|
||||
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
@@ -87,7 +87,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("westend"),
|
||||
impl_name: create_runtime_str!("parity-westend"),
|
||||
authoring_version: 2,
|
||||
spec_version: 47,
|
||||
spec_version: 48,
|
||||
impl_version: 0,
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
@@ -253,16 +253,46 @@ parameter_types! {
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct OldSessionKeys {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub para_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub para_assignment: AssignmentSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
|
||||
fn transform_session_keys(v: AccountId, old: OldSessionKeys) -> SessionKeys {
|
||||
SessionKeys {
|
||||
grandpa: old.grandpa,
|
||||
babe: old.babe,
|
||||
im_online: old.im_online,
|
||||
para_validator: old.para_validator,
|
||||
para_assignment: {
|
||||
// We need to produce a dummy value that's unique for the validator.
|
||||
let mut id = AssignmentId::default();
|
||||
let id_raw: &mut [u8] = id.as_mut();
|
||||
id_raw.copy_from_slice(v.as_ref());
|
||||
id_raw[0..4].copy_from_slice(b"asgn");
|
||||
|
||||
id
|
||||
},
|
||||
authority_discovery: old.authority_discovery,
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
|
||||
}
|
||||
@@ -722,11 +752,20 @@ pub type Executive = frame_executive::Executive<
|
||||
frame_system::ChainContext<Runtime>,
|
||||
Runtime,
|
||||
AllModules,
|
||||
CustomOnRuntimeUpgrade,
|
||||
UpgradeSessionKeys,
|
||||
>;
|
||||
/// The payload being signed in transactions.
|
||||
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
|
||||
|
||||
// When this is removed, should also remove `OldSessionKeys`.
|
||||
pub struct UpgradeSessionKeys;
|
||||
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
|
||||
fn on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
|
||||
Perbill::from_percent(50) * BlockWeights::get().max_block
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CustomOnRuntimeUpgrade;
|
||||
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
|
||||
fn on_runtime_upgrade() -> frame_support::weights::Weight {
|
||||
|
||||
Reference in New Issue
Block a user