From 8c23149e79cc9cb608031af019aea1c35060932e Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:51:58 +0000 Subject: [PATCH] refactor: cleanup contracts folder --- .gitignore | 2 + packages/contracts/contracts/MACI.sol | 9 +-- packages/contracts/contracts/Poll.sol | 6 +- packages/contracts/contracts/Tally.sol | 2 +- .../gatekeepers/AnonAadhaarGatekeeper.sol | 3 +- .../contracts/gatekeepers/EASGatekeeper.sol | 2 +- .../gatekeepers/GitcoinPassportGatekeeper.sol | 2 +- .../gatekeepers/HatsGatekeeperBase.sol | 2 +- .../gatekeepers/SemaphoreGatekeeper.sol | 2 +- .../interfaces/IAnonAadhaar.sol | 0 .../{ => gatekeepers}/interfaces/IEAS.sol | 0 .../interfaces/IGitcoinPassportDecoder.sol | 0 .../{ => gatekeepers}/interfaces/IHats.sol | 0 .../interfaces/ISemaphore.sol | 0 .../mocks/MockAnonAadhaar.sol | 0 .../{ => gatekeepers}/mocks/MockEAS.sol | 0 .../mocks/MockGitcoinPassportDecoder.sol | 0 .../mocks/MockHatsProtocol.sol | 0 .../{ => gatekeepers}/mocks/MockSemaphore.sol | 0 .../mocks}/SignUpToken.sol | 0 .../{crypto => mocks}/MockVerifier.sol | 4 +- .../contracts/trees/EmptyBallotRoots.sol | 30 --------- .../contracts/trees/zeros/MerkleBinary0.sol | 43 ------------- .../trees/zeros/MerkleBinaryBlankSl.sol | 43 ------------- .../trees/zeros/MerkleBinaryMaci.sol | 43 ------------- .../contracts/trees/zeros/MerkleQuinary0.sol | 43 ------------- .../trees/zeros/MerkleQuinaryBlankSl.sol | 43 ------------- .../trees/zeros/MerkleQuinaryMaci.sol | 43 ------------- .../zeros/MerkleQuinaryMaciWithSha256.sol | 43 ------------- packages/contracts/package.json | 16 +++-- packages/contracts/scripts/compileSol.ts | 61 ------------------- .../AnonAadhaarGatekeeper.test.ts | 11 ++-- .../{ => gatekeepers}/EASGatekeeper.test.ts | 11 ++-- .../GitcoinPassportGatekeeper.test.ts | 9 ++- .../{ => gatekeepers}/HatsGatekeeper.test.ts | 11 ++-- .../MerkleProofGatekeeper.test.ts | 11 ++-- .../SemaphoreGatekeeper.test.ts | 11 ++-- .../SignUpGatekeeper.test.ts | 11 ++-- .../ZupassGatekeeper.test.ts | 11 ++-- 39 files changed, 61 insertions(+), 467 deletions(-) rename packages/contracts/contracts/{ => gatekeepers}/interfaces/IAnonAadhaar.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/interfaces/IEAS.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/interfaces/IGitcoinPassportDecoder.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/interfaces/IHats.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/interfaces/ISemaphore.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/mocks/MockAnonAadhaar.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/mocks/MockEAS.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/mocks/MockGitcoinPassportDecoder.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/mocks/MockHatsProtocol.sol (100%) rename packages/contracts/contracts/{ => gatekeepers}/mocks/MockSemaphore.sol (100%) rename packages/contracts/contracts/{utilities => gatekeepers/mocks}/SignUpToken.sol (100%) rename packages/contracts/contracts/{crypto => mocks}/MockVerifier.sol (82%) delete mode 100644 packages/contracts/contracts/trees/EmptyBallotRoots.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleBinary0.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleBinaryBlankSl.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleBinaryMaci.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleQuinary0.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleQuinaryBlankSl.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleQuinaryMaci.sol delete mode 100644 packages/contracts/contracts/trees/zeros/MerkleQuinaryMaciWithSha256.sol rename packages/contracts/tests/{ => gatekeepers}/AnonAadhaarGatekeeper.test.ts (96%) rename packages/contracts/tests/{ => gatekeepers}/EASGatekeeper.test.ts (94%) rename packages/contracts/tests/{ => gatekeepers}/GitcoinPassportGatekeeper.test.ts (96%) rename packages/contracts/tests/{ => gatekeepers}/HatsGatekeeper.test.ts (97%) rename packages/contracts/tests/{ => gatekeepers}/MerkleProofGatekeeper.test.ts (94%) rename packages/contracts/tests/{ => gatekeepers}/SemaphoreGatekeeper.test.ts (93%) rename packages/contracts/tests/{ => gatekeepers}/SignUpGatekeeper.test.ts (92%) rename packages/contracts/tests/{ => gatekeepers}/ZupassGatekeeper.test.ts (97%) diff --git a/.gitignore b/.gitignore index 2c07d300e8..29ad2c9303 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,5 @@ packages/cli/contractAddresses.old.json packages/circuits/circom/test **/ts/__benchmarks__/results/** + +proofs diff --git a/packages/contracts/contracts/MACI.sol b/packages/contracts/contracts/MACI.sol index 3b453b0dc4..8a12ee01f3 100644 --- a/packages/contracts/contracts/MACI.sol +++ b/packages/contracts/contracts/MACI.sol @@ -162,17 +162,14 @@ contract MACI is IMACI, DomainObjs, Params, Utilities { // Get the user's voice credit balance. uint256 voiceCreditBalance = initialVoiceCreditProxy.getVoiceCredits(msg.sender, _initialVoiceCreditProxyData); - uint256 timestamp = block.timestamp; - // Create a state leaf and insert it into the tree. - uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, voiceCreditBalance, timestamp)); - InternalLeanIMT._insert(leanIMTData, stateLeaf); + uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, voiceCreditBalance, block.timestamp)); + uint256 stateRoot = InternalLeanIMT._insert(leanIMTData, stateLeaf); // Store the current state tree root in the array - uint256 stateRoot = InternalLeanIMT._root(leanIMTData); stateRootsOnSignUp.push(stateRoot); - emit SignUp(leanIMTData.size - 1, _pubKey.x, _pubKey.y, voiceCreditBalance, timestamp, stateLeaf); + emit SignUp(leanIMTData.size - 1, _pubKey.x, _pubKey.y, voiceCreditBalance, block.timestamp, stateLeaf); } /// @notice Deploy a new Poll contract. diff --git a/packages/contracts/contracts/Poll.sol b/packages/contracts/contracts/Poll.sol index d091152a1b..50caac72d6 100644 --- a/packages/contracts/contracts/Poll.sol +++ b/packages/contracts/contracts/Poll.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.20; import { Params } from "./utilities/Params.sol"; -import { EmptyBallotRoots } from "./trees/EmptyBallotRoots.sol"; import { SnarkCommon } from "./crypto/SnarkCommon.sol"; import { LazyIMTData, InternalLazyIMT } from "./trees/LazyIMT.sol"; import { IMACI } from "./interfaces/IMACI.sol"; @@ -252,10 +251,7 @@ contract Poll is Params, Utilities, SnarkCommon, IPoll { /// @dev Can only be submitted before the voting deadline /// @param _messages the messages /// @param _encPubKeys the encrypted public keys - function publishMessageBatch( - Message[] calldata _messages, - PubKey[] calldata _encPubKeys - ) public virtual isWithinVotingDeadline { + function publishMessageBatch(Message[] calldata _messages, PubKey[] calldata _encPubKeys) public virtual { if (_messages.length != _encPubKeys.length) { revert InvalidBatchLength(); } diff --git a/packages/contracts/contracts/Tally.sol b/packages/contracts/contracts/Tally.sol index 568d30c4a8..f0ead3590f 100644 --- a/packages/contracts/contracts/Tally.sol +++ b/packages/contracts/contracts/Tally.sol @@ -442,10 +442,10 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher, DomainObjs, ITa TallyResult storage previous = tallyResults[_voteOptionIndex]; if (!previous.flag) { + previous.flag = true; totalTallyResults++; } - previous.flag = true; previous.value = _tallyResult; } } diff --git a/packages/contracts/contracts/gatekeepers/AnonAadhaarGatekeeper.sol b/packages/contracts/contracts/gatekeepers/AnonAadhaarGatekeeper.sol index b675ddbd30..446f3a7fc0 100644 --- a/packages/contracts/contracts/gatekeepers/AnonAadhaarGatekeeper.sol +++ b/packages/contracts/contracts/gatekeepers/AnonAadhaarGatekeeper.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; + import { SignUpGatekeeper } from "./SignUpGatekeeper.sol"; -import { IAnonAadhaar } from "../interfaces/IAnonAadhaar.sol"; +import { IAnonAadhaar } from "./interfaces/IAnonAadhaar.sol"; /// @title AnonAadhaarGatekeeper /// @notice A gatekeeper contract which allows users to sign up to MACI diff --git a/packages/contracts/contracts/gatekeepers/EASGatekeeper.sol b/packages/contracts/contracts/gatekeepers/EASGatekeeper.sol index 94f0977f17..0b79b6ec46 100644 --- a/packages/contracts/contracts/gatekeepers/EASGatekeeper.sol +++ b/packages/contracts/contracts/gatekeepers/EASGatekeeper.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { SignUpGatekeeper } from "./SignUpGatekeeper.sol"; -import { IEAS } from "../interfaces/IEAS.sol"; +import { IEAS } from "./interfaces/IEAS.sol"; /// @title EASGatekeeper /// @notice A gatekeeper contract which allows users to sign up to MACI diff --git a/packages/contracts/contracts/gatekeepers/GitcoinPassportGatekeeper.sol b/packages/contracts/contracts/gatekeepers/GitcoinPassportGatekeeper.sol index a683dbff59..60217d7881 100644 --- a/packages/contracts/contracts/gatekeepers/GitcoinPassportGatekeeper.sol +++ b/packages/contracts/contracts/gatekeepers/GitcoinPassportGatekeeper.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { SignUpGatekeeper } from "./SignUpGatekeeper.sol"; -import { IGitcoinPassportDecoder } from "../interfaces/IGitcoinPassportDecoder.sol"; +import { IGitcoinPassportDecoder } from "./interfaces/IGitcoinPassportDecoder.sol"; /// @title GitcoinPassportGatekeeper /// @notice A gatekeeper contract which allows users to sign up to MACI diff --git a/packages/contracts/contracts/gatekeepers/HatsGatekeeperBase.sol b/packages/contracts/contracts/gatekeepers/HatsGatekeeperBase.sol index 3ffb56ceb6..80764ad6bf 100644 --- a/packages/contracts/contracts/gatekeepers/HatsGatekeeperBase.sol +++ b/packages/contracts/contracts/gatekeepers/HatsGatekeeperBase.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.10; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; -import { IHats } from "../interfaces/IHats.sol"; +import { IHats } from "./interfaces/IHats.sol"; import { SignUpGatekeeper } from "./SignUpGatekeeper.sol"; /// @title HatsGatekeeperBase diff --git a/packages/contracts/contracts/gatekeepers/SemaphoreGatekeeper.sol b/packages/contracts/contracts/gatekeepers/SemaphoreGatekeeper.sol index 0b6ed88efd..ea448857a2 100644 --- a/packages/contracts/contracts/gatekeepers/SemaphoreGatekeeper.sol +++ b/packages/contracts/contracts/gatekeepers/SemaphoreGatekeeper.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { SignUpGatekeeper } from "./SignUpGatekeeper.sol"; -import { ISemaphore } from "../interfaces/ISemaphore.sol"; +import { ISemaphore } from "./interfaces/ISemaphore.sol"; /// @title SemaphoreGatekeeper /// @notice A gatekeeper contract which allows users to sign up to MACI diff --git a/packages/contracts/contracts/interfaces/IAnonAadhaar.sol b/packages/contracts/contracts/gatekeepers/interfaces/IAnonAadhaar.sol similarity index 100% rename from packages/contracts/contracts/interfaces/IAnonAadhaar.sol rename to packages/contracts/contracts/gatekeepers/interfaces/IAnonAadhaar.sol diff --git a/packages/contracts/contracts/interfaces/IEAS.sol b/packages/contracts/contracts/gatekeepers/interfaces/IEAS.sol similarity index 100% rename from packages/contracts/contracts/interfaces/IEAS.sol rename to packages/contracts/contracts/gatekeepers/interfaces/IEAS.sol diff --git a/packages/contracts/contracts/interfaces/IGitcoinPassportDecoder.sol b/packages/contracts/contracts/gatekeepers/interfaces/IGitcoinPassportDecoder.sol similarity index 100% rename from packages/contracts/contracts/interfaces/IGitcoinPassportDecoder.sol rename to packages/contracts/contracts/gatekeepers/interfaces/IGitcoinPassportDecoder.sol diff --git a/packages/contracts/contracts/interfaces/IHats.sol b/packages/contracts/contracts/gatekeepers/interfaces/IHats.sol similarity index 100% rename from packages/contracts/contracts/interfaces/IHats.sol rename to packages/contracts/contracts/gatekeepers/interfaces/IHats.sol diff --git a/packages/contracts/contracts/interfaces/ISemaphore.sol b/packages/contracts/contracts/gatekeepers/interfaces/ISemaphore.sol similarity index 100% rename from packages/contracts/contracts/interfaces/ISemaphore.sol rename to packages/contracts/contracts/gatekeepers/interfaces/ISemaphore.sol diff --git a/packages/contracts/contracts/mocks/MockAnonAadhaar.sol b/packages/contracts/contracts/gatekeepers/mocks/MockAnonAadhaar.sol similarity index 100% rename from packages/contracts/contracts/mocks/MockAnonAadhaar.sol rename to packages/contracts/contracts/gatekeepers/mocks/MockAnonAadhaar.sol diff --git a/packages/contracts/contracts/mocks/MockEAS.sol b/packages/contracts/contracts/gatekeepers/mocks/MockEAS.sol similarity index 100% rename from packages/contracts/contracts/mocks/MockEAS.sol rename to packages/contracts/contracts/gatekeepers/mocks/MockEAS.sol diff --git a/packages/contracts/contracts/mocks/MockGitcoinPassportDecoder.sol b/packages/contracts/contracts/gatekeepers/mocks/MockGitcoinPassportDecoder.sol similarity index 100% rename from packages/contracts/contracts/mocks/MockGitcoinPassportDecoder.sol rename to packages/contracts/contracts/gatekeepers/mocks/MockGitcoinPassportDecoder.sol diff --git a/packages/contracts/contracts/mocks/MockHatsProtocol.sol b/packages/contracts/contracts/gatekeepers/mocks/MockHatsProtocol.sol similarity index 100% rename from packages/contracts/contracts/mocks/MockHatsProtocol.sol rename to packages/contracts/contracts/gatekeepers/mocks/MockHatsProtocol.sol diff --git a/packages/contracts/contracts/mocks/MockSemaphore.sol b/packages/contracts/contracts/gatekeepers/mocks/MockSemaphore.sol similarity index 100% rename from packages/contracts/contracts/mocks/MockSemaphore.sol rename to packages/contracts/contracts/gatekeepers/mocks/MockSemaphore.sol diff --git a/packages/contracts/contracts/utilities/SignUpToken.sol b/packages/contracts/contracts/gatekeepers/mocks/SignUpToken.sol similarity index 100% rename from packages/contracts/contracts/utilities/SignUpToken.sol rename to packages/contracts/contracts/gatekeepers/mocks/SignUpToken.sol diff --git a/packages/contracts/contracts/crypto/MockVerifier.sol b/packages/contracts/contracts/mocks/MockVerifier.sol similarity index 82% rename from packages/contracts/contracts/crypto/MockVerifier.sol rename to packages/contracts/contracts/mocks/MockVerifier.sol index 004739b332..56c001130c 100644 --- a/packages/contracts/contracts/crypto/MockVerifier.sol +++ b/packages/contracts/contracts/mocks/MockVerifier.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; -import { SnarkConstants } from "./SnarkConstants.sol"; -import { SnarkCommon } from "./SnarkCommon.sol"; +import { SnarkConstants } from "../crypto/SnarkConstants.sol"; +import { SnarkCommon } from "../crypto/SnarkCommon.sol"; import { IVerifier } from "../interfaces/IVerifier.sol"; /// @title MockVerifier diff --git a/packages/contracts/contracts/trees/EmptyBallotRoots.sol b/packages/contracts/contracts/trees/EmptyBallotRoots.sol deleted file mode 100644 index 89a4e9d910..0000000000 --- a/packages/contracts/contracts/trees/EmptyBallotRoots.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract EmptyBallotRoots { - // emptyBallotRoots contains the roots of Ballot trees of five leaf - // configurations. - // Each tree has a depth of 10, which is the hardcoded state tree depth. - // Each leaf is an empty ballot. A configuration refers to the depth of the - // voice option tree for that ballot. - - // The leaf for the root at index 0 contains hash(0, root of a VO tree with - // depth 1 and zero-value 0) - - // The leaf for the root at index 1 contains hash(0, root of a VO tree with - // depth 2 and zero-value 0) - - // ... and so on. - - // The first parameter to the hash function is the nonce, which is 0. - - uint256[5] internal emptyBallotRoots; - - constructor() { - emptyBallotRoots[0] = uint256(16015576667038038422103932363190100635991292382181099511410843174865570503661); - emptyBallotRoots[1] = uint256(166510078825589460025300915201657086611944528317298994959376081297530246971); - emptyBallotRoots[2] = uint256(10057734083972610459557695472359628128485394923403014377687504571662791937025); - emptyBallotRoots[3] = uint256(4904828619307091008204672239231377290495002626534171783829482835985709082773); - emptyBallotRoots[4] = uint256(18694062287284245784028624966421731916526814537891066525886866373016385890569); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleBinary0.sol b/packages/contracts/contracts/trees/zeros/MerkleBinary0.sol deleted file mode 100644 index 3ff547ff70..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleBinary0.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Binary tree zeros (0) - constructor() { - zeros[0] = uint256(0); - zeros[1] = uint256(14744269619966411208579211824598458697587494354926760081771325075741142829156); - zeros[2] = uint256(7423237065226347324353380772367382631490014989348495481811164164159255474657); - zeros[3] = uint256(11286972368698509976183087595462810875513684078608517520839298933882497716792); - zeros[4] = uint256(3607627140608796879659380071776844901612302623152076817094415224584923813162); - zeros[5] = uint256(19712377064642672829441595136074946683621277828620209496774504837737984048981); - zeros[6] = uint256(20775607673010627194014556968476266066927294572720319469184847051418138353016); - zeros[7] = uint256(3396914609616007258851405644437304192397291162432396347162513310381425243293); - zeros[8] = uint256(21551820661461729022865262380882070649935529853313286572328683688269863701601); - zeros[9] = uint256(6573136701248752079028194407151022595060682063033565181951145966236778420039); - zeros[10] = uint256(12413880268183407374852357075976609371175688755676981206018884971008854919922); - zeros[11] = uint256(14271763308400718165336499097156975241954733520325982997864342600795471836726); - zeros[12] = uint256(20066985985293572387227381049700832219069292839614107140851619262827735677018); - zeros[13] = uint256(9394776414966240069580838672673694685292165040808226440647796406499139370960); - zeros[14] = uint256(11331146992410411304059858900317123658895005918277453009197229807340014528524); - zeros[15] = uint256(15819538789928229930262697811477882737253464456578333862691129291651619515538); - zeros[16] = uint256(19217088683336594659449020493828377907203207941212636669271704950158751593251); - zeros[17] = uint256(21035245323335827719745544373081896983162834604456827698288649288827293579666); - zeros[18] = uint256(6939770416153240137322503476966641397417391950902474480970945462551409848591); - zeros[19] = uint256(10941962436777715901943463195175331263348098796018438960955633645115732864202); - zeros[20] = uint256(15019797232609675441998260052101280400536945603062888308240081994073687793470); - zeros[21] = uint256(11702828337982203149177882813338547876343922920234831094975924378932809409969); - zeros[22] = uint256(11217067736778784455593535811108456786943573747466706329920902520905755780395); - zeros[23] = uint256(16072238744996205792852194127671441602062027943016727953216607508365787157389); - zeros[24] = uint256(17681057402012993898104192736393849603097507831571622013521167331642182653248); - zeros[25] = uint256(21694045479371014653083846597424257852691458318143380497809004364947786214945); - zeros[26] = uint256(8163447297445169709687354538480474434591144168767135863541048304198280615192); - zeros[27] = uint256(14081762237856300239452543304351251708585712948734528663957353575674639038357); - zeros[28] = uint256(16619959921569409661790279042024627172199214148318086837362003702249041851090); - zeros[29] = uint256(7022159125197495734384997711896547675021391130223237843255817587255104160365); - zeros[30] = uint256(4114686047564160449611603615418567457008101555090703535405891656262658644463); - zeros[31] = uint256(12549363297364877722388257367377629555213421373705596078299904496781819142130); - zeros[32] = uint256(21443572485391568159800782191812935835534334817699172242223315142338162256601); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleBinaryBlankSl.sol b/packages/contracts/contracts/trees/zeros/MerkleBinaryBlankSl.sol deleted file mode 100644 index dde438be02..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleBinaryBlankSl.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Binary tree zeros (hash of a blank state leaf) - constructor() { - zeros[0] = uint256(6769006970205099520508948723718471724660867171122235270773600567925038008762); - zeros[1] = uint256(2972820301952105722688860985556183033855705951263221082702981787813754939537); - zeros[2] = uint256(19009473369953096352828532459942637819279786575057870804186038131433538383332); - zeros[3] = uint256(1877001762518233819645599208989578372605193385355680834239714249281096297174); - zeros[4] = uint256(4022598852800694816938652741439614774645858989706174527409714109784047480520); - zeros[5] = uint256(8078617093048295855521451309865989496051030103472138252021705658681696298712); - zeros[6] = uint256(21861637049723057871988413507302821095913894718242489848472531680353400271584); - zeros[7] = uint256(2969626195902860050407584814596940245443093107470116547781577350415736914038); - zeros[8] = uint256(13863086449569754493134198846069090996475357615094865751949144794620598051673); - zeros[9] = uint256(13774233155966252113965527228795435224641075024674384267997743867571011718458); - zeros[10] = uint256(7674682532432601125535053858292577379388329393276537570517515727197672122157); - zeros[11] = uint256(2657471847139856346360223652201172662911313292042510535836997980857168085414); - zeros[12] = uint256(14112562742724116016492623819773686970029672095023612838615540190985426106768); - zeros[13] = uint256(16966520284141749853106006448832965932249937855809150844697400390499975107456); - zeros[14] = uint256(21146121663662200258116396149536742745305242191891337170899444969488030502620); - zeros[15] = uint256(8395571901509192935479743034608666551563743095742598750914087478677907730358); - zeros[16] = uint256(11584898446168752024843587018551921614604785083342073076015560385003528300499); - zeros[17] = uint256(19681365563800708744156562671961079617734353445922751560400662591064339349816); - zeros[18] = uint256(11060693795061987995391612467169498625108376769265861980249917517984263067473); - zeros[19] = uint256(20136055137568042031318427040358591430196153124171666293804511634641041409480); - zeros[20] = uint256(10438448879123510479428288344427042332522761183009746406441238260861529360499); - zeros[21] = uint256(20302411580043873005239406811066876697276902025885155920151067303221158887923); - zeros[22] = uint256(16905699456770804689394621400052823445587122726651394178036372609288266146575); - zeros[23] = uint256(13317924909658910751179983108234689413063120680580702936091220805509299490708); - zeros[24] = uint256(11624463897690689883938167321830091369950933831231839575225419984927228390345); - zeros[25] = uint256(12388077003631746290497429926117583834311703848735670874049584990731919769551); - zeros[26] = uint256(16641943593086083573943184041147806885253724243247212515325749241831788827569); - zeros[27] = uint256(8675770901378242337954792996483564563211065498082968464791979179678744114204); - zeros[28] = uint256(3741944068643598116715410464277276913339851849923986024648161859457213369743); - zeros[29] = uint256(9365051374992868354747065577256691008852056444829383197903446097138255771103); - zeros[30] = uint256(19608043542461863702809013760105552654336523908709289008189330402608282498922); - zeros[31] = uint256(15116478429455923389320892447700153271977917184085737305957533984219061034768); - zeros[32] = uint256(13372161856163346716845871420623647679532631520878788090782842562075678687737); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleBinaryMaci.sol b/packages/contracts/contracts/trees/zeros/MerkleBinaryMaci.sol deleted file mode 100644 index 370efb087c..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleBinaryMaci.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Binary tree zeros (Keccak hash of 'Maci') - constructor() { - zeros[0] = uint256(8370432830353022751713833565135785980866757267633941821328460903436894336785); - zeros[1] = uint256(13883108378505681706501741077199723943829197421795883447299356576923144768890); - zeros[2] = uint256(15419121528227002346615807695865368688447806543310218580451656713665933966440); - zeros[3] = uint256(6318262337906428951291657677634338300639543013249211096760913778778957055324); - zeros[4] = uint256(17768974272065709481357540291486641669761745417382244600494648537227290564775); - zeros[5] = uint256(1030673773521289386438564854581137730704523062376261329171486101180288653537); - zeros[6] = uint256(2456832313683926177308273721786391957119973242153180895324076357329047000368); - zeros[7] = uint256(8719489529991410281576768848178751308798998844697260960510058606396118487868); - zeros[8] = uint256(1562826620410077272445821684229580081819470607145780146992088471567204924361); - zeros[9] = uint256(2594027261737512958249111386518678417918764295906952540494120924791242533396); - zeros[10] = uint256(7454652670930646290900416353463196053308124896106736687630886047764171239135); - zeros[11] = uint256(5636576387316613237724264020484439958003062686927585603917058282562092206685); - zeros[12] = uint256(6668187911340361678685285736007075111202281125695563765600491898900267193410); - zeros[13] = uint256(11734657993452490720698582048616543923742816272311967755126326688155661525563); - zeros[14] = uint256(13463263143201754346725031241082259239721783038365287587742190796879610964010); - zeros[15] = uint256(7428603293293611296009716236093531014060986236553797730743998024965500409844); - zeros[16] = uint256(3220236805148173410173179641641444848417275827082321553459407052920864882112); - zeros[17] = uint256(5702296734156546101402281555025360809782656712426280862196339683480526959100); - zeros[18] = uint256(18054517726590450486276822815339944904333304893252063892146748222745553261079); - zeros[19] = uint256(15845875411090302918698896692858436856780638250734551924718281082237259235021); - zeros[20] = uint256(15856603049544947491266127020967880429380981635456797667765381929897773527801); - zeros[21] = uint256(16947753390809968528626765677597268982507786090032633631001054889144749318212); - zeros[22] = uint256(4409871880435963944009375001829093050579733540305802511310772748245088379588); - zeros[23] = uint256(3999924973235726549616800282209401324088787314476870617570702819461808743202); - zeros[24] = uint256(5910085476731597359542102744346894725393370185329725031545263392891885548800); - zeros[25] = uint256(8329789525184689042321668445575725185257025982565085347238469712583602374435); - zeros[26] = uint256(21731745958669991600655184668442493750937309130671773804712887133863507145115); - zeros[27] = uint256(13908786229946466860099145463206281117295829828306413881947857340025780878375); - zeros[28] = uint256(2746378384965515118858350021060497341885459652705230422460541446030288889144); - zeros[29] = uint256(4024247518003740702537513711866227003187955635058512298109553363285388770811); - zeros[30] = uint256(13465368596069181921705381841358161201578991047593533252870698635661853557810); - zeros[31] = uint256(1901585547727445451328488557530824986692473576054582208711800336656801352314); - zeros[32] = uint256(3444131905730490180878137209421656122704458854785641062326389124060978485990); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleQuinary0.sol b/packages/contracts/contracts/trees/zeros/MerkleQuinary0.sol deleted file mode 100644 index e8806376bb..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleQuinary0.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Quinary tree zeros (0) - constructor() { - zeros[0] = uint256(0); - zeros[1] = uint256(14655542659562014735865511769057053982292279840403315552050801315682099828156); - zeros[2] = uint256(19261153649140605024552417994922546473530072875902678653210025980873274131905); - zeros[3] = uint256(21526503558325068664033192388586640128492121680588893182274749683522508994597); - zeros[4] = uint256(20017764101928005973906869479218555869286328459998999367935018992260318153770); - zeros[5] = uint256(16998355316577652097112514691750893516081130026395813155204269482715045879598); - zeros[6] = uint256(2612442706402737973181840577010736087708621987282725873936541279764292204086); - zeros[7] = uint256(17716535433480122581515618850811568065658392066947958324371350481921422579201); - zeros[8] = uint256(17437916409890180001398333108882255895598851862997171508841759030332444017770); - zeros[9] = uint256(20806704410832383274034364623685369279680495689837539882650535326035351322472); - zeros[10] = uint256(6821382292698461711184253213986441870942786410912797736722948342942530789476); - zeros[11] = uint256(5916648769022832355861175588931687601652727028178402815013820610204855544893); - zeros[12] = uint256(8979092375429814404031883906996857902016801693563521316025319397481362525766); - zeros[13] = uint256(2921214989930864339537708350754648834701757280474461132621735242274490553963); - zeros[14] = uint256(8930183771974746972686153669144011224662017420905079900118160414492327314176); - zeros[15] = uint256(235368305313252659057202520253547068193638476511860624369389264358598810396); - zeros[16] = uint256(11594802086624841314469980089838552727386894436467147447204224403068085066609); - zeros[17] = uint256(6527402365840056202903190531155009847198979121365335038364206235405082926579); - zeros[18] = uint256(7890267294950363768070024023123773394579161137981585347919627664365669195485); - zeros[19] = uint256(7743021844925994795008658518659888250339967931662466893787320922384170613250); - zeros[20] = uint256(3315762791558236426429898223445373782079540514426385620818139644150484427120); - zeros[21] = uint256(12047412166753578299610528762227103229354276396579409944098869901020016693788); - zeros[22] = uint256(7346375653460369101190037700418084792046605818930533590372465301789036536); - zeros[23] = uint256(16686328169837855831280640081580124364395471639440725186157725609010405016551); - zeros[24] = uint256(19105160640579355001844872723857900201603625359252284777965070378555675817865); - zeros[25] = uint256(17054399483511247964029303840879817843788388567881464290309597953132679359256); - zeros[26] = uint256(5296258093842160235704190490839277292290579093574356735268980000023915581697); - zeros[27] = uint256(8993437003863084469472897416707962588904917898547964184966432920162387360131); - zeros[28] = uint256(7234267096117283161039619077058835089667467648437312224957703988301725566335); - zeros[29] = uint256(21640448288319814375882234036901598260365718394023649234526744669922384765526); - zeros[30] = uint256(1595567811792178436811872247033324109773732075641399161664435302467654689847); - zeros[31] = uint256(15291095622175285816966181294098521638815701170497062413595539727181544870101); - zeros[32] = uint256(15837036953038489303182430773663047564827202645548797032627170282475341436016); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleQuinaryBlankSl.sol b/packages/contracts/contracts/trees/zeros/MerkleQuinaryBlankSl.sol deleted file mode 100644 index 4f3a8fe09d..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleQuinaryBlankSl.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Quinary tree zeros (hash of a blank state leaf) - constructor() { - zeros[0] = uint256(6769006970205099520508948723718471724660867171122235270773600567925038008762); - zeros[1] = uint256(1817443256073160983037956906834195537015546107754139333779374752610409243040); - zeros[2] = uint256(5025334324706345710800763986625066818722194863275454698142520938431664775139); - zeros[3] = uint256(14192954438167108345302805021925904074255585459982294518284934685870159779036); - zeros[4] = uint256(20187882570958996766847085412101405873580281668670041750401431925441526137696); - zeros[5] = uint256(19003337309269317766726592380821628773167513668895143249995308839385810331053); - zeros[6] = uint256(8492845964288036916491732908697290386617362835683911619537012952509890847451); - zeros[7] = uint256(21317322053785868903775560086424946986124609731059541056518805391492871868814); - zeros[8] = uint256(4256218134522031233385262696416028085306220785615095518146227774336224649500); - zeros[9] = uint256(20901832483812704342876390942522900825096860186886589193649848721504734341597); - zeros[10] = uint256(9267454486648593048583319961333207622177969074484816717792204743506543655505); - zeros[11] = uint256(7650747654726613674993974917452464536868175649563857452207429547024788245109); - zeros[12] = uint256(12795449162487060618571749226308575208199045387848354123797521555997299022426); - zeros[13] = uint256(2618557044910497521493457299926978327841926538380467450910611798747947773417); - zeros[14] = uint256(4921285654960018268026585535199462620025474147042548993648101553653712920841); - zeros[15] = uint256(3955171118947393404895230582611078362154691627898437205118006583966987624963); - zeros[16] = uint256(14699122743207261418107167543163571550551347592030521489185842204376855027947); - zeros[17] = uint256(19194001556311522650950142975587831061973644651464593103195262630226529549573); - zeros[18] = uint256(6797319293744791648201295415173228627305696583566554220235084234134847845566); - zeros[19] = uint256(1267384159070923114421683251804507954363252272096341442482679590950570779538); - zeros[20] = uint256(3856223245980092789300785214737986268213218594679123772901587106666007826613); - zeros[21] = uint256(18676489457897260843888223351978541467312325190019940958023830749320128516742); - zeros[22] = uint256(1264182110328471160091364892521750324454825019784514769029658712768604765832); - zeros[23] = uint256(2656996430278859489720531694992812241970377217691981498421470018287262214836); - zeros[24] = uint256(18383091906017498328025573868990834275527351249551450291689105976789994000945); - zeros[25] = uint256(13529005048172217954112431586843818755284974925259175262114689118374272942448); - zeros[26] = uint256(12992932230018177961399273443546858115054107741258772159002781102941121463198); - zeros[27] = uint256(2863122912185356538647249583178796893334871904920344676880115119793539219810); - zeros[28] = uint256(21225940722224750787686036600289689346822264717843340643526494987845938066724); - zeros[29] = uint256(10287710058152238258370855601473179390407624438853416678054122418589867334291); - zeros[30] = uint256(19473882726731003241332772446613588021823731071450664115530121948154136765165); - zeros[31] = uint256(5317840242664832852914696563734700089268851122527105938301831862363938018455); - zeros[32] = uint256(16560004488485252485490851383643926099553282582813695748927880827248594395952); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleQuinaryMaci.sol b/packages/contracts/contracts/trees/zeros/MerkleQuinaryMaci.sol deleted file mode 100644 index c120dbec49..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleQuinaryMaci.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Quinary tree zeros (Keccak hash of 'Maci') - constructor() { - zeros[0] = uint256(8370432830353022751713833565135785980866757267633941821328460903436894336785); - zeros[1] = uint256(12915444503621073454579416579430905206970714557680052030066757042249102605307); - zeros[2] = uint256(15825388848727206932541662858173052318786639683743459477657913288690190505308); - zeros[3] = uint256(20672917177817295069558894035958266756825295443848082659014905185716743537191); - zeros[4] = uint256(448586013948167251740855715259393055429962470693972912240018559200278204556); - zeros[5] = uint256(3228865992178886480410396198366133115832717015233640381802715479176981303177); - zeros[6] = uint256(19116532419590876304532847271428641103751206695152259493043279205958851263600); - zeros[7] = uint256(13531983203936271379763604150672239370281863210813769735936250692178889682484); - zeros[8] = uint256(8276490051100115441938424474671329955897359239518198952109759468777824929104); - zeros[9] = uint256(1234816188709792521426066175633785051600533236493067959807265450339481920006); - zeros[10] = uint256(14253963034950198848796956783804665963745244419038717333683296599064556174281); - zeros[11] = uint256(6367560368479067766970398112009211893636892126125767203198799843543931913172); - zeros[12] = uint256(9086778412328290069463938062555298073857321633960448227011862356090607842391); - zeros[13] = uint256(1440983698234119608650157588008070947531139377294971527360643096251396484622); - zeros[14] = uint256(3957599085599383799297196095384587366602816424699353871878382158004571037876); - zeros[15] = uint256(2874250189355749385170216620368454832544508482778847425177457138604069991955); - zeros[16] = uint256(21009179226085449764156117702096359546848859855915028677582017987249294772778); - zeros[17] = uint256(11639371146919469643603772238908032714588430905217730187804009793768292270213); - zeros[18] = uint256(6279313411277883478350325643881386249374023631847602720184182017599127173896); - zeros[19] = uint256(21059196126634383551994255775761712285020874549906884292741523421591865338509); - zeros[20] = uint256(9444544622817172574621750245792527383369133221167610044960147559319164808325); - zeros[21] = uint256(5374570219497355452080912323548395721574511162814862844226178635172695078543); - zeros[22] = uint256(4155904241440251764630449308160227499466701168124519106689866311729092343061); - zeros[23] = uint256(15881609944326576145786405158479503217901875433072026818450276983706463215155); - zeros[24] = uint256(20831546672064137588434602157208687297579005252478070660473540633558666587287); - zeros[25] = uint256(3209071488384365842993449718919243416332014108747571544339190291353564426179); - zeros[26] = uint256(10030934989297780221224272248227257782450689603145083016739151821673604746295); - zeros[27] = uint256(16504852316033851373501270056537918974469380446508638487151124538300880427080); - zeros[28] = uint256(5226137093551352657015038416264755428944140743893702595442932837011856178457); - zeros[29] = uint256(18779994066356991319291039019820482828679702085087990978933303018673869446075); - zeros[30] = uint256(12037506572124351893114409509086276299115869080424687624451184925646292710978); - zeros[31] = uint256(12049750997011422639258622747494178076018128204515149991024639355149614767606); - zeros[32] = uint256(3171463916443906096008599541392648187002297410622977814790586531203175805057); - } -} diff --git a/packages/contracts/contracts/trees/zeros/MerkleQuinaryMaciWithSha256.sol b/packages/contracts/contracts/trees/zeros/MerkleQuinaryMaciWithSha256.sol deleted file mode 100644 index f21468cf9d..0000000000 --- a/packages/contracts/contracts/trees/zeros/MerkleQuinaryMaciWithSha256.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -abstract contract MerkleZeros { - uint256[33] internal zeros; - - // Quinary tree (with SHA256) zeros (Keccak hash of 'Maci') - constructor() { - zeros[0] = uint256(8370432830353022751713833565135785980866757267633941821328460903436894336785); - zeros[1] = uint256(15325010760924867811060011598468731160102892305643597546418886993209427402124); - zeros[2] = uint256(5333436556486022924864323600267292046975057763731162279859756425998760869639); - zeros[3] = uint256(10977687713725258236554818575005054118245377800202335296681050076688083648086); - zeros[4] = uint256(17224613048028572295675465280070534343823303585304562923867790579733480935264); - zeros[5] = uint256(17706041913665507482150667409133417574717160680803140264120398284023956076290); - zeros[6] = uint256(9653598640710890037650186704093119545289422499247280741743943320819000499646); - zeros[7] = uint256(3206708589682338778875464217516564639886138074743860970529166723769308693331); - zeros[8] = uint256(20534426109262125257001376157024458165019301442070720434223770308413031897106); - zeros[9] = uint256(20045595674714290179477944839500625050021328745176742196691278453734645214461); - zeros[10] = uint256(1990443879384407462884849355600260727579259402554912319388203567178699099823); - zeros[11] = uint256(15030670756630149022405255264285307614365927334767433095054187593088567423357); - zeros[12] = uint256(18151643848963813172699123574112664048044995742942448148573079318091374187889); - zeros[13] = uint256(12716797128662011430654728594886216826078433472768452754660103993065334317074); - zeros[14] = uint256(1778668013271642889777963040449750701990462149853502233417669847457236064652); - zeros[15] = uint256(5310295518327181913512672840814534597220436900477241678956359474542866650820); - zeros[16] = uint256(13698756698956924170299002904918188137369325655270855940405108330875686641692); - zeros[17] = uint256(16978698509212058134355374823422776609466830925429320593002017159097039391798); - zeros[18] = uint256(21122904167710384374017181343962526230952584354459613272526061056824616537143); - zeros[19] = uint256(5985710021335277534018076016950505662155095700842597825798268278683684529911); - zeros[20] = uint256(12532916265365969493430834411976825909479396013951866588908395278818546013433); - zeros[21] = uint256(8930761113974965197874653050290197596753921117163820694764716198465769499045); - zeros[22] = uint256(7923291528963393397483250836756011061887097780645138922028359275174896145293); - zeros[23] = uint256(3165523255399386676797999966015195343651238663671903081942130824893771740953); - zeros[24] = uint256(16498953853801480907823499768835003172991697981391001961022924988055514153444); - zeros[25] = uint256(4646652977614280202033130495149148518982017582438403557846318228188699893314); - zeros[26] = uint256(16063634456514132367413661909718374200540548246284043795891576706199387111176); - zeros[27] = uint256(6432449679436816515158314256021560028822839412197804709124582783531979581762); - zeros[28] = uint256(16549548229658147491856279832226477385154640474741924661165993652668688816447); - zeros[29] = uint256(17839947633190642328550610337345984157351952156869520211179465702618934306508); - zeros[30] = uint256(12740635476725314448365579529753493622477881762096050379151557051600454293132); - zeros[31] = uint256(14450546044445547667240670175592035046062311068467905405735885913523641104070); - zeros[32] = uint256(16649881337797029358598450172037019406882299786178038601098631221224645092238); - } -} diff --git a/packages/contracts/package.json b/packages/contracts/package.json index e3cf5adca8..eb6e443ba7 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -47,19 +47,17 @@ "test:tallyNonQv": "pnpm run test ./tests/TallyNonQv.test.ts", "test:hasher": "pnpm run test ./tests/Hasher.test.ts", "test:utilities": "pnpm run test ./tests/Utilities.test.ts", - "test:signupGatekeeper": "pnpm run test ./tests/SignUpGatekeeper.test.ts", + "test:signupGatekeeper": "pnpm run test ./tests/gatekeepers/SignUpGatekeeper.test.ts", "test:verifier": "pnpm run test ./tests/Verifier.test.ts", "test:hasherBenchmarks": "pnpm run test ./tests/HasherBenchmarks.test.ts", "test:vkRegistry": "pnpm run test ./tests/VkRegistry.test.ts", "test:pollFactory": "pnpm run test ./tests/PollFactory.test.ts", - "test:eas_gatekeeper": "pnpm run test ./tests/EASGatekeeper.test.ts", - "test:hats_gatekeeper": "pnpm run test ./tests/HatsGatekeeper.test.ts", - "test:gitcoin_gatekeeper": "pnpm run test ./tests/GitcoinPassportGatekeeper.test.ts", - "test:zupass_gatekeeper": "pnpm run test ./tests/ZupassGatekeeper.test.ts", - "test:semaphore_gatekeeper": "pnpm run test ./tests/SemaphoreGatekeeper.test.ts", - "test:anon_aadhaar_gatekeeper": "pnpm run test ./tests/AnonAadhaarGatekeeper.test.ts", - "test:simpleProjectRegistry": "pnpm run test ./tests/extensions/SimpleProjectRegistry.test.ts", - "test:simplePayout": "pnpm run test ./tests/extensions/SimplePayout.test.ts", + "test:eas_gatekeeper": "pnpm run test ./tests/gatekeepers/EASGatekeeper.test.ts", + "test:hats_gatekeeper": "pnpm run test ./tests/gatekeepers/HatsGatekeeper.test.ts", + "test:gitcoin_gatekeeper": "pnpm run test ./tests/gatekeepers/GitcoinPassportGatekeeper.test.ts", + "test:zupass_gatekeeper": "pnpm run test ./tests/gatekeepers/ZupassGatekeeper.test.ts", + "test:semaphore_gatekeeper": "pnpm run test ./tests/gatekeepers/SemaphoreGatekeeper.test.ts", + "test:anon_aadhaar_gatekeeper": "pnpm run test ./tests/gatekeepers/AnonAadhaarGatekeeper.test.ts", "deploy": "hardhat deploy-full", "deploy-poll": "hardhat deploy-poll", "verify": "hardhat verify-full", diff --git a/packages/contracts/scripts/compileSol.ts b/packages/contracts/scripts/compileSol.ts index a0fa5c8eac..27548bb8fd 100644 --- a/packages/contracts/scripts/compileSol.ts +++ b/packages/contracts/scripts/compileSol.ts @@ -4,57 +4,12 @@ import hre from "hardhat"; import fs from "fs"; import path from "path"; -import { genZerosContract } from "../ts/genZerosContract"; - const PATHS = [ path.resolve(__dirname, "..", "artifacts"), path.resolve(__dirname, "..", "cache"), path.resolve(__dirname, "..", "typechain-types"), ]; -const NOTHING_UP_MY_SLEEVE_MACI_NUMS = 8370432830353022751713833565135785980866757267633941821328460903436894336785n; -const BLANK_STATE_LEAF = 6769006970205099520508948723718471724660867171122235270773600567925038008762n; -const NUM_ZEROS = 33; - -const ZERO_TREES = [ - { - name: "MerkleBinary0", - zero: 0n, - hashLength: 2, - comment: "Binary tree zeros (0)", - }, - { - name: "MerkleBinaryMaci", - zero: NOTHING_UP_MY_SLEEVE_MACI_NUMS, - hashLength: 2, - comment: "Binary tree zeros (Keccak hash of 'Maci')", - }, - { - name: "MerkleBinaryBlankSl", - zero: BLANK_STATE_LEAF, - hashLength: 2, - comment: "Binary tree zeros (hash of a blank state leaf)", - }, - { - name: "MerkleQuinary0", - zero: 0n, - hashLength: 5, - comment: "Quinary tree zeros (0)", - }, - { - name: "MerkleQuinaryMaci", - zero: NOTHING_UP_MY_SLEEVE_MACI_NUMS, - hashLength: 5, - comment: "Quinary tree zeros (Keccak hash of 'Maci')", - }, - { - name: "MerkleQuinaryBlankSl", - zero: BLANK_STATE_LEAF, - hashLength: 5, - comment: "Quinary tree zeros (hash of a blank state leaf)", - }, -]; - type ExtendedHre = typeof hre & { overwriteArtifact: (name: string, code: unknown) => Promise }; const buildPoseidon = async (numInputs: number) => { @@ -69,22 +24,6 @@ const buildPoseidonT6 = (): Promise => buildPoseidon(5); async function main(): Promise { await Promise.all(PATHS.map((filepath) => fs.existsSync(filepath) && fs.promises.rm(filepath, { recursive: true }))); - await Promise.all( - ZERO_TREES.map(({ name, zero, hashLength, comment }) => - genZerosContract({ - name, - zeroVal: zero, - hashLength, - numZeros: NUM_ZEROS, - comment, - useSha256: false, - subDepth: 0, - }).then((text) => - fs.promises.writeFile(path.resolve(__dirname, "..", "contracts/trees/zeros", `${name}.sol`), `${text}\n`), - ), - ), - ); - await hre.run("compile"); await Promise.all([buildPoseidonT3(), buildPoseidonT4(), buildPoseidonT5(), buildPoseidonT6()]); diff --git a/packages/contracts/tests/AnonAadhaarGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/AnonAadhaarGatekeeper.test.ts similarity index 96% rename from packages/contracts/tests/AnonAadhaarGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/AnonAadhaarGatekeeper.test.ts index aee68ec283..815ba7d0aa 100644 --- a/packages/contracts/tests/AnonAadhaarGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/AnonAadhaarGatekeeper.test.ts @@ -2,12 +2,11 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deployAnonAadhaarGatekeeper, deployContract } from "../ts/deploy"; -import { getDefaultSigner, getSigners } from "../ts/utils"; -import { MACI, AnonAadhaarGatekeeper, MockAnonAadhaar } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deployAnonAadhaarGatekeeper, deployContract } from "../../ts/deploy"; +import { getDefaultSigner, getSigners } from "../../ts/utils"; +import { MACI, AnonAadhaarGatekeeper, MockAnonAadhaar } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("AnonAadhaar Gatekeeper", () => { let anonAadhaarGatekeeper: AnonAadhaarGatekeeper; diff --git a/packages/contracts/tests/EASGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/EASGatekeeper.test.ts similarity index 94% rename from packages/contracts/tests/EASGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/EASGatekeeper.test.ts index e78504a1b5..eddd1cff0a 100644 --- a/packages/contracts/tests/EASGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/EASGatekeeper.test.ts @@ -2,12 +2,11 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress, toBeArray } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deployContract } from "../ts/deploy"; -import { getDefaultSigner, getSigners } from "../ts/utils"; -import { EASGatekeeper, MACI } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deployContract } from "../../ts/deploy"; +import { getDefaultSigner, getSigners } from "../../ts/utils"; +import { EASGatekeeper, MACI } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("EAS Gatekeeper", () => { let easGatekeeper: EASGatekeeper; diff --git a/packages/contracts/tests/GitcoinPassportGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/GitcoinPassportGatekeeper.test.ts similarity index 96% rename from packages/contracts/tests/GitcoinPassportGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/GitcoinPassportGatekeeper.test.ts index 77b58c201a..797e8c26c0 100644 --- a/packages/contracts/tests/GitcoinPassportGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/GitcoinPassportGatekeeper.test.ts @@ -2,11 +2,10 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deployContract, getDefaultSigner, getSigners } from "../ts"; -import { GitcoinPassportGatekeeper, MACI, MockGitcoinPassportDecoder } from "../typechain-types"; - -import { initialVoiceCreditBalance, STATE_TREE_DEPTH } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deployContract, getDefaultSigner, getSigners } from "../../ts"; +import { GitcoinPassportGatekeeper, MACI, MockGitcoinPassportDecoder } from "../../typechain-types"; +import { initialVoiceCreditBalance, STATE_TREE_DEPTH } from "../constants"; +import { deployTestContracts } from "../utils"; describe("GitcoinPassport Gatekeeper", () => { let gitcoinGatekeeper: GitcoinPassportGatekeeper; diff --git a/packages/contracts/tests/HatsGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/HatsGatekeeper.test.ts similarity index 97% rename from packages/contracts/tests/HatsGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/HatsGatekeeper.test.ts index 5e43e574af..02a03020d9 100644 --- a/packages/contracts/tests/HatsGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/HatsGatekeeper.test.ts @@ -2,12 +2,11 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deployContract } from "../ts/deploy"; -import { getSigners } from "../ts/utils"; -import { HatsGatekeeperMultiple, HatsGatekeeperSingle, MACI, MockHatsProtocol } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deployContract } from "../../ts/deploy"; +import { getSigners } from "../../ts/utils"; +import { HatsGatekeeperMultiple, HatsGatekeeperSingle, MACI, MockHatsProtocol } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("HatsProtocol Gatekeeper", () => { let maciContract: MACI; diff --git a/packages/contracts/tests/MerkleProofGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/MerkleProofGatekeeper.test.ts similarity index 94% rename from packages/contracts/tests/MerkleProofGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/MerkleProofGatekeeper.test.ts index 6f86b98290..bf3200b830 100644 --- a/packages/contracts/tests/MerkleProofGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/MerkleProofGatekeeper.test.ts @@ -3,12 +3,11 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress, encodeBytes32String } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deployContract } from "../ts/deploy"; -import { getDefaultSigner, getSigners, generateMerkleTree } from "../ts/utils"; -import { MerkleProofGatekeeper, MACI } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deployContract } from "../../ts/deploy"; +import { getDefaultSigner, getSigners, generateMerkleTree } from "../../ts/utils"; +import { MerkleProofGatekeeper, MACI } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("MerkleProof Gatekeeper", () => { let merkleProofGatekeeper: MerkleProofGatekeeper; diff --git a/packages/contracts/tests/SemaphoreGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/SemaphoreGatekeeper.test.ts similarity index 93% rename from packages/contracts/tests/SemaphoreGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/SemaphoreGatekeeper.test.ts index 0d9f0b7e28..05d8a7fc4f 100644 --- a/packages/contracts/tests/SemaphoreGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/SemaphoreGatekeeper.test.ts @@ -2,12 +2,11 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deploySemaphoreGatekeeper, deployContract } from "../ts/deploy"; -import { getDefaultSigner, getSigners } from "../ts/utils"; -import { MACI, SemaphoreGatekeeper, MockSemaphore } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deploySemaphoreGatekeeper, deployContract } from "../../ts/deploy"; +import { getDefaultSigner, getSigners } from "../../ts/utils"; +import { MACI, SemaphoreGatekeeper, MockSemaphore } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("Semaphore Gatekeeper", () => { let semaphoreGatekeeper: SemaphoreGatekeeper; diff --git a/packages/contracts/tests/SignUpGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/SignUpGatekeeper.test.ts similarity index 92% rename from packages/contracts/tests/SignUpGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/SignUpGatekeeper.test.ts index cdf4937025..8b69986c20 100644 --- a/packages/contracts/tests/SignUpGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/SignUpGatekeeper.test.ts @@ -2,12 +2,11 @@ import { expect } from "chai"; import { AbiCoder, ZeroAddress, Signer } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deploySignupToken, deploySignupTokenGatekeeper, deployFreeForAllSignUpGatekeeper } from "../ts/deploy"; -import { getDefaultSigner } from "../ts/utils"; -import { FreeForAllGatekeeper, MACI, SignUpToken, SignUpTokenGatekeeper } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deploySignupToken, deploySignupTokenGatekeeper, deployFreeForAllSignUpGatekeeper } from "../../ts/deploy"; +import { getDefaultSigner } from "../../ts/utils"; +import { FreeForAllGatekeeper, MACI, SignUpToken, SignUpTokenGatekeeper } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("SignUpGatekeeper", () => { let signUpToken: SignUpToken; diff --git a/packages/contracts/tests/ZupassGatekeeper.test.ts b/packages/contracts/tests/gatekeepers/ZupassGatekeeper.test.ts similarity index 97% rename from packages/contracts/tests/ZupassGatekeeper.test.ts rename to packages/contracts/tests/gatekeepers/ZupassGatekeeper.test.ts index 077590b759..6d766a973a 100644 --- a/packages/contracts/tests/ZupassGatekeeper.test.ts +++ b/packages/contracts/tests/gatekeepers/ZupassGatekeeper.test.ts @@ -2,12 +2,11 @@ import { expect } from "chai"; import { AbiCoder, Signer, ZeroAddress } from "ethers"; import { Keypair } from "maci-domainobjs"; -import { deployContract } from "../ts/deploy"; -import { getDefaultSigner, getSigners } from "../ts/utils"; -import { MACI, ZupassGatekeeper } from "../typechain-types"; - -import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants"; -import { deployTestContracts } from "./utils"; +import { deployContract } from "../../ts/deploy"; +import { getDefaultSigner, getSigners } from "../../ts/utils"; +import { MACI, ZupassGatekeeper } from "../../typechain-types"; +import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants"; +import { deployTestContracts } from "../utils"; describe("Zupass Gatekeeper", () => { let zupassGatekeeper: ZupassGatekeeper;