feat(ctb): Fail relayed XDM messages on reentry#5444
Conversation
|
✅ Deploy Preview for opstack-docs canceled.
|
|
This definitely seems quite sane, just be sure to squash commits when ready for review |
388b212 to
70cff67
Compare
|
I'm trying to build the bindings locally to see if i get a diff |
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
packages/contracts-bedrock/contracts/test/CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
e963bfa to
b9ac9ef
Compare
|
Hey @maurelian! This PR has merge conflicts. Please fix them before continuing review. |
a4440a2 to
7ff3c96
Compare
maurelian
left a comment
There was a problem hiding this comment.
I'm unable to approve since I opened the PR, but LGTM other than one nit in a test file.
77bbc37 to
74586d6
Compare
|
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. |
`CrossDomainMessager` whereby `relayMessage` naively reset the `xDomainMsgSender` after a call. The issue here was that a nested call would reset this value to the `Constants.DEFAULT_L2_SENDER` which deviates from the expected behavior that the `xDomainMsgSender` is set to the `_sender` for the entirety of the subcall. This change sets a message as failed upon re-entry to the `relayMessage` function by checking the value of `xDomainMsgSender`. We then also remove the `reentrancyLocks` from storage and don't have to worry about re-entrency here since any subcall through the `SafeCall` lib to the XDM `relayMessage` will be caught and recorded as failed by the aforementioned `xDomainMsgSender` check. Also removes the revert in `relayMessage` when the minimum gas threshold is not met. See: - ethereum-optimism/optimism#5475 - ethereum-optimism/optimism#5444 - ethereum-optimism/optimism#5493 - ethereum-optimism/optimism#5508
Description
This PR is an alternative to #5440.
The solution implementation as well as fuzz tests are included in this PR. Invariant testing will be split out to properly iterate and introduce invariant testing.
The sherlock-identified issue in the
CrossDomainMessagerwherebyrelayMessagenaively reset thexDomainMsgSenderafter a call. The issue here was that a nested call would reset this value to theConstants.DEFAULT_L2_SENDERwhich deviates from the expected behavior that thexDomainMsgSenderis set to the_senderfor the entirety of the subcall.As opposed to the minimal solution outlined in #5440, this change sets a message as failed upon re-entry to the
relayMessagefunction by checking the value ofxDomainMsgSender.This check is a simple addition of the following
We then also remove the
reentrancyLocksfrom storage and don't have to worry about re-entrency here since any subcall through theSafeCalllib to the XDMrelayMessagewill be caught and recorded as failed by the aforementionedxDomainMsgSendercheck.Benefits of this solution
reentrancyLockssavingSSTOREs andSLOADs as well as removing the storage mapping altogether.Potential Solution Cons
Metadata
Fixes CLI-3834