From 111d18fbfba6076570cb6454573f88afe0ee53b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Tue, 28 May 2024 19:25:59 +0200 Subject: [PATCH] Base native currency price for dApp Staking (#1252) * Base native currency price for dApp Staking * Remove redundant condition check * Version bumps * Comments * Comment * Remove migration code --- Cargo.lock | 10 +- bin/collator/Cargo.toml | 2 +- .../dapp-staking-v3/src/benchmarking/utils.rs | 15 +-- pallets/dapp-staking-v3/src/lib.rs | 40 ++++--- pallets/dapp-staking-v3/src/test/mock.rs | 8 +- pallets/dapp-staking-v3/src/test/tests.rs | 100 +++++++++++++++++- .../dapp-staking-v3/src/test/tests_types.rs | 7 +- pallets/dapp-staking-v3/src/types.rs | 48 +++++---- precompiles/dapp-staking-v3/src/test/mock.rs | 5 + runtime/astar/Cargo.toml | 2 +- runtime/astar/src/lib.rs | 36 +------ runtime/local/Cargo.toml | 2 +- runtime/local/src/lib.rs | 7 +- runtime/shibuya/Cargo.toml | 2 +- runtime/shibuya/src/lib.rs | 6 +- runtime/shiden/Cargo.toml | 2 +- runtime/shiden/src/lib.rs | 6 +- tests/xcm-simulator/src/mocks/parachain.rs | 5 + 18 files changed, 212 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02e231823..b6f411ff5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -623,7 +623,7 @@ dependencies = [ [[package]] name = "astar-collator" -version = "5.39.0" +version = "5.39.1" dependencies = [ "astar-primitives", "astar-runtime", @@ -757,7 +757,7 @@ dependencies = [ [[package]] name = "astar-runtime" -version = "5.39.0" +version = "5.39.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -6697,7 +6697,7 @@ dependencies = [ [[package]] name = "local-runtime" -version = "5.39.0" +version = "5.39.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -13961,7 +13961,7 @@ dependencies = [ [[package]] name = "shibuya-runtime" -version = "5.39.0" +version = "5.39.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -14077,7 +14077,7 @@ dependencies = [ [[package]] name = "shiden-runtime" -version = "5.39.0" +version = "5.39.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", diff --git a/bin/collator/Cargo.toml b/bin/collator/Cargo.toml index ab1455801..d9e207f8b 100644 --- a/bin/collator/Cargo.toml +++ b/bin/collator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-collator" -version = "5.39.0" +version = "5.39.1" description = "Astar collator implementation in Rust." build = "build.rs" default-run = "astar-collator" diff --git a/pallets/dapp-staking-v3/src/benchmarking/utils.rs b/pallets/dapp-staking-v3/src/benchmarking/utils.rs index 4a690ba9e..a21123422 100644 --- a/pallets/dapp-staking-v3/src/benchmarking/utils.rs +++ b/pallets/dapp-staking-v3/src/benchmarking/utils.rs @@ -197,13 +197,14 @@ pub(super) fn init_tier_settings() { }; // Init tier config, based on the initial params - let init_tier_config = TiersConfiguration:: { - number_of_slots: NUMBER_OF_SLOTS.try_into().unwrap(), - slots_per_tier: BoundedVec::try_from(vec![10, 20, 30, 40]).unwrap(), - reward_portion: tier_params.reward_portion.clone(), - tier_thresholds: tier_params.tier_thresholds.clone(), - _phantom: Default::default(), - }; + let init_tier_config = + TiersConfiguration:: { + number_of_slots: NUMBER_OF_SLOTS.try_into().unwrap(), + slots_per_tier: BoundedVec::try_from(vec![10, 20, 30, 40]).unwrap(), + reward_portion: tier_params.reward_portion.clone(), + tier_thresholds: tier_params.tier_thresholds.clone(), + _phantom: Default::default(), + }; assert!(tier_params.is_valid()); assert!(init_tier_config.is_valid()); diff --git a/pallets/dapp-staking-v3/src/lib.rs b/pallets/dapp-staking-v3/src/lib.rs index e9d3ea8c7..9c64c3e01 100644 --- a/pallets/dapp-staking-v3/src/lib.rs +++ b/pallets/dapp-staking-v3/src/lib.rs @@ -44,6 +44,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::*; +use sp_arithmetic::fixed_point::FixedU128; use sp_runtime::{ traits::{BadOrigin, One, Saturating, UniqueSaturatedInto, Zero}, Perbill, Permill, SaturatedConversion, @@ -148,6 +149,17 @@ pub mod pallet { /// Used to calculate total number of tier slots for some price. type TierSlots: TierSlotFunc; + /// Base native currency price used to calculate base number of slots. + /// This is used to adjust tier configuration, tier thresholds specifically, based on the native token price changes. + /// + /// When dApp staking thresholds were modeled, a base price was set from which the initial configuration is derived. + /// E.g. for a price of 0.05$, we get 100 slots, and certain tier thresholds. + /// Using these values as the base, we can adjust the configuration based on the current price. + /// + /// This is connected with the `TierSlots` associated type, since it's used to calculate the total number of slots for the given price. + #[pallet::constant] + type BaseNativeCurrencyPrice: Get; + /// Maximum length of a single era reward span length entry. #[pallet::constant] type EraRewardSpanLength: Get; @@ -446,8 +458,11 @@ pub mod pallet { /// Tier configuration user for current & preceding eras. #[pallet::storage] - pub type TierConfig = - StorageValue<_, TiersConfiguration, ValueQuery>; + pub type TierConfig = StorageValue< + _, + TiersConfiguration, + ValueQuery, + >; /// Information about which tier a dApp belonged to in a specific era. #[pallet::storage] @@ -509,16 +524,17 @@ pub mod pallet { let number_of_slots = self.slots_per_tier.iter().fold(0_u16, |acc, &slots| { acc.checked_add(slots).expect("Overflow") }); - let tier_config = TiersConfiguration:: { - number_of_slots, - slots_per_tier: BoundedVec::::try_from( - self.slots_per_tier.clone(), - ) - .expect("Invalid number of slots per tier entries provided."), - reward_portion: tier_params.reward_portion.clone(), - tier_thresholds: tier_params.tier_thresholds.clone(), - _phantom: Default::default(), - }; + let tier_config = + TiersConfiguration:: { + number_of_slots, + slots_per_tier: BoundedVec::::try_from( + self.slots_per_tier.clone(), + ) + .expect("Invalid number of slots per tier entries provided."), + reward_portion: tier_params.reward_portion.clone(), + tier_thresholds: tier_params.tier_thresholds.clone(), + _phantom: Default::default(), + }; assert!( tier_params.is_valid(), "Invalid tier config values provided." diff --git a/pallets/dapp-staking-v3/src/test/mock.rs b/pallets/dapp-staking-v3/src/test/mock.rs index 4806204ab..4551a0be7 100644 --- a/pallets/dapp-staking-v3/src/test/mock.rs +++ b/pallets/dapp-staking-v3/src/test/mock.rs @@ -115,7 +115,7 @@ impl PriceProvider for DummyPriceProvider { thread_local! { pub(crate) static DOES_PAYOUT_SUCCEED: RefCell = RefCell::new(false); pub(crate) static BLOCK_BEFORE_NEW_ERA: RefCell = RefCell::new(0); - pub(crate) static NATIVE_PRICE: RefCell = RefCell::new(FixedU128::from_rational(1, 10)); + pub(crate) static NATIVE_PRICE: RefCell = RefCell::new(BaseNativeCurrencyPrice::get()); } pub struct DummyStakingRewardHandler; @@ -195,6 +195,10 @@ impl AccountCheck for DummyAccountCheck { } } +parameter_types! { + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); +} + impl pallet_dapp_staking::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; @@ -207,6 +211,7 @@ impl pallet_dapp_staking::Config for Test { type Observers = DummyDappStakingObserver; type AccountCheck = DummyAccountCheck; type TierSlots = StandardTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; @@ -315,6 +320,7 @@ impl ExtBuilder { let init_tier_config = TiersConfiguration::< ::NumberOfTiers, ::TierSlots, + ::BaseNativeCurrencyPrice, > { number_of_slots: 40, slots_per_tier: BoundedVec::try_from(vec![2, 5, 13, 20]).unwrap(), diff --git a/pallets/dapp-staking-v3/src/test/tests.rs b/pallets/dapp-staking-v3/src/test/tests.rs index 0f59307b8..3e64d853b 100644 --- a/pallets/dapp-staking-v3/src/test/tests.rs +++ b/pallets/dapp-staking-v3/src/test/tests.rs @@ -35,7 +35,7 @@ use frame_support::{ use sp_runtime::{traits::Zero, FixedU128}; use astar_primitives::{ - dapp_staking::{CycleConfiguration, EraNumber, SmartContractHandle}, + dapp_staking::{CycleConfiguration, EraNumber, SmartContractHandle, TierSlots}, Balance, BlockNumber, }; @@ -3022,3 +3022,101 @@ fn safeguard_configurable_by_genesis_config() { assert!(Safeguard::::get()); }); } + +#[test] +fn base_number_of_slots_is_respected() { + ExtBuilder::build().execute_with(|| { + // 0. Get expected number of slots for the base price + let base_native_price = ::BaseNativeCurrencyPrice::get(); + let base_number_of_slots = ::TierSlots::number_of_slots(base_native_price); + + // 1. Make sure base native price is set initially and calculate the new config. Store the thresholds for later comparison. + NATIVE_PRICE.with(|v| *v.borrow_mut() = base_native_price); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + + assert_eq!( + TierConfig::::get().number_of_slots, + base_number_of_slots, + "Base number of slots is expected for base native currency price." + ); + + let base_thresholds = TierConfig::::get().tier_thresholds; + + // 2. Increase the price significantly, and ensure number of slots has increased, and thresholds have been saturated. + let higher_price = base_native_price * FixedU128::from(1000); + NATIVE_PRICE.with(|v| *v.borrow_mut() = higher_price); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + + assert!( + TierConfig::::get().number_of_slots > base_number_of_slots, + "Price has increased, therefore number of slots must increase." + ); + assert_eq!( + TierConfig::::get().number_of_slots, + ::TierSlots::number_of_slots(higher_price), + ); + + for tier_threshold in TierConfig::::get().tier_thresholds.iter() { + if let TierThreshold::DynamicTvlAmount { + amount, + minimum_amount, + } = tier_threshold + { + assert_eq!(*amount, *minimum_amount, "Thresholds must be saturated."); + } + } + + // 3. Bring it back down to the base price, and expect number of slots to be the same as the base number of slots, + // and thresholds to be the same as the base thresholds. + NATIVE_PRICE.with(|v| *v.borrow_mut() = base_native_price); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + + assert_eq!( + TierConfig::::get().number_of_slots, + base_number_of_slots, + "Base number of slots is expected for base native currency price." + ); + + assert_eq!( + TierConfig::::get().tier_thresholds, + base_thresholds, + "Thresholds must be the same as the base thresholds." + ); + + // 4. Bring it below the base price, and expect number of slots to decrease. + let lower_price = base_native_price * FixedU128::from_rational(1, 1000); + NATIVE_PRICE.with(|v| *v.borrow_mut() = lower_price); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + + assert!( + TierConfig::::get().number_of_slots < base_number_of_slots, + "Price has decreased, therefore number of slots must decrease." + ); + assert_eq!( + TierConfig::::get().number_of_slots, + ::TierSlots::number_of_slots(lower_price), + ); + + // 5. Bring it back to the base price, and expect number of slots to be the same as the base number of slots, + // and thresholds to be the same as the base thresholds. + NATIVE_PRICE.with(|v| *v.borrow_mut() = base_native_price); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + + assert_eq!( + TierConfig::::get().number_of_slots, + base_number_of_slots, + "Base number of slots is expected for base native currency price." + ); + + assert_eq!( + TierConfig::::get().tier_thresholds, + base_thresholds, + "Thresholds must be the same as the base thresholds." + ); + }) +} diff --git a/pallets/dapp-staking-v3/src/test/tests_types.rs b/pallets/dapp-staking-v3/src/test/tests_types.rs index 437b5cbea..72ead8fd5 100644 --- a/pallets/dapp-staking-v3/src/test/tests_types.rs +++ b/pallets/dapp-staking-v3/src/test/tests_types.rs @@ -17,7 +17,7 @@ // along with Astar. If not, see . use astar_primitives::{dapp_staking::StandardTierSlots, Balance}; -use frame_support::assert_ok; +use frame_support::{assert_ok, parameter_types}; use sp_arithmetic::fixed_point::FixedU128; use sp_runtime::Permill; @@ -2877,7 +2877,10 @@ fn tier_configuration_basic_tests() { assert!(params.is_valid(), "Example params must be valid!"); // Create a configuration with some values - let init_config = TiersConfiguration:: { + parameter_types! { + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); + } + let init_config = TiersConfiguration:: { number_of_slots: 100, slots_per_tier: BoundedVec::try_from(vec![10, 20, 30, 40]).unwrap(), reward_portion: params.reward_portion.clone(), diff --git a/pallets/dapp-staking-v3/src/types.rs b/pallets/dapp-staking-v3/src/types.rs index aa32d6be5..a0062eaa5 100644 --- a/pallets/dapp-staking-v3/src/types.rs +++ b/pallets/dapp-staking-v3/src/types.rs @@ -1579,8 +1579,8 @@ impl> Default for TierParameters { CloneNoBound, TypeInfo, )] -#[scale_info(skip_type_params(NT, T))] -pub struct TiersConfiguration, T: TierSlotsFunc> { +#[scale_info(skip_type_params(NT, T, P))] +pub struct TiersConfiguration, T: TierSlotsFunc, P: Get> { /// Total number of slots. #[codec(compact)] pub number_of_slots: u16, @@ -1596,10 +1596,10 @@ pub struct TiersConfiguration, T: TierSlotsFunc> { pub tier_thresholds: BoundedVec, /// Phantom data to keep track of the tier slots function. #[codec(skip)] - pub(crate) _phantom: PhantomData, + pub(crate) _phantom: PhantomData<(T, P)>, } -impl, T: TierSlotsFunc> Default for TiersConfiguration { +impl, T: TierSlotsFunc, P: Get> Default for TiersConfiguration { fn default() -> Self { Self { number_of_slots: 0, @@ -1616,7 +1616,7 @@ impl, T: TierSlotsFunc> Default for TiersConfiguration { // * There's no need to keep thresholds in two separate storage items since the calculation can always be done compared to the // anchor value of 5 cents. This still needs to be checked & investigated, but it's worth a try. -impl, T: TierSlotsFunc> TiersConfiguration { +impl, T: TierSlotsFunc, P: Get> TiersConfiguration { /// Check if parameters are valid. pub fn is_valid(&self) -> bool { let number_of_tiers: usize = NT::get() as usize; @@ -1651,32 +1651,38 @@ impl, T: TierSlotsFunc> TiersConfiguration { // // According to formula: %_threshold = (100% / (100% - delta_%_slots) - 1) * 100% // - // where delta_%_slots is simply: (old_num_slots - new_num_slots) / old_num_slots + // where delta_%_slots is simply: (base_num_slots - new_num_slots) / base_num_slots + // + // `base_num_slots` is the number of slots at the base native currency price. // // When these entries are put into the threshold formula, we get: - // = 1 / ( 1 - (old_num_slots - new_num_slots) / old_num_slots ) - 1 - // = 1 / ( new / old) - 1 - // = old / new - 1 - // = (old - new) / new + // = 1 / ( 1 - (base_num_slots - new_num_slots) / base_num_slots ) - 1 + // = 1 / ( new / base) - 1 + // = base / new - 1 + // = (base - new) / new // // This number can be negative. In order to keep all operations in unsigned integer domain, // formulas are adjusted like: // // 1. Number of slots has increased, threshold is expected to decrease - // %_threshold = (new_num_slots - old_num_slots) / new_num_slots - // new_threshold = old_threshold * (1 - %_threshold) + // %_threshold = (new_num_slots - base_num_slots) / new_num_slots + // new_threshold = base_threshold * (1 - %_threshold) // // 2. Number of slots has decreased, threshold is expected to increase - // %_threshold = (old_num_slots - new_num_slots) / new_num_slots - // new_threshold = old_threshold * (1 + %_threshold) + // %_threshold = (base_num_slots - new_num_slots) / new_num_slots + // new_threshold = base_threshold * (1 + %_threshold) // - let new_tier_thresholds = if new_number_of_slots > self.number_of_slots { + let base_number_of_slots = T::number_of_slots(P::get()).max(1); + + // NOTE: even though we could ignore the situation when the new & base slot numbers are equal, it's necessary to re-calculate it since + // other params related to calculation might have changed. + let new_tier_thresholds = if new_number_of_slots >= base_number_of_slots { let delta_threshold_decrease = FixedU128::from_rational( - (new_number_of_slots - self.number_of_slots).into(), + (new_number_of_slots - base_number_of_slots).into(), new_number_of_slots.into(), ); - let mut new_tier_thresholds = self.tier_thresholds.clone(); + let mut new_tier_thresholds = params.tier_thresholds.clone(); new_tier_thresholds .iter_mut() .for_each(|threshold| match threshold { @@ -1692,13 +1698,13 @@ impl, T: TierSlotsFunc> TiersConfiguration { }); new_tier_thresholds - } else if new_number_of_slots < self.number_of_slots { + } else { let delta_threshold_increase = FixedU128::from_rational( - (self.number_of_slots - new_number_of_slots).into(), + (base_number_of_slots - new_number_of_slots).into(), new_number_of_slots.into(), ); - let mut new_tier_thresholds = self.tier_thresholds.clone(); + let mut new_tier_thresholds = params.tier_thresholds.clone(); new_tier_thresholds .iter_mut() .for_each(|threshold| match threshold { @@ -1710,8 +1716,6 @@ impl, T: TierSlotsFunc> TiersConfiguration { }); new_tier_thresholds - } else { - self.tier_thresholds.clone() }; Self { diff --git a/precompiles/dapp-staking-v3/src/test/mock.rs b/precompiles/dapp-staking-v3/src/test/mock.rs index d76b34671..fe9596bbd 100644 --- a/precompiles/dapp-staking-v3/src/test/mock.rs +++ b/precompiles/dapp-staking-v3/src/test/mock.rs @@ -245,6 +245,10 @@ impl pallet_dapp_staking_v3::BenchmarkHelper fn set_balance(_account: &AccountId, _amount: Balance) {} } +parameter_types! { + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); +} + impl pallet_dapp_staking_v3::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; @@ -257,6 +261,7 @@ impl pallet_dapp_staking_v3::Config for Test { type Observers = (); type AccountCheck = (); type TierSlots = StandardTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 73060bf01..04cdbd030 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-runtime" -version = "5.39.0" +version = "5.39.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index f3a309658..a2883f07c 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -64,7 +64,7 @@ use sp_runtime::{ DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, Zero, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, - ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -154,7 +154,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("astar"), impl_name: create_runtime_str!("astar"), authoring_version: 1, - spec_version: 87, + spec_version: 88, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -326,6 +326,7 @@ impl pallet_multisig::Config for Runtime { parameter_types! { pub const MinimumStakingAmount: Balance = 500 * ASTR; + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } #[cfg(feature = "runtime-benchmarks")] @@ -368,6 +369,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Observers = Inflation; type AccountCheck = AccountCheck; type TierSlots = StandardTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<4>; type MaxNumberOfContracts = ConstU32<500>; @@ -1168,38 +1170,10 @@ pub type Executive = frame_executive::Executive< Migrations, >; -parameter_types! { - pub const StaticPriceProviderName: &'static str = "StaticPriceProvider"; - // 0.18 $ - pub const InitPrice: CurrencyAmount = CurrencyAmount::from_rational(18, 100); -} - /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. -pub type Migrations = ( - frame_support::migrations::RemovePallet< - StaticPriceProviderName, - ::DbWeight, - >, - OracleIntegrationLogic, - pallet_price_aggregator::PriceAggregatorInitializer, -); - -use frame_support::traits::OnRuntimeUpgrade; -pub struct OracleIntegrationLogic; -impl OnRuntimeUpgrade for OracleIntegrationLogic { - fn on_runtime_upgrade() -> Weight { - // 1. Set initial storage versions for the membership pallet - use frame_support::traits::StorageVersion; - StorageVersion::new(4) - .put::>(); - - // No storage version for the `orml_oracle` pallet, it's essentially 0 - - ::DbWeight::get().writes(1) - } -} +pub type Migrations = (); type EventRecord = frame_system::EventRecord< ::RuntimeEvent, diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index f84d9c67f..b62104e15 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "local-runtime" -version = "5.39.0" +version = "5.39.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 3990c2ee6..b4d380717 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -59,7 +59,7 @@ use sp_runtime::{ DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, - ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -448,6 +448,10 @@ impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId } } +parameter_types! { + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); +} + impl pallet_dapp_staking_v3::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; @@ -460,6 +464,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Observers = Inflation; type AccountCheck = (); type TierSlots = StandardTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<100>; diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 1aad2d181..4bc4547a0 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shibuya-runtime" -version = "5.39.0" +version = "5.39.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 380daa082..8f40b5123 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -64,7 +64,7 @@ use sp_runtime::{ DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, - ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -176,7 +176,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("shibuya"), impl_name: create_runtime_str!("shibuya"), authoring_version: 1, - spec_version: 129, + spec_version: 130, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -419,6 +419,7 @@ impl DappStakingAccountCheck for AccountCheck { parameter_types! { pub const MinimumStakingAmount: Balance = 5 * SBY; + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } impl pallet_dapp_staking_v3::Config for Runtime { @@ -433,6 +434,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Observers = Inflation; type AccountCheck = AccountCheck; type TierSlots = StandardTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<500>; diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 62e36d1c0..084a60e99 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shiden-runtime" -version = "5.39.0" +version = "5.39.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 8f017f006..d89466519 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -63,7 +63,7 @@ use sp_runtime::{ DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, }, transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, - ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; @@ -155,7 +155,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("shiden"), impl_name: create_runtime_str!("shiden"), authoring_version: 1, - spec_version: 126, + spec_version: 127, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -366,6 +366,7 @@ impl TierSlotsFunc for ShidenTierSlots { parameter_types! { pub const MinimumStakingAmount: Balance = 50 * SDN; + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } impl pallet_dapp_staking_v3::Config for Runtime { @@ -380,6 +381,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Observers = Inflation; type AccountCheck = AccountCheck; type TierSlots = ShidenTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<3>; type MaxNumberOfContracts = ConstU32<500>; diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 398c88c10..d4f95e4bb 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -709,6 +709,10 @@ impl pallet_dapp_staking_v3::BenchmarkHelper } } +parameter_types! { + pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); +} + impl pallet_dapp_staking_v3::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; @@ -721,6 +725,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Observers = (); type AccountCheck = DummyAccountCheck; type TierSlots = astar_primitives::dapp_staking::StandardTierSlots; + type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<1>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>;