Skip to content

Commit

Permalink
use checked-sub in refund weight (#2346)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec authored Jun 14, 2023
1 parent 116df29 commit a3e40a9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion precompiles/utils/src/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ where
// Refund weights and compute used weight them record used gas
// TODO: refund ref time when precompile will be benchmarked
let used_weight = if let Some(actual_weight) = maybe_actual_weight {
let refund_weight = weight - actual_weight;
let refund_weight = weight.checked_sub(&actual_weight).unwrap_or_default();
handle.refund_external_cost(None, Some(refund_weight.proof_size()));
actual_weight
} else {
Expand Down

0 comments on commit a3e40a9

Please sign in to comment.