diff --git a/examples/CRISP/packages/crisp-contracts/hardhat.config.ts b/examples/CRISP/packages/crisp-contracts/hardhat.config.ts index f2ae3a7493..6bfc74660e 100644 --- a/examples/CRISP/packages/crisp-contracts/hardhat.config.ts +++ b/examples/CRISP/packages/crisp-contracts/hardhat.config.ts @@ -6,7 +6,7 @@ import type { HardhatUserConfig } from 'hardhat/config' import { cleanDeploymentsTask } from '@enclave-e3/contracts/tasks/utils' -import { ciphernodeAdd, ciphernodeAdminAdd, ciphernodeMintTokens } from '@enclave-e3/contracts/tasks/ciphernode' +import { ciphernodeAdd, ciphernodeAdminAdd, ciphernodeMintTokens, updateSubmissionWindow } from '@enclave-e3/contracts/tasks/ciphernode' import dotenv from 'dotenv' import hardhatEthersChaiMatchers from '@nomicfoundation/hardhat-ethers-chai-matchers' @@ -63,7 +63,7 @@ function getChainConfig(chain: keyof typeof chainIds, apiUrl: string) { const config: HardhatUserConfig = { plugins: [hardhatTypechainPlugin, hardhatEthersChaiMatchers, hardhatNetworkHelpers, hardhatToolboxMochaEthersPlugin, hardhatVerify], - tasks: [cleanDeploymentsTask, ciphernodeAdd, ciphernodeAdminAdd, ciphernodeMintTokens], + tasks: [cleanDeploymentsTask, ciphernodeAdd, ciphernodeAdminAdd, ciphernodeMintTokens, updateSubmissionWindow], networks: { default: { accounts: { diff --git a/examples/CRISP/packages/crisp-contracts/package.json b/examples/CRISP/packages/crisp-contracts/package.json index 65dd8a3dc6..cfe8425563 100644 --- a/examples/CRISP/packages/crisp-contracts/package.json +++ b/examples/CRISP/packages/crisp-contracts/package.json @@ -33,9 +33,10 @@ "ciphernode:add:self": "hardhat ciphernode:add", "clean:deployments": "hardhat utils:clean-deployments", "deploy:contracts": "hardhat run deploy/deploy.ts", - "deploy:contracts:full": "export DEPLOY_ENCLAVE=true && pnpm deploy:contracts", + "deploy:contracts:full": "export DEPLOY_ENCLAVE=true USE_MOCK_VERIFIER=true && pnpm deploy:contracts", "test": "hardhat test mocha", - "verify": "hardhat run deploy/verify.ts" + "verify": "hardhat run deploy/verify.ts", + "updateSubmissionWindow": "hardhat ciphernode:window" }, "dependencies": { "@enclave-e3/contracts": "workspace:*", diff --git a/packages/enclave-contracts/hardhat.config.ts b/packages/enclave-contracts/hardhat.config.ts index 66509ea589..fda3e1daf7 100644 --- a/packages/enclave-contracts/hardhat.config.ts +++ b/packages/enclave-contracts/hardhat.config.ts @@ -18,6 +18,7 @@ import { ciphernodeMintTokens, ciphernodeRemove, ciphernodeSiblings, + updateSubmissionWindow, } from "./tasks/ciphernode"; import { activateE3, @@ -101,6 +102,7 @@ const config: HardhatUserConfig = { publishCommittee, enableE3, cleanDeploymentsTask, + updateSubmissionWindow, ], networks: { hardhat: { diff --git a/packages/enclave-contracts/package.json b/packages/enclave-contracts/package.json index a8ca86a83f..44b671f69b 100644 --- a/packages/enclave-contracts/package.json +++ b/packages/enclave-contracts/package.json @@ -170,7 +170,8 @@ "test:ciphernodeRegistry": "pnpm run test test/CiphernodeRegistry/CiphernodeRegistryOwnable.spec.ts", "prerelease": "pnpm clean && pnpm compile && pnpm typechain", "release": "pnpm publish", - "verify:contracts": "hardhat run scripts/runVerification.ts" + "verify:contracts": "hardhat run scripts/runVerification.ts", + "updateSubmissionWindow": "hardhat ciphernode:window" }, "dependencies": { "@openzeppelin/contracts-upgradeable": "^5.0.2", diff --git a/packages/enclave-contracts/tasks/ciphernode.ts b/packages/enclave-contracts/tasks/ciphernode.ts index 5ed2fa2405..8007725b2c 100644 --- a/packages/enclave-contracts/tasks/ciphernode.ts +++ b/packages/enclave-contracts/tasks/ciphernode.ts @@ -6,6 +6,7 @@ import { LeanIMT } from "@zk-kit/lean-imt"; import { ZeroAddress } from "ethers"; import { task } from "hardhat/config"; +import { ArgumentType } from "hardhat/types/arguments"; import { poseidon2 } from "poseidon-lite"; export const ciphernodeAdd = task( @@ -532,3 +533,41 @@ export const ciphernodeSiblings = task( }, })) .build(); + +export const updateSubmissionWindow = task( + "ciphernode:window", + "Update the submission window for the ciphernode registry", +) + .addOption({ + name: "newWindow", + description: "the new submission window", + defaultValue: 10, + type: ArgumentType.INT, + }) + .setAction(async () => ({ + default: async ({ newWindow }, hre) => { + const { deployAndSaveCiphernodeRegistryOwnable } = await import( + "../scripts/deployAndSave/ciphernodeRegistryOwnable" + ); + + const { deployAndSavePoseidonT3 } = await import( + "../scripts/deployAndSave/poseidonT3" + ); + const poseidonT3 = await deployAndSavePoseidonT3({ hre }); + + const { ciphernodeRegistry } = + await deployAndSaveCiphernodeRegistryOwnable({ + hre, + poseidonT3Address: poseidonT3, + }); + + const tx = + await ciphernodeRegistry.setSortitionSubmissionWindow(newWindow); + + console.log("Updating submission window... ", tx.hash); + await tx.wait(); + + console.log(`Submission window update to ${newWindow}`); + }, + })) + .build();