/
IL1MessageQueue.sol
113 lines (98 loc) · 4.48 KB
/
IL1MessageQueue.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IL1MessageQueue {
/**********
* Events *
**********/
/// @notice Emitted when a new L1 => L2 transaction is appended to the queue.
/// @param sender The address of account who initiates the transaction.
/// @param target The address of account who will receive the transaction.
/// @param value The value passed with the transaction.
/// @param queueIndex The index of this transaction in the queue.
/// @param gasLimit Gas limit required to complete the message relay on L2.
/// @param data The calldata of the transaction.
event QueueTransaction(
address indexed sender,
address indexed target,
uint256 value,
uint256 queueIndex,
uint256 gasLimit,
bytes data
);
/// @notice Emitted when some L1 => L2 transactions are included in L1.
/// @param startIndex The start index of messages popped.
/// @param count The number of messages popped.
/// @param skippedBitmap A bitmap indicates whether a message is skipped.
event DequeueTransaction(uint256 startIndex, uint256 count, uint256 skippedBitmap);
/*************************
* Public View Functions *
*************************/
/// @notice The start index of all pending inclusion messages.
function pendingQueueIndex() external view returns (uint256);
/// @notice Return the index of next appended message.
/// @dev Also the total number of appended messages.
function nextCrossDomainMessageIndex() external view returns (uint256);
/// @notice Return the message of in `queueIndex`.
/// @param queueIndex The index to query.
function getCrossDomainMessage(uint256 queueIndex) external view returns (bytes32);
/// @notice Return the amount of ETH should pay for cross domain message.
/// @param gasLimit Gas limit required to complete the message relay on L2.
function estimateCrossDomainMessageFee(uint256 gasLimit) external view returns (uint256);
/// @notice Return the amount of intrinsic gas fee should pay for cross domain message.
/// @param _calldata The calldata of L1-initiated transaction.
function calculateIntrinsicGasFee(bytes memory _calldata) external view returns (uint256);
/// @notice Return the hash of a L1 message.
/// @param sender The address of sender.
/// @param queueIndex The queue index of this message.
/// @param value The amount of Ether transfer to target.
/// @param target The address of target.
/// @param gasLimit The gas limit provided.
/// @param data The calldata passed to target address.
function computeTransactionHash(
address sender,
uint256 queueIndex,
uint256 value,
address target,
uint256 gasLimit,
bytes calldata data
) external view returns (bytes32);
/*****************************
* Public Mutating Functions *
*****************************/
/// @notice Append a L1 to L2 message into this contract.
/// @param target The address of target contract to call in L2.
/// @param gasLimit The maximum gas should be used for relay this message in L2.
/// @param data The calldata passed to target contract.
function appendCrossDomainMessage(
address target,
uint256 gasLimit,
bytes calldata data
) external;
/// @notice Append an enforced transaction to this contract.
/// @dev The address of sender should be an EOA.
/// @param sender The address of sender who will initiate this transaction in L2.
/// @param target The address of target contract to call in L2.
/// @param value The value passed
/// @param gasLimit The maximum gas should be used for this transaction in L2.
/// @param data The calldata passed to target contract.
function appendEnforcedTransaction(
address sender,
address target,
uint256 value,
uint256 gasLimit,
bytes calldata data
) external;
/// @notice Pop finalized messages from queue.
///
/// @dev We can pop at most 256 messages each time. And if the message is not skipped,
/// the corresponding entry will be cleared.
///
/// @param startIndex The start index to pop.
/// @param count The number of messages to pop.
/// @param skippedBitmap A bitmap indicates whether a message is skipped.
function popCrossDomainMessage(
uint256 startIndex,
uint256 count,
uint256 skippedBitmap
) external;
}