From a213e2aef42b4a24fc7eb02472d24a10a4bcbe5a Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 20 Feb 2024 08:49:54 +0100 Subject: [PATCH] A0-4022: Reduced multi block contract migration weight by 4 (#2) * A0-4022: Reduced multi block contract migration weight by 4 * Previous approach was a no-op --- substrate/frame/contracts/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index 55aea0300c9b..a3b13b6fc09b 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -417,8 +417,9 @@ pub mod pallet { use migration::MigrateResult::*; loop { - let (result, weight) = Migration::::migrate(remaining_weight); - remaining_weight.saturating_reduce(weight); + const reduced_weight_factor: u64 = 4; + let (result, weight) = Migration::::migrate(remaining_weight.saturating_div(reduced_weight_factor)); + remaining_weight.saturating_reduce(weight.saturating_mul(reduced_weight_factor)); match result { // There is not enough weight to perform a migration, or make any progress, we