Skip to content

Commit

Permalink
add enforced batch in ScrollChain
Browse files Browse the repository at this point in the history
  • Loading branch information
zimpha committed Jan 16, 2024
1 parent 317ba26 commit fc3dc8d
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 145 deletions.
76 changes: 74 additions & 2 deletions contracts/docs/apis/ScrollChain.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,28 @@ Add an account to the sequencer list.
|---|---|---|
| _account | address | The address of account to add. |

### commitAndFinalizeBatchEnforced

```solidity
function commitAndFinalizeBatchEnforced(bytes _parentBatchHeader, bytes[] _chunks, bytes _skippedL1MessageBitmap, bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes _withdrawRootProof, bytes _aggrProof) external nonpayable
```

Commit and finalize enforced batch.

*This function can by used to commit and finalize a new batch in a single step if all previous batches are finalized. It can also be used to finalize the earliest pending batch. In this case, the provided batch should match the pending batch. If user choose to finalize a pending batch, the batch hash of current header should match with `committedBatches[currentIndex]`. Otherwise, `committedBatches[currentIndex]` should be `bytes32(0)`.*

#### Parameters

| Name | Type | Description |
|---|---|---|
| _parentBatchHeader | bytes | undefined |
| _chunks | bytes[] | undefined |
| _skippedL1MessageBitmap | bytes | undefined |
| _postStateRoot | bytes32 | undefined |
| _withdrawRoot | bytes32 | undefined |
| _withdrawRootProof | bytes | undefined |
| _aggrProof | bytes | undefined |

### commitBatch

```solidity
Expand Down Expand Up @@ -86,7 +108,7 @@ Return the batch hash of a committed batch.
### finalizeBatchWithProof

```solidity
function finalizeBatchWithProof(bytes _batchHeader, bytes32 _prevStateRoot, bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes _aggrProof) external nonpayable
function finalizeBatchWithProof(bytes _batchHeader, bytes32, bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes _aggrProof) external nonpayable
```

Finalize a committed batch on layer 1.
Expand All @@ -98,7 +120,7 @@ Finalize a committed batch on layer 1.
| Name | Type | Description |
|---|---|---|
| _batchHeader | bytes | undefined |
| _prevStateRoot | bytes32 | undefined |
| _1 | bytes32 | undefined |
| _postStateRoot | bytes32 | undefined |
| _withdrawRoot | bytes32 | undefined |
| _aggrProof | bytes | undefined |
Expand Down Expand Up @@ -160,6 +182,22 @@ Initialize the storage of ScrollChain.
| _verifier | address | The address of zkevm verifier contract. |
| _maxNumTxInChunk | uint256 | The maximum number of transactions allowed in each chunk. |

### initializeV2

```solidity
function initializeV2(address _zkTrieVerifier) external nonpayable
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| _zkTrieVerifier | address | undefined |

### isBatchFinalized

```solidity
Expand Down Expand Up @@ -260,6 +298,23 @@ The chain id of the corresponding layer 2 chain.
|---|---|---|
| _0 | uint64 | undefined |

### maxFinalizationDelay

```solidity
function maxFinalizationDelay() external view returns (uint256)
```

The maximum finalization delay in seconds before entering the enforced mode.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | undefined |

### maxNumTxInChunk

```solidity
Expand Down Expand Up @@ -475,6 +530,23 @@ Return the message root of a committed batch.
|---|---|---|
| _0 | bytes32 | undefined |

### zkTrieVerifier

```solidity
function zkTrieVerifier() external view returns (address)
```

The address of zk trie verifier.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | address | undefined |



## Events
Expand Down
19 changes: 19 additions & 0 deletions contracts/src/L1/rollup/IScrollChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,23 @@ interface IScrollChain {
bytes32 withdrawRoot,
bytes calldata aggrProof
) external;

/// @notice Commit and finalize enforced batch.
///
/// @param parentBatchHeader The header of parent batch, see the comments of `BatchHeaderV0Codec`.
/// @param chunks The list of encoded chunks, see the comments of `ChunkCodec`.
/// @param skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not.
/// @param postStateRoot The state root of current batch.
/// @param withdrawRoot The withdraw trie root of current batch.
/// @param withdrawRootProof The proof used to verify the correctness of `withdrawRoot`.
/// @param aggrProof The aggregation proof for current batch.
function commitAndFinalizeBatchEnforced(
bytes calldata parentBatchHeader,
bytes[] memory chunks,
bytes calldata skippedL1MessageBitmap,
bytes32 postStateRoot,
bytes32 withdrawRoot,
bytes calldata withdrawRootProof,
bytes calldata aggrProof
) external;
}
Loading

0 comments on commit fc3dc8d

Please sign in to comment.