diff --git a/gn-runtime/src/lib.rs b/gn-runtime/src/lib.rs index 699f3786..f18b2306 100644 --- a/gn-runtime/src/lib.rs +++ b/gn-runtime/src/lib.rs @@ -79,6 +79,15 @@ pub mod opaque { /// Opaque block identifier type. pub type BlockId = generic::BlockId; + // 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, @@ -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, @@ -277,7 +286,7 @@ impl pallet_im_online::Config for Runtime { type RuntimeEvent = RuntimeEvent; type NextSessionRotation = pallet_session::PeriodicSessions; type ValidatorSet = ValidatorManager; - type ReportUnresponsiveness = ValidatorManager; + type ReportUnresponsiveness = (); type UnsignedPriority = ImOnlineUnsignedPriority; type WeightInfo = pallet_im_online::weights::SubstrateWeight; type MaxKeys = MaxKeys; @@ -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::(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 @@ -437,6 +466,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + UpgradeSessionKeys, >; #[cfg(feature = "runtime-benchmarks")]