-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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(ctb): Per-message reentrancy guard for relayMessage
#4919
Conversation
🦋 Changeset detectedLatest commit: 6b9373f The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
Hey @clabby! This PR has merge conflicts. Please fix them before continuing review. |
15a6c19
to
9907214
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #4919 +/- ##
===========================================
- Coverage 40.57% 39.97% -0.61%
===========================================
Files 324 303 -21
Lines 19537 18909 -628
Branches 767 653 -114
===========================================
- Hits 7928 7558 -370
+ Misses 11009 10755 -254
+ Partials 600 596 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not entirely clear to me that this is the right solution to the problem. Are we sure that we even still need a reentrancy guard here?
What invariants are we trying to preserve?
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
Hey @clabby! This PR has merge conflicts. Please fix them before continuing review. |
334ed4c
to
84d9cc0
Compare
84d9cc0
to
13d25e4
Compare
The big invariant that we are trying to preserve here is that, if given gas >= the minimum gas limit, a cross domain message will always successfully be relayed if the transaction itself does not revert. Shooting over a DM for more. |
13d25e4
to
b096ccc
Compare
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
I would strongly prefer not using assembly here and just stick with a simple mapping. This is the sort of stuff that IMO should be saved for the optimization release. Any changes to the Bedrock code at this point should be dead simple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel strongly enough about not having any assembly here that I'm going to block this for now. Much rather have a simple mapping, especially because we want to reduce the mental overhead down to an absolute minimum for any auditor that's going to be looking at this code before the Bedrock vote.
Dismissing earlier review given the updates.
We can also satisfy that invariant by removing the reentrancy guard entirely. If we can't do that, then there must be another invariant we need to maintain? Even without assembly code, this adds complexity so we need to ensure that it's justified. |
The other very important invariant we need to maintain here is that "cross domain messages should only be able to be successfully relayed once." With the current design, removing the reentrancy guard entirely would allow for relaying a message multiple times before the message hash was assigned to the |
f200fec
to
3be08f3
Compare
ee48d14
to
6e34593
Compare
6e34593
to
99ab58b
Compare
Storage snapshot
422fc89
to
849e30d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we can dedupe the tests in the future but fine for now
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
This looks good to me, includes test coverage and is a simple implementation |
This PR has been added to the merge queue, and will be merged soon. |
This PR is next in line to be merged, and will be merged as soon as checks pass. |
Overview
Changes the
CrossDomainMessenger
'srelayMessage
reentrancy guard to be per-message rather than disallowing reentrancy entirely.Dislikes about this soln
- TheEDIT: Added a gap array instead.CrossDomainMessenger
no longer needs to inheritReentrancyGuardUpgradeable
, but we would need to alter the storage layouts in order to remove this. Furthers the case for EIP-1967 esq storage slots.Metadata
Closes CLI-3388