From 011e11e0bb95c28b0a300f08933d1e8ac63a463f Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 9 Dec 2024 09:04:45 +0100 Subject: [PATCH] safety precautions for on_idle hook --- pallets/rolldown/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/rolldown/src/lib.rs b/pallets/rolldown/src/lib.rs index db7ff88cd..d83a4f076 100644 --- a/pallets/rolldown/src/lib.rs +++ b/pallets/rolldown/src/lib.rs @@ -178,6 +178,10 @@ pub mod pallet { fn on_idle(_now: BlockNumberFor, 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);