Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions substrate/frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this saturating_reduce is weird xD it requires One and it's suspicious that it is more effective that saturating_sub (because that's my guess for the only reason for such a function)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's actually less effective, it's only that saturating_sub outputs a value and saturating_reduce mutates self. But why the hell is saturating_reduce implemented the way it is I have no idea


match result {
// There is not enough weight to perform a migration, or make any progress, we
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is actually not correct to return from on_idle in the first case of the match expression - we should try making some other work (like process_deletion_queue) - does this sound reasonable?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably right, we could break instead, but it doesn't matter much anyway, as in practice the migration take just a few blocks of time

Expand Down