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

fix(protocol): check invocation gas limit also in retryMessage #16660

Merged
merged 9 commits into from
Apr 5, 2024
10 changes: 10 additions & 0 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,16 @@ contract Bridge is EssentialContract, IBridge {
revert B_NON_RETRIABLE();
}

// We check gasleft() against _message.gasLimit to make sure we not only need to bridge
// invocation call to succeed, we also need it to succeed with a gas limit no smaller than
// the message's gasLimit.
if (
_message.gasLimit != 0 && msg.sender != _message.destOwner
&& _message.gasLimit > (gasleft() * 63) >> 6
) {
revert B_NOT_ENOUGH_GASLEFT();
}

// Attempt to invoke the messageCall.
if (_invokeMessageCall(_message, msgHash, gasleft())) {
_updateMessageStatus(msgHash, Status.DONE);
Expand Down
Loading