-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathScrollChainMockBlob.sol
86 lines (70 loc) · 2.73 KB
/
ScrollChainMockBlob.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
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import {ScrollChain} from "../L1/rollup/ScrollChain.sol";
contract ScrollChainMockBlob is ScrollChain {
mapping(uint256 => bytes32) private blobhashes;
bool overrideBatchHashCheck;
/***************
* Constructor *
***************/
constructor(
uint64 _chainId,
address _messageQueueV1,
address _messageQueueV2,
address _verifier,
address _system
) ScrollChain(_chainId, _messageQueueV1, _messageQueueV2, _verifier, address(_system)) {}
/**********************
* Internal Functions *
**********************/
function setBlobVersionedHash(uint256 index, bytes32 _blobVersionedHash) external {
blobhashes[index] = _blobVersionedHash;
}
function setLastFinalizedBatchIndex(uint256 index) external {
miscData.lastFinalizedBatchIndex = uint64(index);
}
function setFinalizedStateRoots(uint256 index, bytes32 value) external {
finalizedStateRoots[index] = value;
}
function setCommittedBatches(uint256 index, bytes32 value) external {
if (miscData.lastCommittedBatchIndex < index) {
miscData.lastCommittedBatchIndex = uint64(index);
}
committedBatches[index] = value;
}
function setOverrideBatchHashCheck(bool status) external {
overrideBatchHashCheck = status;
}
function _getBlobVersionedHash() internal virtual override returns (bytes32 _blobVersionedHash) {
_blobVersionedHash = blobhashes[0];
}
function _getBlobVersionedHash(uint256 index) internal virtual override returns (bytes32 _blobVersionedHash) {
_blobVersionedHash = blobhashes[index];
}
/// @dev Internal function to load batch header from calldata to memory.
/// @param _batchHeader The batch header in calldata.
/// @return batchPtr The start memory offset of loaded batch header.
/// @return _batchHash The hash of the loaded batch header.
/// @return _batchIndex The index of this batch.
/// @param _totalL1MessagesPoppedOverall The number of L1 messages popped after this batch.
function _loadBatchHeader(bytes calldata _batchHeader, uint256 _lastCommittedBatchIndex)
internal
view
virtual
override
returns (
uint256 batchPtr,
bytes32 _batchHash,
uint256 _batchIndex,
uint256 _totalL1MessagesPoppedOverall
)
{
(batchPtr, _batchHash, _batchIndex, _totalL1MessagesPoppedOverall) = ScrollChain._loadBatchHeader(
_batchHeader,
_lastCommittedBatchIndex
);
if (overrideBatchHashCheck) {
_batchHash = committedBatches[_batchIndex];
}
}
}