Deploy verifier with verifier key per network

This commit is contained in:
Mark Spanbroek 2024-01-23 13:56:52 +01:00 committed by markspanbroek
parent 903cdf3541
commit 5d2842c69b
6 changed files with 11 additions and 13 deletions

View File

@ -1,11 +1,9 @@
const { loadVerificationKey } = require ("../verifier/verifier.js")
module.exports = async ({ deployments, getNamedAccounts }) => {
module.exports = async ({ deployments, getNamedAccounts, network }) => {
const { deployer } = await getNamedAccounts()
// TODO: Add logic to deploy specific version of verifier based on the network: network.tags....
// The `contract: ...` part allows to fully specify the contract to be
// deployed even if they are with the same names.
await deployments.deploy("Verifier", { from: deployer, contract: "contracts/verifiers/testing/verifier.sol:Groth16Verifier" })
const verificationKey = loadVerificationKey(network.name)
await deployments.deploy("Groth16Verifier", { args: [verificationKey], from: deployer })
}
module.exports.tags = ["Verifier"]
module.exports.tags = ["Groth16Verifier"]

View File

@ -1,5 +1,5 @@
const { expect } = require("chai")
const { ethers } = require("hardhat")
const { ethers, deployments } = require("hardhat")
const { hexlify, randomBytes } = ethers.utils
const {
snapshot,
@ -11,7 +11,7 @@ const {
advanceTimeToForNextBlock,
} = require("./evm")
const { periodic } = require("./time")
const { loadProof, loadPublicInput, loadVerificationKey } = require("./proof")
const { loadProof, loadPublicInput } = require("../verifier/verifier")
const { SlotState } = require("./requests")
const binomialTest = require("@stdlib/stats-binomial-test")
const { exampleProof } = require("./examples")
@ -30,8 +30,8 @@ describe("Proofs", function () {
await snapshot()
await ensureMinimumBlockHeight(256)
const Proofs = await ethers.getContractFactory("TestProofs")
const Verifier = await ethers.getContractFactory("Groth16Verifier")
const verifier = await Verifier.deploy(loadVerificationKey("local"))
await deployments.fixture(["Groth16Verifier"])
const verifier = await deployments.get("Groth16Verifier")
proofs = await Proofs.deploy(
{ period, timeout, downtime },
verifier.address
@ -159,8 +159,8 @@ describe("Proofs", function () {
})
describe("when proofs are required", function () {
const proof = loadProof("local")
const pubSignals = loadPublicInput("local")
const proof = loadProof("hardhat")
const pubSignals = loadPublicInput("hardhat")
beforeEach(async function () {
await proofs.setSlotState(slotId, SlotState.Filled)