Skip to content

Commit

Permalink
fix: reference commit v102 w/o obsolete storage migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
OnyxSkyscape committed Mar 22, 2023
1 parent 3bc4824 commit 4423dcf
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions gn-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ pub mod opaque {
/// Opaque block identifier type.
pub type BlockId = generic::BlockId<Block>;

// TODO Remove after im_online runtime upgrade is done.
impl_opaque_keys! {
pub struct OldSessionKeys {
pub aura: Aura,
pub grandpa: Grandpa,

}
}

impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
Expand All @@ -100,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 103,
spec_version: 102,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -277,7 +286,7 @@ impl pallet_im_online::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type ValidatorSet = ValidatorManager;
type ReportUnresponsiveness = ValidatorManager;
type ReportUnresponsiveness = ();
type UnsignedPriority = ImOnlineUnsignedPriority;
type WeightInfo = pallet_im_online::weights::SubstrateWeight<Runtime>;
type MaxKeys = MaxKeys;
Expand Down Expand Up @@ -381,6 +390,26 @@ impl pallet_validator_manager::Config for Runtime {
type MinAuthorities = MinAuthorities;
}

// should be removed along with UpgradeSessionKeys
fn transform_session_keys(_v: AccountId, old: opaque::OldSessionKeys) -> opaque::SessionKeys {
let dummy_id = pallet_im_online::sr25519::AuthorityId::try_from(old.aura.as_ref()).unwrap();

opaque::SessionKeys {
grandpa: old.grandpa,
aura: old.aura,
im_online: dummy_id,
}
}

// 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::<opaque::OldSessionKeys, _>(transform_session_keys);
BlockWeights::get().max_block
}
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime where
Expand Down Expand Up @@ -437,6 +466,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
UpgradeSessionKeys,
>;

#[cfg(feature = "runtime-benchmarks")]
Expand Down

0 comments on commit 4423dcf

Please sign in to comment.