From 92ca3911de27d46d995814f506c7c771df7bcba0 Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Wed, 7 Jun 2023 22:08:10 +0700 Subject: [PATCH] runtime(gear,vara): Remove unused migrations (#2728) --- runtime/common/src/lib.rs | 1 - runtime/common/src/migration.rs | 63 --------------------------------- runtime/gear/src/migrations.rs | 10 +----- runtime/vara/src/migrations.rs | 4 --- 4 files changed, 1 insertion(+), 77 deletions(-) delete mode 100644 runtime/common/src/migration.rs diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index de1f63347b2..8620bd086fd 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -20,7 +20,6 @@ mod apis; pub mod constants; -pub mod migration; pub mod weights; use frame_support::{ diff --git a/runtime/common/src/migration.rs b/runtime/common/src/migration.rs deleted file mode 100644 index 9c92abf8aae..00000000000 --- a/runtime/common/src/migration.rs +++ /dev/null @@ -1,63 +0,0 @@ -// This file is part of Gear. -// -// Copyright (C) 2023 Gear Technologies Inc. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Common runtime migrations. - -use frame_support::{ - traits::{Get, OnRuntimeUpgrade}, - weights::Weight, -}; -use sp_std::marker::PhantomData; - -pub struct SessionValidatorSetMigration(PhantomData); - -impl OnRuntimeUpgrade for SessionValidatorSetMigration -where - T: pallet_session::Config - + validator_set::Config::AccountId>, -{ - fn on_runtime_upgrade() -> Weight { - log::info!("🚚 Running migration"); - - let mut weight = T::DbWeight::get().reads( - 1 // read pallet session validators - + 1 // read validator set - + 1, // read approved validator set - ); - - let session_validators = pallet_session::Pallet::::validators(); - let validator_set = validator_set::Validators::::get(); - let approved_validator_set = validator_set::ApprovedValidators::::get(); - - if session_validators == validator_set && session_validators == approved_validator_set { - log::info!("❌ Migration did not execute. This probably should be removed"); - } else { - log::info!("Set {} validators", session_validators.len()); - - validator_set::Validators::::put(session_validators.clone()); - validator_set::ApprovedValidators::::put(session_validators); - - weight += T::DbWeight::get().writes( - 1 // write validator set - + 1, // write approved validator set - ); - } - - weight - } -} diff --git a/runtime/gear/src/migrations.rs b/runtime/gear/src/migrations.rs index 665d7864102..b8c5b86f3d9 100644 --- a/runtime/gear/src/migrations.rs +++ b/runtime/gear/src/migrations.rs @@ -1,11 +1,3 @@ use crate::*; -use runtime_common::migration::SessionValidatorSetMigration; - -pub type Migrations = ( - SessionValidatorSetMigration, - pallet_gear_gas::migrations::v1::MigrateToV1, - pallet_gear_scheduler::migration::MigrateToV2, - pallet_gear_program::migration::MigrateToV2, - pallet_gear_gas::migrations::v2::MigrateToV2, -); +pub type Migrations = (pallet_gear_gas::migrations::v2::MigrateToV2,); diff --git a/runtime/vara/src/migrations.rs b/runtime/vara/src/migrations.rs index 665d7864102..73b8929f447 100644 --- a/runtime/vara/src/migrations.rs +++ b/runtime/vara/src/migrations.rs @@ -1,11 +1,7 @@ use crate::*; -use runtime_common::migration::SessionValidatorSetMigration; - pub type Migrations = ( - SessionValidatorSetMigration, pallet_gear_gas::migrations::v1::MigrateToV1, pallet_gear_scheduler::migration::MigrateToV2, - pallet_gear_program::migration::MigrateToV2, pallet_gear_gas::migrations::v2::MigrateToV2, );