IArbSys.sol 5.1 KB

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