diff --git a/scripts/foundry/DeployL1BridgeContracts.s.sol b/scripts/foundry/DeployL1BridgeContracts.s.sol index 2733f47..827db49 100644 --- a/scripts/foundry/DeployL1BridgeContracts.s.sol +++ b/scripts/foundry/DeployL1BridgeContracts.s.sol @@ -96,7 +96,7 @@ contract DeployL1BridgeContracts is Script { address[] memory _verifiers = new address[](1); _versions[0] = 0; _verifiers[0] = address(zkEvmVerifierV1); - rollupVerifier = new MultipleVersionRollupVerifier(L1_SCROLL_CHAIN_PROXY_ADDR, _versions, _verifiers); + rollupVerifier = new MultipleVersionRollupVerifier(_versions, _verifiers); logAddress("L1_MULTIPLE_VERSION_ROLLUP_VERIFIER_ADDR", address(rollupVerifier)); } diff --git a/src/L1/rollup/MultipleVersionRollupVerifier.sol b/src/L1/rollup/MultipleVersionRollupVerifier.sol index 7c6a72b..eba5e14 100644 --- a/src/L1/rollup/MultipleVersionRollupVerifier.sol +++ b/src/L1/rollup/MultipleVersionRollupVerifier.sol @@ -4,7 +4,6 @@ pragma solidity =0.8.24; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -import {IScrollChain} from "./IScrollChain.sol"; import {IRollupVerifier} from "../../libraries/verifier/IRollupVerifier.sol"; import {IZkEvmVerifier} from "../../libraries/verifier/IZkEvmVerifier.sol"; @@ -28,19 +27,9 @@ contract MultipleVersionRollupVerifier is IRollupVerifier, Ownable { /// @dev Thrown when the given address is `address(0)`. error ErrorZeroAddress(); - /// @dev Thrown when the given start batch index is finalized. - error ErrorStartBatchIndexFinalized(); - /// @dev Thrown when the given start batch index is smaller than `latestVerifier.startBatchIndex`. error ErrorStartBatchIndexTooSmall(); - /************* - * Constants * - *************/ - - /// @notice The address of ScrollChain contract. - address public immutable scrollChain; - /*********** * Structs * ***********/ @@ -67,14 +56,7 @@ contract MultipleVersionRollupVerifier is IRollupVerifier, Ownable { * Constructor * ***************/ - constructor( - address _scrollChain, - uint256[] memory _versions, - address[] memory _verifiers - ) { - if (_scrollChain == address(0)) revert ErrorZeroAddress(); - scrollChain = _scrollChain; - + constructor(uint256[] memory _versions, address[] memory _verifiers) { for (uint256 i = 0; i < _versions.length; i++) { if (_verifiers[i] == address(0)) revert ErrorZeroAddress(); latestVerifier[_versions[i]].verifier = _verifiers[i]; @@ -157,8 +139,11 @@ contract MultipleVersionRollupVerifier is IRollupVerifier, Ownable { uint64 _startBatchIndex, address _verifier ) external onlyOwner { - if (_startBatchIndex <= IScrollChain(scrollChain).lastFinalizedBatchIndex()) - revert ErrorStartBatchIndexFinalized(); + // We are using version to decide the verifier to use and also this function is + // controlled by 7 days TimeLock. It is hard to predict `lastFinalizedBatchIndex` after 7 days. + // So we decide to remove this check to make verifier updating more easier. + // if (_startBatchIndex <= IScrollChain(scrollChain).lastFinalizedBatchIndex()) + // revert ErrorStartBatchIndexFinalized(); Verifier memory _latestVerifier = latestVerifier[_version]; if (_startBatchIndex < _latestVerifier.startBatchIndex) revert ErrorStartBatchIndexTooSmall(); diff --git a/src/test/MultipleVersionRollupVerifier.t.sol b/src/test/MultipleVersionRollupVerifier.t.sol index cd9a168..878c3e5 100644 --- a/src/test/MultipleVersionRollupVerifier.t.sol +++ b/src/test/MultipleVersionRollupVerifier.t.sol @@ -18,19 +18,17 @@ contract MultipleVersionRollupVerifierTest is DSTestPlus { MockZkEvmVerifier private v0; MockZkEvmVerifier private v1; MockZkEvmVerifier private v2; - MockScrollChain private chain; function setUp() external { v0 = new MockZkEvmVerifier(); v1 = new MockZkEvmVerifier(); v2 = new MockZkEvmVerifier(); - chain = new MockScrollChain(address(1), address(1)); uint256[] memory _versions = new uint256[](1); address[] memory _verifiers = new address[](1); _versions[0] = 0; _verifiers[0] = address(v0); - verifier = new MultipleVersionRollupVerifier(address(chain), _versions, _verifiers); + verifier = new MultipleVersionRollupVerifier(_versions, _verifiers); } function testUpdateVerifierVersion0(address _newVerifier) external { @@ -42,10 +40,6 @@ contract MultipleVersionRollupVerifierTest is DSTestPlus { verifier.updateVerifier(0, 0, address(0)); hevm.stopPrank(); - // start batch index finalized, revert - hevm.expectRevert(MultipleVersionRollupVerifier.ErrorStartBatchIndexFinalized.selector); - verifier.updateVerifier(0, 0, address(1)); - // zero verifier address, revert hevm.expectRevert(MultipleVersionRollupVerifier.ErrorZeroAddress.selector); verifier.updateVerifier(0, 1, address(0)); @@ -93,10 +87,6 @@ contract MultipleVersionRollupVerifierTest is DSTestPlus { verifier.updateVerifier(version, 0, address(0)); hevm.stopPrank(); - // start batch index finalized, revert - hevm.expectRevert(MultipleVersionRollupVerifier.ErrorStartBatchIndexFinalized.selector); - verifier.updateVerifier(version, 0, address(1)); - // zero verifier address, revert hevm.expectRevert(MultipleVersionRollupVerifier.ErrorZeroAddress.selector); verifier.updateVerifier(version, 1, address(0));