Skip to content

Commit

Permalink
feat(merkleroot-gatekeeper): added deploy scripts and config (#1822)
Browse files Browse the repository at this point in the history
Co-authored-by: Crisgarner <@crisgarner>
  • Loading branch information
crisgarner authored Sep 12, 2024
1 parent f730dd7 commit 0a55bbc
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
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

0 comments on commit 0a55bbc

Please sign in to comment.