Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): use 35000 as gas limit for sending Ether in Brdge #16666

Merged
merged 7 commits into from
Apr 8, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading