-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: move masternode payments processing to helper class, move C{Governance,Spork}Manager to NodeContext #5908
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
|
This pull request has conflicts, please rebase. |
src/masternode/payments.cpp
Outdated
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: that's a small method, but I don't see a reason to move it to the top of cpp file. especially in the next commit (rename MNSubsidy to CSHelper) most of code removed from this file.
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.
Only most of the header contents of masternode/payments.h are moved to evo/cshelper.h, the contents of masternode/payments.cpp and evo/specialtxman.cpp remain where they are and are only modified to the extent that the new name was being used.
The new header exists somewhat document that ChainstateHelper is just an vessel for logic implemented in those two files and the logic implemented in specialtxman.cpp should not be considered a part of masternode payment code (which would've been in the implication had the special transaction functions been defined in masternode/payments.h).
I kept it at the top because it's a relatively small function (and now additionally, because it's the only function actually defined in its corresponding header, the rest being implementations of the definitions now in cshelper.h)
src/miner.cpp
Outdated
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 like constructor of BlockAssembler to accept many-many arguments; this commit make list of arguments longer --- I don't feel like that is a useful refactoring, moreover I feel like that's getting worse.
If that's a staging temporary changes - I'd like to know what is a next step, but BlockAssembler having +1 more argument as it is done now that is defactoring, not refactoring in my opinion
IMO much better to let BlockAssembler to use mnhfman, creditpool, from chainparams or from cs_helper rather than have that long list of arguments in constructor
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.
we could simply pass node context here I guess c764c09255
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 know how I feel about making the managers available from cs_helper (everywhere else we accept the references for the classes' use but don't actually expose it) but I do agree, the long arguments are frustration-inducing (I'd know, reordering commits and cleaning up required me to fix up the argument list manually multiple times).
But the truth of the matter is, we have a lot of managers. Excluding CoinJoin and LLMQ managers (which are managed by their own context), we have ~10 managers and I don't think that's all of them. There's no real way to avoid it without consolidating them. There's a reason I got rid of CGovernanceTriggerManager, we don't need more managers.
I did think about creating DashContext but then accessing something like CBLSWorker would require doing something like node.dash_ctx->llmq_ctx->bls_worker and that, at least on initial impression, seems like too much nesting.
Using CChainState seems unideal imo, I've tried experimenting with aliasing the CDeterministicMNList query function to CChainState (similar to what was done with CMNHFManager) but it seemed unwieldly to do so, not only was I adding yet another argument to pass through ChainstateManager and CChainState, for a function that CChainState doesn't really need, it's more likely than not that if CDeterministicMNList is passed upwards enough, we'll eventually reach a point where CDeterministicMNManager would be needed.
The reason why I did the refactoring for CMNHFManager is because I'd prefer if CChainState accepts the fewest possible arguments. It's the reason ChainstateHelper exists, because the alternative would be piping CGovernanceManager, CSporkManager and others.
I'm not quite sure of adding NodeContext as an argument, it doesn't really seem to be meant to be used that way. Especially since, unlike LLMQContext, where the constructor initializes its members, there's no such guarantee for NodeContext.
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'm not quite sure of adding
NodeContextas an argument, it doesn't really seem to be meant to be used that way.
Don't know, for me passing node context instead of individual members make perfect sense. Check this for example.
Especially since, unlike
LLMQContext, where the constructor initializes its members, there's no such guarantee forNodeContext.
Check that diff a bit closer ;) and you'll notice that we do the same pointer dereference without checking anything already so there should be no side effects if we move these dereferences somewhere else. But it's true, it would probably make sense to have some (inline) asserts, see f5b3875578.
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.
Cherry-picked and squashed in latest push
src/miner.cpp
Outdated
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.
with credit pool here that's getting even worse. Need to think how to wrap things up here. Credit pool and mnhfman and mn_subsidy - that's a things that should be inside m_chainstate, as by design and by idea.
src/evo/cshelper.h
Outdated
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 don't move all of that directly to CChainState instead?
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 I'd prefer CChainState to be as close to upstream as possible, not only to make backports and maintenance easier, but to also maintain a soft barrier between Dash and Bitcoin code.
ChainstateHelper lets primarily Bitcoin logic access predominantly Dash logic, acting as a vessel that abstracts the inner machinations from CChainState, letting us change and update Dash-specific code as we see fit without having to make too many changes to Bitcoin-maintained code.
|
@kwvg let's split it one more time to 2 PRs? Please, check this branch for part I: Remaining commits I'd like to refactor and change a bit, I will prepare patches later |
|
The deglobalization of 7f5f37c643941c6ff53250ff5a5138b72b47125d and 27ad7fb0cb89c5874b2eaafe29cffc3b1b534ede are find-and-replace operations, 285985647ebf3133b840b779c60653b9510c5865 and 90d908fac9d9a09e975b4dc394b16617f6dc244c are responses to feedback, 58336d44d6c6c79ec2e4d6b92bf6cefb3812aa5e is in response to CI linting and 600be3f90ce3d0fb51ffd2b106246c24d680ffb1 is just cleanups and additional assertions. Leaving ten commits. IMO this PR doesn't need to be split into smaller chunks. This PR was already part of a larger set of changes and split once and after this, there is a dedicated PR just to deal with I think this PR is fine as it is, at least as far as size is concerned. |
7103eec to
4e42e5a
Compare
|
PR has been updated to make |
src/governance/governance.h
Outdated
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 (not a blocker to get merged):
#include <vector>
#include <memory>
#include <optional>Addressing review feedback dashpay#5908 (comment)
https://github.com/knst/dash/branches/deglob3-p1 part II will update later |
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
left a comment
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 febdaa5
src/evo/chainhelper.h
Outdated
|
|
||
| #include <masternode/payments.h> | ||
|
|
||
| class CChainstateHelper : public CMNPaymentsProcessor |
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 there's used inheritance instead aggregation? Why do we even need CMNPaymentProcessor?
Whoops; reviewed too fast. Agree, shouldn't be inheritance. Also; wasn't there another manager for special transactions that was a part of CChainstateHelper?
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.
Let's move this PR and get it merged soon.
Please, add this one: knst@39f1dea
otherwise LGTM
Also; wasn't there another manager for special transactions that was a part of CChainstateHelper?
that went (split) to new PR I assume
sorry for delay, it seems as impossible to refactor as I planned at the moment and make it nice and tidy.
My current version removes 4 circular dependencies, but it also adds 10 new circular dependencies. They are possible to resolve, but each of them is non-trivial and worth own PR.
there's my draft that I dropped but may pick some commits later in new PR: https://github.com/knst/dash/commits/deglob3-p3
extra note for me: these backports are related
Merge bitcoin#25168: refactor: Avoid passing params where not needed
Merge bitcoin#21526: validation: UpdateTip/CheckBlockIndex assumeutxo support
Merge bitcoin#21866: [Bundle 7/7] validation: Farewell, global Chainstate!
@PastaPastaPasta, those changes were moved to #5929
It's being tracked in https://github.com/dashpay/dash-issues/issues/36 and https://github.com/dashpay/dash-issues/issues/52
@knst, due to a concern raised in code review that two different domains, masternode payments processing and special transaction processing, would be under one head (
Because we already have two Dash-specific aggregations ( Creating another aggregation that will only be used by I really don't look forward to a worst case scenario of |
so, when there's will be another member inside
So, it will be a time to rename |
|
Agree with KNST |
Co-authored-by: Konstantin Akimov <[email protected]>
…alid` We're already checking if the block height is after the budget payment start block and fast-failing if it isn't. There's no need to check again a few lines later (consensus params are expected to be constant). Reported by linter in CI build, https://gitlab.com/dashpay/dash/-/jobs/6281174570#L99
sporkManager was the name of the global that's been removed a commit ago, remove variable names that could be misread as the global still existing
knst
left a comment
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 a93de86
PastaPastaPasta
left a comment
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 a93de86
UdjinM6
left a comment
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
As found in a review comment in dashpay#5908[1], validation.h is not needed for specialtxman.cpp and removing the header uncovers other circular dependencies that were obscured by the shortest circular path[2]. [1] - dashpay#5929 (comment) [2] - dashpay#5929 (comment)
… move C{CreditPool, NetFulfilledRequest}Manager to NodeContext, CDSTXManager to CJContext
991c9ec refactor: accept NodeContext arg into BlockAssembler instead of managers (Kittywhiskers Van Gogh)
c427305 refactor: remove CNetFulfilledRequestManager global, move to NodeContext (Kittywhiskers Van Gogh)
a53046c refactor: remove CDSTXManager global and alias, move to CJContext (Kittywhiskers Van Gogh)
f0451fb refactor: remove CCreditPoolManager global, move to NodeContext (Kittywhiskers Van Gogh)
67cfee7 refactor: remove CMNHFManager::GetSignalsStage alias from CChainState (Kittywhiskers Van Gogh)
667852c refactor: cleanup CDSNotificationInterface member names, add asserts (Kittywhiskers Van Gogh)
0d6f736 fix: add missing entity for destruction in DashTestSetupClose (Kittywhiskers Van Gogh)
2dd6082 refactor: move special transaction processing into helper class (Kittywhiskers Van Gogh)
Pull request description:
## Additional Information
* Dependent on #5908
## Breaking Changes
None. Changes are limited to refactoring, no logical changes have been made.
## 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
- [x] I have made corresponding changes to the documentation **(note: N/A)**
- [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
ACKs for top commit:
PastaPastaPasta:
utACK 991c9ec
Tree-SHA512: 7a8d90416b6de4915639908b5f6bd59caee73e26462864d12a14a5d74af300a3733d8d9b0863e267b82d2807a8a5753acf5574306a0493bb7f3d83d8f0a7da4f
Additional Information
PeerManager's initialization has been moved downwards (it used to be initialized afterCGovernanceManager) to now afterCMasternodeSync. This is to avoid having to passCSporkManager'sunique_ptrcontainer and instead pass the its dereferenced pointer.CChainstateHelperis just proxy for helper classes meant to hold references to managers that would be needed by functions that are called byCChainState. It's the alternative to passing every single manager intoCChainStatethroughChainstateManager.Instead, they're all bunched up via
CChainstateHelperand is accessible toCChainStatethrough passing it as an argument. For this reason, it should ideally initialized after all relevant managers are setup but before the chain is validated. We would want to avoid deferred dereferencing if we can help it.[[nodiscard]].Breaking Changes
None. Changes are limited to refactoring, no logical changes have been made.
Checklist: