Skip to content

Commit

Permalink
adds task for requesting committee
Browse files Browse the repository at this point in the history
  • Loading branch information
samepant committed Sep 16, 2024
1 parent 7913104 commit bbc29c1
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/evm/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { NetworkUserConfig } from "hardhat/types";

import "./tasks/accounts";
import "./tasks/ciphernode";
import "./tasks/committee";

dotenv.config();

Expand Down
105 changes: 105 additions & 0 deletions packages/evm/tasks/committee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { task, types } from "hardhat/config";
import type { ProviderRpcError, TaskArguments } from "hardhat/types";

Check failure on line 2 in packages/evm/tasks/committee.ts

View workflow job for this annotation

GitHub Actions / ci

'ProviderRpcError' is defined but never used. Allowed unused vars must match /_/u

task("committee:new", "Request a new ciphernode committee")
.addOptionalParam(
"filter",
"address of filter contract to use",
"0x0000000000000000000000000000000000000006",
types.string,
)
.addOptionalParam(
"thresholdQuorum",
"threshold quorum for committee",
2,
types.int,
)
.addOptionalParam(
"thresholdTotal",
"threshold total for committee",
2,
types.int,
)
.addOptionalParam(
"windowStart",
"timestamp start of window for the E3 (default: now)",
Math.floor(Date.now() / 1000),
types.int,
)
.addOptionalParam(
"windowEnd",
"timestamp end of window for the E3 (default: now + 1 day)",
Math.floor(Date.now() / 1000) + 86400,
types.int,
)
.addOptionalParam(
"duration",
"duration in seconds of the E3 (default: 1 day)",
86400,
types.int,
)
.addOptionalParam(
"e3Address",
"address of the E3 program",
"0x95E366f13c16976A26339aBe7992a1AB523388f5",
types.string,
)
.addOptionalParam(
"e3Params",
"parameters for the E3 program",
"0x0000000000000000000000009f3ebc4f6be495901a29bba2ae5a45fb870cdc14",
types.string,
)
.addOptionalParam(
"computeParams",
"parameters for the compute provider",
"0x000000000000000000000000404af1c0780a9269e4d3308a0812fb87bf5fc490",
types.string,
)
.setAction(async function (taskArguments: TaskArguments, hre) {
const enclave = await hre.deployments.get("Enclave");

const enclaveContract = await hre.ethers.getContractAt(
"Enclave",
enclave.address,
);

try {
const enableE3Tx = await enclaveContract.enableE3Program(
taskArguments.e3Address,
);
await enableE3Tx.wait();
} catch (e: unknown) {
console.log(
"E3 program enabling failed, probably already enabled: ",
e.message,
);
}

console.log(
"requesting committee...",
taskArguments.filter,
[taskArguments.thresholdQuorum, taskArguments.thresholdTotal],
[taskArguments.windowStart, taskArguments.windowEnd],
taskArguments.duration,
taskArguments.e3Address,
taskArguments.e3Params,
taskArguments.computeParams,
);
const tx = await enclaveContract.request(
taskArguments.filter,
[taskArguments.thresholdQuorum, taskArguments.thresholdTotal],
[taskArguments.windowStart, taskArguments.windowEnd],
taskArguments.duration,
taskArguments.e3Address,
taskArguments.e3Params,
taskArguments.computeParams,
// 1 ETH
{ value: "1000000000000000000" },
);

console.log("Reequesting committee... ", tx.hash);
await tx.wait();

console.log(`Committee requested`);
});

0 comments on commit bbc29c1

Please sign in to comment.