Skip to content

Commit

Permalink
add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehao committed Jul 16, 2024
1 parent 4ad30a8 commit ad2bd4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
16 changes: 6 additions & 10 deletions src/L1/rollup/IL1MessageQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ interface IL1MessageQueue {
/// @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;
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.
Expand All @@ -146,11 +142,7 @@ interface IL1MessageQueue {
/// @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;
function popCrossDomainMessage(uint256 startIndex, uint256 count, uint256 skippedBitmap) external;

/// @notice Reset status of popped messages.
///
Expand All @@ -165,4 +157,8 @@ interface IL1MessageQueue {

/// @notice Drop a skipped message from the queue.
function dropCrossDomainMessage(uint256 index) external;

function appendHashes(uint256 _fromQueueIndex, bytes32[] memory _hashes) external;

function setPendingQueueIndex(uint256 index) external;
}
25 changes: 15 additions & 10 deletions src/L1/rollup/L1MessageQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ contract L1MessageQueue is OwnableUpgradeable, IL1MessageQueue {
/// @param _messenger The address of `L1ScrollMessenger` contract.
/// @param _scrollChain The address of `ScrollChain` contract.
/// @param _enforcedTxGateway The address of `EnforcedTxGateway` contract.
constructor(
address _messenger,
address _scrollChain,
address _enforcedTxGateway
) {
constructor(address _messenger, address _scrollChain, address _enforcedTxGateway) {
if (_messenger == address(0) || _scrollChain == address(0) || _enforcedTxGateway == address(0)) {
revert ErrorZeroAddress();
}
Expand Down Expand Up @@ -401,11 +397,9 @@ contract L1MessageQueue is OwnableUpgradeable, IL1MessageQueue {
}

/// @inheritdoc IL1MessageQueue
function finalizePoppedCrossDomainMessage(uint256 _newFinalizedQueueIndexPlusOne)
external
override
onlyScrollChain
{
function finalizePoppedCrossDomainMessage(
uint256 _newFinalizedQueueIndexPlusOne
) external override onlyScrollChain {
uint256 cachedFinalizedQueueIndexPlusOne = nextUnfinalizedQueueIndex;
if (_newFinalizedQueueIndexPlusOne == cachedFinalizedQueueIndexPlusOne) return;
require(_newFinalizedQueueIndexPlusOne > cachedFinalizedQueueIndexPlusOne, "finalized index too small");
Expand Down Expand Up @@ -452,6 +446,17 @@ contract L1MessageQueue is OwnableUpgradeable, IL1MessageQueue {
emit UpdateMaxGasLimit(_oldMaxGasLimit, _newMaxGasLimit);
}

function appendHashes(uint256 _fromQueueIndex, bytes32[] memory _hashes) external {
require(_fromQueueIndex == messageQueue.length, "messageQueue index mismatch");
for (uint256 i = 0; i < _hashes.length; i++) {
messageQueue.push(_hashes[i]);
}
}

function setPendingQueueIndex(uint256 index) external {
pendingQueueIndex = index;
}

/**********************
* Internal Functions *
**********************/
Expand Down

0 comments on commit ad2bd4d

Please sign in to comment.