From b7f7fd3acee3b236af9df81f61342cdbc2921b28 Mon Sep 17 00:00:00 2001 From: jaypan Date: Fri, 5 Jul 2024 12:24:46 +0200 Subject: [PATCH 1/3] Extend the timing --- runtime/krest/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/krest/src/lib.rs b/runtime/krest/src/lib.rs index 037599bd..fd086bda 100644 --- a/runtime/krest/src/lib.rs +++ b/runtime/krest/src/lib.rs @@ -979,8 +979,8 @@ parameter_types! { inflation_stagnation_rate: Perbill::from_percent(1), inflation_stagnation_year: 10, }; - // Estimation is around 2024-10-15 00:00 in the ideal case - pub const InitializeInflationAt: BlockNumber = 3_469_624; + // Estimation is around 2024-10-31 00:00 in the ideal case + pub const InitializeInflationAt: BlockNumber = 3_583_831; pub const BlockRewardBeforeInitialize: Balance = 3_805_175_038_050_000_000; } From 3b25383b6a897cf3170b2041fee6ff192fc62312 Mon Sep 17 00:00:00 2001 From: jaypan Date: Tue, 9 Jul 2024 14:25:48 +0200 Subject: [PATCH 2/3] Add block rewards extrinsic --- pallets/inflation-manager/src/benchmarking.rs | 9 +++++++++ pallets/inflation-manager/src/lib.rs | 13 +++++++++++++ pallets/inflation-manager/src/tests.rs | 12 ++++++++++++ pallets/inflation-manager/src/weightinfo.rs | 1 + pallets/inflation-manager/src/weights.rs | 11 +++++++++++ 5 files changed, 46 insertions(+) diff --git a/pallets/inflation-manager/src/benchmarking.rs b/pallets/inflation-manager/src/benchmarking.rs index 7e60a629..9b13eea0 100644 --- a/pallets/inflation-manager/src/benchmarking.rs +++ b/pallets/inflation-manager/src/benchmarking.rs @@ -28,12 +28,21 @@ benchmarks! { assert_eq!(TotalIssuanceNum::::get(), supply.into()); } + // Need to remove the conditions on the extrinsic call + // Otherwise, the benchmark will fail set_recalculation_time { let delay = 1000 as u32; }: _(RawOrigin::Root, delay.into()) verify { assert_eq!(DoRecalculationAt::::get(), delay.into()); } + + set_block_reward { + let reward = 1000 as u128; + }: _(RawOrigin::Root, reward.into()) + verify { + assert_eq!(BlockRewards::::get(), reward.into()); + } } #[cfg(test)] diff --git a/pallets/inflation-manager/src/lib.rs b/pallets/inflation-manager/src/lib.rs index ce4b52aa..c60c6c85 100644 --- a/pallets/inflation-manager/src/lib.rs +++ b/pallets/inflation-manager/src/lib.rs @@ -300,6 +300,19 @@ pub mod pallet { Ok(().into()) } + + #[pallet::call_index(3)] + #[pallet::weight(T::WeightInfo::set_block_reward())] + pub fn set_block_reward( + origin: OriginFor, + reward: Balance, + ) -> DispatchResultWithPostInfo { + ensure_root(origin)?; + + BlockRewards::::put(reward); + + Ok(().into()) + } } impl Pallet { diff --git a/pallets/inflation-manager/src/tests.rs b/pallets/inflation-manager/src/tests.rs index f92c1f8a..2802f771 100644 --- a/pallets/inflation-manager/src/tests.rs +++ b/pallets/inflation-manager/src/tests.rs @@ -381,6 +381,18 @@ fn recaluclation_change_fail() { }) } +#[test] +fn block_reward_change() { + ExternalityBuilder::default().build().execute_with(|| { + assert_eq!( + InflationManager::block_rewards(), + ::BlockRewardBeforeInitialize::get() + ); + assert_ok!(InflationManager::set_block_reward(RawOrigin::Root.into(), 100)); + assert_eq!(InflationManager::block_rewards(), 100); + }) +} + /// Represents inflation manager storage snapshot at current block #[derive(PartialEq, Eq, Clone, RuntimeDebug)] struct InflationManagerSnapshot { diff --git a/pallets/inflation-manager/src/weightinfo.rs b/pallets/inflation-manager/src/weightinfo.rs index 1ae8754a..26fa2425 100644 --- a/pallets/inflation-manager/src/weightinfo.rs +++ b/pallets/inflation-manager/src/weightinfo.rs @@ -6,4 +6,5 @@ pub trait WeightInfo { fn transfer_all_pot() -> Weight; fn set_delayed_tge() -> Weight; fn set_recalculation_time() -> Weight; + fn set_block_reward() -> Weight; } diff --git a/pallets/inflation-manager/src/weights.rs b/pallets/inflation-manager/src/weights.rs index 89eba94c..22cd3cea 100644 --- a/pallets/inflation-manager/src/weights.rs +++ b/pallets/inflation-manager/src/weights.rs @@ -68,4 +68,15 @@ impl crate::WeightInfo for WeightInfo { .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: InflationManager BlockRewards (r:0 w:1) + /// Proof: InflationManager BlockRewards (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn set_block_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 10_720_000 picoseconds. + Weight::from_parts(10_941_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } } From 27b2c53049e6927095427fcbd613a310450de202 Mon Sep 17 00:00:00 2001 From: jaypan Date: Tue, 9 Jul 2024 17:09:38 +0200 Subject: [PATCH 3/3] Update the krest parameters --- runtime/krest/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/krest/src/lib.rs b/runtime/krest/src/lib.rs index fd086bda..eb62678b 100644 --- a/runtime/krest/src/lib.rs +++ b/runtime/krest/src/lib.rs @@ -970,7 +970,7 @@ impl zenlink_protocol::Config for Runtime { parameter_types! { pub const InfaltionPot: PalletId = PalletId(*b"inflapot"); - pub const DefaultTotalIssuanceNum: Balance = 320_000_000 * DOLLARS; + pub const DefaultTotalIssuanceNum: Balance = 400_000_000 * DOLLARS; pub const DefaultInflationConfiguration: InflationConfiguration = InflationConfiguration { inflation_parameters: InflationParameters { inflation_rate: Perbill::from_perthousand(25u32), @@ -979,8 +979,8 @@ parameter_types! { inflation_stagnation_rate: Perbill::from_percent(1), inflation_stagnation_year: 10, }; - // Estimation is around 2024-10-31 00:00 in the ideal case - pub const InitializeInflationAt: BlockNumber = 3_583_831; + // Estimation is around 2025-12-31 00:00 in the ideal case + pub const InitializeInflationAt: BlockNumber = 6_651_031; pub const BlockRewardBeforeInitialize: Balance = 3_805_175_038_050_000_000; }