Skip to content

Commit acc72ea

Browse files
committed
readjust config in force_set_decay_rate
1 parent 41b7709 commit acc72ea

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

pallets/inflation/src/benchmarking.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ mod benchmarks {
123123
#[extrinsic_call]
124124
_(RawOrigin::Root, new_decay_rate);
125125

126-
assert_last_event::<T>(Event::<T>::DecayRateUpdated { new_decay_rate }.into());
126+
let config = ActiveInflationConfig::<T>::get();
127+
assert_last_event::<T>(Event::<T>::DecayRateUpdated { config }.into());
127128
}
128129

129130
#[benchmark]

pallets/inflation/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub mod pallet {
174174
/// New inflation configuration has been set.
175175
NewInflationConfiguration { config: InflationConfiguration },
176176
/// Inflation decay rate has been updated. This will take effect in the next cycle.
177-
DecayRateUpdated { new_decay_rate: Perquintill },
177+
DecayRateUpdated { config: InflationConfiguration },
178178
}
179179

180180
#[pallet::error]
@@ -332,8 +332,6 @@ pub mod pallet {
332332
/// Used to force-set the per-block decay rate for rewards.
333333
///
334334
/// Must be called by `root` origin.
335-
///
336-
/// The new rate will be applied starting from the next inflation recalculation (next cycle).
337335
#[pallet::call_index(3)]
338336
#[pallet::weight(T::WeightInfo::force_set_decay_rate())]
339337
pub fn force_set_decay_rate(
@@ -346,8 +344,11 @@ pub mod pallet {
346344
params.decay_rate = decay_rate;
347345
});
348346

347+
let config = Self::readjusted_config();
348+
ActiveInflationConfig::<T>::put(config.clone());
349+
349350
Self::deposit_event(Event::<T>::DecayRateUpdated {
350-
new_decay_rate: decay_rate,
351+
config,
351352
});
352353

353354
Ok(().into())

pallets/inflation/src/tests.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,9 @@ fn set_decay_rate_works() {
568568
RuntimeOrigin::root(),
569569
new_decay_rate
570570
));
571-
System::assert_last_event(Event::DecayRateUpdated { new_decay_rate }.into());
571+
let config = ActiveInflationConfig::<Test>::get();
572+
System::assert_last_event(Event::DecayRateUpdated { config }.into());
573+
assert_eq!(config.decay_rate, new_decay_rate);
572574
assert_eq!(InflationParams::<Test>::get().decay_rate, new_decay_rate);
573575
})
574576
}

0 commit comments

Comments
 (0)