From 4909782194ae025ff78438126c1e595f404e16a9 Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:30:36 +0800 Subject: [PATCH] feat(protocol): use 35000 as gas limit for sending Ether in Brdge (#16666) --- packages/protocol/contracts/bridge/Bridge.sol | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 200f560c81e..05ec40a50a2 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -23,6 +23,13 @@ contract Bridge is EssentialContract, IBridge { bytes32 private constant _CTX_SLOT = 0xe4ece82196de19aabe639620d7f716c433d1348f96ce727c9989a982dbadc2b9; + /// @dev Gas limit for sending Ether. + // - EOA gas used is < 21000 + // - For Loopring smart wallet, gas used is about 23000 + // - For Argent smart wallet on Ethereum, gas used is about 24000 + // - For Gnosis Safe wallet, gas used is about 28000 + uint256 private constant _SEND_ETHER_GAS_LIMIT = 35_000; + /// @dev Place holder value when not using transient storage uint256 internal constant PLACEHOLDER = type(uint256).max; @@ -210,7 +217,7 @@ contract Bridge is EssentialContract, IBridge { // Must reset the context after the message call _resetContext(); } else { - _message.srcOwner.sendEtherAndVerify(_message.value); + _message.srcOwner.sendEtherAndVerify(_message.value, _SEND_ETHER_GAS_LIMIT); } emit MessageRecalled(msgHash); } else if (isNewlyProven) { @@ -318,11 +325,11 @@ contract Bridge is EssentialContract, IBridge { // Refund the processing fee if (msg.sender == refundTo) { - refundTo.sendEtherAndVerify(_message.fee + refundAmount); + refundTo.sendEtherAndVerify(_message.fee + refundAmount, _SEND_ETHER_GAS_LIMIT); } else { // If sender is another address, reward it and refund the rest - msg.sender.sendEtherAndVerify(_message.fee); - refundTo.sendEtherAndVerify(refundAmount); + msg.sender.sendEtherAndVerify(_message.fee, _SEND_ETHER_GAS_LIMIT); + refundTo.sendEtherAndVerify(refundAmount, _SEND_ETHER_GAS_LIMIT); } emit MessageExecuted(msgHash); } else if (isNewlyProven) {