From 539badfcf3fe5de9509afd55a9d5022d58bcc886 Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 23 Jan 2025 17:38:24 +0100 Subject: [PATCH] remove VerifierLib and move functionality to Verifier --- contracts/lib/VerifierLib.sol | 73 ------------------- contracts/verifiers/Verifier.sol | 72 ++++++++++++++++-- helpers/DeployHelper.ts | 19 ----- ...niversalVerifierContractMigrationHelper.ts | 6 +- helpers/constants.ts | 10 +-- ignition/modules/libraries.ts | 5 -- .../deployCrossChainVerifierWithRequests.ts | 9 +-- scripts/deploy/deployUniversalVerifier.ts | 21 ------ .../checkContractsVerificationManually.ts | 5 -- .../verifiers/embedded-verifier-upgrade.ts | 8 -- .../verifiers/universal-verifier-upgrade.ts | 11 +-- .../integration-verifier.test.ts | 7 +- test/verifier/embedded-verifier.test.ts | 5 +- test/verifier/requestDisableable.test.ts | 5 +- test/verifier/requestOwnership.test.ts | 5 +- test/verifier/universal-verifier.test.ts | 2 - test/verifier/validatorWhitelist.test.ts | 5 +- test/verifier/verifer.test.ts | 13 ++-- 18 files changed, 82 insertions(+), 199 deletions(-) delete mode 100644 contracts/lib/VerifierLib.sol diff --git a/contracts/lib/VerifierLib.sol b/contracts/lib/VerifierLib.sol deleted file mode 100644 index bd207ae4..00000000 --- a/contracts/lib/VerifierLib.sol +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.27; - -import {Verifier} from "../verifiers/Verifier.sol"; -import {IRequestValidator} from "../interfaces/IRequestValidator.sol"; - -error ResponseFieldAlreadyExists(string responseFieldName); - -/** - * @title VerifierLib - * @dev A library for writing proof results. - */ -library VerifierLib { - /** - * @dev Struct to store proof and associated data - */ - struct Proof { - bool isVerified; - mapping(string key => uint256 inputValue) storageFields; - string validatorVersion; - // TODO: discuss if we need this field - // uint256 blockNumber; - uint256 blockTimestamp; - // This empty reserved space is put in place to allow future versions - // (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps) - string[] keys; - // introduce artificial shift + 1 to avoid 0 index - mapping(string key => uint256 keyIndex) keyIndexes; - uint256[44] __gap; - } - - /** - * @dev Struct to store auth proof and associated data - */ - struct AuthProof { - bool isVerified; - mapping(string key => uint256 inputValue) storageFields; - string validatorVersion; - uint256 blockTimestamp; - // This empty reserved space is put in place to allow future versions - // (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps) - uint256[45] __gap; - } - - /** - * @dev Writes proof results. - * @param requestId The request ID of the proof - * @param sender The address of the sender of the proof - * @param responseFields The array of response fields of the proof - */ - function writeProofResults( - Verifier.VerifierStorage storage self, - uint256 requestId, - address sender, - IRequestValidator.ResponseField[] memory responseFields - ) public { - Proof storage proof = self._proofs[requestId][sender]; - // We only keep only 1 proof now without history. Prepared for the future if needed. - for (uint256 i = 0; i < responseFields.length; i++) { - proof.storageFields[responseFields[i].name] = responseFields[i].value; - if (proof.keyIndexes[responseFields[i].name] == 0) { - proof.keys.push(responseFields[i].name); - proof.keyIndexes[responseFields[i].name] = proof.keys.length; - } else { - revert ResponseFieldAlreadyExists(responseFields[i].name); - } - } - - proof.isVerified = true; - proof.validatorVersion = self._requests[requestId].validator.version(); - proof.blockTimestamp = block.timestamp; - } -} diff --git a/contracts/verifiers/Verifier.sol b/contracts/verifiers/Verifier.sol index e72fc8f1..85104f9c 100644 --- a/contracts/verifiers/Verifier.sol +++ b/contracts/verifiers/Verifier.sol @@ -6,7 +6,6 @@ import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/Cont import {IRequestValidator} from "../interfaces/IRequestValidator.sol"; import {IAuthValidator} from "../interfaces/IAuthValidator.sol"; import {IState} from "../interfaces/IState.sol"; -import {VerifierLib} from "../lib/VerifierLib.sol"; import {IVerifier} from "../interfaces/IVerifier.sol"; import {GenesisUtils} from "../lib/GenesisUtils.sol"; @@ -20,6 +19,7 @@ error MetadataNotSupportedYet(); error MultiRequestIdAlreadyExists(uint256 multiRequestId); error MultiRequestIdNotFound(uint256 multiRequestId); error NullifierSessionIDAlreadyExists(uint256 nullifierSessionID); +error ResponseFieldAlreadyExists(string responseFieldName); error RequestIdAlreadyExists(uint256 requestId); error RequestIdNotFound(uint256 requestId); error RequestIdNotValid(); @@ -47,7 +47,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable { struct VerifierStorage { // Information about requests // solhint-disable-next-line - mapping(uint256 requestId => mapping(address sender => VerifierLib.Proof)) _proofs; + mapping(uint256 requestId => mapping(address sender => Proof)) _proofs; mapping(uint256 requestId => IVerifier.RequestData) _requests; uint256[] _requestIds; IState _state; @@ -64,13 +64,45 @@ abstract contract Verifier is IVerifier, ContextUpgradeable { uint256 _verifierID; } + /** + * @dev Struct to store proof and associated data + */ + struct Proof { + bool isVerified; + mapping(string key => uint256 inputValue) storageFields; + string validatorVersion; + // TODO: discuss if we need this field + // uint256 blockNumber; + uint256 blockTimestamp; + // This empty reserved space is put in place to allow future versions + // (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps) + string[] keys; + // introduce artificial shift + 1 to avoid 0 index + mapping(string key => uint256 keyIndex) keyIndexes; + uint256[44] __gap; + } + + /** + * @dev Struct to store auth proof and associated data + */ + struct AuthProof { + bool isVerified; + mapping(string key => uint256 inputValue) storageFields; + string validatorVersion; + uint256 blockTimestamp; + // This empty reserved space is put in place to allow future versions + // (see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps) + uint256[45] __gap; + } + // solhint-disable-next-line // keccak256(abi.encode(uint256(keccak256("iden3.storage.Verifier")) -1 )) & ~bytes32(uint256(0xff)); bytes32 internal constant VerifierStorageLocation = 0x11369addde4aae8af30dcf56fa25ad3d864848d3201d1e9197f8b4da18a51a00; bytes2 internal constant VerifierIdType = 0x01A1; - using VerifierLib for VerifierStorage; + + /** * @dev Modifier to check if the request exists @@ -323,7 +355,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable { // Check if userID from authResponse is the same as the one in the signals _checkUserIDMatch(userIDFromAuthResponse, signals); - $.writeProofResults(response.requestId, sender, signals); + _writeProofResults(response.requestId, sender, signals); if (response.metadata.length > 0) { revert MetadataNotSupportedYet(); @@ -537,7 +569,7 @@ abstract contract Verifier is IVerifier, ContextUpgradeable { uint256 requestId ) public view checkRequestExistence(requestId, true) returns (IVerifier.RequestStatus memory) { VerifierStorage storage s = _getVerifierStorage(); - VerifierLib.Proof storage proof = s._proofs[requestId][sender]; + Proof storage proof = s._proofs[requestId][sender]; return IVerifier.RequestStatus( @@ -855,4 +887,34 @@ abstract contract Verifier is IVerifier, ContextUpgradeable { VerifierStorage storage $ = _getVerifierStorage(); return $._requests[requestId]; } + + /** + * @dev Writes proof results. + * @param requestId The request ID of the proof + * @param sender The address of the sender of the proof + * @param responseFields The array of response fields of the proof + */ + function _writeProofResults( + uint256 requestId, + address sender, + IRequestValidator.ResponseField[] memory responseFields + ) internal { + VerifierStorage storage s = _getVerifierStorage(); + Proof storage proof = s._proofs[requestId][sender]; + + // We only keep only 1 proof now without history. Prepared for the future if needed. + for (uint256 i = 0; i < responseFields.length; i++) { + proof.storageFields[responseFields[i].name] = responseFields[i].value; + if (proof.keyIndexes[responseFields[i].name] == 0) { + proof.keys.push(responseFields[i].name); + proof.keyIndexes[responseFields[i].name] = proof.keys.length; + } else { + revert ResponseFieldAlreadyExists(responseFields[i].name); + } + } + + proof.isVerified = true; + proof.validatorVersion = s._requests[requestId].validator.version(); + proof.blockTimestamp = block.timestamp; + } } diff --git a/helpers/DeployHelper.ts b/helpers/DeployHelper.ts index 63546aba..3a6315da 100644 --- a/helpers/DeployHelper.ts +++ b/helpers/DeployHelper.ts @@ -442,17 +442,6 @@ export class DeployHelper { return stateLibWrapper; } - async deployVerifierLib(): Promise { - const contractName = "VerifierLib"; - - const verifierLib = await ethers.deployContract(contractName); - await verifierLib.waitForDeployment(); - - Logger.success(`${contractName} deployed to: ${await verifierLib.getAddress()}`); - - return verifierLib; - } - async deployBinarySearchTestWrapper(): Promise { this.log("deploying poseidons..."); const [poseidon2Elements, poseidon3Elements] = await deployPoseidons([2, 3]); @@ -860,7 +849,6 @@ export class DeployHelper { async upgradeUniversalVerifier( verifierAddress: string, - verifierLibAddr: string, verifierContractName = contractsInfo.UNIVERSAL_VERIFIER.name, ): Promise { this.log("======== Verifier: upgrade started ========"); @@ -869,9 +857,6 @@ export class DeployHelper { this.log("upgrading verifier..."); const VerifierFactory = await ethers.getContractFactory(verifierContractName, { signer: proxyAdminOwner, - libraries: { - VerifierLib: verifierLibAddr, - }, }); this.log("upgrading proxy..."); @@ -915,7 +900,6 @@ export class DeployHelper { async deployUniversalVerifier( owner: SignerWithAddress | undefined, stateAddr: string, - verifierLibAddr: string, deployStrategy: "basic" | "create2" = "basic", ): Promise { if (!owner) { @@ -925,9 +909,6 @@ export class DeployHelper { contractsInfo.UNIVERSAL_VERIFIER.name, { signer: owner, - libraries: { - VerifierLib: verifierLibAddr, - }, }, ); const Create2AddressAnchorFactory = await ethers.getContractFactory( diff --git a/helpers/UniversalVerifierContractMigrationHelper.ts b/helpers/UniversalVerifierContractMigrationHelper.ts index aab0623a..3bec09d3 100644 --- a/helpers/UniversalVerifierContractMigrationHelper.ts +++ b/helpers/UniversalVerifierContractMigrationHelper.ts @@ -104,13 +104,9 @@ export class UniversalVerifierContractMigrationHelper extends ContractMigrationS } @log - async upgradeContract( - universalVerifierContract: Contract, - opts: { verifierLibAddress: string }, - ): Promise { + async upgradeContract(universalVerifierContract: Contract): Promise { return await this._universalVerifierDeployHelper.upgradeUniversalVerifier( await universalVerifierContract.getAddress(), - opts.verifierLibAddress, ); } } diff --git a/helpers/constants.ts b/helpers/constants.ts index c339b562..16b6f9c3 100644 --- a/helpers/constants.ts +++ b/helpers/constants.ts @@ -390,15 +390,7 @@ export const contractsInfo = Object.freeze({ libraries: {}, }, }, - VERIFIER_LIB: { - name: "VerifierLib", - unifiedAddress: "", - create2Address: "", - verificationOpts: { - constructorArgsImplementation: [], - libraries: {}, - }, - }, + EMBEDDED_VERIFIER_WRAPPER: { name: "EmbeddedVerifierWrapper", unifiedAddress: "", diff --git a/ignition/modules/libraries.ts b/ignition/modules/libraries.ts index e6225aac..ddb26aab 100644 --- a/ignition/modules/libraries.ts +++ b/ignition/modules/libraries.ts @@ -125,8 +125,3 @@ export const SpongePoseidonModule = buildModule("SpongePoseidonModule", (m) => { }); return { spongePoseidon }; }); - -export const VerifierLibModule = buildModule("VerifierLibModule", (m) => { - const verifierLib = m.contract("VerifierLib"); - return { verifierLib }; -}); diff --git a/scripts/deploy/deployCrossChainVerifierWithRequests.ts b/scripts/deploy/deployCrossChainVerifierWithRequests.ts index a12bd732..006c6b5e 100644 --- a/scripts/deploy/deployCrossChainVerifierWithRequests.ts +++ b/scripts/deploy/deployCrossChainVerifierWithRequests.ts @@ -52,15 +52,8 @@ async function main() { const { validator: validatorV3 } = await deployHelper.deployValidatorContractsWithVerifiers("v3"); - // ##################### VerifierLib deploy ##################### - const verifierLib = await deployHelper.deployVerifierLib(); - // ##################### Universal Verifier deploy ##################### - const verifier = await deployHelper.deployUniversalVerifier( - undefined, - await state.getAddress(), - await verifierLib.getAddress(), - ); + const verifier = await deployHelper.deployUniversalVerifier(undefined, await state.getAddress()); const addToWhiteList1 = await verifier.addValidatorToWhitelist(await validatorSig.getAddress()); await addToWhiteList1.wait(); diff --git a/scripts/deploy/deployUniversalVerifier.ts b/scripts/deploy/deployUniversalVerifier.ts index 2d1e42e9..69410866 100644 --- a/scripts/deploy/deployUniversalVerifier.ts +++ b/scripts/deploy/deployUniversalVerifier.ts @@ -27,29 +27,9 @@ async function main() { "./scripts/deployments_output/temp_deployments_output.json", ); - let verifierLib = await tmpContractDeployments.getContract(contractsInfo.VERIFIER_LIB.name); - if (verifierLib) { - Logger.warning( - `${contractsInfo.VERIFIER_LIB.name} found already deployed to: ${await verifierLib?.getAddress()}`, - ); - } else { - verifierLib = await deployHelper.deployVerifierLib(); - const tx = await verifierLib.deploymentTransaction(); - await waitNotToInterfereWithHardhatIgnition(tx); - tmpContractDeployments.addContract( - contractsInfo.VERIFIER_LIB.name, - await verifierLib.getAddress(), - ); - await verifyContract( - await verifierLib.getAddress(), - contractsInfo.VERIFIER_LIB.verificationOpts, - ); - } - const universalVerifier = await deployHelper.deployUniversalVerifier( undefined, stateContractAddress, - await verifierLib.getAddress(), deployStrategy, ); tmpContractDeployments.remove(); @@ -67,7 +47,6 @@ async function main() { const outputJson = { proxyAdminOwnerAddress: await signer.getAddress(), universalVerifier: await universalVerifier.getAddress(), - verifierLib: await verifierLib.getAddress(), state: stateContractAddress, network: networkName, chainId, diff --git a/scripts/maintenance/checkContractsVerificationManually.ts b/scripts/maintenance/checkContractsVerificationManually.ts index 8687abbe..04a218df 100644 --- a/scripts/maintenance/checkContractsVerificationManually.ts +++ b/scripts/maintenance/checkContractsVerificationManually.ts @@ -3,7 +3,6 @@ import { contractsInfo } from "../../helpers/constants"; async function main() { const StateLibAddress: string = ""; - const VerifierLibAddress: string = ""; const StateAddress: string = ""; if (StateAddress.includes("0x")) { @@ -13,10 +12,6 @@ async function main() { if (StateLibAddress.includes("0x")) { await verifyContract(StateLibAddress, contractsInfo.STATE_LIB.verificationOpts); } - - if (VerifierLibAddress.includes("0x")) { - await verifyContract(VerifierLibAddress, contractsInfo.VERIFIER_LIB.verificationOpts); - } } main() diff --git a/scripts/upgrade/verifiers/embedded-verifier-upgrade.ts b/scripts/upgrade/verifiers/embedded-verifier-upgrade.ts index f7ba72f8..461be044 100644 --- a/scripts/upgrade/verifiers/embedded-verifier-upgrade.ts +++ b/scripts/upgrade/verifiers/embedded-verifier-upgrade.ts @@ -41,16 +41,9 @@ async function main() { const verifierRequestsCountBeforeUpgrade = await verifierContract.getZKPRequestsCount(); console.log("Owner Address Before Upgrade: ", verifierOwnerAddressBeforeUpgrade); - const verifierLib = await deployerHelper.deployVerifierLib(); - // **** Upgrade Embedded Verifier **** const verifierFactory = await ethers.getContractFactory( contractsInfo.EMBEDDED_VERIFIER_WRAPPER.name, - { - libraries: { - VerifierLib: await verifierLib.getAddress(), - }, - }, ); try { @@ -100,7 +93,6 @@ async function main() { const outputJson = { proxyAdminOwnerAddress: await signer.getAddress(), verifierContract: await verifierContract.getAddress(), - verifierLib: await verifierLib.getAddress(), state: stateContractAddress, network: network, chainId, diff --git a/scripts/upgrade/verifiers/universal-verifier-upgrade.ts b/scripts/upgrade/verifiers/universal-verifier-upgrade.ts index e760c931..614ab813 100644 --- a/scripts/upgrade/verifiers/universal-verifier-upgrade.ts +++ b/scripts/upgrade/verifiers/universal-verifier-upgrade.ts @@ -121,16 +121,8 @@ async function main() { expect(await universalVerifierContract.isWhitelistedValidator(validator)).to.equal(true); } - const verifierLib = await deployerHelper.deployVerifierLib(); - const txVerifLib = await verifierLib.deploymentTransaction(); - await waitNotToInterfereWithHardhatIgnition(txVerifLib); - - await verifyContract(await verifierLib.getAddress(), contractsInfo.VERIFIER_LIB.verificationOpts); - // **** Upgrade Universal Verifier **** - await universalVerifierMigrationHelper.upgradeContract(universalVerifierContract, { - verifierLibAddress: await verifierLib.getAddress(), - }); + await universalVerifierMigrationHelper.upgradeContract(universalVerifierContract); // ************************ console.log("Checking data after upgrade"); @@ -215,7 +207,6 @@ async function main() { const outputJson = { proxyAdminOwnerAddress: await proxyAdminOwnerSigner.getAddress(), universalVerifier: await universalVerifierContract.getAddress(), - verifierLib: await verifierLib.getAddress(), state: stateContractAddress, network: network, chainId, diff --git a/test/integration-tests/integration-verifier.test.ts b/test/integration-tests/integration-verifier.test.ts index 8112518b..7109f061 100644 --- a/test/integration-tests/integration-verifier.test.ts +++ b/test/integration-tests/integration-verifier.test.ts @@ -102,10 +102,7 @@ describe("Verifier Integration test", function () { async function deployContractsFixture() { [signer] = await ethers.getSigners(); - const verifierLib = await ethers.deployContract("VerifierLib"); - const verifier = await ethers.deployContract("VerifierTestWrapper", [], { - libraries: { VerifierLib: await verifierLib.getAddress() }, - }); + const verifier = await ethers.deployContract("VerifierTestWrapper", []); const deployHelper = await DeployHelper.initialize(null, true); const { state } = await deployHelper.deployStateWithLibraries(["0x0212"]); @@ -131,7 +128,7 @@ describe("Verifier Integration test", function () { const { validator: lmkValidator } = await deployHelper.deployValidatorContractsWithVerifiers("lmk"); - return { state, verifier, verifierLib, authValidator, v3Validator, lmkValidator }; + return { state, verifier, authValidator, v3Validator, lmkValidator }; } beforeEach(async () => { diff --git a/test/verifier/embedded-verifier.test.ts b/test/verifier/embedded-verifier.test.ts index ddd0eb6a..aae364e4 100644 --- a/test/verifier/embedded-verifier.test.ts +++ b/test/verifier/embedded-verifier.test.ts @@ -10,10 +10,7 @@ describe("EmbeddedVerifier tests", function () { async function deployContractsFixture() { [signer] = await ethers.getSigners(); const deployHelper = await DeployHelper.initialize(null, true); - const verifierLib = await ethers.deployContract("VerifierLib"); - const verifier = await ethers.deployContract("EmbeddedVerifierWrapper", [], { - libraries: { VerifierLib: await verifierLib.getAddress() }, - }); + const verifier = await ethers.deployContract("EmbeddedVerifierWrapper", []); const { state } = await deployHelper.deployStateWithLibraries([], "Groth16VerifierStub"); await verifier.initialize(await signer.getAddress(), await state.getAddress()); diff --git a/test/verifier/requestDisableable.test.ts b/test/verifier/requestDisableable.test.ts index 5b2bd487..3f596b08 100644 --- a/test/verifier/requestDisableable.test.ts +++ b/test/verifier/requestDisableable.test.ts @@ -9,10 +9,7 @@ describe("RequestDisableable tests", function () { async function deployContractsFixture() { const deployHelper = await DeployHelper.initialize(null, true); - const verifierLib = await ethers.deployContract("VerifierLib"); - const verifier = await ethers.deployContract("RequestDisableableTestWrapper", [], { - libraries: { VerifierLib: await verifierLib.getAddress() }, - }); + const verifier = await ethers.deployContract("RequestDisableableTestWrapper", []); const { state } = await deployHelper.deployStateWithLibraries([], "Groth16VerifierStub"); await verifier.initialize(await state.getAddress()); diff --git a/test/verifier/requestOwnership.test.ts b/test/verifier/requestOwnership.test.ts index 4f2f9993..7a89ead7 100644 --- a/test/verifier/requestOwnership.test.ts +++ b/test/verifier/requestOwnership.test.ts @@ -12,10 +12,7 @@ describe("RequestOwnership tests", function () { [signer1, signer2] = await ethers.getSigners(); const deployHelper = await DeployHelper.initialize(null, true); - const verifierLib = await ethers.deployContract("VerifierLib"); - const verifier = await ethers.deployContract("RequestOwnershipTestWrapper", [], { - libraries: { VerifierLib: await verifierLib.getAddress() }, - }); + const verifier = await ethers.deployContract("RequestOwnershipTestWrapper", []); const { state } = await deployHelper.deployStateWithLibraries([], "Groth16VerifierStub"); await verifier.initialize(await state.getAddress()); diff --git a/test/verifier/universal-verifier.test.ts b/test/verifier/universal-verifier.test.ts index d2f85e2f..2c90d296 100644 --- a/test/verifier/universal-verifier.test.ts +++ b/test/verifier/universal-verifier.test.ts @@ -32,7 +32,6 @@ describe("Universal Verifier tests", function () { deployHelper = await DeployHelper.initialize(null, true); const { state: stateContract } = await deployHelper.deployStateWithLibraries(["0x0112"]); - const verifierLib = await deployHelper.deployVerifierLib(); const validator = await deployHelper.deployValidatorStub("RequestValidatorStub"); await validator.stub_setVerifyResults([ @@ -43,7 +42,6 @@ describe("Universal Verifier tests", function () { const universalVerifier: any = await deployHelper.deployUniversalVerifier( ethSigner, await stateContract.getAddress(), - await verifierLib.getAddress(), ); await universalVerifier.addValidatorToWhitelist(await validator.getAddress()); diff --git a/test/verifier/validatorWhitelist.test.ts b/test/verifier/validatorWhitelist.test.ts index 162fd5ec..58ba19b5 100644 --- a/test/verifier/validatorWhitelist.test.ts +++ b/test/verifier/validatorWhitelist.test.ts @@ -12,10 +12,7 @@ describe("ValidatorWhitelist tests", function () { [signer1, signer2] = await ethers.getSigners(); const deployHelper = await DeployHelper.initialize(null, true); - const verifierLib = await ethers.deployContract("VerifierLib"); - const verifier = await ethers.deployContract("ValidatorWhitelistTestWrapper", [], { - libraries: { VerifierLib: await verifierLib.getAddress() }, - }); + const verifier = await ethers.deployContract("ValidatorWhitelistTestWrapper", []); const { state } = await deployHelper.deployStateWithLibraries([], "Groth16VerifierStub"); await verifier.initialize(await state.getAddress()); diff --git a/test/verifier/verifer.test.ts b/test/verifier/verifer.test.ts index 77814dc1..7d9bf9e5 100644 --- a/test/verifier/verifer.test.ts +++ b/test/verifier/verifer.test.ts @@ -5,7 +5,7 @@ import { expect } from "chai"; describe("Verifer tests", function () { let sender: any; - let verifier, verifierLib, validator1, validator2: any; + let verifier, validator1, validator2: any; let request, paramsFromValidator, authType: any; let multiRequest: any; let signer: any; @@ -17,10 +17,7 @@ describe("Verifer tests", function () { signerAddress = await signer.getAddress(); const deployHelper = await DeployHelper.initialize(null, true); - const verifierLib = await ethers.deployContract("VerifierLib"); - const verifier = await ethers.deployContract("VerifierTestWrapper", [], { - libraries: { VerifierLib: await verifierLib.getAddress() }, - }); + const verifier = await ethers.deployContract("VerifierTestWrapper", []); const { state } = await deployHelper.deployStateWithLibraries([], "Groth16VerifierStub"); await verifier.initialize(await state.getAddress()); @@ -38,13 +35,13 @@ describe("Verifer tests", function () { const validator1 = await ethers.deployContract("RequestValidatorStub"); const validator2 = await ethers.deployContract("RequestValidatorStub"); - return { verifier, verifierLib, validator1, validator2 }; + return { verifier, validator1, validator2 }; } describe("Single request tests", function () { beforeEach(async function () { [sender] = await ethers.getSigners(); - ({ verifier, verifierLib, validator1, validator2 } = await deployContractsFixture()); + ({ verifier, validator1, validator2 } = await deployContractsFixture()); verifierId = await verifier.getVerifierID(); @@ -313,7 +310,7 @@ describe("Verifer tests", function () { }; const crossChainProofs = "0x"; await expect(verifier.submitResponse(authResponse, [response], crossChainProofs)) - .to.revertedWithCustomError(verifierLib, "ResponseFieldAlreadyExists") + .to.revertedWithCustomError(verifier, "ResponseFieldAlreadyExists") .withArgs("someFieldName1"); });