IOutbox.sol 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. // OpenZeppelin Contracts (last updated v4.8.0-rc.2) (vendor/arbitrum/IOutbox.sol)
  5. // solhint-disable-next-line compiler-version
  6. pragma solidity >=0.6.9 <0.9.0;
  7. import "./IBridge.sol";
  8. interface IOutbox {
  9. event SendRootUpdated(bytes32 indexed blockHash, bytes32 indexed outputRoot);
  10. event OutBoxTransactionExecuted(
  11. address indexed to,
  12. address indexed l2Sender,
  13. uint256 indexed zero,
  14. uint256 transactionIndex
  15. );
  16. function rollup() external view returns (address); // the rollup contract
  17. function bridge() external view returns (IBridge); // the bridge contract
  18. function spent(uint256) external view returns (bytes32); // packed spent bitmap
  19. function roots(bytes32) external view returns (bytes32); // maps root hashes => L2 block hash
  20. // solhint-disable-next-line func-name-mixedcase
  21. function OUTBOX_VERSION() external view returns (uint128); // the outbox version
  22. function updateSendRoot(bytes32 sendRoot, bytes32 l2BlockHash) external;
  23. /// @notice When l2ToL1Sender returns a nonzero address, the message was originated by an L2 account
  24. /// When the return value is zero, that means this is a system message
  25. /// @dev the l2ToL1Sender behaves as the tx.origin, the msg.sender should be validated to protect against reentrancies
  26. function l2ToL1Sender() external view returns (address);
  27. /// @return l2Block return L2 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active
  28. function l2ToL1Block() external view returns (uint256);
  29. /// @return l1Block return L1 block when the L2 tx was initiated or 0 if no L2 to L1 transaction is active
  30. function l2ToL1EthBlock() external view returns (uint256);
  31. /// @return timestamp return L2 timestamp when the L2 tx was initiated or 0 if no L2 to L1 transaction is active
  32. function l2ToL1Timestamp() external view returns (uint256);
  33. /// @return outputId returns the unique output identifier of the L2 to L1 tx or 0 if no L2 to L1 transaction is active
  34. function l2ToL1OutputId() external view returns (bytes32);
  35. /**
  36. * @notice Executes a messages in an Outbox entry.
  37. * @dev Reverts if dispute period hasn't expired, since the outbox entry
  38. * is only created once the rollup confirms the respective assertion.
  39. * @dev it is not possible to execute any L2-to-L1 transaction which contains data
  40. * to a contract address without any code (as enforced by the Bridge contract).
  41. * @param proof Merkle proof of message inclusion in send root
  42. * @param index Merkle path to message
  43. * @param l2Sender sender if original message (i.e., caller of ArbSys.sendTxToL1)
  44. * @param to destination address for L1 contract call
  45. * @param l2Block l2 block number at which sendTxToL1 call was made
  46. * @param l1Block l1 block number at which sendTxToL1 call was made
  47. * @param l2Timestamp l2 Timestamp at which sendTxToL1 call was made
  48. * @param value wei in L1 message
  49. * @param data abi-encoded L1 message data
  50. */
  51. function executeTransaction(
  52. bytes32[] calldata proof,
  53. uint256 index,
  54. address l2Sender,
  55. address to,
  56. uint256 l2Block,
  57. uint256 l1Block,
  58. uint256 l2Timestamp,
  59. uint256 value,
  60. bytes calldata data
  61. ) external;
  62. /**
  63. * @dev function used to simulate the result of a particular function call from the outbox
  64. * it is useful for things such as gas estimates. This function includes all costs except for
  65. * proof validation (which can be considered offchain as a somewhat of a fixed cost - it's
  66. * not really a fixed cost, but can be treated as so with a fixed overhead for gas estimation).
  67. * We can't include the cost of proof validation since this is intended to be used to simulate txs
  68. * that are included in yet-to-be confirmed merkle roots. The simulation entrypoint could instead pretend
  69. * to confirm a pending merkle root, but that would be less practical for integrating with tooling.
  70. * It is only possible to trigger it when the msg sender is address zero, which should be impossible
  71. * unless under simulation in an eth_call or eth_estimateGas
  72. */
  73. function executeTransactionSimulation(
  74. uint256 index,
  75. address l2Sender,
  76. address to,
  77. uint256 l2Block,
  78. uint256 l1Block,
  79. uint256 l2Timestamp,
  80. uint256 value,
  81. bytes calldata data
  82. ) external;
  83. /**
  84. * @param index Merkle path to message
  85. * @return true if the message has been spent
  86. */
  87. function isSpent(uint256 index) external view returns (bool);
  88. function calculateItemHash(
  89. address l2Sender,
  90. address to,
  91. uint256 l2Block,
  92. uint256 l1Block,
  93. uint256 l2Timestamp,
  94. uint256 value,
  95. bytes calldata data
  96. ) external pure returns (bytes32);
  97. function calculateMerkleRoot(
  98. bytes32[] memory proof,
  99. uint256 path,
  100. bytes32 item
  101. ) external pure returns (bytes32);
  102. }