diff --git a/state-chain/pallets/cf-cfe-interface/src/lib.rs b/state-chain/pallets/cf-cfe-interface/src/lib.rs index 53f3f63657..0d8fc49fc2 100644 --- a/state-chain/pallets/cf-cfe-interface/src/lib.rs +++ b/state-chain/pallets/cf-cfe-interface/src/lib.rs @@ -21,7 +21,7 @@ use frame_system::pallet_prelude::*; pub use pallet::*; use sp_std::vec::Vec; -pub const PALLET_VERSION: StorageVersion = StorageVersion::new(1); +pub const PALLET_VERSION: StorageVersion = StorageVersion::new(0); pub type EventId = u64; diff --git a/state-chain/pallets/cf-cfe-interface/src/migrations.rs b/state-chain/pallets/cf-cfe-interface/src/migrations.rs index 0a28096190..9667705e72 100644 --- a/state-chain/pallets/cf-cfe-interface/src/migrations.rs +++ b/state-chain/pallets/cf-cfe-interface/src/migrations.rs @@ -1,6 +1,4 @@ -pub mod add_arb_to_cfe_events; - -use cf_runtime_upgrade_utilities::VersionedMigration; +use cf_runtime_upgrade_utilities::{migration_template, VersionedMigration}; pub type PalletMigration = - (VersionedMigration, add_arb_to_cfe_events::Migration, 0, 1>,); + (VersionedMigration, migration_template::Migration, 0, 1>,); diff --git a/state-chain/pallets/cf-cfe-interface/src/migrations/add_arb_to_cfe_events.rs b/state-chain/pallets/cf-cfe-interface/src/migrations/add_arb_to_cfe_events.rs deleted file mode 100644 index 9db34e5df0..0000000000 --- a/state-chain/pallets/cf-cfe-interface/src/migrations/add_arb_to_cfe_events.rs +++ /dev/null @@ -1,76 +0,0 @@ -use crate::*; -use core::marker::PhantomData; -use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade}; -use sp_std::vec; - -pub struct Migration(PhantomData); - -mod old { - use super::*; - use cfe_events::{ - KeyHandoverRequest, KeygenRequest, ThresholdSignatureRequest, TxBroadcastRequest, - }; - - #[derive(Clone, RuntimeDebug, Encode, Decode, PartialEq, Eq, TypeInfo)] - pub enum CfeEvent { - EthThresholdSignatureRequest(ThresholdSignatureRequest), - DotThresholdSignatureRequest(ThresholdSignatureRequest), - BtcThresholdSignatureRequest(ThresholdSignatureRequest), - EthKeygenRequest(KeygenRequest), - DotKeygenRequest(KeygenRequest), - BtcKeygenRequest(KeygenRequest), - BtcKeyHandoverRequest(KeyHandoverRequest), - EthTxBroadcastRequest(TxBroadcastRequest), - DotTxBroadcastRequest(TxBroadcastRequest), - BtcTxBroadcastRequest(TxBroadcastRequest), - PeerIdRegistered { - account_id: ValidatorId, - pubkey: Ed25519PublicKey, - port: Port, - ip: Ipv6Addr, - }, - PeerIdDeregistered { - account_id: ValidatorId, - pubkey: Ed25519PublicKey, - }, - } -} - -impl OnRuntimeUpgrade for Migration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - CfeEvents::::translate(|old_cfe_events| { - let mut new_cfe_events: Vec> = vec![]; - old_cfe_events.into_iter().for_each(|old_cfe_event| new_cfe_events.push(match old_cfe_event { - old::CfeEvent::<::ValidatorId>::EthThresholdSignatureRequest(sig_request) => CfeEvent::::EvmThresholdSignatureRequest(sig_request), - old::CfeEvent::<::ValidatorId>::DotThresholdSignatureRequest(sig_request) => CfeEvent::::DotThresholdSignatureRequest(sig_request), - old::CfeEvent::<::ValidatorId>::BtcThresholdSignatureRequest(sig_request) => CfeEvent::::BtcThresholdSignatureRequest(sig_request), - old::CfeEvent::<::ValidatorId>::EthKeygenRequest(keygen_request) => CfeEvent::::EvmKeygenRequest(keygen_request), - old::CfeEvent::<::ValidatorId>::DotKeygenRequest(keygen_request) => CfeEvent::::DotKeygenRequest(keygen_request), - old::CfeEvent::<::ValidatorId>::BtcKeygenRequest(keygen_request) => CfeEvent::::BtcKeygenRequest(keygen_request), - old::CfeEvent::<::ValidatorId>::BtcKeyHandoverRequest(handover_request) => CfeEvent::::BtcKeyHandoverRequest(handover_request), - old::CfeEvent::<::ValidatorId>::EthTxBroadcastRequest(broadcast_request) => CfeEvent::::EthTxBroadcastRequest(broadcast_request), - old::CfeEvent::<::ValidatorId>::DotTxBroadcastRequest(broadcast_request) => CfeEvent::::DotTxBroadcastRequest(broadcast_request), - old::CfeEvent::<::ValidatorId>::BtcTxBroadcastRequest(broadcast_request) => CfeEvent::::BtcTxBroadcastRequest(broadcast_request), - old::CfeEvent::<::ValidatorId>::PeerIdRegistered { - account_id, - pubkey, - port, - ip, - } => CfeEvent::::PeerIdRegistered { account_id, pubkey, port, ip }, - old::CfeEvent::<::ValidatorId>::PeerIdDeregistered { account_id, pubkey } => CfeEvent::::PeerIdDeregistered{account_id, pubkey}, - })); - Some(new_cfe_events) - }).expect("vvv"); - Weight::zero() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, DispatchError> { - Ok(vec![]) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), DispatchError> { - Ok(()) - } -}