Skip to content

Commit

Permalink
add minor code comments explaining 1/64
Browse files Browse the repository at this point in the history
  • Loading branch information
RnkSngh committed Apr 22, 2024
1 parent c1d3749 commit 89ddc8d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contracts/core/Dispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,14 @@ contract Dispatcher is OwnableUpgradeable, UUPSUpgradeable, IDispatcher {
// https://docs.soliditylang.org/en/latest/cheatsheet.html#members-of-address
uint256 gasBeforeCall = gasleft();
(success, message) = receiver.call(args);

// x is the amount of gas left right before the low level call. Solidity will allocate x*63/64 to the low level
// call
// and x/64 for the remaining execution after the low-level call. If this low-level call runs out of gas, then
// gasLeft will be equal to x/64 at the start of the remaining execution. so we should check gasBefore < 1/64
if (!success && gasleft() < gasBeforeCall / 64) {
// Only check for out of gas if the call failed; if it was a successful call then it was gauranteed to not
// run out of gas
revert IBCErrors.notEnoughGas();
}
}
Expand Down

0 comments on commit 89ddc8d

Please sign in to comment.