From 9cd56ada7c7cb20ea58a3fb84fb60438c60cf4be Mon Sep 17 00:00:00 2001 From: TuDo1403 Date: Wed, 19 Jun 2024 13:06:20 +0700 Subject: [PATCH] fix(BridgeReward): bump default addition gas for sending RON --- src/extensions/RONTransferHelper.sol | 6 ++++++ src/ronin/gateway/BridgeReward.sol | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/extensions/RONTransferHelper.sol b/src/extensions/RONTransferHelper.sol index 95fe234a..7aff395a 100644 --- a/src/extensions/RONTransferHelper.sol +++ b/src/extensions/RONTransferHelper.sol @@ -47,6 +47,12 @@ abstract contract RONTransferHelper { * @dev Same purpose with {_unsafeSendRONLimitGas(address,uin256)} but containing gas limit stipend forwarded in the call. */ function _unsafeSendRONLimitGas(address payable recipient, uint256 amount, uint256 gas) internal returns (bool success) { + // When msg.value = 0, the forwarding gas will not be auto-added 2300. + // We add an extra 2300 to make sure all calls will have the same amount of gas. + if (amount == 0) { + gas += 2300; + } + (success,) = recipient.call{ value: amount, gas: gas }(""); } } diff --git a/src/ronin/gateway/BridgeReward.sol b/src/ronin/gateway/BridgeReward.sol index e1719d98..7020b2a0 100644 --- a/src/ronin/gateway/BridgeReward.sol +++ b/src/ronin/gateway/BridgeReward.sol @@ -16,6 +16,8 @@ import { TUint256Slot } from "../../types/Types.sol"; import { ErrSyncTooFarPeriod, ErrInvalidArguments, ErrLengthMismatch, ErrUnauthorizedCall } from "../../utils/CommonErrors.sol"; contract BridgeReward is IBridgeReward, BridgeTrackingHelper, HasContracts, RONTransferHelper, Initializable { + /// @dev Configuration of gas stipend to ensure sufficient gas after the London Hardfork + uint256 public constant DEFAULT_ADDITION_GAS = 6200; /// @dev value is equal to keccak256("@ronin.dpos.gateway.BridgeReward.rewardInfo.slot") - 1 bytes32 private constant $_REWARD_INFO = 0x518cfd198acbffe95e740cfce1af28a3f7de51f0d784893d3d72c5cc59d7062a; /// @dev value is equal to keccak256("@ronin.dpos.gateway.BridgeReward.rewardPerPeriod.slot") - 1 @@ -316,7 +318,7 @@ contract BridgeReward is IBridgeReward, BridgeTrackingHelper, HasContracts, RONT return false; } - if (_unsafeSendRONLimitGas({ recipient: payable(operator), amount: reward, gas: 0 })) { + if (_unsafeSendRONLimitGas({ recipient: payable(operator), amount: reward, gas: DEFAULT_ADDITION_GAS })) { _iRewardInfo.claimed += reward; emit BridgeRewardScattered(period, operator, reward); return true;