Skip to content

Commit 5e3d97e

Browse files
s0me0ne-unkn0wnAnk4n
authored andcommitted
im-online removal final cleanup (#3902)
Rejoice! Rejoice! The story is nearly over. This PR removes stale migrations, auxiliary structures, and package dependencies, thus making Rococo and Westend totally free from any `im-online`-related stuff. `im-online` still stays a part of the Substrate node and its runtime: https://github.com/paritytech/polkadot-sdk/blob/0d9324847391e902bb42f84f0e76096b1f764efe/substrate/bin/node/runtime/src/lib.rs#L2276-L2277 I'm not sure if it makes sense to remove it from there considering that we're not removing `im-online` from FRAME. Please share your opinion.
1 parent be8bd2d commit 5e3d97e

File tree

7 files changed

+2
-291
lines changed

7 files changed

+2
-291
lines changed

Cargo.lock

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cumulus/test/service/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ pallet-timestamp = { path = "../../../substrate/frame/timestamp" }
8888
futures = "0.3.28"
8989
portpicker = "0.1.1"
9090
rococo-parachain-runtime = { path = "../../parachains/runtimes/testing/rococo-parachain" }
91-
pallet-im-online = { path = "../../../substrate/frame/im-online" }
9291
sp-consensus-grandpa = { path = "../../../substrate/primitives/consensus/grandpa" }
9392
sp-authority-discovery = { path = "../../../substrate/primitives/authority-discovery" }
9493
cumulus-test-client = { path = "../client" }
@@ -106,7 +105,6 @@ runtime-benchmarks = [
106105
"cumulus-primitives-core/runtime-benchmarks",
107106
"cumulus-test-client/runtime-benchmarks",
108107
"frame-system/runtime-benchmarks",
109-
"pallet-im-online/runtime-benchmarks",
110108
"pallet-timestamp/runtime-benchmarks",
111109
"parachains-common/runtime-benchmarks",
112110
"polkadot-cli/runtime-benchmarks",

polkadot/node/service/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ sp-version = { path = "../../../substrate/primitives/version" }
6565

6666
# Substrate Pallets
6767
pallet-babe = { path = "../../../substrate/frame/babe" }
68-
pallet-im-online = { path = "../../../substrate/frame/im-online" }
6968
pallet-staking = { path = "../../../substrate/frame/staking" }
7069
pallet-transaction-payment-rpc-runtime-api = { path = "../../../substrate/frame/transaction-payment/rpc/runtime-api" }
7170
frame-system = { path = "../../../substrate/frame/system" }
@@ -197,7 +196,6 @@ runtime-benchmarks = [
197196
"frame-support/runtime-benchmarks",
198197
"frame-system/runtime-benchmarks",
199198
"pallet-babe/runtime-benchmarks",
200-
"pallet-im-online/runtime-benchmarks",
201199
"pallet-staking/runtime-benchmarks",
202200
"polkadot-parachain-primitives/runtime-benchmarks",
203201
"polkadot-primitives/runtime-benchmarks",
@@ -213,7 +211,6 @@ try-runtime = [
213211
"frame-support/try-runtime",
214212
"frame-system/try-runtime",
215213
"pallet-babe/try-runtime",
216-
"pallet-im-online/try-runtime",
217214
"pallet-staking/try-runtime",
218215
"pallet-transaction-payment/try-runtime",
219216
"polkadot-runtime-parachains/try-runtime",

polkadot/runtime/rococo/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ pallet-asset-rate = { path = "../../../substrate/frame/asset-rate", default-feat
6060
frame-executive = { path = "../../../substrate/frame/executive", default-features = false }
6161
pallet-grandpa = { path = "../../../substrate/frame/grandpa", default-features = false }
6262
pallet-identity = { path = "../../../substrate/frame/identity", default-features = false }
63-
pallet-im-online = { path = "../../../substrate/frame/im-online", default-features = false }
6463
pallet-indices = { path = "../../../substrate/frame/indices", default-features = false }
6564
pallet-membership = { path = "../../../substrate/frame/membership", default-features = false }
6665
pallet-message-queue = { path = "../../../substrate/frame/message-queue", default-features = false }
@@ -153,7 +152,6 @@ std = [
153152
"pallet-elections-phragmen/std",
154153
"pallet-grandpa/std",
155154
"pallet-identity/std",
156-
"pallet-im-online/std",
157155
"pallet-indices/std",
158156
"pallet-membership/std",
159157
"pallet-message-queue/std",
@@ -228,7 +226,6 @@ runtime-benchmarks = [
228226
"pallet-elections-phragmen/runtime-benchmarks",
229227
"pallet-grandpa/runtime-benchmarks",
230228
"pallet-identity/runtime-benchmarks",
231-
"pallet-im-online/runtime-benchmarks",
232229
"pallet-indices/runtime-benchmarks",
233230
"pallet-membership/runtime-benchmarks",
234231
"pallet-message-queue/runtime-benchmarks",
@@ -284,7 +281,6 @@ try-runtime = [
284281
"pallet-elections-phragmen/try-runtime",
285282
"pallet-grandpa/try-runtime",
286283
"pallet-identity/try-runtime",
287-
"pallet-im-online/try-runtime",
288284
"pallet-indices/try-runtime",
289285
"pallet-membership/try-runtime",
290286
"pallet-message-queue/try-runtime",

polkadot/runtime/rococo/src/lib.rs

Lines changed: 1 addition & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ use sp_runtime::{
8888
IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion, Verify,
8989
},
9090
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
91-
ApplyExtrinsicResult, BoundToRuntimeAppPublic, FixedU128, KeyTypeId, Perbill, Percent, Permill,
92-
RuntimeAppPublic, RuntimeDebug,
91+
ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug,
9392
};
9493
use sp_staking::SessionIndex;
9594
#[cfg(any(feature = "std", test))]
@@ -347,46 +346,6 @@ impl pallet_authorship::Config for Runtime {
347346
type EventHandler = ();
348347
}
349348

350-
#[derive(Clone, Debug, PartialEq, Eq, Encode, Decode)]
351-
pub struct OldSessionKeys {
352-
pub grandpa: <Grandpa as BoundToRuntimeAppPublic>::Public,
353-
pub babe: <Babe as BoundToRuntimeAppPublic>::Public,
354-
pub im_online: pallet_im_online::sr25519::AuthorityId,
355-
pub para_validator: <Initializer as BoundToRuntimeAppPublic>::Public,
356-
pub para_assignment: <ParaSessionInfo as BoundToRuntimeAppPublic>::Public,
357-
pub authority_discovery: <AuthorityDiscovery as BoundToRuntimeAppPublic>::Public,
358-
pub beefy: <Beefy as BoundToRuntimeAppPublic>::Public,
359-
}
360-
361-
impl OpaqueKeys for OldSessionKeys {
362-
type KeyTypeIdProviders = ();
363-
fn key_ids() -> &'static [KeyTypeId] {
364-
&[
365-
<<Grandpa as BoundToRuntimeAppPublic>::Public>::ID,
366-
<<Babe as BoundToRuntimeAppPublic>::Public>::ID,
367-
sp_core::crypto::key_types::IM_ONLINE,
368-
<<Initializer as BoundToRuntimeAppPublic>::Public>::ID,
369-
<<ParaSessionInfo as BoundToRuntimeAppPublic>::Public>::ID,
370-
<<AuthorityDiscovery as BoundToRuntimeAppPublic>::Public>::ID,
371-
<<Beefy as BoundToRuntimeAppPublic>::Public>::ID,
372-
]
373-
}
374-
fn get_raw(&self, i: KeyTypeId) -> &[u8] {
375-
match i {
376-
<<Grandpa as BoundToRuntimeAppPublic>::Public>::ID => self.grandpa.as_ref(),
377-
<<Babe as BoundToRuntimeAppPublic>::Public>::ID => self.babe.as_ref(),
378-
sp_core::crypto::key_types::IM_ONLINE => self.im_online.as_ref(),
379-
<<Initializer as BoundToRuntimeAppPublic>::Public>::ID => self.para_validator.as_ref(),
380-
<<ParaSessionInfo as BoundToRuntimeAppPublic>::Public>::ID =>
381-
self.para_assignment.as_ref(),
382-
<<AuthorityDiscovery as BoundToRuntimeAppPublic>::Public>::ID =>
383-
self.authority_discovery.as_ref(),
384-
<<Beefy as BoundToRuntimeAppPublic>::Public>::ID => self.beefy.as_ref(),
385-
_ => &[],
386-
}
387-
}
388-
}
389-
390349
impl_opaque_keys! {
391350
pub struct SessionKeys {
392351
pub grandpa: Grandpa,
@@ -398,18 +357,6 @@ impl_opaque_keys! {
398357
}
399358
}
400359

401-
// remove this when removing `OldSessionKeys`
402-
fn transform_session_keys(_val: AccountId, old: OldSessionKeys) -> SessionKeys {
403-
SessionKeys {
404-
grandpa: old.grandpa,
405-
babe: old.babe,
406-
para_validator: old.para_validator,
407-
para_assignment: old.para_assignment,
408-
authority_discovery: old.authority_discovery,
409-
beefy: old.beefy,
410-
}
411-
}
412-
413360
/// Special `ValidatorIdOf` implementation that is just returning the input as result.
414361
pub struct ValidatorIdOf;
415362
impl sp_runtime::traits::Convert<AccountId, Option<AccountId>> for ValidatorIdOf {
@@ -1486,8 +1433,6 @@ pub mod migrations {
14861433

14871434
use frame_support::traits::LockIdentifier;
14881435
use frame_system::pallet_prelude::BlockNumberFor;
1489-
#[cfg(feature = "try-runtime")]
1490-
use sp_core::crypto::ByteArray;
14911436

14921437
pub struct GetLegacyLeaseImpl;
14931438
impl coretime::migration::GetLegacyLease<BlockNumber> for GetLegacyLeaseImpl {
@@ -1514,7 +1459,6 @@ pub mod migrations {
15141459
pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
15151460
pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
15161461
pub const TipsPalletName: &'static str = "Tips";
1517-
pub const ImOnlinePalletName: &'static str = "ImOnline";
15181462
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
15191463
}
15201464

@@ -1551,79 +1495,6 @@ pub mod migrations {
15511495
type PalletName = TipsPalletName;
15521496
}
15531497

1554-
/// Upgrade Session keys to exclude `ImOnline` key.
1555-
/// When this is removed, should also remove `OldSessionKeys`.
1556-
pub struct UpgradeSessionKeys;
1557-
const UPGRADE_SESSION_KEYS_FROM_SPEC: u32 = 104000;
1558-
1559-
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
1560-
#[cfg(feature = "try-runtime")]
1561-
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, sp_runtime::TryRuntimeError> {
1562-
if System::last_runtime_upgrade_spec_version() > UPGRADE_SESSION_KEYS_FROM_SPEC {
1563-
log::warn!(target: "runtime::session_keys", "Skipping session keys migration pre-upgrade check due to spec version (already applied?)");
1564-
return Ok(Vec::new());
1565-
}
1566-
1567-
log::info!(target: "runtime::session_keys", "Collecting pre-upgrade session keys state");
1568-
let key_ids = SessionKeys::key_ids();
1569-
frame_support::ensure!(
1570-
key_ids.into_iter().find(|&k| *k == sp_core::crypto::key_types::IM_ONLINE) == None,
1571-
"New session keys contain the ImOnline key that should have been removed",
1572-
);
1573-
let storage_key = pallet_session::QueuedKeys::<Runtime>::hashed_key();
1574-
let mut state: Vec<u8> = Vec::new();
1575-
frame_support::storage::unhashed::get::<Vec<(ValidatorId, OldSessionKeys)>>(
1576-
&storage_key,
1577-
)
1578-
.ok_or::<sp_runtime::TryRuntimeError>("Queued keys are not available".into())?
1579-
.into_iter()
1580-
.for_each(|(id, keys)| {
1581-
state.extend_from_slice(id.as_slice());
1582-
for key_id in key_ids {
1583-
state.extend_from_slice(keys.get_raw(*key_id));
1584-
}
1585-
});
1586-
frame_support::ensure!(state.len() > 0, "Queued keys are not empty before upgrade");
1587-
Ok(state)
1588-
}
1589-
1590-
fn on_runtime_upgrade() -> Weight {
1591-
if System::last_runtime_upgrade_spec_version() > UPGRADE_SESSION_KEYS_FROM_SPEC {
1592-
log::info!("Skipping session keys upgrade: already applied");
1593-
return <Runtime as frame_system::Config>::DbWeight::get().reads(1);
1594-
}
1595-
log::trace!("Upgrading session keys");
1596-
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
1597-
Perbill::from_percent(50) * BlockWeights::get().max_block
1598-
}
1599-
1600-
#[cfg(feature = "try-runtime")]
1601-
fn post_upgrade(
1602-
old_state: sp_std::vec::Vec<u8>,
1603-
) -> Result<(), sp_runtime::TryRuntimeError> {
1604-
if System::last_runtime_upgrade_spec_version() > UPGRADE_SESSION_KEYS_FROM_SPEC {
1605-
log::warn!(target: "runtime::session_keys", "Skipping session keys migration post-upgrade check due to spec version (already applied?)");
1606-
return Ok(());
1607-
}
1608-
1609-
let key_ids = SessionKeys::key_ids();
1610-
let mut new_state: Vec<u8> = Vec::new();
1611-
pallet_session::QueuedKeys::<Runtime>::get().into_iter().for_each(|(id, keys)| {
1612-
new_state.extend_from_slice(id.as_slice());
1613-
for key_id in key_ids {
1614-
new_state.extend_from_slice(keys.get_raw(*key_id));
1615-
}
1616-
});
1617-
frame_support::ensure!(new_state.len() > 0, "Queued keys are not empty after upgrade");
1618-
frame_support::ensure!(
1619-
old_state == new_state,
1620-
"Pre-upgrade and post-upgrade keys do not match!"
1621-
);
1622-
log::info!(target: "runtime::session_keys", "Session keys migrated successfully");
1623-
Ok(())
1624-
}
1625-
}
1626-
16271498
// We don't have a limit in the Relay Chain.
16281499
const IDENTITY_MIGRATION_KEY_LIMIT: u64 = u64::MAX;
16291500

@@ -1657,12 +1528,6 @@ pub mod migrations {
16571528
pallet_grandpa::migrations::MigrateV4ToV5<Runtime>,
16581529
parachains_configuration::migration::v10::MigrateToV10<Runtime>,
16591530

1660-
// Upgrade `SessionKeys` to exclude `ImOnline`
1661-
UpgradeSessionKeys,
1662-
1663-
// Remove `im-online` pallet on-chain storage
1664-
frame_support::migrations::RemovePallet<ImOnlinePalletName, <Runtime as frame_system::Config>::DbWeight>,
1665-
16661531
// Migrate Identity pallet for Usernames
16671532
pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
16681533
parachains_configuration::migration::v11::MigrateToV11<Runtime>,

polkadot/runtime/westend/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ pallet-election-provider-multi-phase = { path = "../../../substrate/frame/electi
6464
pallet-fast-unstake = { path = "../../../substrate/frame/fast-unstake", default-features = false }
6565
pallet-grandpa = { path = "../../../substrate/frame/grandpa", default-features = false }
6666
pallet-identity = { path = "../../../substrate/frame/identity", default-features = false }
67-
pallet-im-online = { path = "../../../substrate/frame/im-online", default-features = false }
6867
pallet-indices = { path = "../../../substrate/frame/indices", default-features = false }
6968
pallet-membership = { path = "../../../substrate/frame/membership", default-features = false }
7069
pallet-message-queue = { path = "../../../substrate/frame/message-queue", default-features = false }
@@ -169,7 +168,6 @@ std = [
169168
"pallet-fast-unstake/std",
170169
"pallet-grandpa/std",
171170
"pallet-identity/std",
172-
"pallet-im-online/std",
173171
"pallet-indices/std",
174172
"pallet-membership/std",
175173
"pallet-message-queue/std",
@@ -254,7 +252,6 @@ runtime-benchmarks = [
254252
"pallet-fast-unstake/runtime-benchmarks",
255253
"pallet-grandpa/runtime-benchmarks",
256254
"pallet-identity/runtime-benchmarks",
257-
"pallet-im-online/runtime-benchmarks",
258255
"pallet-indices/runtime-benchmarks",
259256
"pallet-membership/runtime-benchmarks",
260257
"pallet-message-queue/runtime-benchmarks",
@@ -314,7 +311,6 @@ try-runtime = [
314311
"pallet-fast-unstake/try-runtime",
315312
"pallet-grandpa/try-runtime",
316313
"pallet-identity/try-runtime",
317-
"pallet-im-online/try-runtime",
318314
"pallet-indices/try-runtime",
319315
"pallet-membership/try-runtime",
320316
"pallet-message-queue/try-runtime",

0 commit comments

Comments
 (0)