Skip to content

Commit

Permalink
Merge pull request #1877 from privacy-scaling-explorations/chore/tall…
Browse files Browse the repository at this point in the history
…y-struct

chore: move add tally results args struct to interface
  • Loading branch information
0xmad authored Oct 28, 2024
2 parents e9b4b32 + 8370f78 commit 8e76436
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
24 changes: 1 addition & 23 deletions packages/contracts/contracts/Tally.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,6 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher, DomainObjs, ITa
bool flag;
}

/// @notice tally result args
struct AddTallyResultsArgs {
/// @param voteOptionIndices Vote option index.
uint256[] voteOptionIndices;
/// @param tallyResults The results of vote tally for the recipients.
uint256[] tallyResults;
/// @param tallyResultProofs Proofs of correctness of the vote tally results.
uint256[][][] tallyResultProofs;
/// @param totalSpent spent field retrieved in the totalSpentVoiceCredits object
uint256 totalSpent;
/// @param totalSpentSalt spent salt
uint256 totalSpentSalt;
/// @param tallyResultSalt the respective salt in the results object in the tally.json
uint256 tallyResultSalt;
/// @param newResultsCommitment The salted commitment of the vote tally for this batch of leaves plus the vote tally from currentResults
uint256 newResultsCommitment;
/// @param spentVoiceCreditsHash hashLeftRight(number of spent voice credits, spent salt)
uint256 spentVoiceCreditsHash;
/// @param perVOSpentVoiceCreditsHash hashLeftRight(merkle root of the no spent voice credits per vote option, perVOSpentVoiceCredits salt)
uint256 perVOSpentVoiceCreditsHash;
}

/// @notice The commitment to the tally results. Its initial value is 0, but after
/// the tally of each batch is proven on-chain via a zk-SNARK, it should be
/// updated to:
Expand Down Expand Up @@ -390,7 +368,7 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher, DomainObjs, ITa
* @notice Add and verify tally results by batch.
* @param args add tally result args
*/
function addTallyResults(AddTallyResultsArgs calldata args) public virtual onlyOwner {
function addTallyResults(ITally.AddTallyResultsArgs calldata args) public virtual onlyOwner {
if (!isTallied()) {
revert VotesNotTallied();
}
Expand Down
22 changes: 22 additions & 0 deletions packages/contracts/contracts/interfaces/ITally.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ pragma solidity ^0.8.10;
/// @title ITally
/// @notice Tally interface
interface ITally {
/// @notice tally result args
struct AddTallyResultsArgs {
/// @param voteOptionIndices Vote option index.
uint256[] voteOptionIndices;
/// @param tallyResults The results of vote tally for the recipients.
uint256[] tallyResults;
/// @param tallyResultProofs Proofs of correctness of the vote tally results.
uint256[][][] tallyResultProofs;
/// @param totalSpent spent field retrieved in the totalSpentVoiceCredits object
uint256 totalSpent;
/// @param totalSpentSalt spent salt
uint256 totalSpentSalt;
/// @param tallyResultSalt the respective salt in the results object in the tally.json
uint256 tallyResultSalt;
/// @param newResultsCommitment The salted commitment of the vote tally for this batch of leaves plus the vote tally from currentResults
uint256 newResultsCommitment;
/// @param spentVoiceCreditsHash hashLeftRight(number of spent voice credits, spent salt)
uint256 spentVoiceCreditsHash;
/// @param perVOSpentVoiceCreditsHash hashLeftRight(merkle root of the no spent voice credits per vote option, perVOSpentVoiceCredits salt)
uint256 perVOSpentVoiceCreditsHash;
}

/// @notice Verify the number of spent voice credits per vote option from the tally.json
/// @param _voteOptionIndex the index of the vote option where credits were spent
/// @param _spent the spent voice credits for a given vote option index
Expand Down

0 comments on commit 8e76436

Please sign in to comment.