@arbitrum/nitro-contracts 1.0.0-beta.5 → 1.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/src/bridge/Bridge.sol +138 -32
- package/src/bridge/IBridge.sol +34 -14
- package/src/bridge/IDelayedMessageProvider.sol +15 -0
- package/src/bridge/IInbox.sol +8 -19
- package/src/bridge/IOutbox.sol +43 -23
- package/src/bridge/IOwnable.sol +10 -0
- package/src/bridge/ISequencerInbox.sol +30 -32
- package/src/bridge/Inbox.sol +133 -35
- package/src/bridge/Outbox.sol +145 -33
- package/src/bridge/SequencerInbox.sol +179 -60
- package/src/challenge/ChallengeLib.sol +0 -2
- package/src/challenge/ChallengeManager.sol +4 -8
- package/src/challenge/IChallengeManager.sol +1 -1
- package/src/libraries/Error.sol +113 -0
- package/src/libraries/IGasRefunder.sol +15 -14
- package/src/libraries/MerkleLib.sol +11 -2
- package/src/libraries/MessageTypes.sol +1 -0
- package/src/mocks/BridgeStub.sol +69 -21
- package/src/mocks/InboxStub.sol +2 -0
- package/src/mocks/SequencerInboxStub.sol +10 -8
- package/src/mocks/Simple.sol +8 -0
- package/src/node-interface/NodeInterface.sol +62 -4
- package/src/osp/IOneStepProver.sol +1 -2
- package/src/osp/OneStepProver0.sol +1 -87
- package/src/osp/OneStepProverHostIo.sol +5 -6
- package/src/osp/OneStepProverMath.sol +37 -27
- package/src/osp/OneStepProverMemory.sol +3 -4
- package/src/precompiles/ArbAggregator.sol +23 -33
- package/src/precompiles/ArbBLS.sol +1 -43
- package/src/precompiles/ArbGasInfo.sol +10 -19
- package/src/precompiles/ArbOwner.sol +21 -15
- package/src/precompiles/ArbRetryableTx.sol +10 -1
- package/src/precompiles/ArbSys.sol +4 -4
- package/src/precompiles/ArbosActs.sol +9 -2
- package/src/rollup/BridgeCreator.sol +23 -28
- package/src/rollup/IRollupCore.sol +3 -3
- package/src/rollup/{IRollupEventBridge.sol → IRollupEventInbox.sol} +2 -2
- package/src/rollup/IRollupLogic.sol +21 -18
- package/src/rollup/RollupAdminLogic.sol +72 -34
- package/src/rollup/RollupCore.sol +20 -9
- package/src/rollup/RollupCreator.sol +21 -11
- package/src/rollup/{RollupEventBridge.sol → RollupEventInbox.sol} +10 -10
- package/src/rollup/RollupLib.sol +21 -5
- package/src/rollup/RollupUserLogic.sol +10 -18
- package/src/rollup/ValidatorWallet.sol +125 -8
- package/src/rollup/ValidatorWalletCreator.sol +11 -6
- package/src/state/Deserialize.sol +3 -22
- package/src/state/GlobalState.sol +7 -0
- package/src/state/Instructions.sol +2 -10
- package/src/state/Machine.sol +0 -4
- package/src/state/ModuleMemory.sol +2 -1
- package/src/state/Value.sol +2 -3
- package/src/test-helpers/BridgeTester.sol +233 -0
- package/src/test-helpers/InterfaceCompatibilityTester.sol +11 -0
- package/src/test-helpers/OutboxWithoutOptTester.sol +214 -0
- package/src/test-helpers/RollupMock.sol +21 -0
- package/src/bridge/IMessageProvider.sol +0 -11
- package/src/state/PcStack.sol +0 -32
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arbitrum/nitro-contracts",
|
3
|
-
"version": "1.0.0-beta.
|
3
|
+
"version": "1.0.0-beta.8",
|
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,10 @@
|
|
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"
|
25
28
|
},
|
26
29
|
"dependencies": {
|
27
30
|
"@openzeppelin/contracts": "4.5.0",
|
@@ -41,6 +44,7 @@
|
|
41
44
|
"ethereum-waffle": "^3.4.0",
|
42
45
|
"ethers": "^5.5.2",
|
43
46
|
"hardhat-deploy": "^0.11.4",
|
47
|
+
"hardhat-gas-reporter": "^1.0.8",
|
44
48
|
"prettier": "^2.5.1",
|
45
49
|
"prettier-plugin-solidity": "^1.0.0-beta.19",
|
46
50
|
"solhint": "^3.3.7",
|
package/src/bridge/Bridge.sol
CHANGED
@@ -4,21 +4,31 @@
|
|
4
4
|
|
5
5
|
pragma solidity ^0.8.4;
|
6
6
|
|
7
|
-
import "@openzeppelin/contracts-upgradeable/
|
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
|
+
} from "../libraries/Error.sol";
|
10
18
|
import "./IBridge.sol";
|
11
19
|
import "./Messages.sol";
|
12
20
|
import "../libraries/DelegateCallAware.sol";
|
13
21
|
|
22
|
+
import {L1MessageType_batchPostingReport} from "../libraries/MessageTypes.sol";
|
23
|
+
|
14
24
|
/**
|
15
25
|
* @title Staging ground for incoming and outgoing messages
|
16
|
-
* @notice Holds the inbox accumulator for
|
17
|
-
* for value sent with these messages.
|
26
|
+
* @notice Holds the inbox accumulator for sequenced and delayed messages.
|
27
|
+
* It is also the ETH escrow for value sent with these messages.
|
18
28
|
* Since the escrow is held here, this contract also contains a list of allowed
|
19
29
|
* outboxes that can make calls from here and withdraw this escrow.
|
20
30
|
*/
|
21
|
-
contract Bridge is
|
31
|
+
contract Bridge is Initializable, DelegateCallAware, IBridge {
|
22
32
|
using AddressUpgradeable for address;
|
23
33
|
|
24
34
|
struct InOutInfo {
|
@@ -26,29 +36,109 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
26
36
|
bool allowed;
|
27
37
|
}
|
28
38
|
|
29
|
-
mapping(address => InOutInfo) private
|
39
|
+
mapping(address => InOutInfo) private allowedDelayedInboxesMap;
|
30
40
|
mapping(address => InOutInfo) private allowedOutboxesMap;
|
31
41
|
|
32
|
-
address[] public
|
42
|
+
address[] public allowedDelayedInboxList;
|
33
43
|
address[] public allowedOutboxList;
|
34
44
|
|
35
|
-
address
|
45
|
+
address private _activeOutbox;
|
36
46
|
|
37
47
|
/// @dev Accumulator for delayed inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
|
38
|
-
bytes32[] public override
|
48
|
+
bytes32[] public override delayedInboxAccs;
|
49
|
+
|
50
|
+
/// @dev Accumulator for sequencer inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
|
51
|
+
bytes32[] public override sequencerInboxAccs;
|
52
|
+
|
53
|
+
IOwnable public override rollup;
|
54
|
+
address public sequencerInbox;
|
55
|
+
|
56
|
+
address private constant EMPTY_ACTIVEOUTBOX = address(type(uint160).max);
|
57
|
+
|
58
|
+
function initialize(IOwnable rollup_) external initializer onlyDelegated {
|
59
|
+
_activeOutbox = EMPTY_ACTIVEOUTBOX;
|
60
|
+
rollup = rollup_;
|
61
|
+
}
|
62
|
+
|
63
|
+
modifier onlyRollupOrOwner() {
|
64
|
+
if (msg.sender != address(rollup)) {
|
65
|
+
address rollupOwner = rollup.owner();
|
66
|
+
if (msg.sender != rollupOwner) {
|
67
|
+
revert NotRollupOrOwner(msg.sender, address(rollup), rollupOwner);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
_;
|
71
|
+
}
|
39
72
|
|
40
|
-
|
41
|
-
|
73
|
+
/// @dev returns the address of current active Outbox, or zero if no outbox is active
|
74
|
+
function activeOutbox() public view returns (address) {
|
75
|
+
address outbox = _activeOutbox;
|
76
|
+
// address zero is returned if no outbox is set, but the value used in storage
|
77
|
+
// is non-zero to save users some gas (as storage refunds are usually maxed out)
|
78
|
+
// EIP-1153 would help here.
|
79
|
+
// we don't return `EMPTY_ACTIVEOUTBOX` to avoid a breaking change on the current api
|
80
|
+
if (outbox == EMPTY_ACTIVEOUTBOX) return address(0);
|
81
|
+
return outbox;
|
42
82
|
}
|
43
83
|
|
44
|
-
function
|
45
|
-
return
|
84
|
+
function allowedDelayedInboxes(address inbox) external view override returns (bool) {
|
85
|
+
return allowedDelayedInboxesMap[inbox].allowed;
|
46
86
|
}
|
47
87
|
|
48
88
|
function allowedOutboxes(address outbox) external view override returns (bool) {
|
49
89
|
return allowedOutboxesMap[outbox].allowed;
|
50
90
|
}
|
51
91
|
|
92
|
+
modifier onlySequencerInbox() {
|
93
|
+
if (msg.sender != sequencerInbox) revert NotSequencerInbox(msg.sender);
|
94
|
+
_;
|
95
|
+
}
|
96
|
+
|
97
|
+
function enqueueSequencerMessage(bytes32 dataHash, uint256 afterDelayedMessagesRead)
|
98
|
+
external
|
99
|
+
override
|
100
|
+
onlySequencerInbox
|
101
|
+
returns (
|
102
|
+
uint256 seqMessageIndex,
|
103
|
+
bytes32 beforeAcc,
|
104
|
+
bytes32 delayedAcc,
|
105
|
+
bytes32 acc
|
106
|
+
)
|
107
|
+
{
|
108
|
+
seqMessageIndex = sequencerInboxAccs.length;
|
109
|
+
if (sequencerInboxAccs.length > 0) {
|
110
|
+
beforeAcc = sequencerInboxAccs[sequencerInboxAccs.length - 1];
|
111
|
+
}
|
112
|
+
if (afterDelayedMessagesRead > 0) {
|
113
|
+
delayedAcc = delayedInboxAccs[afterDelayedMessagesRead - 1];
|
114
|
+
}
|
115
|
+
acc = keccak256(abi.encodePacked(beforeAcc, dataHash, delayedAcc));
|
116
|
+
sequencerInboxAccs.push(acc);
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* @dev allows the sequencer inbox to submit a delayed message of the batchPostingReport type
|
121
|
+
* This is done through a separate function entrypoint instead of allowing the sequencer inbox
|
122
|
+
* to call `enqueueDelayedMessage` to avoid the gas overhead of an extra SLOAD in either
|
123
|
+
* every delayed inbox or every sequencer inbox call.
|
124
|
+
*/
|
125
|
+
function submitBatchSpendingReport(address sender, bytes32 messageDataHash)
|
126
|
+
external
|
127
|
+
override
|
128
|
+
onlySequencerInbox
|
129
|
+
returns (uint256)
|
130
|
+
{
|
131
|
+
return
|
132
|
+
addMessageToDelayedAccumulator(
|
133
|
+
L1MessageType_batchPostingReport,
|
134
|
+
sender,
|
135
|
+
uint64(block.number),
|
136
|
+
uint64(block.timestamp), // solhint-disable-line not-rely-on-time,
|
137
|
+
block.basefee,
|
138
|
+
messageDataHash
|
139
|
+
);
|
140
|
+
}
|
141
|
+
|
52
142
|
/**
|
53
143
|
* @dev Enqueue a message in the delayed inbox accumulator.
|
54
144
|
* These messages are later sequenced in the SequencerInbox, either by the sequencer as
|
@@ -59,9 +149,9 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
59
149
|
address sender,
|
60
150
|
bytes32 messageDataHash
|
61
151
|
) external payable override returns (uint256) {
|
62
|
-
if (!
|
152
|
+
if (!allowedDelayedInboxesMap[msg.sender].allowed) revert NotDelayedInbox(msg.sender);
|
63
153
|
return
|
64
|
-
|
154
|
+
addMessageToDelayedAccumulator(
|
65
155
|
kind,
|
66
156
|
sender,
|
67
157
|
uint64(block.number),
|
@@ -71,7 +161,7 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
71
161
|
);
|
72
162
|
}
|
73
163
|
|
74
|
-
function
|
164
|
+
function addMessageToDelayedAccumulator(
|
75
165
|
uint8 kind,
|
76
166
|
address sender,
|
77
167
|
uint64 blockNumber,
|
@@ -79,7 +169,7 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
79
169
|
uint256 baseFeeL1,
|
80
170
|
bytes32 messageDataHash
|
81
171
|
) internal returns (uint256) {
|
82
|
-
uint256 count =
|
172
|
+
uint256 count = delayedInboxAccs.length;
|
83
173
|
bytes32 messageHash = Messages.messageHash(
|
84
174
|
kind,
|
85
175
|
sender,
|
@@ -91,9 +181,9 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
91
181
|
);
|
92
182
|
bytes32 prevAcc = 0;
|
93
183
|
if (count > 0) {
|
94
|
-
prevAcc =
|
184
|
+
prevAcc = delayedInboxAccs[count - 1];
|
95
185
|
}
|
96
|
-
|
186
|
+
delayedInboxAccs.push(Messages.accumulateInboxMessage(prevAcc, messageHash));
|
97
187
|
emit MessageDelivered(
|
98
188
|
count,
|
99
189
|
prevAcc,
|
@@ -114,37 +204,46 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
114
204
|
) external override returns (bool success, bytes memory returnData) {
|
115
205
|
if (!allowedOutboxesMap[msg.sender].allowed) revert NotOutbox(msg.sender);
|
116
206
|
if (data.length > 0 && !to.isContract()) revert NotContract(to);
|
117
|
-
address prevOutbox =
|
118
|
-
|
207
|
+
address prevOutbox = _activeOutbox;
|
208
|
+
_activeOutbox = msg.sender;
|
119
209
|
// We set and reset active outbox around external call so activeOutbox remains valid during call
|
120
210
|
|
121
211
|
// We use a low level call here since we want to bubble up whether it succeeded or failed to the caller
|
122
212
|
// rather than reverting on failure as well as allow contract and non-contract calls
|
123
213
|
// solhint-disable-next-line avoid-low-level-calls
|
124
214
|
(success, returnData) = to.call{value: value}(data);
|
125
|
-
|
215
|
+
_activeOutbox = prevOutbox;
|
126
216
|
emit BridgeCallTriggered(msg.sender, to, value, data);
|
127
217
|
}
|
128
218
|
|
129
|
-
function
|
130
|
-
|
219
|
+
function setSequencerInbox(address _sequencerInbox) external override onlyRollupOrOwner {
|
220
|
+
sequencerInbox = _sequencerInbox;
|
221
|
+
emit SequencerInboxUpdated(_sequencerInbox);
|
222
|
+
}
|
223
|
+
|
224
|
+
function setDelayedInbox(address inbox, bool enabled) external override onlyRollupOrOwner {
|
225
|
+
InOutInfo storage info = allowedDelayedInboxesMap[inbox];
|
131
226
|
bool alreadyEnabled = info.allowed;
|
132
227
|
emit InboxToggle(inbox, enabled);
|
133
228
|
if ((alreadyEnabled && enabled) || (!alreadyEnabled && !enabled)) {
|
134
229
|
return;
|
135
230
|
}
|
136
231
|
if (enabled) {
|
137
|
-
|
138
|
-
|
232
|
+
allowedDelayedInboxesMap[inbox] = InOutInfo(allowedDelayedInboxList.length, true);
|
233
|
+
allowedDelayedInboxList.push(inbox);
|
139
234
|
} else {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
235
|
+
allowedDelayedInboxList[info.index] = allowedDelayedInboxList[
|
236
|
+
allowedDelayedInboxList.length - 1
|
237
|
+
];
|
238
|
+
allowedDelayedInboxesMap[allowedDelayedInboxList[info.index]].index = info.index;
|
239
|
+
allowedDelayedInboxList.pop();
|
240
|
+
delete allowedDelayedInboxesMap[inbox];
|
144
241
|
}
|
145
242
|
}
|
146
243
|
|
147
|
-
function setOutbox(address outbox, bool enabled) external override
|
244
|
+
function setOutbox(address outbox, bool enabled) external override onlyRollupOrOwner {
|
245
|
+
if (outbox == EMPTY_ACTIVEOUTBOX) revert InvalidOutboxSet(outbox);
|
246
|
+
|
148
247
|
InOutInfo storage info = allowedOutboxesMap[outbox];
|
149
248
|
bool alreadyEnabled = info.allowed;
|
150
249
|
emit OutboxToggle(outbox, enabled);
|
@@ -162,7 +261,14 @@ contract Bridge is OwnableUpgradeable, DelegateCallAware, IBridge {
|
|
162
261
|
}
|
163
262
|
}
|
164
263
|
|
165
|
-
function
|
166
|
-
return
|
264
|
+
function delayedMessageCount() external view override returns (uint256) {
|
265
|
+
return delayedInboxAccs.length;
|
167
266
|
}
|
267
|
+
|
268
|
+
function sequencerMessageCount() external view override returns (uint256) {
|
269
|
+
return sequencerInboxAccs.length;
|
270
|
+
}
|
271
|
+
|
272
|
+
/// @dev For the classic -> nitro migration. TODO: remove post-migration.
|
273
|
+
function acceptFundsFromOldBridge() external payable {}
|
168
274
|
}
|
package/src/bridge/IBridge.sol
CHANGED
@@ -2,17 +2,10 @@
|
|
2
2
|
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
3
|
// SPDX-License-Identifier: BUSL-1.1
|
4
4
|
|
5
|
-
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.6.9 <0.9.0;
|
6
7
|
|
7
|
-
import
|
8
|
-
|
9
|
-
/// @dev Thrown when an un-authorized address tries to access an only-inbox function
|
10
|
-
/// @param sender The un-authorized sender
|
11
|
-
error NotInbox(address sender);
|
12
|
-
|
13
|
-
/// @dev Thrown when an un-authorized address tries to access an only-outbox function
|
14
|
-
/// @param sender The un-authorized sender
|
15
|
-
error NotOutbox(address sender);
|
8
|
+
import "./IOwnable.sol";
|
16
9
|
|
17
10
|
interface IBridge {
|
18
11
|
event MessageDelivered(
|
@@ -37,12 +30,27 @@ interface IBridge {
|
|
37
30
|
|
38
31
|
event OutboxToggle(address indexed outbox, bool enabled);
|
39
32
|
|
33
|
+
event SequencerInboxUpdated(address newSequencerInbox);
|
34
|
+
|
40
35
|
function enqueueDelayedMessage(
|
41
36
|
uint8 kind,
|
42
37
|
address sender,
|
43
38
|
bytes32 messageDataHash
|
44
39
|
) external payable returns (uint256);
|
45
40
|
|
41
|
+
function enqueueSequencerMessage(bytes32 dataHash, uint256 afterDelayedMessagesRead)
|
42
|
+
external
|
43
|
+
returns (
|
44
|
+
uint256 seqMessageIndex,
|
45
|
+
bytes32 beforeAcc,
|
46
|
+
bytes32 delayedAcc,
|
47
|
+
bytes32 acc
|
48
|
+
);
|
49
|
+
|
50
|
+
function submitBatchSpendingReport(address batchPoster, bytes32 dataHash)
|
51
|
+
external
|
52
|
+
returns (uint256 msgNum);
|
53
|
+
|
46
54
|
function executeCall(
|
47
55
|
address to,
|
48
56
|
uint256 value,
|
@@ -50,19 +58,31 @@ interface IBridge {
|
|
50
58
|
) external returns (bool success, bytes memory returnData);
|
51
59
|
|
52
60
|
// These are only callable by the admin
|
53
|
-
function
|
61
|
+
function setDelayedInbox(address inbox, bool enabled) external;
|
54
62
|
|
55
63
|
function setOutbox(address inbox, bool enabled) external;
|
56
64
|
|
65
|
+
function setSequencerInbox(address _sequencerInbox) external;
|
66
|
+
|
57
67
|
// View functions
|
58
68
|
|
69
|
+
function sequencerInbox() external view returns (address);
|
70
|
+
|
59
71
|
function activeOutbox() external view returns (address);
|
60
72
|
|
61
|
-
function
|
73
|
+
function allowedDelayedInboxes(address inbox) external view returns (bool);
|
62
74
|
|
63
75
|
function allowedOutboxes(address outbox) external view returns (bool);
|
64
76
|
|
65
|
-
function
|
77
|
+
function delayedInboxAccs(uint256 index) external view returns (bytes32);
|
78
|
+
|
79
|
+
function sequencerInboxAccs(uint256 index) external view returns (bytes32);
|
80
|
+
|
81
|
+
function delayedMessageCount() external view returns (uint256);
|
82
|
+
|
83
|
+
function sequencerMessageCount() external view returns (uint256);
|
84
|
+
|
85
|
+
function rollup() external view returns (IOwnable);
|
66
86
|
|
67
|
-
function
|
87
|
+
function acceptFundsFromOldBridge() external payable;
|
68
88
|
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
+
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
|
+
// SPDX-License-Identifier: BUSL-1.1
|
4
|
+
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.6.9 <0.9.0;
|
7
|
+
|
8
|
+
interface IDelayedMessageProvider {
|
9
|
+
/// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator
|
10
|
+
event InboxMessageDelivered(uint256 indexed messageNum, bytes data);
|
11
|
+
|
12
|
+
/// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator
|
13
|
+
/// same as InboxMessageDelivered but the batch data is available in tx.input
|
14
|
+
event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum);
|
15
|
+
}
|
package/src/bridge/IInbox.sol
CHANGED
@@ -2,28 +2,13 @@
|
|
2
2
|
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
3
|
// SPDX-License-Identifier: BUSL-1.1
|
4
4
|
|
5
|
-
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.6.9 <0.9.0;
|
6
7
|
|
7
8
|
import "./IBridge.sol";
|
8
|
-
import "./
|
9
|
-
import {AlreadyInit, NotOrigin, DataTooLarge} from "../libraries/Error.sol";
|
9
|
+
import "./IDelayedMessageProvider.sol";
|
10
10
|
|
11
|
-
|
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);
|
25
|
-
|
26
|
-
interface IInbox is IMessageProvider {
|
11
|
+
interface IInbox is IDelayedMessageProvider {
|
27
12
|
function sendL2Message(bytes calldata messageData) external returns (uint256);
|
28
13
|
|
29
14
|
function sendUnsignedTransaction(
|
@@ -58,6 +43,7 @@ interface IInbox is IMessageProvider {
|
|
58
43
|
bytes calldata data
|
59
44
|
) external payable returns (uint256);
|
60
45
|
|
46
|
+
/// @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
|
61
47
|
function createRetryableTicket(
|
62
48
|
address to,
|
63
49
|
uint256 arbTxCallValue,
|
@@ -69,6 +55,7 @@ interface IInbox is IMessageProvider {
|
|
69
55
|
bytes calldata data
|
70
56
|
) external payable returns (uint256);
|
71
57
|
|
58
|
+
/// @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
|
72
59
|
function unsafeCreateRetryableTicket(
|
73
60
|
address to,
|
74
61
|
uint256 arbTxCallValue,
|
@@ -86,4 +73,6 @@ interface IInbox is IMessageProvider {
|
|
86
73
|
function depositEth(uint256 maxSubmissionCost) external payable returns (uint256);
|
87
74
|
|
88
75
|
function bridge() external view returns (IBridge);
|
76
|
+
|
77
|
+
function postUpgradeInit(IBridge _bridge) external;
|
89
78
|
}
|
package/src/bridge/IOutbox.sol
CHANGED
@@ -2,29 +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
|
-
|
6
|
-
|
7
|
-
import {AlreadyInit, NotRollup} from "../libraries/Error.sol";
|
8
|
-
|
9
|
-
/// @dev The provided proof was too long
|
10
|
-
/// @param proofLength The length of the too-long proof
|
11
|
-
error ProofTooLong(uint256 proofLength);
|
12
|
-
|
13
|
-
/// @dev The output index was greater than the maximum
|
14
|
-
/// @param index The output index
|
15
|
-
/// @param maxIndex The max the index could be
|
16
|
-
error PathNotMinimal(uint256 index, uint256 maxIndex);
|
17
|
-
|
18
|
-
/// @dev The calculated root does not exist
|
19
|
-
/// @param root The calculated root
|
20
|
-
error UnknownRoot(bytes32 root);
|
21
|
-
|
22
|
-
/// @dev The record has already been spent
|
23
|
-
/// @param index The index of the spent record
|
24
|
-
error AlreadySpent(uint256 index);
|
25
|
-
|
26
|
-
/// @dev A call to the bridge failed with no return data
|
27
|
-
error BridgeCallFailed();
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.6.9 <0.9.0;
|
28
7
|
|
29
8
|
interface IOutbox {
|
30
9
|
event SendRootUpdated(bytes32 indexed blockHash, bytes32 indexed outputRoot);
|
@@ -49,4 +28,45 @@ interface IOutbox {
|
|
49
28
|
function l2ToL1OutputId() external view returns (bytes32);
|
50
29
|
|
51
30
|
function updateSendRoot(bytes32 sendRoot, bytes32 l2BlockHash) external;
|
31
|
+
|
32
|
+
function executeTransaction(
|
33
|
+
bytes32[] calldata proof,
|
34
|
+
uint256 index,
|
35
|
+
address l2Sender,
|
36
|
+
address to,
|
37
|
+
uint256 l2Block,
|
38
|
+
uint256 l1Block,
|
39
|
+
uint256 l2Timestamp,
|
40
|
+
uint256 value,
|
41
|
+
bytes calldata data
|
42
|
+
) external;
|
43
|
+
|
44
|
+
function executeTransactionSimulation(
|
45
|
+
uint256 index,
|
46
|
+
address l2Sender,
|
47
|
+
address to,
|
48
|
+
uint256 l2Block,
|
49
|
+
uint256 l1Block,
|
50
|
+
uint256 l2Timestamp,
|
51
|
+
uint256 value,
|
52
|
+
bytes calldata data
|
53
|
+
) external;
|
54
|
+
|
55
|
+
function isSpent(uint256) external view returns (bool);
|
56
|
+
|
57
|
+
function calculateItemHash(
|
58
|
+
address l2Sender,
|
59
|
+
address to,
|
60
|
+
uint256 l2Block,
|
61
|
+
uint256 l1Block,
|
62
|
+
uint256 l2Timestamp,
|
63
|
+
uint256 value,
|
64
|
+
bytes calldata data
|
65
|
+
) external pure returns (bytes32);
|
66
|
+
|
67
|
+
function calculateMerkleRoot(
|
68
|
+
bytes32[] memory proof,
|
69
|
+
uint256 path,
|
70
|
+
bytes32 item
|
71
|
+
) external pure returns (bytes32);
|
52
72
|
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
// Copyright 2021-2022, Offchain Labs, Inc.
|
2
|
+
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
|
+
// SPDX-License-Identifier: BUSL-1.1
|
4
|
+
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.4.21 <0.9.0;
|
7
|
+
|
8
|
+
interface IOwnable {
|
9
|
+
function owner() external view returns (address);
|
10
|
+
}
|
@@ -2,12 +2,14 @@
|
|
2
2
|
// For license information, see https://github.com/nitro/blob/master/LICENSE
|
3
3
|
// SPDX-License-Identifier: BUSL-1.1
|
4
4
|
|
5
|
-
|
5
|
+
// solhint-disable-next-line compiler-version
|
6
|
+
pragma solidity >=0.6.9 <0.9.0;
|
7
|
+
pragma experimental ABIEncoderV2;
|
6
8
|
|
7
9
|
import "../libraries/IGasRefunder.sol";
|
8
|
-
import
|
10
|
+
import "./IDelayedMessageProvider.sol";
|
9
11
|
|
10
|
-
interface ISequencerInbox {
|
12
|
+
interface ISequencerInbox is IDelayedMessageProvider {
|
11
13
|
struct MaxTimeVariation {
|
12
14
|
uint256 delayBlocks;
|
13
15
|
uint256 futureBlocks;
|
@@ -38,48 +40,44 @@ interface ISequencerInbox {
|
|
38
40
|
BatchDataLocation dataLocation
|
39
41
|
);
|
40
42
|
|
43
|
+
event OwnerFunctionCalled(uint256 indexed id);
|
44
|
+
|
41
45
|
/// @dev a separate event that emits batch data when this isn't easily accessible in the tx.input
|
42
46
|
event SequencerBatchData(uint256 indexed batchSequenceNumber, bytes data);
|
43
47
|
|
44
|
-
/// @dev
|
45
|
-
|
46
|
-
|
47
|
-
/// @dev Thrown when someone attempts to read more messages than exist
|
48
|
-
error DelayedTooFar();
|
49
|
-
|
50
|
-
/// @dev Thrown if the length of the header plus the length of the batch overflows
|
51
|
-
error DataLengthOverflow();
|
52
|
-
|
53
|
-
/// @dev Force include can only read messages more blocks old than the delay period
|
54
|
-
error ForceIncludeBlockTooSoon();
|
55
|
-
|
56
|
-
/// @dev Force include can only read messages more seconds old than the delay period
|
57
|
-
error ForceIncludeTimeTooSoon();
|
48
|
+
/// @dev a valid keyset was added
|
49
|
+
event SetValidKeyset(bytes32 indexed keysetHash, bytes keysetBytes);
|
58
50
|
|
59
|
-
/// @dev
|
60
|
-
|
61
|
-
|
62
|
-
/// @dev This can only be called by the batch poster
|
63
|
-
error NotBatchPoster();
|
64
|
-
|
65
|
-
/// @dev The sequence number provided to this message was inconsistent with the number of batches already included
|
66
|
-
error BadSequencerNumber();
|
67
|
-
|
68
|
-
/// @dev The batch data has the inbox authenticated bit set, but the batch data was not authenticated by the inbox
|
69
|
-
error DataNotAuthenticated();
|
51
|
+
/// @dev a keyset was invalidated
|
52
|
+
event InvalidateKeyset(bytes32 indexed keysetHash);
|
70
53
|
|
71
54
|
function inboxAccs(uint256 index) external view returns (bytes32);
|
72
55
|
|
73
56
|
function batchCount() external view returns (uint256);
|
74
57
|
|
75
|
-
function setMaxTimeVariation(MaxTimeVariation memory timeVariation) external;
|
76
|
-
|
77
|
-
function setIsBatchPoster(address addr, bool isBatchPoster_) external;
|
78
|
-
|
79
58
|
function addSequencerL2Batch(
|
80
59
|
uint256 sequenceNumber,
|
81
60
|
bytes calldata data,
|
82
61
|
uint256 afterDelayedMessagesRead,
|
83
62
|
IGasRefunder gasRefunder
|
84
63
|
) external;
|
64
|
+
|
65
|
+
// Methods only callable by rollup owner
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @notice Set max time variation from actual time for sequencer inbox
|
69
|
+
* @param timeVariation the maximum time variation parameters
|
70
|
+
*/
|
71
|
+
function setMaxTimeVariation(MaxTimeVariation memory timeVariation) external;
|
72
|
+
|
73
|
+
/**
|
74
|
+
* @notice Updates whether an address is authorized to be a batch poster at the sequencer inbox
|
75
|
+
* @param addr the address
|
76
|
+
* @param isBatchPoster if the specified address should be authorized as a batch poster
|
77
|
+
*/
|
78
|
+
function setIsBatchPoster(address addr, bool isBatchPoster) external;
|
79
|
+
|
80
|
+
function setValidKeyset(bytes calldata keysetBytes) external;
|
81
|
+
|
82
|
+
function invalidateKeysetHash(bytes32 ksHash) external;
|
85
83
|
}
|