@@ -10,7 +10,6 @@ contract ZenithTest is Test {
10
10
Zenith.BlockHeader header;
11
11
bytes32 commit;
12
12
/// @dev blockData is ignored by the contract. it's included for the purpose of DA for the node.
13
- bytes32 blockDataHash;
14
13
bytes blockData = "" ;
15
14
16
15
uint256 sequencerKey = 123 ;
@@ -36,37 +35,36 @@ contract ZenithTest is Test {
36
35
header.confirmBy = block .timestamp + 10 minutes ;
37
36
header.gasLimit = 30_000_000 ;
38
37
header.rewardAddress = address (this );
39
-
40
- blockDataHash = keccak256 (blockData);
38
+ header.blockDataHash = keccak256 (blockData);
41
39
42
40
// derive block commitment from the header
43
- commit = target.blockCommitment (header, blockDataHash );
41
+ commit = target.blockCommitment (header);
44
42
}
45
43
46
44
// cannot submit block with incorrect sequence number
47
45
function test_badSequence () public {
48
46
// change to incorrect sequence number
49
47
header.sequence = 100 ;
50
- commit = target.blockCommitment (header, blockDataHash );
48
+ commit = target.blockCommitment (header);
51
49
52
50
// sign block commitmenet with sequencer key
53
51
(uint8 v , bytes32 r , bytes32 s ) = vm.sign (sequencerKey, commit);
54
52
55
53
vm.expectRevert (abi.encodeWithSelector (Zenith.BadSequence.selector , 1 ));
56
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
54
+ target.submitBlock (header, v, r, s, blockData);
57
55
}
58
56
59
57
// cannot submit block with expired confirmBy time
60
58
function test_blockExpired () public {
61
59
// change to expired confirmBy time
62
60
header.confirmBy = block .timestamp - 1 ;
63
- commit = target.blockCommitment (header, blockDataHash );
61
+ commit = target.blockCommitment (header);
64
62
65
63
// sign block commitmenet with sequencer key
66
64
(uint8 v , bytes32 r , bytes32 s ) = vm.sign (sequencerKey, commit);
67
65
68
66
vm.expectRevert (abi.encodeWithSelector (Zenith.BlockExpired.selector ));
69
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
67
+ target.submitBlock (header, v, r, s, blockData);
70
68
}
71
69
72
70
// can submit block successfully with acceptable header & correct signature provided
@@ -83,9 +81,9 @@ contract ZenithTest is Test {
83
81
header.confirmBy,
84
82
header.gasLimit,
85
83
header.rewardAddress,
86
- blockDataHash
84
+ header. blockDataHash
87
85
);
88
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
86
+ target.submitBlock (header, v, r, s, blockData);
89
87
90
88
// should increment sequence number
91
89
assertEq (target.nextSequence (header.rollupChainId), header.sequence + 1 );
@@ -97,7 +95,7 @@ contract ZenithTest is Test {
97
95
(uint8 v , bytes32 r , bytes32 s ) = vm.sign (notSequencerKey, commit);
98
96
99
97
vm.expectRevert (abi.encodeWithSelector (Zenith.BadSignature.selector , vm.addr (notSequencerKey)));
100
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
98
+ target.submitBlock (header, v, r, s, blockData);
101
99
}
102
100
103
101
// cannot submit block with sequencer signature over different block header data
@@ -107,11 +105,11 @@ contract ZenithTest is Test {
107
105
108
106
// change header data from what was signed by sequencer
109
107
header.confirmBy = block .timestamp + 15 minutes ;
110
- bytes32 newCommit = target.blockCommitment (header, blockDataHash );
108
+ bytes32 newCommit = target.blockCommitment (header);
111
109
address derivedSigner = ecrecover (newCommit, v, r, s);
112
110
113
111
vm.expectRevert (abi.encodeWithSelector (Zenith.BadSignature.selector , derivedSigner));
114
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
112
+ target.submitBlock (header, v, r, s, blockData);
115
113
}
116
114
117
115
// cannot submit two rollup blocks within one host block
@@ -128,18 +126,18 @@ contract ZenithTest is Test {
128
126
header.confirmBy,
129
127
header.gasLimit,
130
128
header.rewardAddress,
131
- blockDataHash
129
+ header. blockDataHash
132
130
);
133
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
131
+ target.submitBlock (header, v, r, s, blockData);
134
132
135
133
// incerement the header sequence
136
134
header.sequence += 1 ;
137
- commit = target.blockCommitment (header, blockDataHash );
135
+ commit = target.blockCommitment (header);
138
136
(v, r, s) = vm.sign (sequencerKey, commit);
139
137
140
138
// should revert with OneRollupBlockPerHostBlock
141
139
// (NOTE: this test works because forge does not increment block.number when it mines a transaction)
142
140
vm.expectRevert (abi.encodeWithSelector (Zenith.OneRollupBlockPerHostBlock.selector ));
143
- target.submitBlock (header, blockDataHash, v, r, s, blockData);
141
+ target.submitBlock (header, v, r, s, blockData);
144
142
}
145
143
}
0 commit comments