Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [L02]: Duplicate function execution in commitAndEmitEncryptedVote #4069

Merged
merged 7 commits into from Aug 9, 2022

Conversation

chrismaree
Copy link
Member

Motivation

OZ identified the following issue:

In the VotingV2 contract the overloaded function commitAndEmitEncryptedVote that is
provided for backwards compatibility mistakenly calls commitVote twice: The first call to
commitVote is performed directly within the function body on line 614, and an additional call
is performed indirectly by the call to commitAndEmitEncryptedVote on line 616.
The duplicate call is an unnecessary gas expense and leads to an unintentional duplication of
VoteCommitted event emission.

Fix presented in this PR:

Remove the duplicate call to commitVote.

Testing

Check a box to describe how you tested these changes and list the steps for reviewers to test.

  • Ran end-to-end test, running the code as in production
  • New unit tests created
  • Existing tests adequate, no new tests required
  • All existing tests pass
  • Untested

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
@mrice32 mrice32 added the audit-dvm-2-0 Fixes for the DVM 2.0 Audit label Aug 4, 2022
Copy link
Member

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once extra changes are removed!

function getStartingIndexForStaker() internal virtual returns (uint64) {
return 0;
}
function getStartingIndexForStaker() internal view virtual returns (uint64) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think changes from #4068 were accidentally included. We should probably drop this commit.

@@ -611,8 +611,6 @@ contract VotingV2 is
bytes32 hash,
bytes memory encryptedVote
) public override {
commitVote(identifier, time, "", hash);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this is a great catch!

@mrice32 mrice32 requested a review from md0x August 5, 2022 08:51
Copy link
Contributor

@md0x md0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. LGTM

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
@chrismaree chrismaree merged commit 43faa2b into master Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit-dvm-2-0 Fixes for the DVM 2.0 Audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants