-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: remove llmq::CQuorum{BlockProcessor, Manager} globals, move to LLMQContext #6030
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
Conversation
src/init.cpp
Outdated
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase | ||
node.llmq_ctx->Start(); | ||
|
||
node.mnhf_manager.reset(); |
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.
why that is done? mnhf_manager
is needed to determine if soft-forks are started and this manager if it is not used right now widely, but it means to be initialized close to CChainState
soon as possible, because everything that uses chain may also be interested by status of soft-fork by BIP9. Everything else, such as QuorumManager, Metaman, mn_sync, peerman, quorum-instant-send-lock....
Mnhf_manager
should be initilized early as possible to be sure when CChainState
(and its helpers) are initialized you already have a knowledge about soft-forks
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.
src/evo/mnhftx.cpp:94: const auto quorum = llmq::quorumManager->GetQuorum(llmqType, quorumHash);
due to that. Hm, is there any way to resolve this deglob without reversing initialization order?
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.
I initially took the approach of having {Process
, Undo
}Block
accept llmq::CQuorumManager
, which seemed sensible since it would be called through CSpecialTxProcessor
, which has access to llmq::CQuorumManager
. Unfortunately, ProcessBlock
is also used by GetForBlock
, which is used by GetSignalsStage
and AddSignal
, the former being used in VersionBitsConditionChecker
.
Since threading that needle would be unpleasant, the less unpleasant means would be to give CMNHFManager
knowledge of llmq::CQuorumManager
. That's why I took the approach that I did.
Alternatively, we can do what we did for CTxMemPool
and leave certain functionality unavailable unless you call ConnectManagers
, which then lets you use the desired functionality. Since that was quite easy to do for CTxMemPool
(most of the ProTx validation code was quite easy to segment), it was done there, I wasn't sure about that here.
If CMNHFManager
could be given a read-only mode (which only needs CEvoDB
) and full mode (needing llmq::CQuorumManager
), this approach would be plausible.
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.
Refactored the code to now have (Dis
)connectManagers
, llmq::CQuorumManager
is used only {Process
, Undo
}Block
, appropriate comments and assert
s have been added.
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.
overall LGTM but maybe I'd not touch CMNHFManager initialization before we got mn_rr on mainnet (so far as it is well tested on testnet in the current version)
src/llmq/context.h
Outdated
const std::shared_ptr<CBLSWorker> bls_worker; | ||
const std::unique_ptr<llmq::CDKGDebugManager> dkg_debugman; | ||
llmq::CQuorumBlockProcessor* const quorum_block_processor; | ||
llmq::CQuorumBlockProcessor* const qblockman; |
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.
the name of class is CQuorumBlockProcessor
, why the name is qblockMAN
?
it makes a confusion with CQuorumManager
, I'd avoid renaming it without a good cause
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.
I went with qblockman
because quorum_block_processor
is a long name and because it's the name already used in CSpecialTxProcessor
(source).
The ending with -man
does conflict with the name but it's also the only -Processor
class being passed around in different parts of the codebase like it's a distinct entity and it seems to behave like one, having its own internal state (unlike CSpecialTxProcessor
or CMNPaymentsProcessor
, which only hold references but no state for itself).
qman
and qblockman
are distinct enough IMO to avoid confusion and in all likelihood, any confusion make itself apparent as they don't implement an interface that can be confused for each other.
Placing PR as draft to address |
@kwvg let's get merged these 4 commits as a spare PR?
To avoid further conflicts and reduce rebases. |
ec4a9d4
to
f46df86
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.
utACK
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.
LGTM f46df86
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.
I don't think I support the renaming qman
is too vague IMO, and there's no real value in changing it from quorum_manager
quorum_man
would be fine imo; but I don't like qman
. Same with qblockman
I don't like dropping quorum
. Otherwise fine
src/evo/mnhftx.cpp
Outdated
AddToCache(signals, pindex); | ||
} | ||
|
||
void CMNHFManager::ConnectManagers(llmq::CQuorumManager* qman) |
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.
make this gsl::not_null
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.
Resolved in latest push
if (node.mnhf_manager) { | ||
node.mnhf_manager->DisconnectManagers(); | ||
} | ||
node.llmq_ctx.reset(); |
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.
why no longer checkin for llmq_ctx?
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.
Because reset()
is a no-op on containers that have already been reset, as is the case with the containers being reset()
above and below.
The conditional for node.mnhf_manager
is because we're interacting with the underlying type while reset()
interacts with the container type.
I think I support this |
1964073
to
62ee3d4
Compare
…ontext` We used to store an alias to the `CQuorumBlockProcessor` instance present in the global state in `LLMQContext` but handled construction and destruction of the instance in `LLMQContext`. As direct global usage no longer exists, we can fully subsume it into `LLMQContext`.
Renaming has been removed from this PR |
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 d7c35d0
#include <spentindex.h> | ||
#include <amount.h> | ||
#include <coins.h> | ||
#include <gsl/pointers.h> |
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.
nit:
gsl/pointers.h
is a heavy header due to algorithm
and txmempool.h is used in hundreds of other compilation units. It affects compilation time.
see #6039 which reduces gsl's impact
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
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.
re-utACK d7c35d0
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 d7c35d0
…er pointers, check before `queueman` access, update P2P message map in tests 24f9357 fix: update P2P message map in functional test framework (Kittywhiskers Van Gogh) a432a95 fix: check if `queueman` is initialized before accessing it (Kittywhiskers Van Gogh) 0444e59 trivial: use `std::atomic` to protect connected manager pointers (Kittywhiskers Van Gogh) b7700b3 trivial: use `std::atomic` to protect connected signer pointers (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependency for #6838 This pull request contains the following: * Minor follow-up to [dash#6828](#6828) based on feedback received during review also extended to similar connections introduced in [dash#5980](#5980) ([commit](a5be37c#diff-c065d4cd2398ad0dbcef393c5dfc53f465bf44723348892395fffd2fb3bac522R350-R355)) and [dash#6030](#6030) ([commit](805537e#diff-59f8e9f1b35c1428332caab753a818e3b2146e73bb6c998a2aed5f7eddbc6fa1R357-R363)) * A bugfix to avoid potential crash caused by missing `nullptr` check after `CCoinJoinClientQueueManager` was conditionally initialized in [dash#5163](#5163) ([commit](2d2814e#diff-b1e19192258d83199d8adaa5ac31f067af98f63554bfdd679bd8e8073815e69dR2308-R2310)) * Updating the Python mapping of Dash-specific P2P messages to avoid unexpected test failures ([build](https://github.com/dashpay/dash/actions/runs/17707917238/job/50323243018#step:6:328)), observed when working on [dash#6838](#6838) ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)** - [x] 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)_ ACKs for top commit: UdjinM6: utACK 24f9357 Tree-SHA512: 90b0b2536a7704e3f3da4ece05b6ad09c393a4348aaff87682b7547f6a7d6ffede504176fa1f63bd9ad88961fb1e3b113aae5df357c0dfb70df2fc55500c2b5f
Breaking Changes
None expected.
Checklist