Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(merkleroot-gatekeeper): added deploy scripts and config #1822

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/contracts/deploy-config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"FreeForAllGatekeeper": {
"deploy": false
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"EASGatekeeper": {
"deploy": true,
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
Expand Down Expand Up @@ -69,6 +73,10 @@
"FreeForAllGatekeeper": {
"deploy": false
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"EASGatekeeper": {
"deploy": false,
"easAddress": "0xaEF4103A04090071165F78D45D83A0C0782c2B2a",
Expand Down Expand Up @@ -130,6 +138,10 @@
"FreeForAllGatekeeper": {
"deploy": false
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"EASGatekeeper": {
"deploy": true,
"easAddress": "0x4200000000000000000000000000000000000021",
Expand Down Expand Up @@ -192,6 +204,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"EASGatekeeper": {
"deploy": false,
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
Expand Down Expand Up @@ -254,6 +270,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"EASGatekeeper": {
"deploy": false,
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
Expand Down Expand Up @@ -316,6 +336,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"EASGatekeeper": {
"deploy": false,
"easAddress": "0x4200000000000000000000000000000000000021",
Expand Down Expand Up @@ -378,6 +402,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"HatsGatekeeper": {
"deploy": false,
"criterionHats": ["26960358043289970096177553829315270011263390106506980876069447401472"],
Expand Down Expand Up @@ -445,6 +473,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"HatsGatekeeper": {
"deploy": false,
"criterionHats": ["26960358043289970096177553829315270011263390106506980876069447401472"],
Expand Down Expand Up @@ -512,6 +544,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"HatsGatekeeper": {
"deploy": false,
"criterionHats": ["26960358043289970096177553829315270011263390106506980876069447401472"],
Expand Down Expand Up @@ -579,6 +615,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"HatsGatekeeper": {
"deploy": false,
"criterionHats": ["26960358043289970096177553829315270011263390106506980876069447401472"],
Expand Down Expand Up @@ -646,6 +686,10 @@
"FreeForAllGatekeeper": {
"deploy": true
},
"MerkleProofGatekeeper": {
"deploy": false,
"root": "0x2461fcc4c0965cb7f482dd28f1ca8057b7a62a35e8b7a86bb3ad6523f4bb21c0"
},
"HatsGatekeeper": {
"deploy": false,
"criterionHats": ["26960358043289970096177553829315270011263390106506980876069447401472"],
Expand Down
25 changes: 24 additions & 1 deletion packages/contracts/tasks/deploy/maci/02-gatekeepers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ deployment.deployTask(EDeploySteps.Gatekeepers, "Deploy gatekeepers").then((task
const gitcoinGatekeeperContractAddress = storage.getAddress(EContracts.GitcoinPassportGatekeeper, hre.network.name);
const zupassGatekeeperContractAddress = storage.getAddress(EContracts.ZupassGatekeeper, hre.network.name);
const semaphoreGatekeeperContractAddress = storage.getAddress(EContracts.SemaphoreGatekeeper, hre.network.name);
const merkleProofGatekeeperContractAddress = storage.getAddress(EContracts.MerkleProofGatekeeper, hre.network.name);
const deployFreeForAllGatekeeper = deployment.getDeployConfigField(EContracts.FreeForAllGatekeeper, "deploy");
const deployEASGatekeeper = deployment.getDeployConfigField(EContracts.EASGatekeeper, "deploy");
const deployGitcoinGatekeeper = deployment.getDeployConfigField(EContracts.GitcoinPassportGatekeeper, "deploy");
const deployZupassGatekeeper = deployment.getDeployConfigField(EContracts.ZupassGatekeeper, "deploy");
const deploySemaphoreGatekeeper = deployment.getDeployConfigField(EContracts.SemaphoreGatekeeper, "deploy");
const deployHatsSingleGatekeeper = deployment.getDeployConfigField(EContracts.HatsGatekeeper, "deploy");
const deployMerkleGateekeper = deployment.getDeployConfigField(EContracts.MerkleProofGatekeeper, "deploy");

const skipDeployFreeForAllGatekeeper = deployFreeForAllGatekeeper !== true;
const skipDeployEASGatekeeper = deployEASGatekeeper !== true;
const skipDeployGitcoinGatekeeper = deployGitcoinGatekeeper !== true;
const skipDeployZupassGatekeeper = deployZupassGatekeeper !== true;
const skipDeploySemaphoreGatekeeper = deploySemaphoreGatekeeper !== true;
const skipDeployHatsGatekeeper = deployHatsSingleGatekeeper !== true;
const skipDeployMerkleProofGatekeeper = deployMerkleGateekeper !== true;

const canSkipDeploy =
incremental &&
Expand All @@ -44,12 +47,14 @@ deployment.deployTask(EDeploySteps.Gatekeepers, "Deploy gatekeepers").then((task
(zupassGatekeeperContractAddress || skipDeployZupassGatekeeper) &&
(semaphoreGatekeeperContractAddress || skipDeploySemaphoreGatekeeper) &&
(hatsGatekeeperContractAddress || skipDeployHatsGatekeeper) &&
(merkleProofGatekeeperContractAddress || skipDeployMerkleProofGatekeeper) &&
(!skipDeployFreeForAllGatekeeper ||
!skipDeployEASGatekeeper ||
!skipDeployGitcoinGatekeeper ||
!skipDeployZupassGatekeeper ||
!skipDeploySemaphoreGatekeeper ||
!skipDeployHatsGatekeeper);
!skipDeployHatsGatekeeper ||
!skipDeployMerkleProofGatekeeper);

if (canSkipDeploy) {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -228,5 +233,23 @@ deployment.deployTask(EDeploySteps.Gatekeepers, "Deploy gatekeepers").then((task
network: hre.network.name,
});
}

if (!skipDeployMerkleProofGatekeeper) {
const root = deployment.getDeployConfigField<string>(EContracts.MerkleProofGatekeeper, "root", true);

const MerkleProofGatekeeperContract = await deployment.deployContract(
{
name: EContracts.MerkleProofGatekeeper,
signer: deployer,
},
root,
);
await storage.register({
id: EContracts.MerkleProofGatekeeper,
contract: MerkleProofGatekeeperContract,
args: [root],
network: hre.network.name,
});
}
}),
);
2 changes: 2 additions & 0 deletions packages/contracts/tasks/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ export enum EGatekeepers {
HatsMultiple = "HatsGatekeeperMultiple",
Zupass = "ZupassGatekeeper",
Semaphore = "SemaphoreGatekeeper",
MerkleProof = "MerkleProofGatekeeper",
}

/**
Expand All @@ -570,6 +571,7 @@ export enum EContracts {
ZupassGatekeeper = "ZupassGatekeeper",
ZupassGroth16Verifier = "ZupassGroth16Verifier",
SemaphoreGatekeeper = "SemaphoreGatekeeper",
MerkleProofGatekeeper = "MerkleProofGatekeeper",
Verifier = "Verifier",
MACI = "MACI",
StateAq = "StateAq",
Expand Down
Loading