Skip to content

Commit

Permalink
gas: adjust the computation of self.promises_gas
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Dec 1, 2022
1 parent 1cec161 commit 72d4a4d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runtime/near-vm-logic/src/gas_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl GasCounter {
self.fast_counter.burnt_gas = new_burnt_gas;
Ok(())
} else {
Err(self.process_gas_limit(new_burnt_gas, new_burnt_gas + self.promises_gas).into())
let new_used_gas = new_burnt_gas.wrapping_add(self.promises_gas);
Err(self.process_gas_limit(new_burnt_gas, new_used_gas).into())
}
}

Expand All @@ -144,8 +145,7 @@ impl GasCounter {
// See https://github.com/near/nearcore/issues/5148.
// TODO: consider making this change!
let used_gas_limit = min(self.prepaid_gas, new_used_gas);
assert!(used_gas_limit >= self.fast_counter.burnt_gas);
self.promises_gas = used_gas_limit - self.fast_counter.burnt_gas;
self.promises_gas = used_gas_limit.saturating_sub(self.fast_counter.burnt_gas);

// If we crossed both limits prefer reporting GasLimitExceeded.
// Alternative would be to prefer reporting limit that is lower (or
Expand Down

0 comments on commit 72d4a4d

Please sign in to comment.