fix try-on-runtime-upgrade return weight (#14793)

This commit is contained in:
Liam Aharon
2023-08-21 19:06:30 +10:00
committed by GitHub
parent 9c5315961e
commit a13382f192
+3 -3
View File
@@ -164,13 +164,13 @@ impl OnRuntimeUpgrade for Tuple {
/// that occur. /// that occur.
#[cfg(feature = "try-runtime")] #[cfg(feature = "try-runtime")]
fn try_on_runtime_upgrade(checks: bool) -> Result<Weight, TryRuntimeError> { 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(); let mut errors = Vec::new();
for_tuples!(#( for_tuples!(#(
match Tuple::try_on_runtime_upgrade(checks) { 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); }, Err(err) => { errors.push(err); },
} }
)*); )*);
@@ -194,7 +194,7 @@ impl OnRuntimeUpgrade for Tuple {
return Err("Detected multiple errors while executing `try_on_runtime_upgrade`, check the logs!".into()) 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. /// [`OnRuntimeUpgrade::pre_upgrade`] should not be used on a tuple.