Skip to content

Commit 48dc533

Browse files
authored
fix: allow only top level call in commitAndFinalizeBatch (#126)
1 parent 7309489 commit 48dc533

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/L1/rollup/ScrollChain.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
198198

199199
modifier OnlyTopLevelCall() {
200200
// disallow contract accounts and delegated EOAs
201-
if (msg.sender.code.length != 0) revert ErrorTopLevelCallRequired();
201+
if (msg.sender != tx.origin || msg.sender.code.length != 0) {
202+
revert ErrorTopLevelCallRequired();
203+
}
202204
_;
203205
}
204206

src/test/ScrollChain.t.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ contract ScrollChainTest is DSTestPlus {
339339

340340
// revert when ErrorNotInEnforcedBatchMode
341341
hevm.expectRevert(ScrollChain.ErrorNotInEnforcedBatchMode.selector);
342-
hevm.startPrank(address(999));
342+
hevm.startPrank(address(0x00a329c0648769A73afAc7F9381E08FB43dBEA72));
343343
rollup.commitAndFinalizeBatch(
344344
7,
345345
bytes32(0),
@@ -372,7 +372,7 @@ contract ScrollChainTest is DSTestPlus {
372372
// succeed to call commitAndFinalizeBatch 13
373373
ScrollChainMockBlob(address(rollup)).setBlobVersionedHash(0, blobVersionedHash);
374374
ScrollChainMockBlob(address(rollup)).setBlobVersionedHash(1, bytes32(0));
375-
hevm.startPrank(address(999));
375+
hevm.startPrank(address(0x00a329c0648769A73afAc7F9381E08FB43dBEA72));
376376
rollup.commitAndFinalizeBatch(
377377
7,
378378
keccak256(headers[12]),
@@ -410,7 +410,7 @@ contract ScrollChainTest is DSTestPlus {
410410
// succeed to call commitAndFinalizeBatch 14, no need to warp time
411411
ScrollChainMockBlob(address(rollup)).setBlobVersionedHash(0, blobVersionedHash);
412412
ScrollChainMockBlob(address(rollup)).setBlobVersionedHash(1, bytes32(0));
413-
hevm.startPrank(address(999));
413+
hevm.startPrank(address(0x00a329c0648769A73afAc7F9381E08FB43dBEA72));
414414
rollup.commitAndFinalizeBatch(
415415
7,
416416
keccak256(headers[13]),
@@ -442,7 +442,7 @@ contract ScrollChainTest is DSTestPlus {
442442

443443
// not in enforced mode
444444
hevm.expectRevert(ScrollChain.ErrorNotInEnforcedBatchMode.selector);
445-
hevm.startPrank(address(999));
445+
hevm.startPrank(address(0x00a329c0648769A73afAc7F9381E08FB43dBEA72));
446446
rollup.commitAndFinalizeBatch(
447447
7,
448448
keccak256(headers[13]),
@@ -489,7 +489,7 @@ contract ScrollChainTest is DSTestPlus {
489489

490490
// revert when ErrorNotInEnforcedBatchMode
491491
hevm.expectRevert(ScrollChain.ErrorNotInEnforcedBatchMode.selector);
492-
hevm.startPrank(address(999));
492+
hevm.startPrank(address(0x00a329c0648769A73afAc7F9381E08FB43dBEA72));
493493
rollup.commitAndFinalizeBatch(
494494
7,
495495
bytes32(0),
@@ -514,7 +514,7 @@ contract ScrollChainTest is DSTestPlus {
514514
// succeed to call commitAndFinalizeBatch 13
515515
ScrollChainMockBlob(address(rollup)).setBlobVersionedHash(0, blobVersionedHash);
516516
ScrollChainMockBlob(address(rollup)).setBlobVersionedHash(1, bytes32(0));
517-
hevm.startPrank(address(999));
517+
hevm.startPrank(address(0x00a329c0648769A73afAc7F9381E08FB43dBEA72));
518518
rollup.commitAndFinalizeBatch(
519519
7,
520520
keccak256(headers[12]),

0 commit comments

Comments
 (0)