Skip to content

Commit

Permalink
Migration cleanup and tidy up (#399)
Browse files Browse the repository at this point in the history
This commit cleanups the migrations and fixes some other minor issues:

- Removes migrations from summary, validators manager and staking pallets and their wire up with runtime. These migrations have been completed a long time ago on all active chains. Its good practice to remove from time to time to reduce the size of the codebase and upgrade checks performed. All migrations set the right storage item on the genesis build block, so new chains are skipping the migration.
- updates grade configuration for sepolia.
  • Loading branch information
thadouk authored May 15, 2024
1 parent 157b9f3 commit b1ac34e
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 383 deletions.
4 changes: 2 additions & 2 deletions node/src/chain_spec/test/staging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ pub fn avn_garde_staging_config() -> ChainSpec {
// SUDO account
get_account_id_from_seed::<sr25519::Public>("avn-sudo"),
// AVT contract
H160(hex!("93ba86eCfDDD9CaAAc29bE83aCE5A3188aC47730")),
H160(hex!("a8303c24215F13f69736e445A5C5E2b9d85418DE")),
// AVN contract
H160(hex!("d6C9731A8DCAf6d09076218584c0ab9A2F44485C")),
H160(hex!("41FEed205211095Bdb81655A469A7a2D733Be2B9")),
vec![],
avn_garde_ethereum_public_keys(),
vec![],
Expand Down
7 changes: 3 additions & 4 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod calls;
pub mod migration;
mod nomination_requests;
pub mod proxy_methods;
pub mod session_handler;
Expand Down Expand Up @@ -104,7 +103,6 @@ pub use types::*;
pub type AVN<T> = pallet_avn::Pallet<T>;
pub const PALLET_ID: &'static [u8; 17] = b"parachain_staking";
pub const MAX_OFFENDERS: u32 = 2;

#[pallet]
pub mod pallet {
#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -152,10 +150,11 @@ pub mod pallet {
Perbill,
};
pub use sp_std::{collections::btree_map::BTreeMap, prelude::*};
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(3);

/// Pallet for parachain staking
#[pallet::pallet]
#[pallet::storage_version(crate::migration::STORAGE_VERSION)]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

pub type EraIndex = u32;
Expand Down Expand Up @@ -790,7 +789,7 @@ pub mod pallet {
});

// Set storage version
crate::migration::STORAGE_VERSION.put::<Pallet<T>>();
STORAGE_VERSION.put::<Pallet<T>>();
log::debug!(
"Staking storage chain/current storage version: {:?} / {:?}",
Pallet::<T>::on_chain_storage_version(),
Expand Down
166 changes: 0 additions & 166 deletions pallets/parachain-staking/src/migration.rs

This file was deleted.

5 changes: 0 additions & 5 deletions pallets/summary/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use sp_application_crypto::RuntimeAppPublic;
use sp_core::H256;
use sp_staking::offence::ReportOffence;

pub mod migration;
pub mod offence;
use crate::offence::{create_and_report_summary_offence, SummaryOffence, SummaryOffenceType};

Expand Down Expand Up @@ -258,8 +257,6 @@ pub mod pallet {
#[pallet::getter(fn current_slot)]
pub type CurrentSlot<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;

// TODO: [STATE MIGRATION] - this storage item was changed from returning a default value to
// returning an option
#[pallet::storage]
#[pallet::getter(fn slot_validator)]
pub type CurrentSlotsValidator<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
Expand All @@ -268,8 +265,6 @@ pub mod pallet {
#[pallet::getter(fn last_summary_slot)]
pub type SlotOfLastPublishedSummary<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;

// TODO: [STATE MIGRATION] - this storage item was changed to make RootData.added_by an
// Option<AccountID> instead of AccountId
#[pallet::storage]
pub type Roots<T: Config> = StorageDoubleMap<
_,
Expand Down
101 changes: 0 additions & 101 deletions pallets/summary/src/migration.rs

This file was deleted.

11 changes: 7 additions & 4 deletions pallets/validators-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use alloc::string::String;

pub type EthereumTransactionId = u32;

use frame_support::{dispatch::DispatchResult, ensure, log, traits::Get, transactional};
use frame_support::{
dispatch::DispatchResult, ensure, log, pallet_prelude::StorageVersion, traits::Get,
transactional,
};
use frame_system::{offchain::SendTransactionTypes, RawOrigin};
use pallet_session::{self as session, Config as SessionConfig};
use sp_runtime::{
Expand Down Expand Up @@ -53,7 +56,7 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::storage_version(crate::migration::STORAGE_VERSION)]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(PhantomData<T>);

#[pallet::config]
Expand Down Expand Up @@ -174,7 +177,7 @@ pub mod pallet {
}

// Set storage version
crate::migration::STORAGE_VERSION.put::<Pallet<T>>();
STORAGE_VERSION.put::<Pallet<T>>();
log::debug!(
"Validators manager storage chain/current storage version: {:?} / {:?}",
Pallet::<T>::on_chain_storage_version(),
Expand Down Expand Up @@ -365,7 +368,7 @@ mod benchmarking;
pub mod default_weights;
pub use default_weights::WeightInfo;

pub mod migration;
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

// TODO [TYPE: review][PRI: medium]: if needed, make this the default value to a configurable
// option. See MinimumValidatorCount in Staking pallet as a reference
Expand Down
Loading

0 comments on commit b1ac34e

Please sign in to comment.