Skip to content

Commit

Permalink
Adjust gas check
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeissner committed May 4, 2020
1 parent 271921f commit 62d4bd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/GnosisSafe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ contract GnosisSafe
txHash = keccak256(txHashData);
checkSignatures(txHash, txHashData, signatures, true);
}
// We require some gas to emit the events (2500) after the execution and some to perform code until the execution (500)
// We also increase the amount required by 1/64 to counteract potential shortings because of EIP-150
require(gasleft() - 3000 >= safeTxGas * 65 / 64, "Not enough gas to execute safe transaction");
// We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)
// We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150
require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, "Not enough gas to execute safe transaction");
// Use scope here to limit variable lifetime and prevent `stack too deep` errors
{
uint256 gasUsed = gasleft();
Expand Down
8 changes: 8 additions & 0 deletions contracts/external/GnosisSafeMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ library GnosisSafeMath {
require(b != 0);
return a % b;
}


/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
}

0 comments on commit 62d4bd3

Please sign in to comment.