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: avoid voting for the same trigger multiple times #6155

Merged
merged 4 commits into from
Sep 5, 2024

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Jul 24, 2024

Issue being fixed or feature implemented

We just had a sb voting period and I noticed that the network is way too spammy and produces too many votes (10x+ the expected numbers). It turns out that relying on ProcessVoteAndRelay on mainnet is not enough because rate-check expires too soon and MNs are able to vote again and again. On testnet it was never an issue because the voting period there is really short.

What was done?

Check known votes to make sure we never voted earlier.

How Has This Been Tested?

Run tests, run a MN on mainnet and check logs.

Breaking Changes

n/a

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@UdjinM6 UdjinM6 force-pushed the fix_multivote branch 3 times, most recently from fc7425b to 761f5c0 Compare July 25, 2024 09:31
@UdjinM6 UdjinM6 requested review from knst and PastaPastaPasta July 29, 2024 09:44
@UdjinM6 UdjinM6 added this to the 21 milestone Aug 5, 2024
Copy link
Author

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

NOTE to myself: do clang-format

done

@UdjinM6 UdjinM6 modified the milestones: 21, 21.1 Aug 5, 2024
@UdjinM6 UdjinM6 modified the milestones: 21.1, 21.2 Aug 8, 2024
@PastaPastaPasta
Copy link
Member

because rate-check expires too soon

why not increase this timeout?

Comment on lines 741 to 766
ranges::any_of(voteRecord.mapInstances, [&](const auto& voteInstancePair) {
if (voteInstancePair.first == VOTE_SIGNAL_FUNDING) {
if (voteInstancePair.second.eOutcome == VOTE_OUTCOME_YES) {
votedFundingYesTriggerHash = gov_sb_hash;
}
LogPrint(BCLog::GOBJECT, /* Continued */
"CGovernanceManager::%s "
"Not voting YES-FUNDING for trigger:%s, we voted %s for it already\n",
strFunc, gov_sb_hash.ToString(),
CGovernanceVoting::ConvertOutcomeToString(voteInstancePair.second.eOutcome));
return true;
}
return false;
});
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused.. you're doing ranges::any_of, but discarding the return values?

@UdjinM6 UdjinM6 force-pushed the fix_multivote branch 3 times, most recently from 11b6dba to 4d61b7b Compare August 13, 2024 15:17
if (vote_rec_t voteRecord; trigger_opt.value().GetCurrentMNVotes(mn_activeman.GetOutPoint(), voteRecord)) {
const auto& strFunc = __func__;
// Let's see if there is a VOTE_SIGNAL_FUNDING vote from us already
ranges::any_of(voteRecord.mapInstances, [&](const auto& voteInstancePair) {
Copy link
Member

Choose a reason for hiding this comment

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

still discarding this return value

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK 3e78081; I do wish there was a regression test maybe, but otherwise looks good

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK e92aad7

@UdjinM6
Copy link
Author

UdjinM6 commented Sep 4, 2024

ping @knst

Copy link
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

LGTM e92aad7

@PastaPastaPasta PastaPastaPasta merged commit f222f79 into dashpay:develop Sep 5, 2024
34 of 35 checks passed
@UdjinM6 UdjinM6 modified the milestones: 21.2, 22 Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants