Skip to content

Commit ca7f076

Browse files
authored
feat: import change from scroll-tech/scroll#1372 (#3)
1 parent 9e4e333 commit ca7f076

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

scripts/foundry/DeployL1BridgeContracts.s.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ contract DeployL1BridgeContracts is Script {
9696
address[] memory _verifiers = new address[](1);
9797
_versions[0] = 0;
9898
_verifiers[0] = address(zkEvmVerifierV1);
99-
rollupVerifier = new MultipleVersionRollupVerifier(L1_SCROLL_CHAIN_PROXY_ADDR, _versions, _verifiers);
99+
rollupVerifier = new MultipleVersionRollupVerifier(_versions, _verifiers);
100100

101101
logAddress("L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR", address(rollupVerifier));
102102
}

src/L1/rollup/MultipleVersionRollupVerifier.sol

+6-21
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pragma solidity =0.8.24;
44

55
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
66

7-
import {IScrollChain} from "./IScrollChain.sol";
87
import {IRollupVerifier} from "../../libraries/verifier/IRollupVerifier.sol";
98
import {IZkEvmVerifier} from "../../libraries/verifier/IZkEvmVerifier.sol";
109

@@ -28,19 +27,9 @@ contract MultipleVersionRollupVerifier is IRollupVerifier, Ownable {
2827
/// @dev Thrown when the given address is `address(0)`.
2928
error ErrorZeroAddress();
3029

31-
/// @dev Thrown when the given start batch index is finalized.
32-
error ErrorStartBatchIndexFinalized();
33-
3430
/// @dev Thrown when the given start batch index is smaller than `latestVerifier.startBatchIndex`.
3531
error ErrorStartBatchIndexTooSmall();
3632

37-
/*************
38-
* Constants *
39-
*************/
40-
41-
/// @notice The address of ScrollChain contract.
42-
address public immutable scrollChain;
43-
4433
/***********
4534
* Structs *
4635
***********/
@@ -67,14 +56,7 @@ contract MultipleVersionRollupVerifier is IRollupVerifier, Ownable {
6756
* Constructor *
6857
***************/
6958

70-
constructor(
71-
address _scrollChain,
72-
uint256[] memory _versions,
73-
address[] memory _verifiers
74-
) {
75-
if (_scrollChain == address(0)) revert ErrorZeroAddress();
76-
scrollChain = _scrollChain;
77-
59+
constructor(uint256[] memory _versions, address[] memory _verifiers) {
7860
for (uint256 i = 0; i < _versions.length; i++) {
7961
if (_verifiers[i] == address(0)) revert ErrorZeroAddress();
8062
latestVerifier[_versions[i]].verifier = _verifiers[i];
@@ -157,8 +139,11 @@ contract MultipleVersionRollupVerifier is IRollupVerifier, Ownable {
157139
uint64 _startBatchIndex,
158140
address _verifier
159141
) external onlyOwner {
160-
if (_startBatchIndex <= IScrollChain(scrollChain).lastFinalizedBatchIndex())
161-
revert ErrorStartBatchIndexFinalized();
142+
// We are using version to decide the verifier to use and also this function is
143+
// controlled by 7 days TimeLock. It is hard to predict `lastFinalizedBatchIndex` after 7 days.
144+
// So we decide to remove this check to make verifier updating more easier.
145+
// if (_startBatchIndex <= IScrollChain(scrollChain).lastFinalizedBatchIndex())
146+
// revert ErrorStartBatchIndexFinalized();
162147

163148
Verifier memory _latestVerifier = latestVerifier[_version];
164149
if (_startBatchIndex < _latestVerifier.startBatchIndex) revert ErrorStartBatchIndexTooSmall();

src/test/MultipleVersionRollupVerifier.t.sol

+1-11
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@ contract MultipleVersionRollupVerifierTest is DSTestPlus {
1818
MockZkEvmVerifier private v0;
1919
MockZkEvmVerifier private v1;
2020
MockZkEvmVerifier private v2;
21-
MockScrollChain private chain;
2221

2322
function setUp() external {
2423
v0 = new MockZkEvmVerifier();
2524
v1 = new MockZkEvmVerifier();
2625
v2 = new MockZkEvmVerifier();
2726

28-
chain = new MockScrollChain(address(1), address(1));
2927
uint256[] memory _versions = new uint256[](1);
3028
address[] memory _verifiers = new address[](1);
3129
_versions[0] = 0;
3230
_verifiers[0] = address(v0);
33-
verifier = new MultipleVersionRollupVerifier(address(chain), _versions, _verifiers);
31+
verifier = new MultipleVersionRollupVerifier(_versions, _verifiers);
3432
}
3533

3634
function testUpdateVerifierVersion0(address _newVerifier) external {
@@ -42,10 +40,6 @@ contract MultipleVersionRollupVerifierTest is DSTestPlus {
4240
verifier.updateVerifier(0, 0, address(0));
4341
hevm.stopPrank();
4442

45-
// start batch index finalized, revert
46-
hevm.expectRevert(MultipleVersionRollupVerifier.ErrorStartBatchIndexFinalized.selector);
47-
verifier.updateVerifier(0, 0, address(1));
48-
4943
// zero verifier address, revert
5044
hevm.expectRevert(MultipleVersionRollupVerifier.ErrorZeroAddress.selector);
5145
verifier.updateVerifier(0, 1, address(0));
@@ -93,10 +87,6 @@ contract MultipleVersionRollupVerifierTest is DSTestPlus {
9387
verifier.updateVerifier(version, 0, address(0));
9488
hevm.stopPrank();
9589

96-
// start batch index finalized, revert
97-
hevm.expectRevert(MultipleVersionRollupVerifier.ErrorStartBatchIndexFinalized.selector);
98-
verifier.updateVerifier(version, 0, address(1));
99-
10090
// zero verifier address, revert
10191
hevm.expectRevert(MultipleVersionRollupVerifier.ErrorZeroAddress.selector);
10292
verifier.updateVerifier(version, 1, address(0));

0 commit comments

Comments
 (0)