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: actually vote NO on triggers we don't like, some additional cleanups and tests #5670

Merged
merged 6 commits into from
Nov 6, 2023

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Nov 3, 2023

Issue being fixed or feature implemented

MNs don't really vote NO on triggers that do not match their local candidates because:

  1. they bail out too early when they see that they are not the payee
  2. the hash for objects to vote NO on was picked incorrectly.

What was done?

Moved voting out of CreateGovernanceTrigger and into its own VoteGovernanceTriggers. Refactored related code to use optional while at it, dropped useless/misleading IsValid() call. Added some safety belts, logging, tests.

How Has This Been Tested?

Run tests.

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 added this to the 20 milestone Nov 3, 2023
Comment on lines 296 to 297
const std::optional<CSuperblock> CreateSuperblockCandidate(int nHeight) const;
const std::optional<CGovernanceObject> CreateGovernanceTrigger(const std::optional<CSuperblock>& sb_opt, CConnman& connman);
Copy link
Member

Choose a reason for hiding this comment

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

what is your goal marking these returned values as const?

Copy link
Member

Choose a reason for hiding this comment

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

I think probably if anything you may want std::optional<const T> but probably not const std::optional<T>

Copy link
Author

Choose a reason for hiding this comment

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

oops 🙈 fixed

ogabrielides
ogabrielides previously approved these changes Nov 6, 2023
Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

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

utACK 👍

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.

it looks fine, but check a comment about mnPayee.

I don't also like a new method in public section that accept std::optional because it should not be public but private; and because it doesn't do anything if its argument is nullopt - better to don't call this method at all IMO; but it's not a blocker to get merged.

Comment on lines 682 to 683
auto mnList = deterministicMNManager->GetListForBlock(::ChainActive().Tip());
auto mn_payees = mnList.GetProjectedMNPayees(::ChainActive().Tip());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
auto mnList = deterministicMNManager->GetListForBlock(::ChainActive().Tip());
auto mn_payees = mnList.GetProjectedMNPayees(::ChainActive().Tip());
const CBlockIndex *tip = WITH_LOCK(::cs_main, return ::ChainActive().Tip());
auto mnList = deterministicMNManager->GetListForBlock(tip);
auto mn_payees = mnList.GetProjectedMNPayees(tip);

tip MUST be same for GetListForBlock and for GetProjectedMNPayees due to #5590

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

Copy link
Collaborator

@ogabrielides ogabrielides left a comment

Choose a reason for hiding this comment

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

re-ACK

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 for squash merge; contingent on CI

@UdjinM6
Copy link
Author

UdjinM6 commented Nov 6, 2023

CI is ✅

@UdjinM6 UdjinM6 merged commit c61fe0a into dashpay:develop Nov 6, 2023
10 of 12 checks passed
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.

4 participants