Skip to content

Commit

Permalink
safety precautions for on_idle hook (#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa authored Dec 9, 2024
2 parents 041b37e + 011e11e commit cbe25cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pallets/rolldown/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ pub mod pallet {
fn on_idle(_now: BlockNumberFor<T>, mut remaining_weight: Weight) -> Weight {
let mut used_weight = Weight::default();

// given aproximated nature of weights for huge blob read/wirtes and complicated
// benchmarks of on_idle_hook lets consider only 80% of remaining weight
remaining_weight = remaining_weight.saturating_mul(8).saturating_div(10);

// already cached by using in on_initialize hook
if !T::MaintenanceStatusProvider::is_maintenance() {
let get_update_size_cost = T::DbWeight::get().reads(2);
Expand Down

0 comments on commit cbe25cb

Please sign in to comment.