Skip to content

Commit d0b497d

Browse files
Amxxfrangio
authored andcommitted
Update Arbitrum's vendored contracts to Nitro (OpenZeppelin#3692)
Co-authored-by: Francisco <frangio.1@gmail.com>
1 parent bc01c3e commit d0b497d

File tree

8 files changed

+399
-199
lines changed

8 files changed

+399
-199
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* `Ownable2Step`: extension of `Ownable` that makes the ownership transfers a two step process. ([#3620](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3620))
3535
* `Math` and `SignedMath`: optimize function `max` by using `>` instead of `>=`. ([#3679](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3679))
3636
* `Math`: Add `log2`, `log10` and `log256`. ([#3670](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3670))
37+
* Arbitrum: Update the vendored arbitrum contracts to match the nitro upgrade. ([#3692](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3692))
3738

3839
### Breaking changes
3940

contracts/crosschain/arbitrum/LibArbitrumL1.sol

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
pragma solidity ^0.8.4;
55

66
import {IBridge as ArbitrumL1_Bridge} from "../../vendor/arbitrum/IBridge.sol";
7-
import {IInbox as ArbitrumL1_Inbox} from "../../vendor/arbitrum/IInbox.sol";
87
import {IOutbox as ArbitrumL1_Outbox} from "../../vendor/arbitrum/IOutbox.sol";
98
import "../errors.sol";
109

contracts/vendor/arbitrum/IArbSys.sol

+82-41
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,60 @@
1-
// SPDX-License-Identifier: MIT
2-
// OpenZeppelin Contracts (last updated v4.6.0) (vendor/arbitrum/IArbSys.sol)
1+
// Copyright 2021-2022, Offchain Labs, Inc.
2+
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE
3+
// SPDX-License-Identifier: BUSL-1.1
4+
35
pragma solidity >=0.4.21 <0.9.0;
46

57
/**
6-
* @title Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064. Exposes a variety of system-level functionality.
8+
* @title System level functionality
9+
* @notice For use by contracts to interact with core L2-specific functionality.
10+
* Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064.
711
*/
812
interface IArbSys {
9-
/**
10-
* @notice Get internal version number identifying an ArbOS build
11-
* @return version number as int
12-
*/
13-
function arbOSVersion() external pure returns (uint256);
14-
15-
function arbChainID() external view returns (uint256);
16-
1713
/**
1814
* @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)
1915
* @return block number as int
2016
*/
2117
function arbBlockNumber() external view returns (uint256);
2218

2319
/**
24-
* @notice Send given amount of Eth to dest from sender.
25-
* This is a convenience function, which is equivalent to calling sendTxToL1 with empty calldataForL1.
26-
* @param destination recipient address on L1
27-
* @return unique identifier for this L2-to-L1 transaction.
20+
* @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum)
21+
* @return block hash
2822
*/
29-
function withdrawEth(address destination) external payable returns (uint256);
23+
function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);
3024

3125
/**
32-
* @notice Send a transaction to L1
33-
* @param destination recipient address on L1
34-
* @param calldataForL1 (optional) calldata for L1 contract call
35-
* @return a unique identifier for this L2-to-L1 transaction.
26+
* @notice Gets the rollup's unique chain identifier
27+
* @return Chain identifier as int
3628
*/
37-
function sendTxToL1(address destination, bytes calldata calldataForL1) external payable returns (uint256);
29+
function arbChainID() external view returns (uint256);
3830

3931
/**
40-
* @notice get the number of transactions issued by the given external account or the account sequence number of the given contract
41-
* @param account target account
42-
* @return the number of transactions issued by the given external account or the account sequence number of the given contract
32+
* @notice Get internal version number identifying an ArbOS build
33+
* @return version number as int
4334
*/
44-
function getTransactionCount(address account) external view returns (uint256);
35+
function arbOSVersion() external view returns (uint256);
4536

4637
/**
47-
* @notice get the value of target L2 storage slot
48-
* This function is only callable from address 0 to prevent contracts from being able to call it
49-
* @param account target account
50-
* @param index target index of storage slot
51-
* @return stotage value for the given account at the given index
38+
* @notice Returns 0 since Nitro has no concept of storage gas
39+
* @return uint 0
5240
*/
53-
function getStorageAt(address account, uint256 index) external view returns (uint256);
41+
function getStorageGasAvailable() external view returns (uint256);
5442

5543
/**
56-
* @notice check if current call is coming from l1
57-
* @return true if the caller of this was called directly from L1
44+
* @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract)
45+
* @dev this call has been deprecated and may be removed in a future release
46+
* @return true if current execution frame is not a call by another L2 contract
5847
*/
5948
function isTopLevelCall() external view returns (bool);
6049

50+
/**
51+
* @notice map L1 sender contract address to its L2 alias
52+
* @param sender sender address
53+
* @param unused argument no longer used
54+
* @return aliased sender address
55+
*/
56+
function mapL1SenderContractAddressToL2Alias(address sender, address unused) external pure returns (address);
57+
6158
/**
6259
* @notice check if the caller (of this caller of this) is an aliased L1 contract address
6360
* @return true iff the caller's address is an alias for an L1 contract address
@@ -71,19 +68,55 @@ interface IArbSys {
7168
function myCallersAddressWithoutAliasing() external view returns (address);
7269

7370
/**
74-
* @notice map L1 sender contract address to its L2 alias
75-
* @param sender sender address
76-
* @param dest destination address
77-
* @return aliased sender address
71+
* @notice Send given amount of Eth to dest from sender.
72+
* This is a convenience function, which is equivalent to calling sendTxToL1 with empty data.
73+
* @param destination recipient address on L1
74+
* @return unique identifier for this L2-to-L1 transaction.
7875
*/
79-
function mapL1SenderContractAddressToL2Alias(address sender, address dest) external pure returns (address);
76+
function withdrawEth(address destination) external payable returns (uint256);
8077

8178
/**
82-
* @notice get the caller's amount of available storage gas
83-
* @return amount of storage gas available to the caller
79+
* @notice Send a transaction to L1
80+
* @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data
81+
* to a contract address without any code (as enforced by the Bridge contract).
82+
* @param destination recipient address on L1
83+
* @param data (optional) calldata for L1 contract call
84+
* @return a unique identifier for this L2-to-L1 transaction.
8485
*/
85-
function getStorageGasAvailable() external view returns (uint256);
86+
function sendTxToL1(address destination, bytes calldata data) external payable returns (uint256);
87+
88+
/**
89+
* @notice Get send Merkle tree state
90+
* @return size number of sends in the history
91+
* @return root root hash of the send history
92+
* @return partials hashes of partial subtrees in the send history tree
93+
*/
94+
function sendMerkleTreeState()
95+
external
96+
view
97+
returns (
98+
uint256 size,
99+
bytes32 root,
100+
bytes32[] memory partials
101+
);
102+
103+
/**
104+
* @notice creates a send txn from L2 to L1
105+
* @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf
106+
*/
107+
event L2ToL1Tx(
108+
address caller,
109+
address indexed destination,
110+
uint256 indexed hash,
111+
uint256 indexed position,
112+
uint256 arbBlockNum,
113+
uint256 ethBlockNum,
114+
uint256 timestamp,
115+
uint256 callvalue,
116+
bytes data
117+
);
86118

119+
/// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade
87120
event L2ToL1Transaction(
88121
address caller,
89122
address indexed destination,
@@ -96,4 +129,12 @@ interface IArbSys {
96129
uint256 callvalue,
97130
bytes data
98131
);
132+
133+
/**
134+
* @notice logs a merkle branch for proof synthesis
135+
* @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event
136+
* @param hash the merkle hash
137+
* @param position = (level << 192) + leaf
138+
*/
139+
event SendMerkleUpdate(uint256 indexed reserved, bytes32 indexed hash, uint256 indexed position);
99140
}

contracts/vendor/arbitrum/IBridge.sol

+76-34
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
// SPDX-License-Identifier: Apache-2.0
2-
// OpenZeppelin Contracts (last updated v4.6.0) (vendor/arbitrum/IBridge.sol)
3-
4-
/*
5-
* Copyright 2021, Offchain Labs, Inc.
6-
*
7-
* Licensed under the Apache License, Version 2.0 (the "License");
8-
* you may not use this file except in compliance with the License.
9-
* You may obtain a copy of the License at
10-
*
11-
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
13-
* Unless required by applicable law or agreed to in writing, software
14-
* distributed under the License is distributed on an "AS IS" BASIS,
15-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
* See the License for the specific language governing permissions and
17-
* limitations under the License.
18-
*/
19-
20-
pragma solidity ^0.8.0;
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;
217

228
interface IBridge {
239
event MessageDelivered(
@@ -26,41 +12,97 @@ interface IBridge {
2612
address inbox,
2713
uint8 kind,
2814
address sender,
29-
bytes32 messageDataHash
15+
bytes32 messageDataHash,
16+
uint256 baseFeeL1,
17+
uint64 timestamp
3018
);
3119

32-
event BridgeCallTriggered(address indexed outbox, address indexed destAddr, uint256 amount, bytes data);
20+
event BridgeCallTriggered(address indexed outbox, address indexed to, uint256 value, bytes data);
3321

3422
event InboxToggle(address indexed inbox, bool enabled);
3523

3624
event OutboxToggle(address indexed outbox, bool enabled);
3725

38-
function deliverMessageToInbox(
26+
event SequencerInboxUpdated(address newSequencerInbox);
27+
28+
function allowedDelayedInboxList(uint256) external returns (address);
29+
30+
function allowedOutboxList(uint256) external returns (address);
31+
32+
/// @dev Accumulator for delayed inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
33+
function delayedInboxAccs(uint256) external view returns (bytes32);
34+
35+
/// @dev Accumulator for sequencer inbox messages; tail represents hash of the current state; each element represents the inclusion of a new message.
36+
function sequencerInboxAccs(uint256) external view returns (bytes32);
37+
38+
// OpenZeppelin: changed return type from IOwnable
39+
function rollup() external view returns (address);
40+
41+
function sequencerInbox() external view returns (address);
42+
43+
function activeOutbox() external view returns (address);
44+
45+
function allowedDelayedInboxes(address inbox) external view returns (bool);
46+
47+
function allowedOutboxes(address outbox) external view returns (bool);
48+
49+
function sequencerReportedSubMessageCount() external view returns (uint256);
50+
51+
/**
52+
* @dev Enqueue a message in the delayed inbox accumulator.
53+
* These messages are later sequenced in the SequencerInbox, either
54+
* by the sequencer as part of a normal batch, or by force inclusion.
55+
*/
56+
function enqueueDelayedMessage(
3957
uint8 kind,
4058
address sender,
4159
bytes32 messageDataHash
4260
) external payable returns (uint256);
4361

4462
function executeCall(
45-
address destAddr,
46-
uint256 amount,
63+
address to,
64+
uint256 value,
4765
bytes calldata data
4866
) external returns (bool success, bytes memory returnData);
4967

50-
// These are only callable by the admin
51-
function setInbox(address inbox, bool enabled) external;
68+
function delayedMessageCount() external view returns (uint256);
5269

53-
function setOutbox(address inbox, bool enabled) external;
70+
function sequencerMessageCount() external view returns (uint256);
5471

55-
// View functions
72+
// ---------- onlySequencerInbox functions ----------
5673

57-
function activeOutbox() external view returns (address);
74+
function enqueueSequencerMessage(
75+
bytes32 dataHash,
76+
uint256 afterDelayedMessagesRead,
77+
uint256 prevMessageCount,
78+
uint256 newMessageCount
79+
)
80+
external
81+
returns (
82+
uint256 seqMessageIndex,
83+
bytes32 beforeAcc,
84+
bytes32 delayedAcc,
85+
bytes32 acc
86+
);
5887

59-
function allowedInboxes(address inbox) external view returns (bool);
88+
/**
89+
* @dev Allows the sequencer inbox to submit a delayed message of the batchPostingReport type
90+
* This is done through a separate function entrypoint instead of allowing the sequencer inbox
91+
* to call `enqueueDelayedMessage` to avoid the gas overhead of an extra SLOAD in either
92+
* every delayed inbox or every sequencer inbox call.
93+
*/
94+
function submitBatchSpendingReport(address batchPoster, bytes32 dataHash) external returns (uint256 msgNum);
6095

61-
function allowedOutboxes(address outbox) external view returns (bool);
96+
// ---------- onlyRollupOrOwner functions ----------
97+
98+
function setSequencerInbox(address _sequencerInbox) external;
99+
100+
function setDelayedInbox(address inbox, bool enabled) external;
101+
102+
function setOutbox(address inbox, bool enabled) external;
62103

63-
function inboxAccs(uint256 index) external view returns (bytes32);
104+
// ---------- initializer ----------
64105

65-
function messageCount() external view returns (uint256);
106+
// OpenZeppelin: changed rollup_ type from IOwnable
107+
function initialize(address rollup_) external;
66108
}
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)