-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@@ -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); |
There was a problem hiding this comment.
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>
94749be
to
614822d
Compare
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
…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)_
Issue being fixed or feature implemented
ConnectBlock
can fail afterProcessSpecialTxsInBlock
, we shouldn't be notifying too early. Same forDisconnectBlock
but that's less of an issue imo.What was done?
Move notifications to the end of
ConnectBlock
/DisconnectBlock
. There is noconnman
inCChainState
and I don't want to pass it in updates struct so I changedNotifyMasternodeListChanged
and usedconnman
fromCDSNotificationInterface
instead.How Has This Been Tested?
run unit test, run testnet qt wallet
Breaking Changes
Checklist: