Skip to content

Commit bb2f3fc

Browse files
author
Eduardo Leegwater Simões
authored
Merge pull request #323 from dusk-network/large-gas-fix
Fix overflow in ICC gas limit calculation
2 parents ac38650 + 3228361 commit bb2f3fc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

piecrust/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- Upgrade `dusk-wasmtime` to version `17`
1717

18+
### Fixed
19+
20+
- Fix overflow in gas limit calculation in inter-contract call
21+
1822
## [0.15.0] - 2024-01-24
1923

2024
### Changed

piecrust/src/imports.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ pub(crate) fn c(
209209
let callee_limit = if gas_limit > 0 && gas_limit < caller_remaining {
210210
gas_limit
211211
} else {
212-
caller_remaining * GAS_PASS_PCT / 100
212+
let div = caller_remaining / 100 * GAS_PASS_PCT;
213+
let rem = caller_remaining % 100 * GAS_PASS_PCT / 100;
214+
div + rem
213215
};
214216

215217
let with_memory = |memory: &mut [u8]| -> Result<_, Error> {

0 commit comments

Comments
 (0)