Conversation
Codecov Report
@@ Coverage Diff @@
## main #421 +/- ##
==========================================
+ Coverage 51.68% 53.10% +1.42%
==========================================
Files 57 62 +5
Lines 5764 6498 +734
==========================================
+ Hits 2979 3451 +472
- Misses 2415 2608 +193
- Partials 370 439 +69
Continue to review full report at Codecov.
|
7dcef83 to
73eef4e
Compare
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Implement the `L1CrossDomainMessenger` and `L2CrossDomainMessenger` based on the base `CrossDomainMessenger`. This makes the interfaces the same on both sides. Co-authored-by: smartcontracts <kelvin@optimism.io>
Also implement the `L1StandardBridge` and `L2StandardBridge` based off of the base `StandardBridge` Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
Co-authored-by: smartcontracts <kelvin@optimism.io>
norswap
left a comment
There was a problem hiding this comment.
-
I'm missing some kind of document (or even better, diagram) that tie all the components together. In particular, illustrating the flow of L1->L2 bridging and L2->L1 bridging through the components & functions would be really a great help in wrapping your head around the logic.
-
We should consolidate the "new API" and the "legacy API" (separately!) and provide a mapping / migration path between both.
-
It seems to me (unless I've missed something) that the
relayMessagecall is never used. It's not necessary when doing L1->L2 (because of deposit inclusion), but it's not used either when doing L2->L1 (instead the logic lives entirely withinOptimismPortal).- Suggest removing
relayMessagefromCrossDomainMessenger. - Preserve it in
L1CrossDomainMessenger(for backward compatibility) but call intoOptimismPortalinstead.
- Suggest removing
|
|
||
| emit ETHBridgeFinalized(_from, _to, _amount, _data); | ||
| (bool success, ) = _to.call{ value: _amount }(new bytes(0)); | ||
| require(success, "TransferHelper::safeTransferETH: ETH transfer failed"); |
There was a problem hiding this comment.
That require string needs to be updated.
| */ | ||
| function _isSystemMessageSender() internal view override returns (bool) { | ||
| return msg.sender == address(portal) && portal.l2Sender() == otherMessenger; | ||
| } |
There was a problem hiding this comment.
This is only used in CrossDomainMessenger#relayMessage, which is never called by the OptimismPortal??
There was a problem hiding this comment.
Also the comment "Ensure that the L1CrossDomainMessenger can only be called by the OptimismPortal" seems false?
The privilege of the messenger is that it can relay messages that have not not been marked as received (but again, the portal never relays currently).
There was a problem hiding this comment.
The OptimismPortal does make calls on L1 for a withdrawal, the flow through the L2 messenger would be encoding a call to the L1 messenger relayMessage
| ) internal { | ||
| emit ERC20DepositInitiated(_l1Token, _l2Token, _from, _to, _amount, _data); | ||
| _initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _data); | ||
| } |
There was a problem hiding this comment.
Is there any reason why the two functions above are not inlined within the external functions that call them?
trianglesphere
left a comment
There was a problem hiding this comment.
I just flagged everywhere I was a gasLimit that was 256 bits, but didn't do as much in terms of determining if it was valid or not.
I also flagged where I had the concern around msg.value and _value on L2. I don't think this is fully relevant yet, but will be in the future.
Otherwise, this looks good to me.
| event l2OutputAppended( | ||
| bytes32 indexed _l2Output, | ||
| uint256 indexed _l1Timestamp, | ||
| uint256 indexed _l2timestamp |
There was a problem hiding this comment.
Should also use block number here. This is a larger refactor though.
There was a problem hiding this comment.
We need consensus before making that large of a change, should put together a doc @trianglesphere and schedule discussion for next office hours @K-Ho
| address _sender, | ||
| address _target, | ||
| uint256 _value, | ||
| uint256 _gasLimit, |
There was a problem hiding this comment.
Is this new code? This is the gas limit that should be limited to 64 bites
| @@ -62,21 +72,20 @@ contract Withdrawer { | |||
| function initiateWithdrawal( | |||
| address _target, | |||
| uint256 _gasLimit, | |||
There was a problem hiding this comment.
too large gas limit.
There was a problem hiding this comment.
This is safe, downstream there is a require(gasleft() > _gasLimit + buffer)
I lean towards not changing any of the gas limits here as the only one that needs to be a uint64 is the one used for deposits. Unless there is strong preference for it to be a uint64 everywhere just for sanity reasons, which I would understand too
There was a problem hiding this comment.
I think that it could be fine. I just flagged each instance without too much thought. It's just that any gas limit that serializes to go / actual execution needs to fit in 64 bits (and probably way fewer) otherwise the deposit gets stuck
| bool _isCreate, | ||
| uint256 _mint, | ||
| uint256 _value, | ||
| uint256 _gas, |
There was a problem hiding this comment.
too large? Maybe not actually?
| address _sender, | ||
| address _target, | ||
| uint256 _value, | ||
| uint256 _gasLimit, |
| address _sender, | ||
| address _target, | ||
| uint256 _value, | ||
| uint256 _gasLimit, |
| address sender, | ||
| bytes message, | ||
| uint256 messageNonce, | ||
| uint256 gasLimit |
| address indexed sender, | ||
| address indexed target, | ||
| uint256 value, | ||
| uint256 gasLimit, |
|
|
||
| if (_isSystemMessageSender()) { | ||
| // Should never happen. | ||
| require(msg.value == _value, "Mismatched message value."); |
There was a problem hiding this comment.
I have concerns about this when we are doing stuff on L2 with this. Specifically the L1 value is set to the L2 mint, and then a user specified (to the deposit tx at least) amount is set to the value field. If these fields do not line up exactly, we have have stuck messages. In particular, we expect one version of the Optimism Portal Deposit function to take eth to pay for L2 gas which would change the amount of value emitted.
fix: withdrawal time
Implements the new messenger flow. This ensures that the messengers and bridges work in a backwards compatible way. The previous iteration of the messengers didn't take into account deposits that were in flight during the upgrade. This pull request has some major architectural changes so that the bridges now go through the messengers again. This allows for replayability in the bridges as well as gives the bridges replay protection.
A main feature of this PR is that the messenger and bridges now extend a base messenger or bridge contract to make the functionality basically the same on both L1 and L2. The previous iteration of the contracts made a distinction between the L1 and L2 sides of things. The previous APIs are persisted, but now there is a universal API that can be used on the bridges/messengers no matter which domain you are in.
Hardhat deploy scripts are added to the
opssetup.The bindings for the
l2osandopnodeare regenerated.Deprecates:
Unblocks:
Closes:
receivefunction #398