Skip to content

Commit

Permalink
feat(protocol): use 35000 as gas limit for sending Ether in Brdge (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Apr 8, 2024
1 parent f31a6ac commit 4909782
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4909782

Please sign in to comment.