@arbitrum/nitro-contracts 1.0.0-beta.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/package.json +13 -2
  2. package/src/bridge/Bridge.sol +49 -29
  3. package/src/bridge/IBridge.sol +58 -45
  4. package/src/bridge/IDelayedMessageProvider.sol +2 -1
  5. package/src/bridge/IInbox.sol +133 -50
  6. package/src/bridge/IOutbox.sol +95 -27
  7. package/src/bridge/IOwnable.sol +2 -1
  8. package/src/bridge/ISequencerInbox.sol +79 -31
  9. package/src/bridge/Inbox.sol +171 -108
  10. package/src/bridge/Outbox.sol +26 -41
  11. package/src/bridge/SequencerInbox.sol +152 -62
  12. package/src/challenge/ChallengeManager.sol +0 -9
  13. package/src/challenge/IChallengeManager.sol +0 -2
  14. package/src/libraries/AdminFallbackProxy.sol +4 -4
  15. package/src/libraries/Constants.sol +3 -0
  16. package/src/libraries/{SecondaryLogicUUPSUpgradeable.sol → DoubleLogicUUPSUpgradeable.sol} +2 -1
  17. package/src/libraries/Error.sol +119 -0
  18. package/src/libraries/IGasRefunder.sol +13 -6
  19. package/src/libraries/MerkleLib.sol +5 -3
  20. package/src/mocks/BridgeStub.sol +22 -1
  21. package/src/mocks/BridgeUnproxied.sol +17 -0
  22. package/src/mocks/InboxStub.sol +49 -2
  23. package/src/mocks/SequencerInboxStub.sol +13 -3
  24. package/src/mocks/Simple.sol +69 -0
  25. package/src/node-interface/NodeInterface.sol +69 -7
  26. package/src/precompiles/ArbGasInfo.sol +16 -4
  27. package/src/precompiles/ArbOwner.sol +18 -0
  28. package/src/precompiles/ArbOwnerPublic.sol +3 -0
  29. package/src/precompiles/ArbSys.sol +7 -4
  30. package/src/rollup/IRollupCore.sol +2 -0
  31. package/src/rollup/IRollupLogic.sol +10 -0
  32. package/src/rollup/RollupAdminLogic.sol +69 -3
  33. package/src/rollup/RollupCore.sol +8 -2
  34. package/src/rollup/RollupCreator.sol +3 -3
  35. package/src/rollup/RollupEventInbox.sol +3 -6
  36. package/src/rollup/RollupLib.sol +1 -0
  37. package/src/{libraries/ArbitrumProxy.sol → rollup/RollupProxy.sol} +3 -3
  38. package/src/rollup/RollupUserLogic.sol +47 -10
  39. package/src/state/GlobalState.sol +7 -0
  40. package/src/test-helpers/BridgeTester.sol +17 -1
  41. package/src/test-helpers/InterfaceCompatibilityTester.sol +11 -0
  42. package/src/test-helpers/OutboxWithoutOptTester.sol +33 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbitrum/nitro-contracts",
3
- "version": "1.0.0-beta.7",
3
+ "version": "1.0.0",
4
4
  "description": "Layer 2 precompiles and rollup for Arbitrum Nitro",
5
5
  "author": "Offchain Labs, Inc.",
6
6
  "license": "BUSL-1.1",
@@ -21,7 +21,12 @@
21
21
  "build": "./scripts/build.bash",
22
22
  "solhint": "solhint -f table src/**/*.sol",
23
23
  "prettier:solidity": "prettier --write src/**/*.sol",
24
- "hardhat:prod": "hardhat --config hardhat.prod-config.js"
24
+ "hardhat:prod": "hardhat --config hardhat.prod-config.js",
25
+ "build:0.6": "INTERFACE_TESTER_SOLC_VERSION=0.6.9 yarn run build",
26
+ "build:0.7": "INTERFACE_TESTER_SOLC_VERSION=0.7.0 yarn run build",
27
+ "test:compatibility": "yarn run build:0.6 && yarn run build:0.7",
28
+ "test:storage": "./test/storage/test.bash",
29
+ "postinstall": "patch-package"
25
30
  },
26
31
  "dependencies": {
27
32
  "@openzeppelin/contracts": "4.5.0",
@@ -31,6 +36,7 @@
31
36
  "private": false,
32
37
  "devDependencies": {
33
38
  "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13",
39
+ "@nomiclabs/hardhat-etherscan": "^3.1.0",
34
40
  "@nomiclabs/hardhat-waffle": "^2.0.1",
35
41
  "@typechain/ethers-v5": "^10.0.0",
36
42
  "@typechain/hardhat": "^6.0.0",
@@ -42,6 +48,8 @@
42
48
  "ethers": "^5.5.2",
43
49
  "hardhat-deploy": "^0.11.4",
44
50
  "hardhat-gas-reporter": "^1.0.8",
51
+ "patch-package": "^6.4.7",
52
+ "postinstall-postinstall": "^2.1.0",
45
53
  "prettier": "^2.5.1",
46
54
  "prettier-plugin-solidity": "^1.0.0-beta.19",
47
55
  "solhint": "^3.3.7",
@@ -50,5 +58,8 @@
50
58
  "ts-node": "^10.4.0",
51
59
  "typechain": "^8.0.0",
52
60
  "typescript": "^4.5.4"
61
+ },
62
+ "optionalDependencies":{
63
+ "sol2uml": "2.2.0"
53
64
  }
54
65
  }
@@ -7,6 +7,15 @@ pragma solidity ^0.8.4;
7
7
  import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
8
8
  import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
9
9
 
10
+ import {
11
+ NotContract,
12
+ NotRollupOrOwner,
13
+ NotDelayedInbox,
14
+ NotSequencerInbox,
15
+ NotOutbox,
16
+ InvalidOutboxSet,
17
+ BadSequencerMessageNumber
18
+ } from "../libraries/Error.sol";
10
19
  import "./IBridge.sol";
11
20
  import "./Messages.sol";
12
21
  import "../libraries/DelegateCallAware.sol";
@@ -34,18 +43,20 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
34
43
  address[] public allowedDelayedInboxList;
35
44
  address[] public allowedOutboxList;
36
45
 
37
- address private _activeOutbox;
46
+ address internal _activeOutbox;
38
47
 
39
- /// @dev Accumulator for delayed inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
40
- bytes32[] public override delayedInboxAccs;
48
+ /// @inheritdoc IBridge
49
+ bytes32[] public delayedInboxAccs;
41
50
 
42
- /// @dev Accumulator for sequencer inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
43
- bytes32[] public override sequencerInboxAccs;
51
+ /// @inheritdoc IBridge
52
+ bytes32[] public sequencerInboxAccs;
44
53
 
45
- IOwnable public override rollup;
54
+ IOwnable public rollup;
46
55
  address public sequencerInbox;
47
56
 
48
- address private constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max);
57
+ uint256 public override sequencerReportedSubMessageCount;
58
+
59
+ address internal constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max);
49
60
 
50
61
  function initialize(IOwnable rollup_) external initializer onlyDelegated {
51
62
  _activeOutbox = EMPTY_ACTIVEOUTBOX;
@@ -73,11 +84,11 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
73
84
  return outbox;
74
85
  }
75
86
 
76
- function allowedDelayedInboxes(address inbox) external view override returns (bool) {
87
+ function allowedDelayedInboxes(address inbox) external view returns (bool) {
77
88
  return allowedDelayedInboxesMap[inbox].allowed;
78
89
  }
79
90
 
80
- function allowedOutboxes(address outbox) external view override returns (bool) {
91
+ function allowedOutboxes(address outbox) external view returns (bool) {
81
92
  return allowedOutboxesMap[outbox].allowed;
82
93
  }
83
94
 
@@ -86,9 +97,13 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
86
97
  _;
87
98
  }
88
99
 
89
- function enqueueSequencerMessage(bytes32 dataHash, uint256 afterDelayedMessagesRead)
100
+ function enqueueSequencerMessage(
101
+ bytes32 dataHash,
102
+ uint256 afterDelayedMessagesRead,
103
+ uint256 prevMessageCount,
104
+ uint256 newMessageCount
105
+ )
90
106
  external
91
- override
92
107
  onlySequencerInbox
93
108
  returns (
94
109
  uint256 seqMessageIndex,
@@ -97,6 +112,14 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
97
112
  bytes32 acc
98
113
  )
99
114
  {
115
+ if (
116
+ sequencerReportedSubMessageCount != prevMessageCount &&
117
+ prevMessageCount != 0 &&
118
+ sequencerReportedSubMessageCount != 0
119
+ ) {
120
+ revert BadSequencerMessageNumber(sequencerReportedSubMessageCount, prevMessageCount);
121
+ }
122
+ sequencerReportedSubMessageCount = newMessageCount;
100
123
  seqMessageIndex = sequencerInboxAccs.length;
101
124
  if (sequencerInboxAccs.length > 0) {
102
125
  beforeAcc = sequencerInboxAccs[sequencerInboxAccs.length - 1];
@@ -108,15 +131,9 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
108
131
  sequencerInboxAccs.push(acc);
109
132
  }
110
133
 
111
- /**
112
- * @dev allows the sequencer inbox to submit a delayed message of the batchPostingReport type
113
- * This is done through a separate function entrypoint instead of allowing the sequencer inbox
114
- * to call `enqueueDelayedMessage` to avoid the gas overhead of an extra SLOAD in either
115
- * every delayed inbox or every sequencer inbox call.
116
- */
134
+ /// @inheritdoc IBridge
117
135
  function submitBatchSpendingReport(address sender, bytes32 messageDataHash)
118
136
  external
119
- override
120
137
  onlySequencerInbox
121
138
  returns (uint256)
122
139
  {
@@ -131,16 +148,12 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
131
148
  );
132
149
  }
133
150
 
134
- /**
135
- * @dev Enqueue a message in the delayed inbox accumulator.
136
- * These messages are later sequenced in the SequencerInbox, either by the sequencer as
137
- * part of a normal batch, or by force inclusion.
138
- */
151
+ /// @inheritdoc IBridge
139
152
  function enqueueDelayedMessage(
140
153
  uint8 kind,
141
154
  address sender,
142
155
  bytes32 messageDataHash
143
- ) external payable override returns (uint256) {
156
+ ) external payable returns (uint256) {
144
157
  if (!allowedDelayedInboxesMap[msg.sender].allowed) revert NotDelayedInbox(msg.sender);
145
158
  return
146
159
  addMessageToDelayedAccumulator(
@@ -193,7 +206,7 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
193
206
  address to,
194
207
  uint256 value,
195
208
  bytes calldata data
196
- ) external override returns (bool success, bytes memory returnData) {
209
+ ) external returns (bool success, bytes memory returnData) {
197
210
  if (!allowedOutboxesMap[msg.sender].allowed) revert NotOutbox(msg.sender);
198
211
  if (data.length > 0 && !to.isContract()) revert NotContract(to);
199
212
  address prevOutbox = _activeOutbox;
@@ -208,12 +221,12 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
208
221
  emit BridgeCallTriggered(msg.sender, to, value, data);
209
222
  }
210
223
 
211
- function setSequencerInbox(address _sequencerInbox) external override onlyRollupOrOwner {
224
+ function setSequencerInbox(address _sequencerInbox) external onlyRollupOrOwner {
212
225
  sequencerInbox = _sequencerInbox;
213
226
  emit SequencerInboxUpdated(_sequencerInbox);
214
227
  }
215
228
 
216
- function setDelayedInbox(address inbox, bool enabled) external override onlyRollupOrOwner {
229
+ function setDelayedInbox(address inbox, bool enabled) external onlyRollupOrOwner {
217
230
  InOutInfo storage info = allowedDelayedInboxesMap[inbox];
218
231
  bool alreadyEnabled = info.allowed;
219
232
  emit InboxToggle(inbox, enabled);
@@ -233,7 +246,7 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
233
246
  }
234
247
  }
235
248
 
236
- function setOutbox(address outbox, bool enabled) external override onlyRollupOrOwner {
249
+ function setOutbox(address outbox, bool enabled) external onlyRollupOrOwner {
237
250
  if (outbox == EMPTY_ACTIVEOUTBOX) revert InvalidOutboxSet(outbox);
238
251
 
239
252
  InOutInfo storage info = allowedOutboxesMap[outbox];
@@ -253,11 +266,18 @@ contract Bridge is Initializable, DelegateCallAware, IBridge {
253
266
  }
254
267
  }
255
268
 
269
+ function setSequencerReportedSubMessageCount(uint256 newMsgCount) external onlyRollupOrOwner {
270
+ sequencerReportedSubMessageCount = newMsgCount;
271
+ }
272
+
256
273
  function delayedMessageCount() external view override returns (uint256) {
257
274
  return delayedInboxAccs.length;
258
275
  }
259
276
 
260
- function sequencerMessageCount() external view override returns (uint256) {
277
+ function sequencerMessageCount() external view returns (uint256) {
261
278
  return sequencerInboxAccs.length;
262
279
  }
280
+
281
+ /// @dev For the classic -> nitro migration. TODO: remove post-migration.
282
+ function acceptFundsFromOldBridge() external payable {}
263
283
  }
@@ -2,27 +2,11 @@
2
2
  // For license information, see https://github.com/nitro/blob/master/LICENSE
3
3
  // SPDX-License-Identifier: BUSL-1.1
4
4
 
5
- pragma solidity ^0.8.4;
5
+ // solhint-disable-next-line compiler-version
6
+ pragma solidity >=0.6.9 <0.9.0;
6
7
 
7
- import {NotContract, NotRollupOrOwner} from "../libraries/Error.sol";
8
8
  import "./IOwnable.sol";
9
9
 
10
- /// @dev Thrown when an un-authorized address tries to access an only-inbox function
11
- /// @param sender The un-authorized sender
12
- error NotDelayedInbox(address sender);
13
-
14
- /// @dev Thrown when an un-authorized address tries to access an only-sequencer-inbox function
15
- /// @param sender The un-authorized sender
16
- error NotSequencerInbox(address sender);
17
-
18
- /// @dev Thrown when an un-authorized address tries to access an only-outbox function
19
- /// @param sender The un-authorized sender
20
- error NotOutbox(address sender);
21
-
22
- /// @dev the provided outbox address isn't valid
23
- /// @param outbox address of outbox being set
24
- error InvalidOutboxSet(address outbox);
25
-
26
10
  interface IBridge {
27
11
  event MessageDelivered(
28
12
  uint256 indexed messageIndex,
@@ -48,13 +32,57 @@ interface IBridge {
48
32
 
49
33
  event SequencerInboxUpdated(address newSequencerInbox);
50
34
 
35
+ function allowedDelayedInboxList(uint256) external returns (address);
36
+
37
+ function allowedOutboxList(uint256) external returns (address);
38
+
39
+ /// @dev Accumulator for delayed inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
40
+ function delayedInboxAccs(uint256) external view returns (bytes32);
41
+
42
+ /// @dev Accumulator for sequencer inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
43
+ function sequencerInboxAccs(uint256) external view returns (bytes32);
44
+
45
+ function rollup() external view returns (IOwnable);
46
+
47
+ function sequencerInbox() external view returns (address);
48
+
49
+ function activeOutbox() external view returns (address);
50
+
51
+ function allowedDelayedInboxes(address inbox) external view returns (bool);
52
+
53
+ function allowedOutboxes(address outbox) external view returns (bool);
54
+
55
+ function sequencerReportedSubMessageCount() external view returns (uint256);
56
+
57
+ /**
58
+ * @dev Enqueue a message in the delayed inbox accumulator.
59
+ * These messages are later sequenced in the SequencerInbox, either
60
+ * by the sequencer as part of a normal batch, or by force inclusion.
61
+ */
51
62
  function enqueueDelayedMessage(
52
63
  uint8 kind,
53
64
  address sender,
54
65
  bytes32 messageDataHash
55
66
  ) external payable returns (uint256);
56
67
 
57
- function enqueueSequencerMessage(bytes32 dataHash, uint256 afterDelayedMessagesRead)
68
+ function executeCall(
69
+ address to,
70
+ uint256 value,
71
+ bytes calldata data
72
+ ) external returns (bool success, bytes memory returnData);
73
+
74
+ function delayedMessageCount() external view returns (uint256);
75
+
76
+ function sequencerMessageCount() external view returns (uint256);
77
+
78
+ // ---------- onlySequencerInbox functions ----------
79
+
80
+ function enqueueSequencerMessage(
81
+ bytes32 dataHash,
82
+ uint256 afterDelayedMessagesRead,
83
+ uint256 prevMessageCount,
84
+ uint256 newMessageCount
85
+ )
58
86
  external
59
87
  returns (
60
88
  uint256 seqMessageIndex,
@@ -63,40 +91,25 @@ interface IBridge {
63
91
  bytes32 acc
64
92
  );
65
93
 
94
+ /**
95
+ * @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type
96
+ * This is done through a separate function entrypoint instead of allowing the sequencer inbox
97
+ * to call `enqueueDelayedMessage` to avoid the gas overhead of an extra SLOAD in either
98
+ * every delayed inbox or every sequencer inbox call.
99
+ */
66
100
  function submitBatchSpendingReport(address batchPoster, bytes32 dataHash)
67
101
  external
68
102
  returns (uint256 msgNum);
69
103
 
70
- function executeCall(
71
- address to,
72
- uint256 value,
73
- bytes calldata data
74
- ) external returns (bool success, bytes memory returnData);
75
-
76
- // These are only callable by the admin
77
- function setDelayedInbox(address inbox, bool enabled) external;
78
-
79
- function setOutbox(address inbox, bool enabled) external;
104
+ // ---------- onlyRollupOrOwner functions ----------
80
105
 
81
106
  function setSequencerInbox(address _sequencerInbox) external;
82
107
 
83
- // View functions
84
-
85
- function sequencerInbox() external view returns (address);
86
-
87
- function activeOutbox() external view returns (address);
88
-
89
- function allowedDelayedInboxes(address inbox) external view returns (bool);
90
-
91
- function allowedOutboxes(address outbox) external view returns (bool);
92
-
93
- function delayedInboxAccs(uint256 index) external view returns (bytes32);
94
-
95
- function sequencerInboxAccs(uint256 index) external view returns (bytes32);
108
+ function setDelayedInbox(address inbox, bool enabled) external;
96
109
 
97
- function delayedMessageCount() external view returns (uint256);
110
+ function setOutbox(address inbox, bool enabled) external;
98
111
 
99
- function sequencerMessageCount() external view returns (uint256);
112
+ // ---------- initializer ----------
100
113
 
101
- function rollup() external view returns (IOwnable);
114
+ function initialize(IOwnable rollup_) external;
102
115
  }
@@ -2,7 +2,8 @@
2
2
  // For license information, see https://github.com/nitro/blob/master/LICENSE
3
3
  // SPDX-License-Identifier: BUSL-1.1
4
4
 
5
- pragma solidity ^0.8.0;
5
+ // solhint-disable-next-line compiler-version
6
+ pragma solidity >=0.6.9 <0.9.0;
6
7
 
7
8
  interface IDelayedMessageProvider {
8
9
  /// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator
@@ -2,47 +2,48 @@
2
2
  // For license information, see https://github.com/nitro/blob/master/LICENSE
3
3
  // SPDX-License-Identifier: BUSL-1.1
4
4
 
5
- pragma solidity ^0.8.4;
5
+ // solhint-disable-next-line compiler-version
6
+ pragma solidity >=0.6.9 <0.9.0;
6
7
 
7
8
  import "./IBridge.sol";
8
9
  import "./IDelayedMessageProvider.sol";
9
- import {AlreadyInit, NotOrigin, DataTooLarge} from "../libraries/Error.sol";
10
+ import "./ISequencerInbox.sol";
10
11
 
11
- /// @dev The contract is paused, so cannot be paused
12
- error AlreadyPaused();
13
-
14
- /// @dev The contract is unpaused, so cannot be unpaused
15
- error AlreadyUnpaused();
16
-
17
- /// @dev The contract is paused
18
- error Paused();
19
-
20
- /// @dev msg.value sent to the inbox isn't high enough
21
- error InsufficientValue(uint256 expected, uint256 actual);
22
-
23
- /// @dev submission cost provided isn't enough to create retryable ticket
24
- error InsufficientSubmissionCost(uint256 expected, uint256 actual);
12
+ interface IInbox is IDelayedMessageProvider {
13
+ function bridge() external view returns (IBridge);
25
14
 
26
- /// @dev address not allowed to interact with the given contract
27
- error NotAllowedOrigin(address origin);
15
+ function sequencerInbox() external view returns (ISequencerInbox);
16
+
17
+ /**
18
+ * @notice Send a generic L2 message to the chain
19
+ * @dev This method is an optimization to avoid having to emit the entirety of the messageData in a log. Instead validators are expected to be able to parse the data from the transaction's input
20
+ * This method will be disabled upon L1 fork to prevent replay attacks on L2
21
+ * @param messageData Data of the message being sent
22
+ */
23
+ function sendL2MessageFromOrigin(bytes calldata messageData) external returns (uint256);
24
+
25
+ /**
26
+ * @notice Send a generic L2 message to the chain
27
+ * @dev This method can be used to send any type of message that doesn't require L1 validation
28
+ * This method will be disabled upon L1 fork to prevent replay attacks on L2
29
+ * @param messageData Data of the message being sent
30
+ */
31
+ function sendL2Message(bytes calldata messageData) external returns (uint256);
28
32
 
29
- /// @dev used to convey retryable tx data in eth calls without requiring a tx trace
30
- /// this follows a pattern similar to EIP-3668 where reverts surface call information
31
- error RetryableData(
32
- address from,
33
- address to,
34
- uint256 l2CallValue,
35
- uint256 deposit,
36
- uint256 maxSubmissionCost,
37
- address excessFeeRefundAddress,
38
- address callValueRefundAddress,
39
- uint256 gasLimit,
40
- uint256 maxFeePerGas,
41
- bytes data
42
- );
33
+ function sendL1FundedUnsignedTransaction(
34
+ uint256 gasLimit,
35
+ uint256 maxFeePerGas,
36
+ uint256 nonce,
37
+ address to,
38
+ bytes calldata data
39
+ ) external payable returns (uint256);
43
40
 
44
- interface IInbox is IDelayedMessageProvider {
45
- function sendL2Message(bytes calldata messageData) external returns (uint256);
41
+ function sendL1FundedContractTransaction(
42
+ uint256 gasLimit,
43
+ uint256 maxFeePerGas,
44
+ address to,
45
+ bytes calldata data
46
+ ) external payable returns (uint256);
46
47
 
47
48
  function sendUnsignedTransaction(
48
49
  uint256 gasLimit,
@@ -61,7 +62,11 @@ interface IInbox is IDelayedMessageProvider {
61
62
  bytes calldata data
62
63
  ) external returns (uint256);
63
64
 
64
- function sendL1FundedUnsignedTransaction(
65
+ /**
66
+ * @dev This method can only be called upon L1 fork and will not alias the caller
67
+ * This method will revert if not called from origin
68
+ */
69
+ function sendL1FundedUnsignedTransactionToFork(
65
70
  uint256 gasLimit,
66
71
  uint256 maxFeePerGas,
67
72
  uint256 nonce,
@@ -69,42 +74,120 @@ interface IInbox is IDelayedMessageProvider {
69
74
  bytes calldata data
70
75
  ) external payable returns (uint256);
71
76
 
72
- function sendL1FundedContractTransaction(
77
+ /**
78
+ * @dev This method can only be called upon L1 fork and will not alias the caller
79
+ * This method will revert if not called from origin
80
+ */
81
+ function sendUnsignedTransactionToFork(
73
82
  uint256 gasLimit,
74
83
  uint256 maxFeePerGas,
84
+ uint256 nonce,
75
85
  address to,
86
+ uint256 value,
76
87
  bytes calldata data
77
- ) external payable returns (uint256);
88
+ ) external returns (uint256);
89
+
90
+ /**
91
+ * @notice Send a message to initiate L2 withdrawal
92
+ * @dev This method can only be called upon L1 fork and will not alias the caller
93
+ * This method will revert if not called from origin
94
+ */
95
+ function sendWithdrawEthToFork(
96
+ uint256 gasLimit,
97
+ uint256 maxFeePerGas,
98
+ uint256 nonce,
99
+ uint256 value,
100
+ address withdrawTo
101
+ ) external returns (uint256);
102
+
103
+ /**
104
+ * @notice Get the L1 fee for submitting a retryable
105
+ * @dev This fee can be paid by funds already in the L2 aliased address or by the current message value
106
+ * @dev This formula may change in the future, to future proof your code query this method instead of inlining!!
107
+ * @param dataLength The length of the retryable's calldata, in bytes
108
+ * @param baseFee The block basefee when the retryable is included in the chain, if 0 current block.basefee will be used
109
+ */
110
+ function calculateRetryableSubmissionFee(uint256 dataLength, uint256 baseFee)
111
+ external
112
+ view
113
+ returns (uint256);
114
+
115
+ /**
116
+ * @notice Deposit eth from L1 to L2 to address of the sender if sender is an EOA, and to its aliased address if the sender is a contract
117
+ * @dev This does not trigger the fallback function when receiving in the L2 side.
118
+ * Look into retryable tickets if you are interested in this functionality.
119
+ * @dev This function should not be called inside contract constructors
120
+ */
121
+ function depositEth() external payable returns (uint256);
78
122
 
79
- /// @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
123
+ /**
124
+ * @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
125
+ * @dev all msg.value will deposited to callValueRefundAddress on L2
126
+ * @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
127
+ * @param to destination L2 contract address
128
+ * @param l2CallValue call value for retryable L2 message
129
+ * @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
130
+ * @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance
131
+ * @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
132
+ * @param gasLimit Max gas deducted from user's L2 balance to cover L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
133
+ * @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
134
+ * @param data ABI encoded data of L2 message
135
+ * @return unique message number of the retryable transaction
136
+ */
80
137
  function createRetryableTicket(
81
138
  address to,
82
- uint256 arbTxCallValue,
139
+ uint256 l2CallValue,
83
140
  uint256 maxSubmissionCost,
84
- address submissionRefundAddress,
85
- address valueRefundAddress,
141
+ address excessFeeRefundAddress,
142
+ address callValueRefundAddress,
86
143
  uint256 gasLimit,
87
144
  uint256 maxFeePerGas,
88
145
  bytes calldata data
89
146
  ) external payable returns (uint256);
90
147
 
91
- /// @notice TEMPORARILY DISABLED as exact mechanics are being worked out
92
- /// @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
148
+ /**
149
+ * @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
150
+ * @dev Same as createRetryableTicket, but does not guarantee that submission will succeed by requiring the needed funds
151
+ * come from the deposit alone, rather than falling back on the user's L2 balance
152
+ * @dev Advanced usage only (does not rewrite aliases for excessFeeRefundAddress and callValueRefundAddress).
153
+ * createRetryableTicket method is the recommended standard.
154
+ * @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
155
+ * @param to destination L2 contract address
156
+ * @param l2CallValue call value for retryable L2 message
157
+ * @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
158
+ * @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance
159
+ * @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
160
+ * @param gasLimit Max gas deducted from user's L2 balance to cover L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
161
+ * @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
162
+ * @param data ABI encoded data of L2 message
163
+ * @return unique message number of the retryable transaction
164
+ */
93
165
  function unsafeCreateRetryableTicket(
94
166
  address to,
95
- uint256 arbTxCallValue,
167
+ uint256 l2CallValue,
96
168
  uint256 maxSubmissionCost,
97
- address submissionRefundAddress,
98
- address valueRefundAddress,
169
+ address excessFeeRefundAddress,
170
+ address callValueRefundAddress,
99
171
  uint256 gasLimit,
100
172
  uint256 maxFeePerGas,
101
173
  bytes calldata data
102
174
  ) external payable returns (uint256);
103
175
 
104
- function depositEth() external payable returns (uint256);
176
+ // ---------- onlyRollupOrOwner functions ----------
105
177
 
106
- /// @notice deprecated in favour of depositEth with no parameters
107
- function depositEth(uint256 maxSubmissionCost) external payable returns (uint256);
178
+ /// @notice pauses all inbox functionality
179
+ function pause() external;
108
180
 
109
- function bridge() external view returns (IBridge);
181
+ /// @notice unpauses all inbox functionality
182
+ function unpause() external;
183
+
184
+ // ---------- initializer ----------
185
+
186
+ /**
187
+ * @dev function to be called one time during the inbox upgrade process
188
+ * this is used to fix the storage slots
189
+ */
190
+ function postUpgradeInit(IBridge _bridge) external;
191
+
192
+ function initialize(IBridge _bridge, ISequencerInbox _sequencerInbox) external;
110
193
  }