Skip to content

Commit 45b2136

Browse files
committed
migration
1 parent e4ff90d commit 45b2136

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

demo/runtime/src/lib.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub type Hash = sp_core::H256;
108108
pub mod opaque {
109109
use super::*;
110110
use authority_selection_inherents::MaybeFromCandidateKeys;
111+
use pallet_session_validator_management::migrations::authority_keys::UpgradeAuthorityKeys;
111112
use parity_scale_codec::MaxEncodedLen;
112113
use sp_core::{ecdsa, ed25519, sr25519};
113114
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
@@ -140,6 +141,24 @@ pub mod opaque {
140141
pub account: CrossChainPublic,
141142
}
142143
}
144+
145+
impl_opaque_keys! {
146+
#[derive(MaxEncodedLen, PartialOrd, Ord)]
147+
pub struct LegacySessionKeys {
148+
pub aura: Aura,
149+
pub grandpa: Grandpa,
150+
}
151+
}
152+
153+
impl UpgradeAuthorityKeys<SessionKeys> for LegacySessionKeys {
154+
fn upgrade(self) -> SessionKeys {
155+
SessionKeys {
156+
aura: self.aura,
157+
grandpa: self.grandpa,
158+
beefy: ecdsa::Public::default().into(),
159+
}
160+
}
161+
}
143162
}
144163

145164
pub type CrossChainPublic = sidechain_domain::cross_chain_app::Public;
@@ -820,7 +839,15 @@ pub type UncheckedExtrinsic =
820839
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
821840
/// The payload being signed in transactions.
822841
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
823-
pub type Migrations = ();
842+
pub type Migrations = (
843+
pallet_session_validator_management::migrations::v1::LegacyToV1Migration<Runtime>,
844+
pallet_session_validator_management::migrations::authority_keys::AuthorityKeysMigration<
845+
Runtime,
846+
opaque::LegacySessionKeys,
847+
0,
848+
1,
849+
>, // More migrations can be added here
850+
);
824851
/// Executive: handles dispatch to the various modules.
825852
pub type Executive = frame_executive::Executive<
826853
Runtime,

0 commit comments

Comments
 (0)