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 63/64 gasleft() not smaller than specified gaslimit #16613

Merged
merged 16 commits into from
Apr 4, 2024

Conversation

dantaik
Copy link
Contributor

@dantaik dantaik commented Apr 2, 2024

@dantaik dantaik marked this pull request as ready for review April 2, 2024 15:25
Copy link

openzeppelin-code bot commented Apr 2, 2024

fix(protocol): check 63/64 gasleft() not smaller than specified gaslimit

Generated at commit: bbf6e1c9b7ce4066f0bb164b2a208e583cc6e585

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
2
0
3
39
46
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

Copy link
Contributor

@Brechtpd Brechtpd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this discussion, I remember it still from the Loopring smart wallet days! For me this is still a UI issue because the gas limit can simply be 1/64 higher to avoid it if it would ever be a problem. But the check is valid, just depends on what you expect the smart contract to check and I think this check goes pretty far because the gas limit is already just an abstract number for users.

@dantaik dantaik marked this pull request as draft April 3, 2024 00:18
@dantaik dantaik changed the title fix(protocol): check gasleft in LibAddress.sendEther fix(protocol): check 63/64 gasleft() not smaller than specified gaslimit Apr 3, 2024
@dantaik
Copy link
Contributor Author

dantaik commented Apr 3, 2024

Simplified the changes:

  • We only check gasleft()*64/64 >= gasLimit when processMessage is called by someone other than the owner. In all other cases (including recall the message), failure due to gas will not cause any issue for the msg owner.
  • No extra gas addition is applied to the above check (as in the Loopring code), if after the external call, the tx failed due to out-of-gas, the whole transaction will revert so no harm will be done to the msg.owner as well.

@dantaik dantaik marked this pull request as ready for review April 3, 2024 01:06
@dantaik dantaik requested a review from Brechtpd April 3, 2024 01:06
@dantaik dantaik enabled auto-merge April 4, 2024 01:46
@dantaik dantaik disabled auto-merge April 4, 2024 01:47
@dantaik dantaik enabled auto-merge April 4, 2024 01:47
@dantaik dantaik added this pull request to the merge queue Apr 4, 2024
Merged via the queue into main with commit 12f73cd Apr 4, 2024
10 checks passed
@dantaik dantaik deleted the check-gasleft branch April 4, 2024 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants