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: should not notify about mnlist changes while ConnectBlock isn't done yet #5711

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Nov 16, 2023

Issue being fixed or feature implemented

ConnectBlock can fail after ProcessSpecialTxsInBlock, we shouldn't be notifying too early. Same for DisconnectBlock but that's less of an issue imo.

What was done?

Move notifications to the end of ConnectBlock/DisconnectBlock. There is no connman in CChainState and I don't want to pass it in updates struct so I changed NotifyMasternodeListChanged and used connman from CDSNotificationInterface instead.

How Has This Been Tested?

run unit test, run testnet qt wallet

Breaking Changes

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.1 milestone Nov 16, 2023
@@ -30,9 +31,9 @@ bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CMNHFManager& mnhfManager,
llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CChainLocksHandler& chainlock_handler,
const Consensus::Params& consensusParams, const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerleRoots,
BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
BlockValidationState& state, std::optional<MNListUpdates>& updatesRet) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
Copy link
Collaborator

@knst knst Nov 16, 2023

Choose a reason for hiding this comment

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

doesn't build on my machine: missing #include <optional>

@UdjinM6 UdjinM6 force-pushed the notify_mnlist_later branch from 94749be to 614822d Compare November 16, 2023 16:29
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.

ACK; I don't love adding return by reference, but it works

@@ -1847,6 +1849,12 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
view.SetBestBlock(pindex->pprev->GetBlockHash());
m_evoDb.WriteBestBlock(pindex->pprev->GetBlockHash());

if (mnlist_updates_opt.has_value()) {
auto mnlu = mnlist_updates_opt.value();
GetMainSignals().NotifyMasternodeListChanged(true, mnlu.old_list, mnlu.diff);
Copy link
Collaborator

Choose a reason for hiding this comment

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

it is done under cs_main lock now; let me think a bit how to change it

Copy link
Author

Choose a reason for hiding this comment

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

previously it was simply done deeper than now so there is no change imo

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.

(due to cs_main)

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.

utACK

@PastaPastaPasta PastaPastaPasta merged commit b5d8283 into dashpay:develop Nov 16, 2023
10 checks passed
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Nov 16, 2023
…done yet (dashpay#5711)

## Issue being fixed or feature implemented
`ConnectBlock` can fail after `ProcessSpecialTxsInBlock`, we shouldn't
be notifying too early. Same for `DisconnectBlock` but that's less of an
issue imo.

## What was done?
Move notifications to the end of `ConnectBlock`/`DisconnectBlock`. There
is no `connman` in `CChainState` and I don't want to pass it in updates
struct so I changed `NotifyMasternodeListChanged` and used `connman`
from `CDSNotificationInterface` instead.

## How Has This Been Tested?
run unit test, run testnet qt wallet

## Breaking Changes

## Checklist:
- [x] 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
- [x] I have assigned this pull request to a milestone _(for repository
code-owners and collaborators only)_
@UdjinM6 UdjinM6 modified the milestones: 20.1, 20.0.1 Nov 16, 2023
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