Skip to content

Commit

Permalink
chore: make solana election migration idempotent again
Browse files Browse the repository at this point in the history
  • Loading branch information
dandanlen committed Nov 8, 2024
1 parent 4985676 commit d5ad2ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion state-chain/pallets/cf-elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ use frame_system::pallet_prelude::*;

pub use pallet::*;

pub const PALLET_VERSION: StorageVersion = StorageVersion::new(1);
pub const PALLET_VERSION: StorageVersion = StorageVersion::new(2);

pub use pallet::UniqueMonotonicIdentifier;

Expand Down
7 changes: 7 additions & 0 deletions state-chain/runtime/src/chainflip/solana_elections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ pub mod old {
Ok(())
}
fn on_runtime_upgrade() -> frame_support::weights::Weight {
if cf_runtime_upgrade_utilities::genesis_hashes::genesis_hash::<Runtime>() ==
cf_runtime_upgrade_utilities::genesis_hashes::SISYPHOS
{
// Already applied on Sisyphos
return Default::default();
}

let election_identifiers = frame_support::migration::storage_key_iter::<
ElectionIdentifierOf<old::SolanaElectoralSystem>,
<old::SolanaElectoralSystem as ElectoralSystem>::ElectionProperties,
Expand Down
2 changes: 1 addition & 1 deletion state-chain/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,6 @@ type AllMigrations = (
MigrationsForV1_7,
migrations::housekeeping::Migration,
migrations::reap_old_accounts::Migration,
SpecVersionedMigration<chainflip::solana_elections::old::Migration, 170>,
);

/// All the pallet-specific migrations and migrations that depend on pallet migration order. Do not
Expand Down Expand Up @@ -1310,6 +1309,7 @@ type MigrationsForV1_7 = (
0,
1,
>,
VersionedMigration<SolanaElections, chainflip::solana_elections::old::Migration, 1, 2>,
);

#[cfg(feature = "runtime-benchmarks")]
Expand Down

0 comments on commit d5ad2ee

Please sign in to comment.