Skip to content

Commit

Permalink
A0-4022: Reduced multi block contract migration weight by 4 (parityte…
Browse files Browse the repository at this point in the history
…ch#2)

* A0-4022: Reduced multi block contract migration weight by 4

* Previous approach was a no-op
  • Loading branch information
Marcin-Radecki authored and lesniak43 committed May 24, 2024
1 parent 431f13f commit a213e2a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions substrate/frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ pub mod pallet {
use migration::MigrateResult::*;

loop {
let (result, weight) = Migration::<T>::migrate(remaining_weight);
remaining_weight.saturating_reduce(weight);
const reduced_weight_factor: u64 = 4;
let (result, weight) = Migration::<T>::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
Expand Down

0 comments on commit a213e2a

Please sign in to comment.