Skip to content

Commit

Permalink
Polkadot: Remove applied migrations (#241)
Browse files Browse the repository at this point in the history
Changes:
- Remove all migrations from Polkadot since 1.1.2 was enacted on-chain.

Two other commits have been manually back-ported to the release branch
and are not shown in the diff:
- Enable idempotency check (#164)
- [CI] Run on all MRs and on release branch (#173)

[x] Does not require a CHANGELOG entry

---------

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez authored Mar 15, 2024
1 parent 4cd930f commit 220049e
Showing 1 changed file with 1 addition and 55 deletions.
56 changes: 1 addition & 55 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,6 @@ impl pallet_authorship::Config for Runtime {
type EventHandler = (Staking, ImOnline);
}

impl_opaque_keys! {
pub struct OldSessionKeys {
pub grandpa: Grandpa,
pub babe: Babe,
pub im_online: ImOnline,
pub para_validator: Initializer,
pub para_assignment: ParaSessionInfo,
pub authority_discovery: AuthorityDiscovery,
}
}

impl_opaque_keys! {
pub struct SessionKeys {
pub grandpa: Grandpa,
Expand All @@ -452,32 +441,6 @@ impl_opaque_keys! {
}
}

// remove this when removing `OldSessionKeys`
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: old.para_assignment,
authority_discovery: old.authority_discovery,
beefy: {
// From Session::upgrade_keys():
//
// Care should be taken that the raw versions of the
// added keys are unique for every `ValidatorId, KeyTypeId` combination.
// This is an invariant that the session pallet typically maintains internally.
//
// So, produce a dummy value that's unique for the `ValidatorId, KeyTypeId` combination.
let mut id: BeefyId = sp_application_crypto::ecdsa::Public::from_raw([0u8; 33]).into();
let id_raw: &mut [u8] = id.as_mut();
id_raw[1..33].copy_from_slice(v.as_ref());
id_raw[0..4].copy_from_slice(b"beef");
id
},
}
}

impl pallet_session::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ValidatorId = AccountId;
Expand Down Expand Up @@ -1687,25 +1650,8 @@ pub type Migrations = migrations::Unreleased;
/// The runtime migrations per release.
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;

/// Upgrade Session keys to include BEEFY key.
/// When this is removed, should also remove `OldSessionKeys`.
pub struct UpgradeSessionKeys;
impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
fn on_runtime_upgrade() -> Weight {
Session::upgrade_keys::<OldSessionKeys, _>(transform_session_keys);
Perbill::from_percent(50) * BlockWeights::get().max_block
}
}

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
// Upgrade SessionKeys to include BEEFY key
UpgradeSessionKeys,
pallet_nomination_pools::migration::versioned_migrations::V5toV6<Runtime>,
pallet_nomination_pools::migration::versioned_migrations::V6ToV7<Runtime>,
);
pub type Unreleased = ();
}

/// Unchecked extrinsic type as expected by this runtime.
Expand Down

0 comments on commit 220049e

Please sign in to comment.