IInbox.sol 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. // solhint-disable-next-line compiler-version
  5. pragma solidity >=0.6.9 <0.9.0;
  6. import "./IBridge.sol";
  7. import "./IDelayedMessageProvider.sol";
  8. interface IInbox is IDelayedMessageProvider {
  9. function bridge() external view returns (IBridge);
  10. // OpenZeppelin: changed return type from ISequencerInbox
  11. function sequencerInbox() external view returns (address);
  12. /**
  13. * @notice Send a generic L2 message to the chain
  14. * @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
  15. * @param messageData Data of the message being sent
  16. */
  17. function sendL2MessageFromOrigin(bytes calldata messageData) external returns (uint256);
  18. /**
  19. * @notice Send a generic L2 message to the chain
  20. * @dev This method can be used to send any type of message that doesn't require L1 validation
  21. * @param messageData Data of the message being sent
  22. */
  23. function sendL2Message(bytes calldata messageData) external returns (uint256);
  24. function sendL1FundedUnsignedTransaction(
  25. uint256 gasLimit,
  26. uint256 maxFeePerGas,
  27. uint256 nonce,
  28. address to,
  29. bytes calldata data
  30. ) external payable returns (uint256);
  31. function sendL1FundedContractTransaction(
  32. uint256 gasLimit,
  33. uint256 maxFeePerGas,
  34. address to,
  35. bytes calldata data
  36. ) external payable returns (uint256);
  37. function sendUnsignedTransaction(
  38. uint256 gasLimit,
  39. uint256 maxFeePerGas,
  40. uint256 nonce,
  41. address to,
  42. uint256 value,
  43. bytes calldata data
  44. ) external returns (uint256);
  45. function sendContractTransaction(
  46. uint256 gasLimit,
  47. uint256 maxFeePerGas,
  48. address to,
  49. uint256 value,
  50. bytes calldata data
  51. ) external returns (uint256);
  52. /**
  53. * @notice Get the L1 fee for submitting a retryable
  54. * @dev This fee can be paid by funds already in the L2 aliased address or by the current message value
  55. * @dev This formula may change in the future, to future proof your code query this method instead of inlining!!
  56. * @param dataLength The length of the retryable's calldata, in bytes
  57. * @param baseFee The block basefee when the retryable is included in the chain, if 0 current block.basefee will be used
  58. */
  59. function calculateRetryableSubmissionFee(uint256 dataLength, uint256 baseFee) external view returns (uint256);
  60. /**
  61. * @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
  62. * @dev This does not trigger the fallback function when receiving in the L2 side.
  63. * Look into retryable tickets if you are interested in this functionality.
  64. * @dev This function should not be called inside contract constructors
  65. */
  66. function depositEth() external payable returns (uint256);
  67. /**
  68. * @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
  69. * @dev all msg.value will deposited to callValueRefundAddress on L2
  70. * @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
  71. * @param to destination L2 contract address
  72. * @param l2CallValue call value for retryable L2 message
  73. * @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
  74. * @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance
  75. * @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
  76. * @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)
  77. * @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
  78. * @param data ABI encoded data of L2 message
  79. * @return unique message number of the retryable transaction
  80. */
  81. function createRetryableTicket(
  82. address to,
  83. uint256 l2CallValue,
  84. uint256 maxSubmissionCost,
  85. address excessFeeRefundAddress,
  86. address callValueRefundAddress,
  87. uint256 gasLimit,
  88. uint256 maxFeePerGas,
  89. bytes calldata data
  90. ) external payable returns (uint256);
  91. /**
  92. * @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
  93. * @dev Same as createRetryableTicket, but does not guarantee that submission will succeed by requiring the needed funds
  94. * come from the deposit alone, rather than falling back on the user's L2 balance
  95. * @dev Advanced usage only (does not rewrite aliases for excessFeeRefundAddress and callValueRefundAddress).
  96. * createRetryableTicket method is the recommended standard.
  97. * @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
  98. * @param to destination L2 contract address
  99. * @param l2CallValue call value for retryable L2 message
  100. * @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
  101. * @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance
  102. * @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
  103. * @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)
  104. * @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
  105. * @param data ABI encoded data of L2 message
  106. * @return unique message number of the retryable transaction
  107. */
  108. function unsafeCreateRetryableTicket(
  109. address to,
  110. uint256 l2CallValue,
  111. uint256 maxSubmissionCost,
  112. address excessFeeRefundAddress,
  113. address callValueRefundAddress,
  114. uint256 gasLimit,
  115. uint256 maxFeePerGas,
  116. bytes calldata data
  117. ) external payable returns (uint256);
  118. // ---------- onlyRollupOrOwner functions ----------
  119. /// @notice pauses all inbox functionality
  120. function pause() external;
  121. /// @notice unpauses all inbox functionality
  122. function unpause() external;
  123. // ---------- initializer ----------
  124. /**
  125. * @dev function to be called one time during the inbox upgrade process
  126. * this is used to fix the storage slots
  127. */
  128. function postUpgradeInit(IBridge _bridge) external;
  129. // OpenZeppelin: changed _sequencerInbox type from ISequencerInbox
  130. function initialize(IBridge _bridge, address _sequencerInbox) external;
  131. }