@@ -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} ;
9493use 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-
390349impl_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.
414361pub struct ValidatorIdOf ;
415362impl 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 > ,
0 commit comments