Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verifier upgrade task #578

Merged
merged 5 commits into from
Oct 16, 2024
Merged
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
1 change: 1 addition & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "./tasks/check"
import "./tasks/query"
import "./tasks/proxy_upgrade"
import "./tasks/staking_upgrade"
import "./tasks/verifier_upgrade"
import "./src/plugin"
import * as process from "process";

Expand Down
35 changes: 35 additions & 0 deletions contracts/tasks/verifier_upgrade.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import "@nomiclabs/hardhat-web3";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";

import { task } from "hardhat/config";
import { ContractFactoryName } from "../src/types";

// yarn hardhat upgradeVerifier --rollupVersion 0 --startBatchIndex 0 --multipleVersionRollupVerifier 0x0165878a594ca255338adfa4d48449f69242eb8f --network l1
task("upgradeVerifier")
.addParam("rollupVersion")
.addParam("startBatchIndex")
.addParam("multipleVersionRollupVerifier")
.setAction(async (taskArgs, hre) => {
const config = hre.deployConfig

// deploy ZkEvmVerifierV1
const ZkEvmVerifierV1ContractFactoryName = ContractFactoryName.ZkEvmVerifierV1
const Factory = await hre.ethers.getContractFactory(ZkEvmVerifierV1ContractFactoryName)
const contract = await Factory.deploy(config.programVkey)
await contract.deployed()
console.log("ZkEvmVerifierV1Contract: %s ; TX_HASH: %s", contract.address.toLocaleLowerCase(), contract.deployTransaction.hash);
let blockNumber = await hre.ethers.provider.getBlockNumber()
console.log("BLOCK_NUMBER: %s", blockNumber)

// add verifier to MultipleVersionRollupVerifier
const MultipleVersionRollupVerifierFactoryName = ContractFactoryName.MultipleVersionRollupVerifier
const MultipleVersionRollupVerifierFactory = await hre.ethers.getContractFactory(MultipleVersionRollupVerifierFactoryName)
const MultipleVersionRollupVerifier = MultipleVersionRollupVerifierFactory.attach(taskArgs.multipleVersionRollupVerifier)

const res = await MultipleVersionRollupVerifier.updateVerifier(taskArgs.rollupVersion, taskArgs.startBatchIndex, contract.address.toLocaleLowerCase())

const receipt = await res.wait()
console.log(`receipt status : ${receipt.status}`)
console.log("upgrade verifier successfully, verifier: %s, rollupVersion: %s, startBatchIndex: %s", contract.address.toLocaleLowerCase(), taskArgs.rollupVersion, taskArgs.startBatchIndex)
});
Loading