Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into feat/subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
hangleang committed Mar 27, 2024
2 parents 5758434 + 57300c0 commit 98a50a0
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 324 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **circuits:** replace execSync with execFileSync ([4c121ca](https://github.com/privacy-scaling-explorations/maci/commit/4c121ca0413495979be7af87da5474a9f0b093bf))
* **cli:** add a check that the subsidy verifying key was set correctly on chain ([6bda14d](https://github.com/privacy-scaling-explorations/maci/commit/6bda14dd7021846a639ce8cffef3a863eda2b447)), closes [#446](https://github.com/privacy-scaling-explorations/maci/issues/446)
* **cli:** add auto mining option for hardhat ([e5ad345](https://github.com/privacy-scaling-explorations/maci/commit/e5ad3452b77be5007b0ddbe593606a7bcd2a9fc5))
* **cli:** add env initialization for hardhat conifg ([5442b8a](https://github.com/privacy-scaling-explorations/maci/commit/5442b8a88e3133f2cbdbcf68ed1710207d5f0988))
* **cli:** add env initialization for hardhat config ([5442b8a](https://github.com/privacy-scaling-explorations/maci/commit/5442b8a88e3133f2cbdbcf68ed1710207d5f0988))
* **cli:** export genLocalState ([0026669](https://github.com/privacy-scaling-explorations/maci/commit/0026669b31420ad31da1fa7eb716822217a3df30))
* **cli:** give priority to gatekeeper and voice credit proxy args ([1597ee3](https://github.com/privacy-scaling-explorations/maci/commit/1597ee3a00c05fdf8ff46811804a78af450f066c))
* **cli:** prioritize contract addresses params ([8ec36c4](https://github.com/privacy-scaling-explorations/maci/commit/8ec36c4d65329b40d7e232861c63208761d73b0a)), closes [#1039](https://github.com/privacy-scaling-explorations/maci/issues/1039)
Expand Down Expand Up @@ -102,7 +102,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* remove HackMD TOC ([7554524](https://github.com/privacy-scaling-explorations/maci/commit/755452414b85c78ff52e5b2ea3b14123a5748602))
* remove trailing chars ([3101a60](https://github.com/privacy-scaling-explorations/maci/commit/3101a6016ebda3385273b47b2de33f5fd9c1221f))
* remove trailing chars ([101fdaf](https://github.com/privacy-scaling-explorations/maci/commit/101fdafe3c094b3615b651b8ff33337f338d2178))
* return new poll addres ([acb38ba](https://github.com/privacy-scaling-explorations/maci/commit/acb38bafe3527ec5541e53c712981127246a007f))
* return new poll address ([acb38ba](https://github.com/privacy-scaling-explorations/maci/commit/acb38bafe3527ec5541e53c712981127246a007f))
* reword main branch list item ([789128a](https://github.com/privacy-scaling-explorations/maci/commit/789128a5380a5dfeb2f7668bacd1f133b51d7937))
* **safelessthan:** replaced several LessThan with SafeLessThan; fixed check on enoughVoiceCredit ([2d7a3a0](https://github.com/privacy-scaling-explorations/maci/commit/2d7a3a0efd33dfc3a5f4d3f95bec3adda7abb963))
* **server:** expanded regex to include capital case values ([ed5915e](https://github.com/privacy-scaling-explorations/maci/commit/ed5915eb524b92299b3a52f2de1000161a8f1a32))
Expand Down
2 changes: 1 addition & 1 deletion circuits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
"mocha": "^10.3.0",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.2"
"typescript": "^5.4.3"
}
}
2 changes: 1 addition & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* add on-chain verification ([6427f37](https://github.com/privacy-scaling-explorations/maci/commit/6427f373d805805adb6205270f5074561d5c3a35))
* **circuits:** enforce use of stateIndex from message ([510e6ee](https://github.com/privacy-scaling-explorations/maci/commit/510e6ee365958e8c7f72cfca6cea75d15a89d28b))
* **cli:** add a check that the subsidy verifying key was set correctly on chain ([6bda14d](https://github.com/privacy-scaling-explorations/maci/commit/6bda14dd7021846a639ce8cffef3a863eda2b447)), closes [#446](https://github.com/privacy-scaling-explorations/maci/issues/446)
* **cli:** add env initialization for hardhat conifg ([5442b8a](https://github.com/privacy-scaling-explorations/maci/commit/5442b8a88e3133f2cbdbcf68ed1710207d5f0988))
* **cli:** add env initialization for hardhat config ([5442b8a](https://github.com/privacy-scaling-explorations/maci/commit/5442b8a88e3133f2cbdbcf68ed1710207d5f0988))
* **cli:** export genLocalState ([0026669](https://github.com/privacy-scaling-explorations/maci/commit/0026669b31420ad31da1fa7eb716822217a3df30))
* **cli:** give priority to gatekeeper and voice credit proxy args ([1597ee3](https://github.com/privacy-scaling-explorations/maci/commit/1597ee3a00c05fdf8ff46811804a78af450f066c))
* **cli:** prioritize contract addresses params ([8ec36c4](https://github.com/privacy-scaling-explorations/maci/commit/8ec36c4d65329b40d7e232861c63208761d73b0a)), closes [#1039](https://github.com/privacy-scaling-explorations/maci/issues/1039)
Expand Down
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"commander": "^12.0.0",
"dotenv": "^16.4.5",
"ethers": "^6.11.1",
"hardhat": "^2.22.1",
"hardhat": "^2.22.2",
"maci-circuits": "^1.2.0",
"maci-contracts": "^1.2.0",
"maci-core": "^1.2.0",
Expand All @@ -67,7 +67,7 @@
"nyc": "^15.1.0",
"snarkjs": "^0.7.3",
"ts-mocha": "^10.0.0",
"typescript": "^5.4.2"
"typescript": "^5.4.3"
},
"nyc": {
"reporter": [
Expand Down
4 changes: 2 additions & 2 deletions cli/ts/commands/proveOnChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const proveOnChain = async ({
logError("There is no VkRegistry contract linked to the specified MACI contract.");
}

const vkRegsitryContract = VkRegistryFactory.connect(vkRegistryContractAddress, signer);
const vkRegistryContract = VkRegistryFactory.connect(vkRegistryContractAddress, signer);
const verifierContractAddress = await mpContract.verifier();

if (!(await contractExists(signer.provider!, verifierContractAddress))) {
Expand Down Expand Up @@ -199,7 +199,7 @@ export const proveOnChain = async ({
const messageRootOnChain = await messageAqContract.getMainRoot(Number(treeDepths.messageTreeDepth));

const stateTreeDepth = Number(await maciContract.stateTreeDepth());
const onChainProcessVk = await vkRegsitryContract.getProcessVk(
const onChainProcessVk = await vkRegistryContract.getProcessVk(
stateTreeDepth,
treeDepths.messageTreeDepth,
treeDepths.voteOptionTreeDepth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SignUpGatekeeper } from "../SignUpGatekeeper.sol";
import { IHats } from "../../interfaces/IHats.sol";

/// @title HatsGatekeeperBase
/// @notice Abastract contract containing the base elements of a Hats Gatekeeper contract
/// @notice Abstract contract containing the base elements of a Hats Gatekeeper contract
abstract contract HatsGatekeeperBase is SignUpGatekeeper, Ownable {
/*//////////////////////////////////////////////////////////////
CUSTOM ERRORS
Expand Down
4 changes: 2 additions & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@openzeppelin/contracts": "^4.8.0",
"circomlibjs": "^0.1.7",
"ethers": "^6.11.1",
"hardhat": "^2.21.1",
"hardhat": "^2.22.2",
"maci-circuits": "^1.2.0",
"maci-core": "^1.2.0",
"maci-crypto": "^1.2.0",
Expand All @@ -96,6 +96,6 @@
"hardhat-contract-sizer": "^2.10.0",
"lowdb": "^1.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.2"
"typescript": "^5.4.3"
}
}
8 changes: 4 additions & 4 deletions contracts/tasks/helpers/Prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Prover {
/**
* VkRegistry contract typechain wrapper
*/
private vkRegsitryContract: VkRegistry;
private vkRegistryContract: VkRegistry;

/**
* Verifier contract typechain wrapper
Expand All @@ -75,7 +75,7 @@ export class Prover {
mpContract,
messageAqContract,
maciContract,
vkRegsitryContract,
vkRegistryContract,
verifierContract,
subsidyContract,
tallyContract,
Expand All @@ -84,7 +84,7 @@ export class Prover {
this.mpContract = mpContract;
this.messageAqContract = messageAqContract;
this.maciContract = maciContract;
this.vkRegsitryContract = vkRegsitryContract;
this.vkRegistryContract = vkRegistryContract;
this.verifierContract = verifierContract;
this.subsidyContract = subsidyContract;
this.tallyContract = tallyContract;
Expand Down Expand Up @@ -119,7 +119,7 @@ export class Prover {

const [messageRootOnChain, onChainProcessVk] = await Promise.all([
this.messageAqContract.getMainRoot(Number(treeDepths[2])),
this.vkRegsitryContract.getProcessVk(
this.vkRegistryContract.getProcessVk(
stateTreeDepth,
treeDepths.messageTreeDepth,
treeDepths.voteOptionTreeDepth,
Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export interface IProverParams {
/**
* VkRegistry contract typechain wrapper
*/
vkRegsitryContract: VkRegistry;
vkRegistryContract: VkRegistry;

/**
* Verifier contract typechain wrapper
Expand Down
4 changes: 2 additions & 2 deletions contracts/tasks/runner/prove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ task("prove", "Command to generate proof and prove the result of a poll on-chain

const maciContractAddress = storage.mustGetAddress(EContracts.MACI, network.name);
const maciContract = await deployment.getContract<MACI>({ name: EContracts.MACI, address: maciContractAddress });
const vkRegsitryContract = await deployment.getContract<VkRegistry>({ name: EContracts.VkRegistry });
const vkRegistryContract = await deployment.getContract<VkRegistry>({ name: EContracts.VkRegistry });
const verifierContract = await deployment.getContract<Verifier>({ name: EContracts.Verifier });

const pollAddress = await maciContract.polls(poll);
Expand Down Expand Up @@ -213,7 +213,7 @@ task("prove", "Command to generate proof and prove the result of a poll on-chain
messageAqContract,
mpContract,
pollContract,
vkRegsitryContract,
vkRegistryContract,
verifierContract,
tallyContract,
subsidyContract,
Expand Down
2 changes: 1 addition & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **deps-dev:** bump lerna from 6.6.2 to 8.0.2 ([4b150ad](https://github.com/privacy-scaling-explorations/maci/commit/4b150ade7c4fbaf88eb0e1f629cec6749377706d))
* **deps-dev:** bump mocha from 10.2.0 to 10.3.0 ([2b76e04](https://github.com/privacy-scaling-explorations/maci/commit/2b76e0445f5da5864a335352f66eac33c070ab29))
* **domainobjs:** apply linter rules and fixes ([6649ca6](https://github.com/privacy-scaling-explorations/maci/commit/6649ca6d2afc83cfec60008fa6314add1cd837cd))
* **intergationTests:** apply linter for intergration tests package ([ef75ec3](https://github.com/privacy-scaling-explorations/maci/commit/ef75ec37b2b4e000ad4b3fcdbdf85ba822690512))
* **intergationTests:** apply linter for integration tests package ([ef75ec3](https://github.com/privacy-scaling-explorations/maci/commit/ef75ec37b2b4e000ad4b3fcdbdf85ba822690512))
* **key-change:** add tests and docs around key-change ([ce394e2](https://github.com/privacy-scaling-explorations/maci/commit/ce394e2d2bf3c8c6748cf8e8d1e401b8f3c924ee))
* linter ([42ea4f0](https://github.com/privacy-scaling-explorations/maci/commit/42ea4f0ae8b342f6bd5ca5ac86f1bdd143978324))
* linter unification ([61a8bcd](https://github.com/privacy-scaling-explorations/maci/commit/61a8bcd915fd3e4b4da3c00d40704d892c02f51b))
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"nyc": "^15.1.0",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.2"
"typescript": "^5.4.3"
},
"nyc": {
"reporter": [
Expand Down
2 changes: 1 addition & 1 deletion crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"nyc": "^15.1.0",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.4.2"
"typescript": "^5.4.3"
},
"nyc": {
"reporter": [
Expand Down
63 changes: 63 additions & 0 deletions crypto/ts/__tests__/AccQueue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,67 @@ describe("AccQueue", function test() {
});
});
});

describe("InsertSubTree", () => {
describe("Binary AccQueue", () => {
const HASH_LENGTH = 2;
const SUB_DEPTH = 2;
const ZERO = BigInt(0);

it("should insert a subtree root into the correct position", () => {
const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO);
const subRoot = BigInt(1);
expect(aq.getSubRoots().length).to.eq(0);
aq.insertSubTree(subRoot);
expect(aq.getSubRoots()[0].toString()).to.eq(subRoot.toString());
});

it("should insert a subtree root when multiple subtrees exist", () => {
const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO);
const subRoot1 = BigInt(1);
const subRoot2 = BigInt(2);
aq.insertSubTree(subRoot1);
aq.insertSubTree(subRoot2);
expect(aq.getSubRoots()[0].toString()).to.eq(subRoot1.toString());
expect(aq.getSubRoots()[1].toString()).to.eq(subRoot2.toString());
});
});
});

describe("Copy", () => {
const HASH_LENGTH = 2;
const SUB_DEPTH = 2;
const ZERO = BigInt(0);

it("should create a deep copy of the AccQueue", () => {
const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO);
aq.enqueue(ZERO);
const copy = aq.copy();

expect(copy).to.be.an.instanceof(AccQueue);
expect(copy.getSubRoots().length).to.eq(aq.getSubRoots().length);
expect(copy.getSubRoots()).to.eql(aq.getSubRoots());
expect(copy.getHashLength()).to.eq(aq.getHashLength());
expect(copy.getSubDepth()).to.eql(aq.getSubDepth());
expect(copy.getZeros()).to.eql(aq.getZeros());
});

it("should not be the same object as the original", () => {
const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO);
const copy = aq.copy();
expect(copy).not.eq(aq);
});

it("should not affect the original AccQueue when modifying the copy", () => {
const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO);

aq.enqueue(ZERO);
const copy = aq.copy();

copy.enqueue(ZERO);
copy.insertSubTree(ZERO);

expect(aq.getSubRoots().length).to.eq(0);
});
});
});
2 changes: 1 addition & 1 deletion integrationTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/node": "^20.11.30",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"hardhat": "^2.22.1",
"hardhat": "^2.22.2",
"hardhat-artifactor": "^0.2.0",
"hardhat-contract-sizer": "^2.0.3",
"mocha": "^10.3.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"solhint": "^4.5.2",
"typedoc": "^0.25.12",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.4.2"
"typescript": "^5.4.3"
},
"config": {
"commitizen": {
Expand Down
Loading

0 comments on commit 98a50a0

Please sign in to comment.