Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct GatewayCTMDeployerConfig {
uint256 protocolVersion;
/// @notice Whether the chain is ZKsyncOS.
bool isZKsyncOS;
/// @notice Default execution version(derived from circuits and zksync os version).
uint32 executionVersion;
}

/// @notice Addresses of state transition related contracts.
Expand Down Expand Up @@ -189,7 +191,13 @@ contract GatewayCTMDeployer {
_isZKsyncOS: _config.isZKsyncOS,
_deployedContracts: contracts
});
_deployVerifier(salt, _config.testnetVerifier, contracts, _config.aliasedGovernanceAddress);
_deployVerifier({
_salt: salt,
_version: _config.executionVersion,
_testnetVerifier: _config.testnetVerifier,
_deployedContracts: contracts,
_verifierOwner: _config.aliasedGovernanceAddress
});

_deployProxyAdmin(salt, _config.aliasedGovernanceAddress, contracts);

Expand Down Expand Up @@ -304,6 +312,7 @@ contract GatewayCTMDeployer {
/// in the process of the execution of this function.
function _deployVerifier(
bytes32 _salt,
uint32 _version,
bool _testnetVerifier,
DeployedContracts memory _deployedContracts,
address _verifierOwner
Expand All @@ -314,11 +323,11 @@ contract GatewayCTMDeployer {
_deployedContracts.stateTransition.verifierPlonk = address(verifierPlonk);
if (_testnetVerifier) {
_deployedContracts.stateTransition.verifier = address(
new TestnetVerifier{salt: _salt}(fflonkVerifier, verifierPlonk, _verifierOwner)
new TestnetVerifier{salt: _salt}(_version, fflonkVerifier, verifierPlonk, _verifierOwner)
);
} else {
_deployedContracts.stateTransition.verifier = address(
new DualVerifier{salt: _salt}(fflonkVerifier, verifierPlonk, _verifierOwner)
new DualVerifier{salt: _salt}(_version, fflonkVerifier, verifierPlonk, _verifierOwner)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ contract DualVerifier is IVerifier {
/// @param _fflonkVerifier The address of the FFLONK verifier contract.
/// @param _plonkVerifier The address of the PLONK verifier contract.
/// @param _ctmOwner The address of the contract owner, who can add or remove verifiers.
constructor(IVerifierV2 _fflonkVerifier, IVerifier _plonkVerifier, address _ctmOwner) {
constructor(uint32 _version, IVerifierV2 _fflonkVerifier, IVerifier _plonkVerifier, address _ctmOwner) {
ctmOwner = _ctmOwner;
fflonkVerifiers[0] = _fflonkVerifier;
plonkVerifiers[0] = _plonkVerifier;
fflonkVerifiers[_version] = _fflonkVerifier;
plonkVerifiers[_version] = _plonkVerifier;
}

function addVerifier(uint32 version, IVerifierV2 _fflonkVerifier, IVerifier _plonkVerifier) external {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import {IVerifier} from "../chain-interfaces/IVerifier.sol";
/// otherwise, it will skip the verification.
contract TestnetVerifier is DualVerifier {
constructor(
uint32 _version,
IVerifierV2 _fflonkVerifier,
IVerifier _plonkVerifier,
address _ctmOwner
) DualVerifier(_fflonkVerifier, _plonkVerifier, _ctmOwner) {
) DualVerifier(_version, _fflonkVerifier, _plonkVerifier, _ctmOwner) {
assert(block.chainid != 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ owner_address = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
testnet_verifier = true
support_l2_legacy_shared_bridge_test = false
is_zk_sync_os = true
execution_version = 2

[gateway]
chain_id = 123
Expand Down
3 changes: 3 additions & 0 deletions l1-contracts/deploy-scripts/DeployUtils.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct Config {
bool testnetVerifier;
bool supportL2LegacySharedBridgeTest;
bool isZKsyncOS;
uint32 executionVersion;
ContractsConfig contracts;
TokensConfig tokens;
}
Expand Down Expand Up @@ -141,6 +142,7 @@ abstract contract DeployUtils is Create2FactoryUtils {
config.testnetVerifier = toml.readBool("$.testnet_verifier");
config.supportL2LegacySharedBridgeTest = toml.readBool("$.support_l2_legacy_shared_bridge_test");
config.isZKsyncOS = toml.readBool("$.is_zk_sync_os");
config.executionVersion = uint32(toml.readUint("$.execution_version"));

config.contracts.governanceSecurityCouncilAddress = toml.readAddress(
"$.contracts.governance_security_council_address"
Expand Down Expand Up @@ -421,6 +423,7 @@ abstract contract DeployUtils is Create2FactoryUtils {
/// In practice we might want to set it to CTM owner (which in production will be less restritive).
return
abi.encode(
config.executionVersion,
addresses.stateTransition.verifierFflonk,
addresses.stateTransition.verifierPlonk,
config.ownerAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ library GatewayCTMDeployerHelper {
contracts,
innerConfig
);
contracts = _deployVerifier(config.testnetVerifier, contracts, innerConfig, config.aliasedGovernanceAddress);
contracts = _deployVerifier(
config.testnetVerifier,
contracts,
innerConfig,
config.executionVersion,
config.aliasedGovernanceAddress
);

contracts.stateTransition.validatorTimelockImplementation = _deployInternal(
"ValidatorTimelock",
Expand Down Expand Up @@ -190,6 +196,7 @@ library GatewayCTMDeployerHelper {
bool _testnetVerifier,
DeployedContracts memory _deployedContracts,
InnerDeployConfig memory innerConfig,
uint32 _version,
address _verifierOwner
) internal returns (DeployedContracts memory) {
address verifierFflonk = _deployInternal("L1VerifierFflonk", "L1VerifierFflonk.sol", hex"", innerConfig);
Expand All @@ -198,7 +205,7 @@ library GatewayCTMDeployerHelper {
_deployedContracts.stateTransition.verifierFflonk = verifierFflonk;
_deployedContracts.stateTransition.verifierPlonk = verifierPlonk;

bytes memory constructorParams = abi.encode(verifierFflonk, verifierPlonk, _verifierOwner);
bytes memory constructorParams = abi.encode(_version, verifierFflonk, verifierPlonk, _verifierOwner);

if (_testnetVerifier) {
_deployedContracts.stateTransition.verifier = _deployInternal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ contract GatewayCTMFromL1 is Script {
forceDeploymentsData: config.forceDeploymentsData,
protocolVersion: config.latestProtocolVersion,
// TODO: for now, zksync os on gateway is not supported
isZKsyncOS: false
isZKsyncOS: false,
executionVersion: 0
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ contract GatewayVotePreparation is DeployCTMScript, GatewayGovernanceUtils {
forceDeploymentsData: forceDeploymentsData,
protocolVersion: config.contracts.latestProtocolVersion,
// TODO: for now, zksync os on gateway is not supported
isZKsyncOS: false
isZKsyncOS: false,
executionVersion: 0
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ owner_address = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
testnet_verifier = true
support_l2_legacy_shared_bridge_test = false
is_zk_sync_os = true
execution_version = 2

[gateway]
chain_id = 123
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract ExecutorProofTest is Test {
UtilsFacet internal utilsFacet;
TestExecutorFacet internal executor;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));

function getTestExecutorFacetSelectors() private pure returns (bytes4[] memory) {
bytes4[] memory selectors = new bytes4[](3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ contract ExecutorTest is Test {
commitment: bytes32("")
});
TestnetVerifier testnetVerifier = new TestnetVerifier(
0,
IVerifierV2(address(0)),
IVerifier(address(0)),
address(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract ChainTypeManagerTest is Test {
uint256 l1ChainId = 5;
uint256 chainId = 112;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
bytes internal forceDeploymentsData = hex"";

uint256 eraChainId = 9;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {IVerifier} from "contracts/state-transition/chain-interfaces/IVerifier.s
contract DiamondInitTest is Test {
Diamond.FacetCut[] internal facetCuts;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));

function setUp() public virtual {
facetCuts.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract TestFacet is ZKChainBase {
contract DiamondProxyTest is Test {
Diamond.FacetCut[] internal facetCuts;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));

function getTestFacetSelectors() public pure returns (bytes4[] memory selectors) {
selectors = new bytes4[](1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract AdminTest is Test {
IAdmin internal adminFacet;
UtilsFacet internal utilsFacet;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));

function getAdminSelectors() public pure returns (bytes4[] memory) {
bytes4[] memory selectors = new bytes4[](13);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract ZKChainBaseTest is Test {
TestBaseFacet internal testBaseFacet;
UtilsFacet internal utilsFacet;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));

function getTestBaseFacetSelectors() public pure returns (bytes4[] memory selectors) {
selectors = new bytes4[](6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract MailboxTest is Test {
address sender;
uint256 constant eraChainId = 9;
address internal testnetVerifier =
address(new TestnetVerifier(IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address(new TestnetVerifier(0, IVerifierV2(address(0)), IVerifier(address(0)), address(0)));
address diamondProxy;
address bridgehub;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract SharedL2ContractL2Deployer is SharedL2ContractDeployer {
instantiateCreate2Factory();
addresses.stateTransition.genesisUpgrade = address(new L1GenesisUpgrade());
addresses.stateTransition.verifier = address(
new TestnetVerifier(IVerifierV2(ADDRESS_ONE), IVerifier(ADDRESS_ONE), address(0))
new TestnetVerifier(0, IVerifierV2(ADDRESS_ONE), IVerifier(ADDRESS_ONE), address(0))
);
uint32 executionDelay = uint32(config.contracts.validatorTimelockExecutionDelay);
addresses.stateTransition.validatorTimelock = address(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ contract GatewayCTMDeployerTest is Test {
new L1VerifierFflonk();
new L1VerifierPlonk();

new TestnetVerifier(L1VerifierFflonk(address(0)), L1VerifierPlonk(address(0)), address(0));
new DualVerifier(L1VerifierFflonk(address(0)), L1VerifierPlonk(address(0)), address(0));
new TestnetVerifier(0, L1VerifierFflonk(address(0)), L1VerifierPlonk(address(0)), address(0));
new DualVerifier(0, L1VerifierFflonk(address(0)), L1VerifierPlonk(address(0)), address(0));

new ValidatorTimelock(L2_BRIDGEHUB_ADDR);
new ServerNotifier();
Expand Down Expand Up @@ -120,7 +120,9 @@ contract GatewayCTMDeployerTest is Test {
genesisBatchCommitment: bytes32(uint256(0x456)),
forceDeploymentsData: hex"deadbeef",
protocolVersion: 1,
isZKsyncOS: false
// TODO: we don't support zksync os on the gateway
isZKsyncOS: false,
executionVersion: 0
});

// Initialize selectors with sample function selectors
Expand Down
Loading