Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

fix: try_on_runtime_upgrade for Tuple weight summation #14793

Merged
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
6 changes: 3 additions & 3 deletions frame/support/src/traits/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ impl OnRuntimeUpgrade for Tuple {
/// that occur.
#[cfg(feature = "try-runtime")]
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, TryRuntimeError> {
let mut weight = Weight::zero();
let mut cumulative_weight = Weight::zero();

let mut errors = Vec::new();

for_tuples!(#(
match Tuple::try_on_runtime_upgrade(checks) {
Ok(weight) => { weight.saturating_add(weight); },
Ok(weight) => { cumulative_weight.saturating_accrue(weight); },
Err(err) => { errors.push(err); },
}
)*);
Expand All @@ -194,7 +194,7 @@ impl OnRuntimeUpgrade for Tuple {
return Err("Detected multiple errors while executing `try_on_runtime_upgrade`, check the logs!".into())
}

Ok(weight)
Ok(cumulative_weight)
}

/// [`OnRuntimeUpgrade::pre_upgrade`] should not be used on a tuple.
Expand Down