Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nuke migration for loans & interest-accrual #1506

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 3 additions & 35 deletions pallets/interest-accrual/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,18 @@ pub struct RateDetails<Rate> {
pub reference_count: u32,
}

#[derive(Encode, Decode, TypeInfo, PartialEq, Eq, MaxEncodedLen, RuntimeDebug)]
#[repr(u32)]
pub enum Release {
V0,
V1,
V2,
}

impl Default for Release {
fn default() -> Self {
Self::V2
}
}

#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;

use super::*;
use crate::weights::WeightInfo;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(3);

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

#[pallet::config]
Expand Down Expand Up @@ -234,10 +223,6 @@ pub mod pallet {
#[pallet::getter(fn last_updated)]
pub(super) type LastUpdated<T: Config> = StorageValue<_, Moment, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn storage_version)]
pub(super) type StorageVersion<T: Config> = StorageValue<_, Release, ValueQuery>;

#[pallet::event]
pub enum Event<T: Config> {}

Expand All @@ -255,23 +240,6 @@ pub mod pallet {
TooManyRates,
}

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config>(core::marker::PhantomData<T>);

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self(core::marker::PhantomData)
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
StorageVersion::<T>::put(Release::V2);
}
}

#[pallet::hooks]
impl<T: Config> Hooks<T::BlockNumber> for Pallet<T> {
fn on_initialize(_: T::BlockNumber) -> Weight {
Expand Down
2 changes: 1 addition & 1 deletion runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ construct_runtime!(
NftSales: pallet_nft_sales::{Pallet, Call, Storage, Event<T>} = 98,
PoolSystem: pallet_pool_system::{Pallet, Call, Storage, Event<T>} = 99,
Loans: pallet_loans::{Pallet, Call, Storage, Event<T>} = 100,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>, Config<T>} = 101,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>} = 101,
Investments: pallet_investments::{Pallet, Call, Storage, Event<T>} = 102,
PoolRegistry: pallet_pool_registry::{Pallet, Call, Storage, Event<T>} = 103,
BlockRewardsBase: pallet_rewards::<Instance1>::{Pallet, Storage, Event<T>, Config<T>} = 104,
Expand Down
2 changes: 2 additions & 0 deletions runtime/altair/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub type UpgradeAltair1028 = (
asset_registry::CrossChainTransferabilityMigration,
orml_tokens_migration::CurrencyIdRefactorMigration,
pool_system::MigrateAUSDPools,
runtime_common::migrations::nuke::Migration<crate::Loans, crate::RocksDbWeight, 1>,
runtime_common::migrations::nuke::Migration<crate::InterestAccrual, crate::RocksDbWeight, 0>,
);

const DEPRECATED_AUSD_CURRENCY_ID: CurrencyId = CurrencyId::AUSD;
Expand Down
2 changes: 1 addition & 1 deletion runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ construct_runtime!(
PoolSystem: pallet_pool_system::{Pallet, Call, Storage, Event<T>} = 181,
Permissions: pallet_permissions::{Pallet, Call, Storage, Event<T>} = 182,
Investments: pallet_investments::{Pallet, Call, Storage, Event<T>} = 183,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>, Config<T>} = 184,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>} = 184,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 185,
Keystore: pallet_keystore::{Pallet, Call, Storage, Event<T>} = 186,
Loans: pallet_loans::{Pallet, Call, Storage, Event<T>} = 187,
Expand Down
6 changes: 5 additions & 1 deletion runtime/centrifuge/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ use frame_support::{traits::OnRuntimeUpgrade, weights::Weight};

use crate::Runtime;

pub type UpgradeCentrifuge1020 = (asset_registry::CrossChainTransferabilityMigration,);
pub type UpgradeCentrifuge1020 = (
asset_registry::CrossChainTransferabilityMigration,
runtime_common::migrations::nuke::Migration<crate::Loans, crate::RocksDbWeight, 1>,
runtime_common::migrations::nuke::Migration<crate::InterestAccrual, crate::RocksDbWeight, 0>,
);

mod asset_registry {
use cfg_types::{tokens as v1, tokens::CustomMetadata};
Expand Down
2 changes: 1 addition & 1 deletion runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ construct_runtime!(
Tokens: pallet_restricted_tokens::{Pallet, Call, Event<T>} = 99,
NftSales: pallet_nft_sales::{Pallet, Call, Storage, Event<T>} = 100,
Bridge: pallet_bridge::{Pallet, Call, Storage, Config<T>, Event<T>} = 101,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>, Config<T>} = 102,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>} = 102,
Nfts: pallet_nft::{Pallet, Call, Event<T>} = 103,
Keystore: pallet_keystore::{Pallet, Call, Storage, Event<T>} = 104,
Investments: pallet_investments::{Pallet, Call, Storage, Event<T>} = 105,
Expand Down
3 changes: 0 additions & 3 deletions src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ fn centrifuge_genesis(
threshold: 1,
},
treasury: Default::default(),
interest_accrual: Default::default(),
block_rewards: centrifuge_runtime::BlockRewardsConfig {
collators: initial_authorities
.iter()
Expand Down Expand Up @@ -769,7 +768,6 @@ fn altair_genesis(
democracy: Default::default(),
parachain_system: Default::default(),
treasury: Default::default(),
interest_accrual: Default::default(),
base_fee: Default::default(),
evm_chain_id: development_runtime::EVMChainIdConfig {
chain_id: chain_id.into(),
Expand Down Expand Up @@ -918,7 +916,6 @@ fn development_genesis(
democracy: Default::default(),
parachain_system: Default::default(),
treasury: Default::default(),
interest_accrual: Default::default(),
block_rewards: development_runtime::BlockRewardsConfig {
collators: initial_authorities
.iter()
Expand Down