Skip to content

Commit

Permalink
refactor: optimize poll and tally contracts variables
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmad committed Jul 2, 2024
1 parent 89fef5a commit f3b6035
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 4 additions & 3 deletions contracts/contracts/Poll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ contract Poll is Params, Utilities, SnarkCommon, EmptyBallotRoots, IPoll {
// set merged to true so it cannot be called again
stateMerged = true;

mergedStateRoot = extContracts.maci.getStateTreeRoot();
uint256 _mergedStateRoot = extContracts.maci.getStateTreeRoot();
mergedStateRoot = _mergedStateRoot;

// Set currentSbCommitment
uint256[3] memory sb;
sb[0] = mergedStateRoot;
sb[0] = _mergedStateRoot;
sb[1] = emptyBallotRoots[treeDepths.voteOptionTreeDepth - 1];
sb[2] = uint256(0);

Expand All @@ -225,7 +226,7 @@ contract Poll is Params, Utilities, SnarkCommon, EmptyBallotRoots, IPoll {

actualStateTreeDepth = depth;

emit MergeMaciState(mergedStateRoot, numSignups);
emit MergeMaciState(_mergedStateRoot, _numSignups);
}

/// @inheritdoc IPoll
Expand Down
5 changes: 0 additions & 5 deletions contracts/contracts/Tally.sol
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher, DomainObjs {
uint256 _resultCommitment,
uint256 _perVOSpentVoiceCreditsHash
) public view returns (bool isValid) {
uint256[3] memory tally;
tally[0] = _resultCommitment;
tally[1] = hashLeftRight(_totalSpent, _totalSpentSalt);
tally[2] = _perVOSpentVoiceCreditsHash;

if (mode == Mode.QV) {
isValid = verifyQvSpentVoiceCredits(_totalSpent, _totalSpentSalt, _resultCommitment, _perVOSpentVoiceCreditsHash);
} else if (mode == Mode.NON_QV) {
Expand Down

0 comments on commit f3b6035

Please sign in to comment.