Skip to content

Commit

Permalink
l2geth: add nightly addresses (#2485)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
tynes and mergify[bot] committed May 1, 2022
1 parent 6b9fc05 commit c799535
Show file tree
Hide file tree
Showing 26 changed files with 464 additions and 448 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-squids-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/l2geth': patch
---

Add system addresses for nightly goerli
6 changes: 6 additions & 0 deletions l2geth/rollup/rcfg/system_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ var SystemAddressDeployers = map[uint64]SystemAddressDeployer{
common.HexToAddress("0xc30276833798867c1dbc5c468bf51ca900b44e4c"),
common.HexToAddress("0x5c679a57e018f5f146838138d3e032ef4913d551"),
},

// Goerli nightly
421: {
common.HexToAddress("0xc30276833798867c1dbc5c468bf51ca900b44e4c"),
common.HexToAddress("0x5c679a57e018f5f146838138d3e032ef4913d551"),
},
}

var envSystemAddressDeployer SystemAddressDeployer
Expand Down
5 changes: 5 additions & 0 deletions l2geth/rollup/rcfg/system_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ func TestSystemAddressFor(t *testing.T) {
common.HexToAddress("0x5c679a57e018f5f146838138d3e032ef4913d551"),
420,
},
{
common.HexToAddress("0xc30276833798867c1dbc5c468bf51ca900b44e4c"),
common.HexToAddress("0x5c679a57e018f5f146838138d3e032ef4913d551"),
421,
},
}
for _, tt := range tests {
chainID := big.NewInt(tt.chainId)
Expand Down
38 changes: 19 additions & 19 deletions packages/contracts/deployments/goerli-nightly/AddressDictator.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions packages/contracts/deployments/goerli-nightly/BondManager.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0xf2b91614E8826f7A01b13dF8AeC5501403C9B0Fd",
"address": "0x2523d13F455531446950DB9C3a88c06431997D97",
"abi": [
{
"inputs": [
Expand Down Expand Up @@ -167,28 +167,28 @@
"type": "function"
}
],
"transactionHash": "0x7def186f652eda213f178ca0f287217030cdee226893ebdc6b0ccc0405a14edc",
"transactionHash": "0x2a9a6a33e3601ab2bca01f16f0c2c21f23cc0e39a142b7d218de42fdc2caa0a4",
"receipt": {
"to": null,
"from": "0x3a605B442055DF2898E18cF518feb2e2A6BD0D31",
"contractAddress": "0xf2b91614E8826f7A01b13dF8AeC5501403C9B0Fd",
"transactionIndex": 7,
"gasUsed": "600252",
"from": "0x26D58aD41d2BE997C02802468B92F1eaB4f8b95C",
"contractAddress": "0x2523d13F455531446950DB9C3a88c06431997D97",
"transactionIndex": 23,
"gasUsed": "600240",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0xb557f1dcb15b221968f0c33b0f9bcbf0dee42374f9fd00aeb51c64a962bfe5c1",
"transactionHash": "0x7def186f652eda213f178ca0f287217030cdee226893ebdc6b0ccc0405a14edc",
"blockHash": "0xed27d12347f019f5ac699739ca67d6d0ef56ff54b49f8955ed171000288580f9",
"transactionHash": "0x2a9a6a33e3601ab2bca01f16f0c2c21f23cc0e39a142b7d218de42fdc2caa0a4",
"logs": [],
"blockNumber": 6680783,
"cumulativeGasUsed": "1328789",
"blockNumber": 6754215,
"cumulativeGasUsed": "5796759",
"status": 1,
"byzantium": true
},
"args": [
"0xe352dDE5d101BB422f78C3eD77f2cD8f0b9B0f82",
"0x4600216A9C733658A48Ef83Ad218BA221514894E",
"0x4F3F400c20448D33ECc12E7d289F49dA7fC51736",
"0x2e552c5e1eaa6bcb8ea89d558309b9a8a26daa8cfe310169433a912499962b95",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x00000000000000000000000084a374C4082252FCEc215C242513c15551b15976",
"0x000000000000000000000000497cdD0F36b3D3012C1fEa605332E77E942C494a",
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000004200000000000000000000000000000000000010"
],
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\n/* Interface Imports */\nimport { ICrossDomainMessenger } from \"../../libraries/bridge/ICrossDomainMessenger.sol\";\n\n/**\n * @title IL2CrossDomainMessenger\n */\ninterface IL2CrossDomainMessenger is ICrossDomainMessenger {\n /********************\n * Public Functions *\n ********************/\n\n /**\n * Relays a cross domain message to a contract.\n * @param _target Target contract address.\n * @param _sender Message sender address.\n * @param _message Message to send to the target.\n * @param _messageNonce Nonce for the provided message.\n */\n function relayMessage(\n address _target,\n address _sender,\n bytes memory _message,\n uint256 _messageNonce\n ) external;\n}\n"
},
"contracts/L2/messaging/L2CrossDomainMessenger.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\n/* Library Imports */\nimport { AddressAliasHelper } from \"../../standards/AddressAliasHelper.sol\";\nimport { Lib_CrossDomainUtils } from \"../../libraries/bridge/Lib_CrossDomainUtils.sol\";\nimport { Lib_DefaultValues } from \"../../libraries/constants/Lib_DefaultValues.sol\";\nimport { Lib_PredeployAddresses } from \"../../libraries/constants/Lib_PredeployAddresses.sol\";\n\n/* Interface Imports */\nimport { IL2CrossDomainMessenger } from \"./IL2CrossDomainMessenger.sol\";\nimport { iOVM_L2ToL1MessagePasser } from \"../predeploys/iOVM_L2ToL1MessagePasser.sol\";\n\n/**\n * @title L2CrossDomainMessenger\n * @dev The L2 Cross Domain Messenger contract sends messages from L2 to L1, and is the entry point\n * for L2 messages sent via the L1 Cross Domain Messenger.\n *\n */\ncontract L2CrossDomainMessenger is IL2CrossDomainMessenger {\n /*************\n * Variables *\n *************/\n\n mapping(bytes32 => bool) public relayedMessages;\n mapping(bytes32 => bool) public successfulMessages;\n mapping(bytes32 => bool) public sentMessages;\n uint256 public messageNonce;\n address internal xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;\n address public l1CrossDomainMessenger;\n\n /***************\n * Constructor *\n ***************/\n\n constructor(address _l1CrossDomainMessenger) {\n l1CrossDomainMessenger = _l1CrossDomainMessenger;\n }\n\n /********************\n * Public Functions *\n ********************/\n\n // slither-disable-next-line external-function\n function xDomainMessageSender() public view returns (address) {\n require(\n xDomainMsgSender != Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER,\n \"xDomainMessageSender is not set\"\n );\n return xDomainMsgSender;\n }\n\n /**\n * Sends a cross domain message to the target messenger.\n * @param _target Target contract address.\n * @param _message Message to send to the target.\n * @param _gasLimit Gas limit for the provided message.\n */\n // slither-disable-next-line external-function\n function sendMessage(\n address _target,\n bytes memory _message,\n uint32 _gasLimit\n ) public {\n bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata(\n _target,\n msg.sender,\n _message,\n messageNonce\n );\n\n sentMessages[keccak256(xDomainCalldata)] = true;\n\n // Actually send the message.\n // slither-disable-next-line reentrancy-no-eth, reentrancy-events\n iOVM_L2ToL1MessagePasser(Lib_PredeployAddresses.L2_TO_L1_MESSAGE_PASSER).passMessageToL1(\n xDomainCalldata\n );\n\n // Emit an event before we bump the nonce or the nonce will be off by one.\n // slither-disable-next-line reentrancy-events\n emit SentMessage(_target, msg.sender, _message, messageNonce, _gasLimit);\n // slither-disable-next-line reentrancy-no-eth\n messageNonce += 1;\n }\n\n /**\n * Relays a cross domain message to a contract.\n * @inheritdoc IL2CrossDomainMessenger\n */\n // slither-disable-next-line external-function\n function relayMessage(\n address _target,\n address _sender,\n bytes memory _message,\n uint256 _messageNonce\n ) public {\n require(\n AddressAliasHelper.undoL1ToL2Alias(msg.sender) == l1CrossDomainMessenger,\n \"Provided message could not be verified.\"\n );\n\n bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata(\n _target,\n _sender,\n _message,\n _messageNonce\n );\n\n bytes32 xDomainCalldataHash = keccak256(xDomainCalldata);\n\n require(\n successfulMessages[xDomainCalldataHash] == false,\n \"Provided message has already been received.\"\n );\n\n // Prevent calls to OVM_L2ToL1MessagePasser, which would enable\n // an attacker to maliciously craft the _message to spoof\n // a call from any L2 account.\n if (_target == Lib_PredeployAddresses.L2_TO_L1_MESSAGE_PASSER) {\n // Write to the successfulMessages mapping and return immediately.\n successfulMessages[xDomainCalldataHash] = true;\n return;\n }\n\n xDomainMsgSender = _sender;\n // slither-disable-next-line reentrancy-no-eth, reentrancy-events, reentrancy-benign\n (bool success, ) = _target.call(_message);\n // slither-disable-next-line reentrancy-benign\n xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;\n\n // Mark the message as received if the call was successful. Ensures that a message can be\n // relayed multiple times in the case that the call reverted.\n if (success == true) {\n // slither-disable-next-line reentrancy-no-eth\n successfulMessages[xDomainCalldataHash] = true;\n // slither-disable-next-line reentrancy-events\n emit RelayedMessage(xDomainCalldataHash);\n } else {\n // slither-disable-next-line reentrancy-events\n emit FailedRelayedMessage(xDomainCalldataHash);\n }\n\n // Store an identifier that can be used to prove that the given message was relayed by some\n // user. Gives us an easy way to pay relayers for their work.\n bytes32 relayId = keccak256(abi.encodePacked(xDomainCalldata, msg.sender, block.number));\n\n // slither-disable-next-line reentrancy-benign\n relayedMessages[relayId] = true;\n }\n}\n"
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\n/* Library Imports */\nimport { AddressAliasHelper } from \"../../standards/AddressAliasHelper.sol\";\nimport { Lib_CrossDomainUtils } from \"../../libraries/bridge/Lib_CrossDomainUtils.sol\";\nimport { Lib_DefaultValues } from \"../../libraries/constants/Lib_DefaultValues.sol\";\nimport { Lib_PredeployAddresses } from \"../../libraries/constants/Lib_PredeployAddresses.sol\";\n\n/* Interface Imports */\nimport { IL2CrossDomainMessenger } from \"./IL2CrossDomainMessenger.sol\";\nimport { iOVM_L2ToL1MessagePasser } from \"../predeploys/iOVM_L2ToL1MessagePasser.sol\";\n\n/**\n * @title L2CrossDomainMessenger\n * @dev The L2 Cross Domain Messenger contract sends messages from L2 to L1, and is the entry point\n * for L2 messages sent via the L1 Cross Domain Messenger.\n *\n */\ncontract L2CrossDomainMessenger is IL2CrossDomainMessenger {\n /*************\n * Variables *\n *************/\n\n mapping(bytes32 => bool) public relayedMessages;\n mapping(bytes32 => bool) public successfulMessages;\n mapping(bytes32 => bool) public sentMessages;\n uint256 public messageNonce;\n address internal xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;\n address public l1CrossDomainMessenger;\n\n /***************\n * Constructor *\n ***************/\n\n constructor(address _l1CrossDomainMessenger) {\n l1CrossDomainMessenger = _l1CrossDomainMessenger;\n }\n\n /********************\n * Public Functions *\n ********************/\n\n // slither-disable-next-line external-function\n function xDomainMessageSender() public view returns (address) {\n require(\n xDomainMsgSender != Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER,\n \"xDomainMessageSender is not set\"\n );\n return xDomainMsgSender;\n }\n\n /**\n * Sends a cross domain message to the target messenger.\n * @param _target Target contract address.\n * @param _message Message to send to the target.\n * @param _gasLimit Gas limit for the provided message.\n */\n // slither-disable-next-line external-function\n function sendMessage(\n address _target,\n bytes memory _message,\n uint32 _gasLimit\n ) public {\n bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata(\n _target,\n msg.sender,\n _message,\n messageNonce\n );\n\n sentMessages[keccak256(xDomainCalldata)] = true;\n\n // Actually send the message.\n // slither-disable-next-line reentrancy-no-eth, reentrancy-events\n iOVM_L2ToL1MessagePasser(Lib_PredeployAddresses.L2_TO_L1_MESSAGE_PASSER).passMessageToL1(\n xDomainCalldata\n );\n\n // Emit an event before we bump the nonce or the nonce will be off by one.\n // slither-disable-next-line reentrancy-events\n emit SentMessage(_target, msg.sender, _message, messageNonce, _gasLimit);\n // slither-disable-next-line reentrancy-no-eth\n messageNonce += 1;\n }\n\n /**\n * Relays a cross domain message to a contract.\n * @inheritdoc IL2CrossDomainMessenger\n */\n // slither-disable-next-line external-function\n function relayMessage(\n address _target,\n address _sender,\n bytes memory _message,\n uint256 _messageNonce\n ) public {\n // Since it is impossible to deploy a contract to an address on L2 which matches\n // the alias of the L1CrossDomainMessenger, this check can only pass when it is called in\n // the first call from of a deposit transaction. Thus reentrancy is prevented here.\n require(\n AddressAliasHelper.undoL1ToL2Alias(msg.sender) == l1CrossDomainMessenger,\n \"Provided message could not be verified.\"\n );\n\n bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata(\n _target,\n _sender,\n _message,\n _messageNonce\n );\n\n bytes32 xDomainCalldataHash = keccak256(xDomainCalldata);\n\n require(\n successfulMessages[xDomainCalldataHash] == false,\n \"Provided message has already been received.\"\n );\n\n // Prevent calls to OVM_L2ToL1MessagePasser, which would enable\n // an attacker to maliciously craft the _message to spoof\n // a call from any L2 account.\n if (_target == Lib_PredeployAddresses.L2_TO_L1_MESSAGE_PASSER) {\n // Write to the successfulMessages mapping and return immediately.\n successfulMessages[xDomainCalldataHash] = true;\n return;\n }\n\n xDomainMsgSender = _sender;\n // slither-disable-next-line reentrancy-no-eth, reentrancy-events, reentrancy-benign\n (bool success, ) = _target.call(_message);\n // slither-disable-next-line reentrancy-benign\n xDomainMsgSender = Lib_DefaultValues.DEFAULT_XDOMAIN_SENDER;\n\n // Mark the message as received if the call was successful. Ensures that a message can be\n // relayed multiple times in the case that the call reverted.\n if (success == true) {\n // slither-disable-next-line reentrancy-no-eth\n successfulMessages[xDomainCalldataHash] = true;\n // slither-disable-next-line reentrancy-events\n emit RelayedMessage(xDomainCalldataHash);\n } else {\n // slither-disable-next-line reentrancy-events\n emit FailedRelayedMessage(xDomainCalldataHash);\n }\n\n // Store an identifier that can be used to prove that the given message was relayed by some\n // user. Gives us an easy way to pay relayers for their work.\n bytes32 relayId = keccak256(abi.encodePacked(xDomainCalldata, msg.sender, block.number));\n\n // slither-disable-next-line reentrancy-benign\n relayedMessages[relayId] = true;\n }\n}\n"
},
"contracts/L2/predeploys/iOVM_L2ToL1MessagePasser.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\n/**\n * @title iOVM_L2ToL1MessagePasser\n */\ninterface iOVM_L2ToL1MessagePasser {\n /**********\n * Events *\n **********/\n\n event L2ToL1Message(uint256 _nonce, address _sender, bytes _data);\n\n /********************\n * Public Functions *\n ********************/\n\n function passMessageToL1(bytes calldata _message) external;\n}\n"
Expand Down Expand Up @@ -262,14 +262,6 @@
"devdoc",
"userdoc",
"devdoc",
"userdoc",
"devdoc",
"userdoc",
"devdoc",
"userdoc",
"devdoc",
"userdoc",
"devdoc",
"userdoc"
],
"": [
Expand Down
Loading

0 comments on commit c799535

Please sign in to comment.