IArbSys.sol 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. // OpenZeppelin Contracts (last updated v4.9.0) (vendor/arbitrum/IArbSys.sol)
  5. pragma solidity >=0.4.21 <0.9.0;
  6. /**
  7. * @title System level functionality
  8. * @notice For use by contracts to interact with core L2-specific functionality.
  9. * Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064.
  10. */
  11. interface IArbSys {
  12. /**
  13. * @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)
  14. * @return block number as int
  15. */
  16. function arbBlockNumber() external view returns (uint256);
  17. /**
  18. * @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum)
  19. * @return block hash
  20. */
  21. function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);
  22. /**
  23. * @notice Gets the rollup's unique chain identifier
  24. * @return Chain identifier as int
  25. */
  26. function arbChainID() external view returns (uint256);
  27. /**
  28. * @notice Get internal version number identifying an ArbOS build
  29. * @return version number as int
  30. */
  31. function arbOSVersion() external view returns (uint256);
  32. /**
  33. * @notice Returns 0 since Nitro has no concept of storage gas
  34. * @return uint 0
  35. */
  36. function getStorageGasAvailable() external view returns (uint256);
  37. /**
  38. * @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract)
  39. * @dev this call has been deprecated and may be removed in a future release
  40. * @return true if current execution frame is not a call by another L2 contract
  41. */
  42. function isTopLevelCall() external view returns (bool);
  43. /**
  44. * @notice map L1 sender contract address to its L2 alias
  45. * @param sender sender address
  46. * @param unused argument no longer used
  47. * @return aliased sender address
  48. */
  49. function mapL1SenderContractAddressToL2Alias(address sender, address unused) external pure returns (address);
  50. /**
  51. * @notice check if the caller (of this caller of this) is an aliased L1 contract address
  52. * @return true iff the caller's address is an alias for an L1 contract address
  53. */
  54. function wasMyCallersAddressAliased() external view returns (bool);
  55. /**
  56. * @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing
  57. * @return address of the caller's caller, without applying L1 contract address aliasing
  58. */
  59. function myCallersAddressWithoutAliasing() external view returns (address);
  60. /**
  61. * @notice Send given amount of Eth to dest from sender.
  62. * This is a convenience function, which is equivalent to calling sendTxToL1 with empty data.
  63. * @param destination recipient address on L1
  64. * @return unique identifier for this L2-to-L1 transaction.
  65. */
  66. function withdrawEth(address destination) external payable returns (uint256);
  67. /**
  68. * @notice Send a transaction to L1
  69. * @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data
  70. * to a contract address without any code (as enforced by the Bridge contract).
  71. * @param destination recipient address on L1
  72. * @param data (optional) calldata for L1 contract call
  73. * @return a unique identifier for this L2-to-L1 transaction.
  74. */
  75. function sendTxToL1(address destination, bytes calldata data) external payable returns (uint256);
  76. /**
  77. * @notice Get send Merkle tree state
  78. * @return size number of sends in the history
  79. * @return root root hash of the send history
  80. * @return partials hashes of partial subtrees in the send history tree
  81. */
  82. function sendMerkleTreeState() external view returns (uint256 size, bytes32 root, bytes32[] memory partials);
  83. /**
  84. * @notice creates a send txn from L2 to L1
  85. * @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf
  86. */
  87. event L2ToL1Tx(
  88. address caller,
  89. address indexed destination,
  90. uint256 indexed hash,
  91. uint256 indexed position,
  92. uint256 arbBlockNum,
  93. uint256 ethBlockNum,
  94. uint256 timestamp,
  95. uint256 callvalue,
  96. bytes data
  97. );
  98. /// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade
  99. event L2ToL1Transaction(
  100. address caller,
  101. address indexed destination,
  102. uint256 indexed uniqueId,
  103. uint256 indexed batchNumber,
  104. uint256 indexInBatch,
  105. uint256 arbBlockNum,
  106. uint256 ethBlockNum,
  107. uint256 timestamp,
  108. uint256 callvalue,
  109. bytes data
  110. );
  111. /**
  112. * @notice logs a merkle branch for proof synthesis
  113. * @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event
  114. * @param hash the merkle hash
  115. * @param position = (level << 192) + leaf
  116. */
  117. event SendMerkleUpdate(uint256 indexed reserved, bytes32 indexed hash, uint256 indexed position);
  118. }