Skip to content

Commit

Permalink
Cleanup migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Dec 21, 2023
1 parent 14f5c04 commit a432dff
Showing 1 changed file with 1 addition and 110 deletions.
111 changes: 1 addition & 110 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,119 +1377,10 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

parameter_types! {
pub const BlockRewardName: &'static str = "BlockReward";
}
/// All migrations that will run on the next runtime upgrade.
///
/// Once done, migrations should be removed from the tuple.
pub type Migrations = (
// The following 4 migrations should be done as part of shibuya-118 upgrade.
pallet_inflation::PalletInflationInitConfig<Runtime, InitInflationParams>,
pallet_dapp_staking_v3::DAppStakingV3InitConfig<Runtime, InitDappStakingv3Params>,
frame_support::migrations::RemovePallet<
BlockRewardName,
<Runtime as frame_system::Config>::DbWeight,
>,
// This will handle new pallet storage version setting & it will put the new pallet into maintenance mode.
// But it's most important for testing with try-runtime.
pallet_dapp_staking_migration::DappStakingMigrationHandler<Runtime>,
);

/// Used to initialize inflation parameters for the runtime.
pub struct InitInflationParams;
impl Get<pallet_inflation::InflationParameters> for InitInflationParams {
fn get() -> pallet_inflation::InflationParameters {
pallet_inflation::InflationParameters {
// Recalculation is done every two weeks, hence the small %.
max_inflation_rate: Perquintill::from_percent(1),
treasury_part: Perquintill::from_percent(5),
collators_part: Perquintill::from_percent(3),
dapps_part: Perquintill::from_percent(20),
base_stakers_part: Perquintill::from_percent(25),
adjustable_stakers_part: Perquintill::from_percent(35),
bonus_part: Perquintill::from_percent(12),
ideal_staking_rate: Perquintill::from_percent(20),
}
}
}

use frame_support::BoundedVec;
use pallet_dapp_staking_v3::{EraNumber, TierParameters, TiersConfiguration};
type NumberOfTiers = <Runtime as pallet_dapp_staking_v3::Config>::NumberOfTiers;
/// Used to initialize dApp staking parameters for the runtime.
pub struct InitDappStakingv3Params;
impl
Get<(
EraNumber,
TierParameters<NumberOfTiers>,
TiersConfiguration<NumberOfTiers>,
)> for InitDappStakingv3Params
{
fn get() -> (
EraNumber,
TierParameters<NumberOfTiers>,
TiersConfiguration<NumberOfTiers>,
) {
// 1. Prepare init values

// Init era of dApp staking v3 should be the next era after dApp staking v2
let init_era = pallet_dapps_staking::CurrentEra::<Runtime>::get().saturating_add(1);

// Reward portions according to the Tokenomics 2.0 report
let reward_portion = BoundedVec::try_from(vec![
Permill::from_percent(40),
Permill::from_percent(30),
Permill::from_percent(20),
Permill::from_percent(10),
])
.unwrap_or_default();

// Tier thresholds adjusted according to numbers observed on Shibuya
let tier_thresholds = BoundedVec::try_from(vec![
TierThreshold::DynamicTvlAmount {
amount: SBY.saturating_mul(1_000_000),
minimum_amount: SBY.saturating_mul(150_000),
},
TierThreshold::DynamicTvlAmount {
amount: SBY.saturating_mul(100_000),
minimum_amount: SBY.saturating_mul(60_000),
},
TierThreshold::DynamicTvlAmount {
amount: SBY.saturating_mul(50_000),
minimum_amount: SBY.saturating_mul(15_000),
},
TierThreshold::FixedTvlAmount {
amount: SBY.saturating_mul(10_000),
},
])
.unwrap_or_default();

// 2. Tier params
let tier_params =
TierParameters::<<Runtime as pallet_dapp_staking_v3::Config>::NumberOfTiers> {
reward_portion: reward_portion.clone(),
slot_distribution: BoundedVec::try_from(vec![
Permill::from_percent(10),
Permill::from_percent(20),
Permill::from_percent(30),
Permill::from_percent(40),
])
.unwrap_or_default(),
tier_thresholds: tier_thresholds.clone(),
};

// 3. Init tier config
let init_tier_config = TiersConfiguration {
number_of_slots: 100,
slots_per_tier: BoundedVec::try_from(vec![10, 20, 30, 40]).unwrap_or_default(),
reward_portion,
tier_thresholds,
};

(init_era, tier_params, init_tier_config)
}
}
pub type Migrations = ();

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
Expand Down

0 comments on commit a432dff

Please sign in to comment.