Skip to content

Commit

Permalink
optimizer and fix VerifierLibReqType1 library link for verifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Nov 7, 2024
1 parent 2577ce2 commit 1bcaa3c
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 2 deletions.
6 changes: 6 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const config: HardhatUserConfig = {
compilers: [
{
version: "0.8.27",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
Expand Down
8 changes: 6 additions & 2 deletions helpers/DeployHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export class DeployHelper {
}

async deployVerifierLib(): Promise<Contract> {
const contractName = "VerifierLib";
const contractName = contractsInfo.VERIFIER_LIB.name;

const verifierLib = await ethers.deployContract(contractName);
await verifierLib.waitForDeployment();
Expand All @@ -486,7 +486,7 @@ export class DeployHelper {
}

async deployVerifierLibReqType1(): Promise<Contract> {
const contractName = "VerifierLibReqType1";
const contractName = contractsInfo.VERIFIER_LIB_REQUEST_TYPE1.name;

const VerifierLibReqType1 = await ethers.deployContract(contractName);
await VerifierLibReqType1.waitForDeployment();
Expand Down Expand Up @@ -898,10 +898,12 @@ export class DeployHelper {
owner: SignerWithAddress | undefined,
stateAddr: string,
verifierLibAddr: string,
verifierLibReqType1Addr: string,
): Promise<Contract> {
const Verifier = await ethers.getContractFactory("EmbeddedZKPVerifierWrapper", {
libraries: {
VerifierLib: verifierLibAddr,
VerifierLibReqType1: verifierLibReqType1Addr,
},
});
// const zkpVerifier = await ZKPVerifier.deploy(await owner.getAddress());
Expand All @@ -917,6 +919,7 @@ export class DeployHelper {
owner: SignerWithAddress | undefined,
stateAddr: string,
verifierLibAddr: string,
verifierLibReqType1Addr: string,
deployStrategy: "basic" | "create2" = "basic",
): Promise<Contract> {
if (!owner) {
Expand All @@ -928,6 +931,7 @@ export class DeployHelper {
signer: owner,
libraries: {
VerifierLib: verifierLibAddr,
VerifierLibReqType1: verifierLibReqType1Addr,
},
},
);
Expand Down
9 changes: 9 additions & 0 deletions helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ export const contractsInfo = Object.freeze({
libraries: {},
},
},
VERIFIER_LIB_REQUEST_TYPE1: {
name: "VerifierLibReqType1",
unifiedAddress: "",
create2Address: "",
verificationOpts: {
constructorArgsImplementation: [],
libraries: {},
},
},
EMBEDDED_ZKP_VERIFIER_WRAPPER: {
name: "EmbeddedZKPVerifierWrapper",
unifiedAddress: "",
Expand Down
2 changes: 2 additions & 0 deletions scripts/deploy/deployCrossChainVerifierWithRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ async function main() {

// ##################### VerifierLib deploy #####################
const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

// ##################### Universal Verifier deploy #####################
const verifier = await deployHelper.deployUniversalVerifier(
undefined,
await state.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);

const addToWhiteList1 = await verifier.addValidatorToWhitelist(await validatorSig.getAddress());
Expand Down
24 changes: 24 additions & 0 deletions scripts/deploy/deployUniversalVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function main() {
);
} else {
verifierLib = await deployHelper.deployVerifierLib();

const tx = await verifierLib.deploymentTransaction();
await waitNotToInterfereWithHardhatIgnition(tx);
tmpContractDeployments.addContract(
Expand All @@ -46,10 +47,33 @@ async function main() {
);
}

let verifierLibReqType1 = await tmpContractDeployments.getContract(
contractsInfo.VERIFIER_LIB_REQUEST_TYPE1.name,
);
if (verifierLibReqType1) {
Logger.warning(
`${contractsInfo.VERIFIER_LIB_REQUEST_TYPE1.name} found already deployed to: ${await verifierLibReqType1?.getAddress()}`,
);
} else {
verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

const tx = await verifierLibReqType1.deploymentTransaction();
await waitNotToInterfereWithHardhatIgnition(tx);
tmpContractDeployments.addContract(
contractsInfo.VERIFIER_LIB_REQUEST_TYPE1.name,
await verifierLibReqType1.getAddress(),
);
await verifyContract(
await verifierLibReqType1.getAddress(),
contractsInfo.VERIFIER_LIB_REQUEST_TYPE1.verificationOpts,
);
}

const universalVerifier = await deployHelper.deployUniversalVerifier(
undefined,
stateContractAddress,
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
deployStrategy,
);
tmpContractDeployments.remove();
Expand Down
2 changes: 2 additions & 0 deletions test/verifier/embedded-zkp-verifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ describe("Embedded ZKP Verifier", function () {
const { state } = await deployHelper.deployStateWithLibraries(["0x0112"]);

const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

verifier = await deployHelper.deployEmbeddedZKPVerifierWrapper(
owner,
await state.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);

const stub = await deployHelper.deployValidatorStub();
Expand Down
2 changes: 2 additions & 0 deletions test/verifier/universal-verifier-linked-proofs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ describe("Universal Verifier Linked proofs", function () {
({ state } = await deployHelper.deployStateWithLibraries(["0x0112"]));

const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

verifier = await deployHelper.deployUniversalVerifier(
signer,
await state.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);

const contracts = await deployHelper.deployValidatorContractsWithVerifiers(
Expand Down
2 changes: 2 additions & 0 deletions test/verifier/universal-verifier-submit-V2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ describe("Universal Verifier V2 MTP & SIG validators", function () {
stateCrossChainStub = state;

const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

verifier = await deployHelper.deployUniversalVerifier(
signer,
await stateCrossChainStub.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);

validatorStub = await deployHelper.deployValidatorStub();
Expand Down
3 changes: 3 additions & 0 deletions test/verifier/universal-verifier.events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ describe("Universal Verifier events", function () {
const { state } = await deployHelper.deployStateWithLibraries(["0x0112"]);

const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

verifier = await deployHelper.deployUniversalVerifier(
signer,
await state.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);

const contracts = await deployHelper.deployValidatorContractsWithVerifiers(
Expand Down
2 changes: 2 additions & 0 deletions test/verifier/universal-verifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ describe("Universal Verifier MTP & SIG validators", function () {
deployHelper = await DeployHelper.initialize(null, true);
({ state } = await deployHelper.deployStateWithLibraries(["0x0112"]));
const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();

verifier = await deployHelper.deployUniversalVerifier(
signer,
await state.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);

const stub = await deployHelper.deployValidatorStub();
Expand Down
2 changes: 2 additions & 0 deletions test/verifier/universal-verifier.v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe("Universal Verifier V3 validator", function () {
const { state: stateContract } = await deployHelper.deployStateWithLibraries(["0x0212"]);
state = stateContract;
const verifierLib = await deployHelper.deployVerifierLib();
const verifierLibReqType1 = await deployHelper.deployVerifierLibReqType1();
const contracts = await deployHelper.deployValidatorContractsWithVerifiers(
"v3",
await state.getAddress(),
Expand All @@ -71,6 +72,7 @@ describe("Universal Verifier V3 validator", function () {
signer,
await state.getAddress(),
await verifierLib.getAddress(),
await verifierLibReqType1.getAddress(),
);
await verifier.addValidatorToWhitelist(await v3.getAddress());
await verifier.connect();
Expand Down

0 comments on commit 1bcaa3c

Please sign in to comment.