Skip to content

Commit

Permalink
Merge branch 'dev' into bug/1207512530452118_without_storage_info
Browse files Browse the repository at this point in the history
  • Loading branch information
sfffaaa authored Aug 7, 2024
2 parents f6419f3 + 24add78 commit 3a01866
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pallets/inflation-manager/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ benchmarks! {
assert_eq!(TotalIssuanceNum::<T>::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::<T>::get(), delay.into());
}

set_block_reward {
let reward = 1000 as u128;
}: _(RawOrigin::Root, reward.into())
verify {
assert_eq!(BlockRewards::<T>::get(), reward.into());
}
}

#[cfg(test)]
Expand Down
13 changes: 13 additions & 0 deletions pallets/inflation-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>,
reward: Balance,
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;

BlockRewards::<T>::put(reward);

Ok(().into())
}
}

impl<T: Config> Pallet<T> {
Expand Down
12 changes: 12 additions & 0 deletions pallets/inflation-manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,18 @@ fn recaluclation_change_fail() {
})
}

#[test]
fn block_reward_change() {
ExternalityBuilder::default().build().execute_with(|| {
assert_eq!(
InflationManager::block_rewards(),
<TestRuntime as Config>::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 {
Expand Down
1 change: 1 addition & 0 deletions pallets/inflation-manager/src/weightinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
11 changes: 11 additions & 0 deletions pallets/inflation-manager/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@ impl<T: frame_system::Config> crate::WeightInfo for WeightInfo<T> {
.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))
}
}
6 changes: 3 additions & 3 deletions runtime/krest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,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),
Expand All @@ -978,8 +978,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 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;
}

Expand Down

0 comments on commit 3a01866

Please sign in to comment.