@@ -78,6 +78,27 @@ contract RollupTest is DecoderBase {
78
78
_;
79
79
}
80
80
81
+ function testRevertProveTwice () public setUpFor ("mixed_block_1 " ) {
82
+ DecoderBase.Data memory data = load ("mixed_block_1 " ).block;
83
+ bytes memory header = data.header;
84
+ bytes32 archive = data.archive;
85
+ bytes memory body = data.body;
86
+
87
+ // Progress time as necessary
88
+ vm.warp (max (block .timestamp , data.decodedHeader.globalVariables.timestamp));
89
+ availabilityOracle.publish (body);
90
+
91
+ // We jump to the time of the block. (unless it is in the past)
92
+ vm.warp (max (block .timestamp , data.decodedHeader.globalVariables.timestamp));
93
+
94
+ rollup.process (header, archive, bytes32 (0 ));
95
+
96
+ rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
97
+
98
+ vm.expectRevert (abi.encodeWithSelector (Errors.Rollup__NonSequentialProving.selector ));
99
+ rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
100
+ }
101
+
81
102
function testTimestamp () public setUpFor ("mixed_block_1 " ) {
82
103
// Ensure that the timestamp of the current slot is never in the future.
83
104
for (uint256 i = 0 ; i < 100 ; i++ ) {
@@ -105,7 +126,7 @@ contract RollupTest is DecoderBase {
105
126
_testBlock ("mixed_block_1 " , false );
106
127
107
128
uint256 currentSlot = rollup.getCurrentSlot ();
108
- (,, uint128 slot , ) = rollup.blocks (1 );
129
+ (,, uint128 slot ) = rollup.blocks (1 );
109
130
uint256 prunableAt = uint256 (slot) + rollup.TIMELINESS_PROVING_IN_SLOTS ();
110
131
111
132
vm.expectRevert (
@@ -127,7 +148,7 @@ contract RollupTest is DecoderBase {
127
148
// Even if we end up reverting block 1, we should still see the same root in the inbox.
128
149
bytes32 inboxRoot2 = inbox.getRoot (2 );
129
150
130
- (,, uint128 slot , ) = rollup.blocks (1 );
151
+ (,, uint128 slot ) = rollup.blocks (1 );
131
152
uint256 prunableAt = uint256 (slot) + rollup.TIMELINESS_PROVING_IN_SLOTS ();
132
153
133
154
uint256 timeOfPrune = rollup.getTimestampForSlot (prunableAt);
@@ -198,6 +219,14 @@ contract RollupTest is DecoderBase {
198
219
// We jump to the time of the block. (unless it is in the past)
199
220
vm.warp (max (block .timestamp , data.decodedHeader.globalVariables.timestamp));
200
221
222
+ address coinbase = data.decodedHeader.globalVariables.coinbase;
223
+ uint256 coinbaseBalance = portalERC20.balanceOf (coinbase);
224
+ assertEq (coinbaseBalance, 0 , "invalid initial coinbase balance " );
225
+
226
+ // Assert that balance have NOT been increased by proposing the block
227
+ rollup.process (header, archive, bytes32 (0 ));
228
+ assertEq (portalERC20.balanceOf (coinbase), 0 , "invalid coinbase balance " );
229
+
201
230
vm.expectRevert (
202
231
abi.encodeWithSelector (
203
232
IERC20Errors .ERC20InsufficientBalance .selector ,
@@ -206,15 +235,13 @@ contract RollupTest is DecoderBase {
206
235
feeAmount
207
236
)
208
237
);
209
- rollup.process (header, archive, bytes32 (0 ));
210
-
211
- address coinbase = data.decodedHeader.globalVariables.coinbase;
212
- uint256 coinbaseBalance = portalERC20.balanceOf (coinbase);
213
- assertEq (coinbaseBalance, 0 , "invalid initial coinbase balance " );
238
+ rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
239
+ assertEq (portalERC20.balanceOf (coinbase), 0 , "invalid coinbase balance " );
214
240
215
241
portalERC20.mint (address (feeJuicePortal), feeAmount - portalBalance);
216
242
217
- rollup.process (header, archive, bytes32 (0 ));
243
+ // When the block is proven we should have received the funds
244
+ rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
218
245
assertEq (portalERC20.balanceOf (coinbase), feeAmount, "invalid coinbase balance " );
219
246
}
220
247
@@ -237,9 +264,18 @@ contract RollupTest is DecoderBase {
237
264
238
265
function testConsecutiveMixedBlocksNonSequentialProof () public setUpFor ("mixed_block_1 " ) {
239
266
_testBlock ("mixed_block_1 " , false );
240
- _testBlock ("mixed_block_2 " , true );
241
267
242
- assertTrue (rollup.isBlockProven (2 ), "Block 2 is not proven " );
268
+ DecoderBase.Data memory data = load ("mixed_block_2 " ).block;
269
+ bytes memory header = data.header;
270
+ bytes32 archive = data.archive;
271
+ bytes memory body = data.body;
272
+
273
+ vm.warp (max (block .timestamp , data.decodedHeader.globalVariables.timestamp));
274
+ availabilityOracle.publish (body);
275
+ rollup.process (header, archive, bytes32 (0 ));
276
+
277
+ vm.expectRevert (abi.encodeWithSelector (Errors.Rollup__NonSequentialProving.selector ));
278
+ rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
243
279
244
280
assertEq (rollup.pendingBlockCount (), 3 , "Invalid pending block count " );
245
281
assertEq (rollup.provenBlockCount (), 1 , "Invalid proven block count " );
@@ -366,9 +402,8 @@ contract RollupTest is DecoderBase {
366
402
367
403
function testSubmitProofInvalidArchive () public setUpFor ("empty_block_1 " ) {
368
404
_testBlock ("empty_block_1 " , false );
369
- _testBlock ("empty_block_2 " , false );
370
405
371
- DecoderBase.Data memory data = load ("empty_block_2 " ).block;
406
+ DecoderBase.Data memory data = load ("empty_block_1 " ).block;
372
407
bytes memory header = data.header;
373
408
bytes32 archive = data.archive;
374
409
@@ -379,7 +414,7 @@ contract RollupTest is DecoderBase {
379
414
380
415
vm.expectRevert (
381
416
abi.encodeWithSelector (
382
- Errors.Rollup__InvalidArchive.selector , rollup.archiveAt (1 ), 0xdeadbeef
417
+ Errors.Rollup__InvalidArchive.selector , rollup.archiveAt (0 ), 0xdeadbeef
383
418
)
384
419
);
385
420
rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
@@ -433,12 +468,11 @@ contract RollupTest is DecoderBase {
433
468
rollup.process (header, archive, bytes32 (0 ));
434
469
435
470
if (_submitProof) {
471
+ uint256 pre = rollup.provenBlockCount ();
472
+
436
473
rollup.submitBlockRootProof (header, archive, bytes32 (0 ), "" , "" );
437
474
438
- assertTrue (
439
- rollup.isBlockProven (full.block .decodedHeader .globalVariables.blockNumber),
440
- "Block not proven "
441
- );
475
+ assertEq (pre + 1 , rollup.provenBlockCount (), "Block not proven " );
442
476
}
443
477
444
478
bytes32 l2ToL1MessageTreeRoot;
0 commit comments