Update Arbitrum's vendored contracts to Nitro (#3692)
Co-authored-by: Francisco <frangio.1@gmail.com>pull/3738/head
parent
c22db8104e
commit
9938a85558
@ -0,0 +1,15 @@ |
|||||||
|
// Copyright 2021-2022, Offchain Labs, Inc. |
||||||
|
// For license information, see https://github.com/nitro/blob/master/LICENSE |
||||||
|
// SPDX-License-Identifier: BUSL-1.1 |
||||||
|
|
||||||
|
// solhint-disable-next-line compiler-version |
||||||
|
pragma solidity >=0.6.9 <0.9.0; |
||||||
|
|
||||||
|
interface IDelayedMessageProvider { |
||||||
|
/// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator |
||||||
|
event InboxMessageDelivered(uint256 indexed messageNum, bytes data); |
||||||
|
|
||||||
|
/// @dev event emitted when a inbox message is added to the Bridge's delayed accumulator |
||||||
|
/// same as InboxMessageDelivered but the batch data is available in tx.input |
||||||
|
event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum); |
||||||
|
} |
@ -1,92 +1,151 @@ |
|||||||
// SPDX-License-Identifier: Apache-2.0 |
// Copyright 2021-2022, Offchain Labs, Inc. |
||||||
// OpenZeppelin Contracts (last updated v4.6.0) (vendor/arbitrum/IInbox.sol) |
// For license information, see https://github.com/nitro/blob/master/LICENSE |
||||||
|
// SPDX-License-Identifier: BUSL-1.1 |
||||||
/* |
|
||||||
* Copyright 2021, Offchain Labs, Inc. |
|
||||||
* |
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
* you may not use this file except in compliance with the License. |
|
||||||
* You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
pragma solidity ^0.8.0; |
// solhint-disable-next-line compiler-version |
||||||
|
pragma solidity >=0.6.9 <0.9.0; |
||||||
|
|
||||||
import "./IMessageProvider.sol"; |
import "./IBridge.sol"; |
||||||
|
import "./IDelayedMessageProvider.sol"; |
||||||
|
|
||||||
interface IInbox is IMessageProvider { |
interface IInbox is IDelayedMessageProvider { |
||||||
function sendL2Message(bytes calldata messageData) external returns (uint256); |
function bridge() external view returns (IBridge); |
||||||
|
|
||||||
function sendUnsignedTransaction( |
// OpenZeppelin: changed return type from ISequencerInbox |
||||||
uint256 maxGas, |
function sequencerInbox() external view returns (address); |
||||||
uint256 gasPriceBid, |
|
||||||
uint256 nonce, |
|
||||||
address destAddr, |
|
||||||
uint256 amount, |
|
||||||
bytes calldata data |
|
||||||
) external returns (uint256); |
|
||||||
|
|
||||||
function sendContractTransaction( |
/** |
||||||
uint256 maxGas, |
* @notice Send a generic L2 message to the chain |
||||||
uint256 gasPriceBid, |
* @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 |
||||||
address destAddr, |
* @param messageData Data of the message being sent |
||||||
uint256 amount, |
*/ |
||||||
bytes calldata data |
function sendL2MessageFromOrigin(bytes calldata messageData) external returns (uint256); |
||||||
) external returns (uint256); |
|
||||||
|
/** |
||||||
|
* @notice Send a generic L2 message to the chain |
||||||
|
* @dev This method can be used to send any type of message that doesn't require L1 validation |
||||||
|
* @param messageData Data of the message being sent |
||||||
|
*/ |
||||||
|
function sendL2Message(bytes calldata messageData) external returns (uint256); |
||||||
|
|
||||||
function sendL1FundedUnsignedTransaction( |
function sendL1FundedUnsignedTransaction( |
||||||
uint256 maxGas, |
uint256 gasLimit, |
||||||
uint256 gasPriceBid, |
uint256 maxFeePerGas, |
||||||
uint256 nonce, |
uint256 nonce, |
||||||
address destAddr, |
address to, |
||||||
bytes calldata data |
bytes calldata data |
||||||
) external payable returns (uint256); |
) external payable returns (uint256); |
||||||
|
|
||||||
function sendL1FundedContractTransaction( |
function sendL1FundedContractTransaction( |
||||||
uint256 maxGas, |
uint256 gasLimit, |
||||||
uint256 gasPriceBid, |
uint256 maxFeePerGas, |
||||||
address destAddr, |
address to, |
||||||
bytes calldata data |
bytes calldata data |
||||||
) external payable returns (uint256); |
) external payable returns (uint256); |
||||||
|
|
||||||
|
function sendUnsignedTransaction( |
||||||
|
uint256 gasLimit, |
||||||
|
uint256 maxFeePerGas, |
||||||
|
uint256 nonce, |
||||||
|
address to, |
||||||
|
uint256 value, |
||||||
|
bytes calldata data |
||||||
|
) external returns (uint256); |
||||||
|
|
||||||
|
function sendContractTransaction( |
||||||
|
uint256 gasLimit, |
||||||
|
uint256 maxFeePerGas, |
||||||
|
address to, |
||||||
|
uint256 value, |
||||||
|
bytes calldata data |
||||||
|
) external returns (uint256); |
||||||
|
|
||||||
|
/** |
||||||
|
* @notice Get the L1 fee for submitting a retryable |
||||||
|
* @dev This fee can be paid by funds already in the L2 aliased address or by the current message value |
||||||
|
* @dev This formula may change in the future, to future proof your code query this method instead of inlining!! |
||||||
|
* @param dataLength The length of the retryable's calldata, in bytes |
||||||
|
* @param baseFee The block basefee when the retryable is included in the chain, if 0 current block.basefee will be used |
||||||
|
*/ |
||||||
|
function calculateRetryableSubmissionFee(uint256 dataLength, uint256 baseFee) external view returns (uint256); |
||||||
|
|
||||||
|
/** |
||||||
|
* @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 |
||||||
|
* @dev This does not trigger the fallback function when receiving in the L2 side. |
||||||
|
* Look into retryable tickets if you are interested in this functionality. |
||||||
|
* @dev This function should not be called inside contract constructors |
||||||
|
*/ |
||||||
|
function depositEth() external payable returns (uint256); |
||||||
|
|
||||||
|
/** |
||||||
|
* @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts |
||||||
|
* @dev all msg.value will deposited to callValueRefundAddress on L2 |
||||||
|
* @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error |
||||||
|
* @param to destination L2 contract address |
||||||
|
* @param l2CallValue call value for retryable L2 message |
||||||
|
* @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee |
||||||
|
* @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance |
||||||
|
* @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled |
||||||
|
* @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) |
||||||
|
* @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error) |
||||||
|
* @param data ABI encoded data of L2 message |
||||||
|
* @return unique message number of the retryable transaction |
||||||
|
*/ |
||||||
function createRetryableTicket( |
function createRetryableTicket( |
||||||
address destAddr, |
address to, |
||||||
uint256 arbTxCallValue, |
uint256 l2CallValue, |
||||||
uint256 maxSubmissionCost, |
uint256 maxSubmissionCost, |
||||||
address submissionRefundAddress, |
address excessFeeRefundAddress, |
||||||
address valueRefundAddress, |
address callValueRefundAddress, |
||||||
uint256 maxGas, |
uint256 gasLimit, |
||||||
uint256 gasPriceBid, |
uint256 maxFeePerGas, |
||||||
bytes calldata data |
bytes calldata data |
||||||
) external payable returns (uint256); |
) external payable returns (uint256); |
||||||
|
|
||||||
function createRetryableTicketNoRefundAliasRewrite( |
/** |
||||||
address destAddr, |
* @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts |
||||||
uint256 arbTxCallValue, |
* @dev Same as createRetryableTicket, but does not guarantee that submission will succeed by requiring the needed funds |
||||||
|
* come from the deposit alone, rather than falling back on the user's L2 balance |
||||||
|
* @dev Advanced usage only (does not rewrite aliases for excessFeeRefundAddress and callValueRefundAddress). |
||||||
|
* createRetryableTicket method is the recommended standard. |
||||||
|
* @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error |
||||||
|
* @param to destination L2 contract address |
||||||
|
* @param l2CallValue call value for retryable L2 message |
||||||
|
* @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee |
||||||
|
* @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance |
||||||
|
* @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled |
||||||
|
* @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) |
||||||
|
* @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error) |
||||||
|
* @param data ABI encoded data of L2 message |
||||||
|
* @return unique message number of the retryable transaction |
||||||
|
*/ |
||||||
|
function unsafeCreateRetryableTicket( |
||||||
|
address to, |
||||||
|
uint256 l2CallValue, |
||||||
uint256 maxSubmissionCost, |
uint256 maxSubmissionCost, |
||||||
address submissionRefundAddress, |
address excessFeeRefundAddress, |
||||||
address valueRefundAddress, |
address callValueRefundAddress, |
||||||
uint256 maxGas, |
uint256 gasLimit, |
||||||
uint256 gasPriceBid, |
uint256 maxFeePerGas, |
||||||
bytes calldata data |
bytes calldata data |
||||||
) external payable returns (uint256); |
) external payable returns (uint256); |
||||||
|
|
||||||
function depositEth(uint256 maxSubmissionCost) external payable returns (uint256); |
// ---------- onlyRollupOrOwner functions ---------- |
||||||
|
|
||||||
function bridge() external view returns (address); |
/// @notice pauses all inbox functionality |
||||||
|
function pause() external; |
||||||
|
|
||||||
function pauseCreateRetryables() external; |
/// @notice unpauses all inbox functionality |
||||||
|
function unpause() external; |
||||||
|
|
||||||
function unpauseCreateRetryables() external; |
// ---------- initializer ---------- |
||||||
|
|
||||||
function startRewriteAddress() external; |
/** |
||||||
|
* @dev function to be called one time during the inbox upgrade process |
||||||
|
* this is used to fix the storage slots |
||||||
|
*/ |
||||||
|
function postUpgradeInit(IBridge _bridge) external; |
||||||
|
|
||||||
function stopRewriteAddress() external; |
// OpenZeppelin: changed _sequencerInbox type from ISequencerInbox |
||||||
|
function initialize(IBridge _bridge, address _sequencerInbox) external; |
||||||
} |
} |
||||||
|
@ -1,26 +0,0 @@ |
|||||||
// SPDX-License-Identifier: Apache-2.0 |
|
||||||
// OpenZeppelin Contracts (last updated v4.6.0) (vendor/arbitrum/IMessageProvider.sol) |
|
||||||
|
|
||||||
/* |
|
||||||
* Copyright 2021, Offchain Labs, Inc. |
|
||||||
* |
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
* you may not use this file except in compliance with the License. |
|
||||||
* You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
pragma solidity ^0.8.0; |
|
||||||
|
|
||||||
interface IMessageProvider { |
|
||||||
event InboxMessageDelivered(uint256 indexed messageNum, bytes data); |
|
||||||
|
|
||||||
event InboxMessageDeliveredFromOrigin(uint256 indexed messageNum); |
|
||||||
} |
|
@ -1,51 +1,120 @@ |
|||||||
// SPDX-License-Identifier: Apache-2.0 |
// Copyright 2021-2022, Offchain Labs, Inc. |
||||||
// OpenZeppelin Contracts (last updated v4.6.0) (vendor/arbitrum/IOutbox.sol) |
// For license information, see https://github.com/nitro/blob/master/LICENSE |
||||||
|
// SPDX-License-Identifier: BUSL-1.1 |
||||||
/* |
|
||||||
* Copyright 2021, Offchain Labs, Inc. |
// solhint-disable-next-line compiler-version |
||||||
* |
pragma solidity >=0.6.9 <0.9.0; |
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
* you may not use this file except in compliance with the License. |
|
||||||
* You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
pragma solidity ^0.8.0; |
import "./IBridge.sol"; |
||||||
|
|
||||||
interface IOutbox { |
interface IOutbox { |
||||||
event OutboxEntryCreated( |
event SendRootUpdated(bytes32 indexed blockHash, bytes32 indexed outputRoot); |
||||||
uint256 indexed batchNum, |
|
||||||
uint256 outboxEntryIndex, |
|
||||||
bytes32 outputRoot, |
|
||||||
uint256 numInBatch |
|
||||||
); |
|
||||||
event OutBoxTransactionExecuted( |
event OutBoxTransactionExecuted( |
||||||
address indexed destAddr, |
address indexed to, |
||||||
address indexed l2Sender, |
address indexed l2Sender, |
||||||
uint256 indexed outboxEntryIndex, |
uint256 indexed zero, |
||||||
uint256 transactionIndex |
uint256 transactionIndex |
||||||
); |
); |
||||||
|
|
||||||
|
function rollup() external view returns (address); // the rollup contract |
||||||
|
|
||||||
|
function bridge() external view returns (IBridge); // the bridge contract |
||||||
|
|
||||||
|
function spent(uint256) external view returns (bytes32); // packed spent bitmap |
||||||
|
|
||||||
|
function roots(bytes32) external view returns (bytes32); // maps root hashes => L2 block hash |
||||||
|
|
||||||
|
// solhint-disable-next-line func-name-mixedcase |
||||||
|
function OUTBOX_VERSION() external view returns (uint128); // the outbox version |
||||||
|
|
||||||
|
function updateSendRoot(bytes32 sendRoot, bytes32 l2BlockHash) external; |
||||||
|
|
||||||
|
/// @notice When l2ToL1Sender returns a nonzero address, the message was originated by an L2 account |
||||||
|
/// When the return value is zero, that means this is a system message |
||||||
|
/// @dev the l2ToL1Sender behaves as the tx.origin, the msg.sender should be validated to protect against reentrancies |
||||||
function l2ToL1Sender() external view returns (address); |
function l2ToL1Sender() external view returns (address); |
||||||
|
|
||||||
|
/// @return l2Block return L2 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active |
||||||
function l2ToL1Block() external view returns (uint256); |
function l2ToL1Block() external view returns (uint256); |
||||||
|
|
||||||
|
/// @return l1Block return L1 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active |
||||||
function l2ToL1EthBlock() external view returns (uint256); |
function l2ToL1EthBlock() external view returns (uint256); |
||||||
|
|
||||||
|
/// @return timestamp return L2 timestamp when the L2 tx was initiated or 0 if no L2 to L1 transaction is active |
||||||
function l2ToL1Timestamp() external view returns (uint256); |
function l2ToL1Timestamp() external view returns (uint256); |
||||||
|
|
||||||
function l2ToL1BatchNum() external view returns (uint256); |
/// @return outputId returns the unique output identifier of the L2 to L1 tx or 0 if no L2 to L1 transaction is active |
||||||
|
|
||||||
function l2ToL1OutputId() external view returns (bytes32); |
function l2ToL1OutputId() external view returns (bytes32); |
||||||
|
|
||||||
function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths) external; |
/** |
||||||
|
* @notice Executes a messages in an Outbox entry. |
||||||
|
* @dev Reverts if dispute period hasn't expired, since the outbox entry |
||||||
|
* is only created once the rollup confirms the respective assertion. |
||||||
|
* @dev it is not possible to execute any L2-to-L1 transaction which contains data |
||||||
|
* to a contract address without any code (as enforced by the Bridge contract). |
||||||
|
* @param proof Merkle proof of message inclusion in send root |
||||||
|
* @param index Merkle path to message |
||||||
|
* @param l2Sender sender if original message (i.e., caller of ArbSys.sendTxToL1) |
||||||
|
* @param to destination address for L1 contract call |
||||||
|
* @param l2Block l2 block number at which sendTxToL1 call was made |
||||||
|
* @param l1Block l1 block number at which sendTxToL1 call was made |
||||||
|
* @param l2Timestamp l2 Timestamp at which sendTxToL1 call was made |
||||||
|
* @param value wei in L1 message |
||||||
|
* @param data abi-encoded L1 message data |
||||||
|
*/ |
||||||
|
function executeTransaction( |
||||||
|
bytes32[] calldata proof, |
||||||
|
uint256 index, |
||||||
|
address l2Sender, |
||||||
|
address to, |
||||||
|
uint256 l2Block, |
||||||
|
uint256 l1Block, |
||||||
|
uint256 l2Timestamp, |
||||||
|
uint256 value, |
||||||
|
bytes calldata data |
||||||
|
) external; |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev function used to simulate the result of a particular function call from the outbox |
||||||
|
* it is useful for things such as gas estimates. This function includes all costs except for |
||||||
|
* proof validation (which can be considered offchain as a somewhat of a fixed cost - it's |
||||||
|
* not really a fixed cost, but can be treated as so with a fixed overhead for gas estimation). |
||||||
|
* We can't include the cost of proof validation since this is intended to be used to simulate txs |
||||||
|
* that are included in yet-to-be confirmed merkle roots. The simulation entrypoint could instead pretend |
||||||
|
* to confirm a pending merkle root, but that would be less practical for integrating with tooling. |
||||||
|
* It is only possible to trigger it when the msg sender is address zero, which should be impossible |
||||||
|
* unless under simulation in an eth_call or eth_estimateGas |
||||||
|
*/ |
||||||
|
function executeTransactionSimulation( |
||||||
|
uint256 index, |
||||||
|
address l2Sender, |
||||||
|
address to, |
||||||
|
uint256 l2Block, |
||||||
|
uint256 l1Block, |
||||||
|
uint256 l2Timestamp, |
||||||
|
uint256 value, |
||||||
|
bytes calldata data |
||||||
|
) external; |
||||||
|
|
||||||
|
/** |
||||||
|
* @param index Merkle path to message |
||||||
|
* @return true if the message has been spent |
||||||
|
*/ |
||||||
|
function isSpent(uint256 index) external view returns (bool); |
||||||
|
|
||||||
|
function calculateItemHash( |
||||||
|
address l2Sender, |
||||||
|
address to, |
||||||
|
uint256 l2Block, |
||||||
|
uint256 l1Block, |
||||||
|
uint256 l2Timestamp, |
||||||
|
uint256 value, |
||||||
|
bytes calldata data |
||||||
|
) external pure returns (bytes32); |
||||||
|
|
||||||
function outboxEntryExists(uint256 batchNum) external view returns (bool); |
function calculateMerkleRoot( |
||||||
|
bytes32[] memory proof, |
||||||
|
uint256 path, |
||||||
|
bytes32 item |
||||||
|
) external pure returns (bytes32); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue