Skip to content

Commit

Permalink
chore(contracts): add acc queue contract to deployed contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad authored and ctrlc03 committed Mar 19, 2024
1 parent 0817d62 commit b12d8a6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
19 changes: 17 additions & 2 deletions contracts/tasks/deploy/maci/10-maci.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EASGatekeeper } from "../../../typechain-types";
import type { EASGatekeeper, MACI } from "../../../typechain-types";

import { ContractStorage } from "../../helpers/ContractStorage";
import { Deployment } from "../../helpers/Deployment";
Expand All @@ -8,6 +8,7 @@ const deployment = Deployment.getInstance();
const storage = ContractStorage.getInstance();

const DEFAULT_STATE_TREE_DEPTH = 10;
const STATE_TREE_SUBDEPTH = 2;

/**
* Deploy step registration and task itself
Expand Down Expand Up @@ -57,7 +58,7 @@ deployment
const stateTreeDepth =
deployment.getDeployConfigField<number | null>(EContracts.MACI, "stateTreeDepth") ?? DEFAULT_STATE_TREE_DEPTH;

const maciContract = await deployment.deployContractWithLinkedLibraries(
const maciContract = await deployment.deployContractWithLinkedLibraries<MACI>(
maciContractFactory,
pollFactoryContractAddress,
messageProcessorFactoryContractAddress,
Expand Down Expand Up @@ -94,4 +95,18 @@ deployment
],
network: hre.network.name,
});

const accQueueAddress = await maciContract.stateAq();
const accQueue = await deployment.getContract({
name: EContracts.AccQueueQuinaryBlankSl,
address: accQueueAddress,
});

await storage.register({
id: EContracts.AccQueueQuinaryBlankSl,
name: "contracts/trees/AccQueueQuinaryBlankSl.sol:AccQueueQuinaryBlankSl",
contract: accQueue,
args: [STATE_TREE_SUBDEPTH],
network: hre.network.name,
});
});
14 changes: 14 additions & 0 deletions contracts/tasks/deploy/poll/01-poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ deployment.deployTask("poll:deploy-poll", "Deploy poll").setAction(async (_, hre
address: tallyContractAddress,
});

const messageAccQueueContract = await deployment.getContract({
name: EContracts.AccQueueQuinaryMaci,
address: extContracts[1],
});

await Promise.all([
storage.register({
id: EContracts.Poll,
Expand Down Expand Up @@ -141,6 +146,15 @@ deployment.deployTask("poll:deploy-poll", "Deploy poll").setAction(async (_, hre
args: [verifierContractAddress, vkRegistryContractAddress, pollContractAddress, messageProcessorContractAddress],
network: hre.network.name,
}),

storage.register({
id: EContracts.AccQueueQuinaryMaci,
key: `poll-${pollId}`,
name: "contracts/trees/AccQueueQuinaryMaci.sol:AccQueueQuinaryMaci",
contract: messageAccQueueContract,
args: [messageTreeSubDepth],
network: hre.network.name,
}),
]);

if (subsidyContractAddress && subsidyContractAddress !== ZeroAddress) {
Expand Down
3 changes: 2 additions & 1 deletion contracts/tasks/helpers/ContractStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ContractStorage {
*
* @param {IRegisterContract} args - register arguments
*/
async register({ id, key, contract, network, args }: IRegisterContract): Promise<void> {
async register({ id, key, contract, network, args, name }: IRegisterContract): Promise<void> {
const contractAddress = await contract.getAddress();

const deploymentTx = contract.deploymentTransaction();
Expand All @@ -84,6 +84,7 @@ export class ContractStorage {

if (args !== undefined) {
logEntry.verify = {
name,
args: JSON.stringify(args),
};
}
Expand Down
8 changes: 7 additions & 1 deletion contracts/tasks/helpers/ContractVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ export class ContractVerifier {
* @param libraries - stringified libraries which can't be detected automatically
* @returns
*/
async verify(address: string, constructorArguments: string, libraries?: string): Promise<[boolean, string]> {
async verify(
address: string,
constructorArguments: string,
contract?: string,
libraries?: string,
): Promise<[boolean, string]> {
const params: IVerificationSubtaskArgs = {
address,
constructorArguments: JSON.parse(constructorArguments) as unknown[],
contract,
};

if (libraries) {
Expand Down
8 changes: 8 additions & 0 deletions contracts/tasks/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ export interface IStorageInstanceEntry {
*/
verify?: {
args?: string;
name?: string;
impl?: string;
subType?: string;
};
Expand Down Expand Up @@ -490,6 +491,11 @@ export interface IRegisterContract {
* Group key for same contracts
*/
key?: BigNumberish;

/**
* Contract name with path specified
*/
name?: string;
}

/**
Expand Down Expand Up @@ -519,6 +525,8 @@ export enum EContracts {
MessageProcessor = "MessageProcessor",
Subsidy = "Subsidy",
AccQueue = "AccQueue",
AccQueueQuinaryBlankSl = "AccQueueQuinaryBlankSl",
AccQueueQuinaryMaci = "AccQueueQuinaryMaci",
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/runner/verifyFull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ task("verify-full", "Verify contracts listed in storage")
console.log("Already verified");
} else {
// eslint-disable-next-line no-await-in-loop
const [ok, err] = await verifier.verify(address, params?.args ?? "");
const [ok, err] = await verifier.verify(address, params?.args ?? "", params?.name);

if (ok) {
storage.setVerified(address, hre.network.name, true);
Expand Down

0 comments on commit b12d8a6

Please sign in to comment.