This repository was archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
refactor: new messengers #421
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
573bc0d
contracts: consolidate OptimismPortal
tynes f56aecb
contracts: delete abstracts
tynes 325f8d0
contracts: base `CrossDomainMessenger` + L1 and L2
tynes 5fbc866
contracts: `StandardBridge`
tynes c79a6ae
contracts: L2OutputOracle
tynes 06af146
contracts: standard bridge tests
tynes 046931b
contracts: cross domain hashing lib + tests
tynes 0408613
contracts: tests for cross domain messengers
tynes bfbf6f3
contracts: L2ToL1MessagePasser
tynes 74673f7
contracts: safe call lib
tynes f7f4ea8
contracts: optimism mintable erc20
tynes 6491415
contracts: common test setup
tynes 502f154
contracts: optimism mintable token factory
tynes a623981
contracts: update forge-std
tynes 4dd57da
contracts: test OptimismPortal
tynes 9d5409c
contracts: L1Block attributes
tynes b5feec7
contracts: update libraries
tynes 8a355a0
contracts: update foundry.toml
tynes 0e19c25
contracts: Burner
tynes 0d42f3d
contracts: delete dead code
tynes 173e961
contracts: update hh deploy scripts
tynes d16b922
contracts: update gas snapshot
tynes 249064d
integration-tests: update for new messengers
tynes c110309
ops: devnet up script new genesis
tynes 5f8e468
opnode: new bindings
tynes 28359ec
l2os: new bindings
tynes 741cccc
contracts: update gas snapshot
tynes aaf62b4
specs: L2ToL1MessagePasser
tynes 1535113
specs: messengers
tynes 03c8c86
specs: bridges
tynes d73feb7
specs: fix linting issues
tynes 230aff6
contracts: better contract for is optimism mintable
tynes e2da9e2
contracts: fix some comments
tynes 97f10cc
contracts: assert finalization window has passed
tynes 1449e24
bindings: regenerate
tynes 5e37e47
contracts: address comments
tynes 756e2a5
Merge pull request #429 from ethereum-optimism/fix/withdrawal-time
tynes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,61 +1,88 @@ | ||
| DepositFeedTest:test_depositTransaction_ContractCreationReverts() (gas: 9290) | ||
| DepositFeedTest:test_depositTransaction_NoValueContract() (gas: 24388) | ||
| DepositFeedTest:test_depositTransaction_NoValueEOA() (gas: 24734) | ||
| DepositFeedTest:test_depositTransaction_createWithZeroValueForContract() (gas: 24451) | ||
| DepositFeedTest:test_depositTransaction_createWithZeroValueForEOA() (gas: 24707) | ||
| DepositFeedTest:test_depositTransaction_withEthValueAndContractContractCreation() (gas: 31429) | ||
| DepositFeedTest:test_depositTransaction_withEthValueAndEOAContractCreation() (gas: 22859) | ||
| DepositFeedTest:test_depositTransaction_withEthValueFromContract() (gas: 31098) | ||
| DepositFeedTest:test_depositTransaction_withEthValueFromEOA() (gas: 31713) | ||
| L1BLockTest:test_basefee() (gas: 7531) | ||
| L1BLockTest:test_hash() (gas: 7530) | ||
| L1BLockTest:test_number() (gas: 7555) | ||
| L1BLockTest:test_sequenceNumber() (gas: 7577) | ||
| L1BLockTest:test_timestamp() (gas: 7587) | ||
| L1CrossDomainMessenger_Test:testCannot_pause() (gas: 10843) | ||
| L1CrossDomainMessenger_Test:test_blockAndUnblockSuccessfulMessage() (gas: 105412) | ||
| L1CrossDomainMessenger_Test:test_pause() (gas: 31793) | ||
| L1CrossDomainMessenger_Test:test_relayMessageBlockingAuth() (gas: 18542) | ||
| L1CrossDomainMessenger_Test:test_relayMessageInsideFraudProofWindow() (gas: 12305) | ||
| L1CrossDomainMessenger_Test:test_relayMessageSucceeds() (gas: 82425) | ||
| L1CrossDomainMessenger_Test:test_relayMessageToSystemContract() (gas: 30160) | ||
| L1CrossDomainMessenger_Test:test_relayRevertOnBlockedMessage() (gas: 55761) | ||
| L1CrossDomainMessenger_Test:test_relayShouldRevertIfPaused() (gas: 41560) | ||
| L1CrossDomainMessenger_Test:test_relayShouldRevertSendingSameMessageTwice() (gas: 188) | ||
| L1CrossDomainMessenger_Test:test_revertOnInvalidOutputRootProof() (gas: 16067) | ||
| L1CrossDomainMessenger_Test:test_sendMessage() (gas: 44041) | ||
| L1CrossDomainMessenger_Test:test_sendMessageTwice() (gas: 49061) | ||
| L1CrossDomainMessenger_Test:test_xDomainMessageSenderResets() (gas: 81565) | ||
| L1StandardBridge_Test:test_L1BridgeSetsPortalAndL2Bridge() (gas: 14825) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerCallsTarget() (gas: 64095) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerCannotCallL2MessagePasser() (gas: 42128) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerCannotRelaySameMessageTwice() (gas: 67491) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerCorrectL1Messenger() (gas: 9762) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerRevertInvalidL1XDomainMessenger() (gas: 11535) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 122584) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerSendSameMessageTwice() (gas: 162903) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerXDomainMessageSenderReset() (gas: 69285) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerxDomainMsgSender() (gas: 11159) | ||
| L2OutputOracleTest:testCannot_appendCurrentTimestamp() (gas: 18605) | ||
| L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 16724) | ||
| L2OutputOracleTest:testCannot_appendFutureTimestamp() (gas: 18642) | ||
| L2OutputOracleTest:testCannot_appendOutputIfNotSequencer() (gas: 16088) | ||
| CrossDomainHashing_Test:test_l2TransactionHash() (gas: 78639) | ||
| L1BLockTest:test_basefee() (gas: 7575) | ||
| L1BLockTest:test_hash() (gas: 7552) | ||
| L1BLockTest:test_number() (gas: 7651) | ||
| L1BLockTest:test_sequenceNumber() (gas: 7585) | ||
| L1BLockTest:test_timestamp() (gas: 7661) | ||
| L1CrossDomainMessenger_Test:testCannot_L1MessengerPause() (gas: 10909) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerMessageVersion() (gas: 8343) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerPause() (gas: 31882) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61062) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44727) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerRelayShouldRevertIfPaused() (gas: 41564) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 74867) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 66341) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerXDomainSenderReverts() (gas: 10565) | ||
| L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 58335) | ||
| L1StandardBridge_Test:test_depositERC20() (gas: 373162) | ||
| L1StandardBridge_Test:test_depositERC20To() (gas: 374939) | ||
| L1StandardBridge_Test:test_depositETH() (gas: 106067) | ||
| L1StandardBridge_Test:test_depositETHTo() (gas: 112908) | ||
| L1StandardBridge_Test:test_donateETH() (gas: 17500) | ||
| L1StandardBridge_Test:test_finalizeERC20Withdrawal() (gas: 438858) | ||
| L1StandardBridge_Test:test_finalizeETHWithdrawal() (gas: 47952) | ||
| L1StandardBridge_Test:test_initialize() (gas: 14863) | ||
| L1StandardBridge_Test:test_onlyEOADepositERC20() (gas: 12085) | ||
| L1StandardBridge_Test:test_onlyEOADepositETH() (gas: 30637) | ||
| L1StandardBridge_Test:test_onlyL2BridgeFinalizeERC20Withdrawal() (gas: 23521) | ||
| L1StandardBridge_Test:test_onlyPortalFinalizeERC20Withdrawal() (gas: 22853) | ||
| L1StandardBridge_Test:test_receive() (gas: 100261) | ||
| L2CrossDomainMessenger_Test:testCannot_L2MessengerPause() (gas: 10865) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerMessageVersion() (gas: 8387) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerPause() (gas: 31792) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageSucceeds() (gas: 57407) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageToSystemContract() (gas: 24523) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerRelayShouldRevertIfPaused() (gas: 41511) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 116411) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 133114) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 10587) | ||
| L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 54749) | ||
| L2OutputOracleTest:testCannot_appendCurrentTimestamp() (gas: 18627) | ||
| L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 16734) | ||
| L2OutputOracleTest:testCannot_appendFutureTimestamp() (gas: 18708) | ||
| L2OutputOracleTest:testCannot_appendOutputIfNotSequencer() (gas: 16458) | ||
| L2OutputOracleTest:testCannot_appendUnexpectedTimestamp() (gas: 18893) | ||
| L2OutputOracleTest:testCannot_computePreHistoricalL2BlockNumber() (gas: 11048) | ||
| L2OutputOracleTest:testCannot_deleteL2Output_ifNotSequencer() (gas: 16287) | ||
| L2OutputOracleTest:testCannot_deleteL2Output_ifWrongOutput() (gas: 23243) | ||
| L2OutputOracleTest:test_appendingAnotherOutput() (gas: 47332) | ||
| L2OutputOracleTest:testCannot_computePreHistoricalL2BlockNumber() (gas: 11093) | ||
| L2OutputOracleTest:testCannot_deleteL2Output_ifNotSequencer() (gas: 18793) | ||
| L2OutputOracleTest:testCannot_deleteWrongL2Output() (gas: 77307) | ||
| L2OutputOracleTest:test_appendingAnotherOutput() (gas: 68605) | ||
| L2OutputOracleTest:test_computeL2BlockNumber() (gas: 15003) | ||
| L2OutputOracleTest:test_deleteL2Output() (gas: 30647) | ||
| L2OutputOracleTest:test_getL2Output() (gas: 15071) | ||
| L2OutputOracleTest:test_latestBlockTimestamp() (gas: 9699) | ||
| L2OutputOracleTest:test_nextTimestamp() (gas: 12031) | ||
| L2OutputOracleTest_Constructor:test_constructor() (gas: 29173) | ||
| L2StandardBridge_Test:test_L2BridgeCorrectL1Bridge() (gas: 9726) | ||
| OptimismPortal_Test:test_receive_withEthValueFromEOA() (gas: 21979) | ||
| WithdrawalsRelay_finalizeWithdrawalTransaction_Test:test_cannotVerifyInvalidProof() (gas: 37418) | ||
| WithdrawalsRelay_finalizeWithdrawalTransaction_Test:test_cannotVerifyRecentWithdrawal() (gas: 33219) | ||
| WithdrawalsRelay_finalizeWithdrawalTransaction_Test:test_verifyWithdrawal() (gas: 190048) | ||
| WithdawerBurnTest:test_burn() (gas: 50276) | ||
| WithdrawerTestInitiateWithdrawal:test_initiateWithdrawal_fromContract() (gas: 71990) | ||
| WithdrawerTestInitiateWithdrawal:test_initiateWithdrawal_fromEOA() (gas: 72475) | ||
| L2OutputOracleTest:test_constructor() (gas: 33752) | ||
| L2OutputOracleTest:test_deleteL2Output() (gas: 64320) | ||
| L2OutputOracleTest:test_getL2Output() (gas: 74601) | ||
| L2OutputOracleTest:test_latestBlockTimestamp() (gas: 68377) | ||
| L2OutputOracleTest:test_nextTimestamp() (gas: 9236) | ||
| L2StandardBridge_Test:test_finalizeDeposit() (gas: 97520) | ||
| L2StandardBridge_Test:test_initialize() (gas: 14812) | ||
| L2StandardBridge_Test:test_receive() (gas: 137222) | ||
| L2StandardBridge_Test:test_withdraw() (gas: 353410) | ||
| L2StandardBridge_Test:test_withdrawTo() (gas: 354225) | ||
| L2ToL1MessagePasserTest:test_burn() (gas: 112001) | ||
| L2ToL1MessagePasserTest:test_initiateWithdrawal_fromContract() (gas: 67935) | ||
| L2ToL1MessagePasserTest:test_initiateWithdrawal_fromEOA() (gas: 74851) | ||
| OptimismMintableTokenFactory_Test:test_bridge() (gas: 9850) | ||
| OptimismMintableTokenFactory_Test:test_burn() (gas: 52791) | ||
| OptimismMintableTokenFactory_Test:test_burnRevertsFromNotBridge() (gas: 13211) | ||
| OptimismMintableTokenFactory_Test:test_l1Token() (gas: 9779) | ||
| OptimismMintableTokenFactory_Test:test_l2Bridge() (gas: 9768) | ||
| OptimismMintableTokenFactory_Test:test_mint() (gas: 65732) | ||
| OptimismMintableTokenFactory_Test:test_mintRevertsFromNotBridge() (gas: 13213) | ||
| OptimismMintableTokenFactory_Test:test_remoteToken() (gas: 9762) | ||
| OptimismMintableTokenFactory_Test:test_bridge() (gas: 9772) | ||
| OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1106538) | ||
| OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2193987) | ||
| OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9374) | ||
| OptimismMintableTokenFactory_Test:test_initializeShouldRevert() (gas: 12696) | ||
| OptimismPortal_Test:test_OptimismPortalConstructor() (gas: 11302) | ||
| OptimismPortal_Test:test_OptimismPortalContractCreationReverts() (gas: 9399) | ||
| OptimismPortal_Test:test_OptimismPortalReceiveEth() (gas: 24797) | ||
| OptimismPortal_Test:test_cannotVerifyRecentWithdrawal() (gas: 19657) | ||
| OptimismPortal_Test:test_depositTransaction_NoValueContract() (gas: 24478) | ||
| OptimismPortal_Test:test_depositTransaction_NoValueEOA() (gas: 24824) | ||
| OptimismPortal_Test:test_depositTransaction_createWithZeroValueForContract() (gas: 24497) | ||
| OptimismPortal_Test:test_depositTransaction_createWithZeroValueForEOA() (gas: 24841) | ||
| OptimismPortal_Test:test_depositTransaction_withEthValueAndContractContractCreation() (gas: 31519) | ||
| OptimismPortal_Test:test_depositTransaction_withEthValueAndEOAContractCreation() (gas: 22949) | ||
| OptimismPortal_Test:test_depositTransaction_withEthValueFromContract() (gas: 31188) | ||
| OptimismPortal_Test:test_depositTransaction_withEthValueFromEOA() (gas: 31804) | ||
| OptimismPortal_Test:test_invalidWithdrawalProof() (gas: 26565) |
67 changes: 67 additions & 0 deletions
67
packages/contracts/contracts/L1/L1CrossDomainMessenger.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.9; | ||
|
|
||
| import { | ||
| Lib_PredeployAddresses | ||
| } from "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol"; | ||
| import { OptimismPortal } from "./OptimismPortal.sol"; | ||
| import { CrossDomainMessenger } from "../universal/CrossDomainMessenger.sol"; | ||
|
|
||
| /** | ||
| * @title L1CrossDomainMessenger | ||
| * @dev The L1 Cross Domain Messenger contract sends messages from L1 to L2, and relays messages | ||
| * from L2 onto L1. | ||
| * This contract should be deployed behind an upgradable proxy | ||
| */ | ||
| contract L1CrossDomainMessenger is CrossDomainMessenger { | ||
| /************* | ||
| * Variables * | ||
| *************/ | ||
|
|
||
| /** | ||
| * @notice Address of the OptimismPortal. | ||
| */ | ||
| OptimismPortal public portal; | ||
|
|
||
| /******************** | ||
| * Public Functions * | ||
| ********************/ | ||
|
|
||
| /** | ||
| * @notice Initialize the L1CrossDomainMessenger | ||
| * @param _portal The OptimismPortal | ||
| */ | ||
| function initialize(OptimismPortal _portal) external { | ||
| portal = _portal; | ||
|
|
||
| address[] memory blockedSystemAddresses = new address[](1); | ||
| blockedSystemAddresses[0] = address(this); | ||
|
|
||
| _initialize(Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER, blockedSystemAddresses); | ||
| } | ||
|
|
||
| /********************** | ||
| * Internal Functions * | ||
| **********************/ | ||
|
|
||
| /** | ||
| * @notice Ensure that the L1CrossDomainMessenger can only be called | ||
| * by the OptimismPortal and the L2 sender is the L2CrossDomainMessenger. | ||
| */ | ||
| function _isSystemMessageSender() internal view override returns (bool) { | ||
| return msg.sender == address(portal) && portal.l2Sender() == otherMessenger; | ||
| } | ||
|
|
||
| /** | ||
| * @notice Sending a message in the L1CrossDomainMessenger involves | ||
| * depositing through the OptimismPortal. | ||
| */ | ||
| function _sendMessage( | ||
| address _to, | ||
| uint64 _gasLimit, | ||
| uint256 _value, | ||
| bytes memory _data | ||
| ) internal override { | ||
| portal.depositTransaction{ value: _value }(_to, _value, _gasLimit, false, _data); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is only used in
CrossDomainMessenger#relayMessage, which is never called by theOptimismPortal??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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
OptimismPortaldoes make calls on L1 for a withdrawal, the flow through the L2 messenger would be encoding a call to the L1 messengerrelayMessageThere 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.
Gotcha, I get it now 👍