浏览代码

add 50% overhead to gas for cross-contract calls

Daniel Chew 10 月之前
父节点
当前提交
32494cc7fa
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      target_chains/ethereum/contracts/contracts/pulse/Pulse.sol

+ 2 - 2
target_chains/ethereum/contracts/contracts/pulse/Pulse.sol

@@ -81,8 +81,8 @@ abstract contract Pulse is IPulse, PulseState {
                 SafeCast.toUint64(req.publishTime)
             );
 
-        // Check if enough gas remains for the callback
-        if (gasleft() < req.callbackGasLimit) {
+        // Check if enough gas remains for the callback plus 50% overhead for cross-contract call (uses integer arithmetic to avoid floating point)
+        if (gasleft() < (req.callbackGasLimit * 3) / 2) {
             revert InsufficientGas();
         }