-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: move special transaction processing to helper, move C{CreditPool, NetFulfilledRequest}Manager to NodeContext, CDSTXManager to CJContext #5929
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
b69d518 to
3f10001
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.
it seems as validation.h is not needed in specialtxman
diff --git a/src/evo/specialtxman.cpp b/src/evo/specialtxman.cpp
index 84a4f6afef..ffb1c3d5cb 100644
--- a/src/evo/specialtxman.cpp
+++ b/src/evo/specialtxman.cpp
@@ -17,7 +17,6 @@
#include <llmq/blockprocessor.h>
#include <llmq/commitment.h>
#include <primitives/block.h>
-#include <validation.h>
static bool CheckSpecialTxInner(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, const std::optional<CRangesSet>& indexes, bool check_sigs, TxValidationState& state)
{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.
Removing it causes the number of circular dependencies to explode
dash@1914d5152e74:/src/dash$ ./test/lint/lint-circular-dependencies.sh
A new circular dependency in the form of "evo/assetlocktx -> validation -> evo/specialtxman -> evo/assetlocktx" appears to have been introduced.
A new circular dependency in the form of "evo/cbtx -> validation -> evo/specialtxman -> evo/cbtx" appears to have been introduced.
A new circular dependency in the form of "evo/chainhelper -> masternode/payments -> validation -> evo/chainhelper" appears to have been introduced.
A new circular dependency in the form of "evo/creditpool -> validation -> evo/specialtxman -> evo/creditpool" appears to have been introduced.
A new circular dependency in the form of "evo/deterministicmns -> validation -> evo/specialtxman -> evo/deterministicmns" appears to have been introduced.
A new circular dependency in the form of "evo/mnhftx -> validation -> evo/specialtxman -> evo/mnhftx" appears to have been introduced.
A new circular dependency in the form of "evo/specialtxman -> llmq/blockprocessor -> validation -> evo/specialtxman" appears to have been introduced.
Good job! The circular dependency "evo/specialtxman -> validation -> evo/specialtxman" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in ./test/lint/lint-circular-dependencies.sh
to make sure this circular dependency is not accidentally reintroduced.
Good job! The circular dependency "evo/chainhelper -> evo/specialtxman -> validation -> evo/chainhelper" is no longer present.
Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in ./test/lint/lint-circular-dependencies.sh
to make sure this circular dependency is not accidentally reintroduced.
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 think that's ok. Still good to resolve any circulars we can. Getting rid of 1 big circular may result in many smaller circulars but 🤷♂️
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 as expected. These circulate dependencies have a longer path and they just had been hidden by the shorter one.
The logic of script shows only the shortest one and by removing it you won't introduce any new circular dependencies but quite opposite reveal already existing. That's expected and fine to have. They can be addressed now one by one.
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/dsnotificationinterface.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.
should dsnotificationinferface do assert? or just return enough? why assert?
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.
If it is accessing (smart) pointers, IMO yes. We check the validity of a (smart) pointer in other parts of the codebase before trying to access them and so far, we've implicitly assumed that in the time between the interface initializing and the first call being made, the dependent contexts/managers have been initialized.
Adding an assertion would alert us to anything that contravenes that assumption by explicitly defining it. For something like BlockConnected, the first call is to a manager in m_llmq_ctx so if a BlockConnected call is made that contravenes the assumption, we'd know about it immediately.
The same doesn't hold true for UpdatedBlockTip, which has some fast-fail conditions until we reach a possibly affected call. This no longer becomes a problem if we explicitly define assertions.
Plus, the assertion serve as a one-liner that enumerates the (smart) pointers being relied on for the rest of the function.
src/validation.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.
Instead removing it is possible to move this method from CChainState to CChainStateHelper.
If do that, BlockAssembler can call chainstate_helper->GeetMNHFSignalsStage and no need to pass mnhfManager in constructor of BlockAssembler.
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)
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.
utACK 47de7deeb17af8c541284721e387231342d45acb
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
…ndencies dfddfd0 trivial: remove unneeded header, enumerate circular dependencies (Kittywhiskers Van Gogh) Pull request description: ## Additional Information As found in #5929 (comment), `validation.h` is not needed for `specialtxman.cpp` and removing the header uncovers other circular dependencies that were obscured by the shortest circular path (see #5929 (comment)). ## Breaking Changes None. ## 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 dfddfd0 Tree-SHA512: c3e74c1a381c0b69985a29f57da3565ec7681548389f09ab8b9907386f0a9f221db92a39409eb46595f3546edffa389774b96b0c9dd8f4fedff46f2d3bd635f1
|
Please rebase: when trying to merge into develop I'm getting this |
|
This pull request has conflicts, please rebase. |
GetMNHFSignalsStage doesn't actually probe anything from CChainState nor is necessary for CChainState members.
We don't need to run `GetDSTX` in `HandleNewRecoveredSig` since we know for sure the transaction being handled is for enhanced hard forking
Decoupling initialization from loading the database means we need to assert if the database is actually loaded before performing any operations on it (i.e. check if the manager is "valid")
Co-authored-by: UdjinM6 <[email protected]>
|
I think the range-diff looks good -: ---------- > 1: f5642281cc Merge #20282: wallet: change upgradewallet return type to be an object
-: ---------- > 2: 19aba38cab Merge #19200: rpc: remove deprecated getaddressinfo fields
-: ---------- > 3: 9c54cb16de Merge #19405: rpc, cli: add network in/out connections to `getnetworkinfo` and `-getinfo`
-: ---------- > 4: 86dd0eabb4 chore: increase amount of build jobs from 4 to 8 for depends
-: ---------- > 5: 58d923cd5b Merge #19528: rpc: Assert that RPCArg names are equal to CRPCCommand ones (misc)
-: ---------- > 6: 41c35fd8dc fix: adjust missing arguments and help for misc rpc: debug, echo, mnsync
-: ---------- > 7: 860d31f504 Merge #19455: rpc generate: print useful help and error message
-: ---------- > 8: 7ac1ee0fb4 Merge #19717: rpc: Assert that RPCArg names are equal to CRPCCommand ones (mining,zmq,rpcdump)
-: ---------- > 9: f525f574b0 fix: follow-up missing changes from Merge #18607: rpc: Fix named arguments in documentation
-: ---------- > 10: c30c8f22dd Merge #19849: Assert that RPCArg names are equal to CRPCCommand ones (blockchain,rawtransaction)
-: ---------- > 11: af9eb81e56 fix: wrong name of arguments for RPC
-: ---------- > 12: 0e1a31159f Merge #19994: Assert that RPCArg names are equal to CRPCCommand ones (net, rpcwallet)
-: ---------- > 13: d0163543d9 refactor: use new format CPCCommand for rpc/coinjoin
-: ---------- > 14: b54f03a0c1 fix: wrong name of argument for coinjoin
-: ---------- > 15: 3621966f12 feat: add todo to drop Throw() from rpc/util.h
-: ---------- > 16: c5031685bc fix: rename arguments for 'voteraw'
-: ---------- > 17: dfddfd09a4 trivial: remove unneeded header, enumerate circular dependencies
1: 40dcfce882 ! 18: 2dd6082e54 refactor: move special transaction processing into helper class
@@ src/validation.h: public:
const std::optional<uint256>& snapshot_blockhash = std::nullopt)
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
-
- ## test/lint/lint-circular-dependencies.sh ##
-@@ test/lint/lint-circular-dependencies.sh: EXPECTED_CIRCULAR_DEPENDENCIES=(
- "llmq/signing -> masternode/node -> validationinterface -> llmq/signing"
- "evo/mnhftx -> validation -> evo/mnhftx"
- "evo/deterministicmns -> validation -> evo/deterministicmns"
-- "evo/chainhelper -> masternode/payments -> validation -> evo/chainhelper"
-+ "evo/chainhelper -> evo/specialtxman -> validation -> evo/chainhelper"
- )
-
- EXIT_CODE=0
2: 459fe7b4db = 19: 0d6f736a19 fix: add missing entity for destruction in DashTestSetupClose
3: 00de06890f = 20: 667852c851 refactor: cleanup CDSNotificationInterface member names, add asserts
4: 044b94fb69 ! 21: 67cfee70f8 refactor: remove CMNHFManager::GetSignalsStage alias from CChainState
@@ src/rpc/blockchain.cpp
#include <llmq/chainlocks.h>
#include <llmq/instantsend.h>
-@@ src/rpc/blockchain.cpp: UniValue getblockchaininfo(const JSONRPCRequest& request)
- },
- }.Check(request);
+@@ src/rpc/blockchain.cpp: RPCHelpMan getblockchaininfo()
+ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
+ {
- ChainstateManager& chainman = EnsureAnyChainman(request.context);
- LOCK(cs_main);
@@ src/rpc/mining.cpp: static UniValue generateBlocks(ChainstateManager& chainman,
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
CBlock *pblock = &pblocktemplate->block;
-@@ src/rpc/mining.cpp: static UniValue generatetodescriptor(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generatetodescriptor()
ChainstateManager& chainman = EnsureChainman(node);
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
- return generateBlocks(chainman, *node.evodb, *node.chain_helper, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ return generateBlocks(chainman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ },
+ };
}
-
- static UniValue generatetoaddress(const JSONRPCRequest& request)
-@@ src/rpc/mining.cpp: static UniValue generatetoaddress(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generatetoaddress()
CScript coinbase_script = GetScriptForDestination(destination);
- return generateBlocks(chainman, *node.evodb, *node.chain_helper, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ return generateBlocks(chainman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ },
+ };
}
-
- static UniValue generateblock(const JSONRPCRequest& request)
-@@ src/rpc/mining.cpp: static UniValue generateblock(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generateblock()
LOCK(cs_main);
CTxMemPool empty_mempool;
@@ src/rpc/mining.cpp: static UniValue generateblock(const JSONRPCRequest& request)
if (!blocktemplate) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
}
-@@ src/rpc/mining.cpp: static UniValue getblocktemplate(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan getblocktemplate()
// Create new block
CScript scriptDummy = CScript() << OP_TRUE;
LLMQContext& llmq_ctx = EnsureAnyLLMQContext(request.context);
5: fe57a46254 ! 22: f0451fb98d refactor: remove CCreditPoolManager global, move to NodeContext
@@ src/rpc/mining.cpp: static UniValue generateBlocks(ChainstateManager& chainman,
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
CBlock *pblock = &pblocktemplate->block;
-@@ src/rpc/mining.cpp: static UniValue generatetodescriptor(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generatetodescriptor()
ChainstateManager& chainman = EnsureChainman(node);
LLMQContext& llmq_ctx = EnsureLLMQContext(node);
- return generateBlocks(chainman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ return generateBlocks(chainman, *node.cpoolman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ },
+ };
}
-
- static UniValue generatetoaddress(const JSONRPCRequest& request)
-@@ src/rpc/mining.cpp: static UniValue generatetoaddress(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generatetoaddress()
CScript coinbase_script = GetScriptForDestination(destination);
- return generateBlocks(chainman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ return generateBlocks(chainman, *node.cpoolman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ },
+ };
}
-
- static UniValue generateblock(const JSONRPCRequest& request)
-@@ src/rpc/mining.cpp: static UniValue generateblock(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generateblock()
LOCK(cs_main);
CTxMemPool empty_mempool;
@@ src/rpc/mining.cpp: static UniValue generateblock(const JSONRPCRequest& request)
if (!blocktemplate) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
}
-@@ src/rpc/mining.cpp: static UniValue getblocktemplate(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan getblocktemplate()
// Create new block
CScript scriptDummy = CScript() << OP_TRUE;
LLMQContext& llmq_ctx = EnsureAnyLLMQContext(request.context);
6: bfbc68513d = 23: a53046c4a9 refactor: remove CDSTXManager global and alias, move to CJContext
7: f280fb8525 = 24: c427305805 refactor: remove CNetFulfilledRequestManager global, move to NodeContext
8: 47de7deeb1 ! 25: 991c9ec1a2 refactor: accept NodeContext arg into BlockAssembler instead of managers
@@ src/rpc/mining.cpp: static UniValue generateBlocks(ChainstateManager& chainman,
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
CBlock *pblock = &pblocktemplate->block;
-@@ src/rpc/mining.cpp: static UniValue generatetodescriptor(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generatetodescriptor()
const NodeContext& node = EnsureAnyNodeContext(request.context);
const CTxMemPool& mempool = EnsureMemPool(node);
ChainstateManager& chainman = EnsureChainman(node);
@@ src/rpc/mining.cpp: static UniValue generatetodescriptor(const JSONRPCRequest& r
- return generateBlocks(chainman, *node.cpoolman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ return generateBlocks(chainman, node, mempool, coinbase_script, num_blocks, max_tries);
+ },
+ };
}
-
- static UniValue generatetoaddress(const JSONRPCRequest& request)
-@@ src/rpc/mining.cpp: static UniValue generatetoaddress(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generatetoaddress()
const NodeContext& node = EnsureAnyNodeContext(request.context);
const CTxMemPool& mempool = EnsureMemPool(node);
ChainstateManager& chainman = EnsureChainman(node);
@@ src/rpc/mining.cpp: static UniValue generatetoaddress(const JSONRPCRequest& requ
- return generateBlocks(chainman, *node.cpoolman, *node.evodb, *node.chain_helper, *node.mnhf_manager, llmq_ctx, mempool, coinbase_script, num_blocks, max_tries);
+ return generateBlocks(chainman, node, mempool, coinbase_script, num_blocks, max_tries);
+ },
+ };
}
-
- static UniValue generateblock(const JSONRPCRequest& request)
-@@ src/rpc/mining.cpp: static UniValue generateblock(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan generateblock()
LOCK(cs_main);
CTxMemPool empty_mempool;
@@ src/rpc/mining.cpp: static UniValue generateblock(const JSONRPCRequest& request)
if (!blocktemplate) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
}
-@@ src/rpc/mining.cpp: static UniValue getblocktemplate(const JSONRPCRequest& request)
+@@ src/rpc/mining.cpp: static RPCHelpMan getblocktemplate()
// Create new block
CScript scriptDummy = CScript() << OP_TRUE; |
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.
re-utACK
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 991c9ec
fa6847d refactor: drop circular dependencies over deterministicmns in validationinterface (Konstantin Akimov) f8d1853 refactor: even more passing CDeterministicMNManager by ref (Kittywhiskers Van Gogh) d4aa891 refactor: more passing CDeterministicMNManager by ref (Kittywhiskers Van Gogh) e628d75 refactor: pass CDeterministicMNManager by ref to CJContext members (Kittywhiskers Van Gogh) d731f41 refactor: pass CDeterministicMNManager by ref to LLMQContext members (Kittywhiskers Van Gogh) 6bd23f4 refactor: pass CDeterministicMNManager by ref to CGovernanceManager (Kittywhiskers Van Gogh) 055dbba refactor: move GetListAtChainTip() calls out of llmq::utils::*, misc changes (Kittywhiskers Van Gogh) da39b73 refactor: move GetListAtChainTip() calls out of CGovernanceVote (Kittywhiskers Van Gogh) e9de972 refactor: move GetListAtChainTip() calls out of CGovernanceObject (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependent on #5929 ## 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: (self) utACK fa6847d knst: utACK fa6847d Tree-SHA512: f1acf44bad25789d03c48788a3ac1807d7c553ee45164276ffa6f0dc39dc02e5d29d364469633aa84b341e8c4c13508e0e7a114de6e01fb624f256acfd97199b
Additional Information
Breaking Changes
None. Changes are limited to refactoring, no logical changes have been made.
Checklist: