Skip to content

Commit

Permalink
fix(maci): reverted a fix and fixed test suits
Browse files Browse the repository at this point in the history
Reverted the fix related to updating a state variable in a for loop for AccQueue. Also fixed the
tests by adding the `NOTHING_UP_MY_SLEEVE` hash on the local MaciState instance.
  • Loading branch information
ctrlc03 committed Sep 20, 2022
1 parent 76c991a commit 8300cc5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion circuits/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions contracts/contracts/trees/AccQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MerkleZeros as MerkleQuinary0 } from "./zeros/MerkleQuinary0.sol";
import { MerkleZeros as MerkleQuinaryMaci } from "./zeros/MerkleQuinaryMaci.sol";
import { MerkleZeros as MerkleQuinaryBlankSl } from "./zeros/MerkleQuinaryBlankSl.sol";
import { MerkleZeros as MerkleQuinaryMaciWithSha256 } from "./zeros/MerkleQuinaryMaciWithSha256.sol";
import "hardhat/console.sol";

/*
* This contract defines a Merkle tree where each leaf insertion only updates a
Expand Down Expand Up @@ -315,9 +316,7 @@ abstract contract AccQueue is Ownable, Hasher {
uint256 depth = calcMinHeight();

uint256 queueOpsPerformed = 0;
uint256 _nextSubRootIndex = nextSubRootIndex;
for (uint256 i = _nextSubRootIndex; i < currentSubtreeIndex; i ++) {

for (uint256 i = nextSubRootIndex; i < currentSubtreeIndex; i ++) {
if (_numSrQueueOps != 0 && queueOpsPerformed == _numSrQueueOps) {
// If the limit is not 0, stop if the limit has been reached
return;
Expand All @@ -331,14 +330,12 @@ abstract contract AccQueue is Ownable, Hasher {
);

// Increment the next subroot counter
_nextSubRootIndex ++;
nextSubRootIndex ++;

// Increment the ops counter
queueOpsPerformed ++;
}

_nextSubRootIndex = nextSubRootIndex;


// The height of the tree of subroots
uint256 m = hashLength ** depth;

Expand Down
1 change: 1 addition & 0 deletions core/ts/MaciState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Poll {
)

this.messageAq.enqueue(NOTHING_UP_MY_SLEEVE);
this.messageTree.insert(NOTHING_UP_MY_SLEEVE);

for (let i = 0; i < this.maxValues.maxVoteOptions; i ++) {
this.results.push(BigInt(0))
Expand Down
3 changes: 2 additions & 1 deletion crypto/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crypto/ts/AccQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,4 @@ class AccQueue {

export {
AccQueue,
}
}

0 comments on commit 8300cc5

Please sign in to comment.