mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
41a6613fba
## Motivation CoinJoin's subsystems are initialized by variables and managers that occupy the global context. The _extent_ to which these subsystems entrench themselves into the codebase is difficult to assess and moving them out of the global context forces us to enumerate the subsystems in the codebase that rely on CoinJoin logic and enumerate the order in which components are initialized and destroyed. Keeping this in mind, the scope of this pull request aims to: * Reduce the amount of CoinJoin-specific entities present in the global scope * Make the remaining usage of these entities in the global scope explicit and easily searchable ## Additional Information * The initialization of `CCoinJoinClientQueueManager` is dependent on blocks-only mode being disabled (which can be alternatively interpreted as enabling the relay of transactions). The same applies to `CBlockPolicyEstimator`, which `CCoinJoinClientQueueManager` depends. Therefore, `CCoinJoinClientQueueManager` is only initialized if transaction relaying is enabled and so is its scheduled maintenance task. This can be found by looking at `init.cpp` [here](93f8df1c31/src/init.cpp (L1681-L1683)
), [here](93f8df1c31/src/init.cpp (L2253-L2255)
) and [here](93f8df1c31/src/init.cpp (L2326-L2327)
). For this reason, `CBlockPolicyEstimator` is not a member of `CJContext` and its usage is fulfilled by passing it as a reference when initializing the scheduling task. * `CJClientManager` has not used `CConnman` or `CTxMemPool` as `const` as existing code that is outside the scope of this PR would cast away constness, which would be unacceptable. Furthermore, some logical paths are taken that will grind to a halt if they are stored as `const`. Examples of such a call chains would be: * `CJClientManager::DoMaintenance > CCoinJoinClientManager::DoMaintenance > DoAutomaticDenominating > CCoinJoinClientSession::DoAutomaticDenominating > CCoinJoinClientSession::StartNewQueue > CConnman::AddPendingMasternode` which modifies `CConnman::vPendingMasternodes`, which is non-const behaviour * `CJClientManager::DoMaintenance > CCoinJoinClientManager::DoMaintenance > DoAutomaticDenominating > CCoinJoin::IsCollateralValid > AcceptToMemoryPool` which adds a transaction to the memory pool, which is non-const behaviour * There were cppcheck [linter failures](https://github.com/dashpay/dash/pull/5337#issuecomment-1685084688) that seemed to be caused by the usage of `Assert` in `coinjoin/client.h`. This seems to be resolved by backporting [bitcoin#24714](https://github.com/bitcoin/bitcoin/pull/24714). (Thanks @knst!) * Depends on #5546 --------- Co-authored-by: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Co-authored-by: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com>
147 lines
7.4 KiB
Bash
Executable File
147 lines
7.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2018-2020 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
# Check for circular dependencies
|
|
|
|
export LC_ALL=C
|
|
|
|
EXPECTED_CIRCULAR_DEPENDENCIES=(
|
|
"chainparamsbase -> util/system -> chainparamsbase"
|
|
"index/txindex -> validation -> index/txindex"
|
|
"node/blockstorage -> validation -> node/blockstorage"
|
|
"index/blockfilterindex -> node/blockstorage -> validation -> index/blockfilterindex"
|
|
"index/base -> validation -> index/blockfilterindex -> index/base"
|
|
"index/coinstatsindex -> node/coinstats -> index/coinstatsindex"
|
|
"policy/fees -> txmempool -> policy/fees"
|
|
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
|
|
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
|
|
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
|
|
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"
|
|
"txmempool -> validation -> txmempool"
|
|
"wallet/fees -> wallet/wallet -> wallet/fees"
|
|
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
|
|
"node/coinstats -> validation -> node/coinstats"
|
|
# Dash
|
|
"coinjoin/server -> net_processing -> coinjoin/server"
|
|
"dsnotificationinterface -> llmq/chainlocks -> node/blockstorage -> dsnotificationinterface"
|
|
"evo/cbtx -> evo/simplifiedmns -> evo/cbtx"
|
|
"evo/deterministicmns -> llmq/commitment -> evo/deterministicmns"
|
|
"evo/deterministicmns -> llmq/utils -> evo/deterministicmns"
|
|
"evo/mnauth -> net_processing -> evo/mnauth"
|
|
"governance/classes -> governance/governance -> governance/classes"
|
|
"governance/governance -> governance/object -> governance/governance"
|
|
"governance/governance -> masternode/sync -> governance/governance"
|
|
"governance/governance -> net_processing -> governance/governance"
|
|
"governance/object -> governance/validators -> governance/object"
|
|
"llmq/quorums -> llmq/utils -> llmq/quorums"
|
|
"llmq/blockprocessor -> net_processing -> llmq/blockprocessor"
|
|
"llmq/chainlocks -> llmq/instantsend -> llmq/chainlocks"
|
|
"llmq/chainlocks -> net_processing -> llmq/chainlocks"
|
|
"llmq/dkgsessionmgr -> net_processing -> llmq/dkgsessionmgr"
|
|
"llmq/instantsend -> net_processing -> llmq/instantsend"
|
|
"llmq/instantsend -> txmempool -> llmq/instantsend"
|
|
"llmq/instantsend -> validation -> llmq/instantsend"
|
|
"llmq/signing -> llmq/signing_shares -> llmq/signing"
|
|
"llmq/signing -> net_processing -> llmq/signing"
|
|
"llmq/signing_shares -> net_processing -> llmq/signing_shares"
|
|
"logging -> util/system -> logging"
|
|
"masternode/payments -> validation -> masternode/payments"
|
|
"masternode/sync -> validation -> masternode/sync"
|
|
"net -> netmessagemaker -> net"
|
|
"net_processing -> spork -> net_processing"
|
|
"netaddress -> netbase -> netaddress"
|
|
"qt/appearancewidget -> qt/guiutil -> qt/appearancewidget"
|
|
"qt/bitcoinaddressvalidator -> qt/guiutil -> qt/bitcoinaddressvalidator"
|
|
"qt/bitcoingui -> qt/guiutil -> qt/bitcoingui"
|
|
"qt/guiutil -> qt/optionsdialog -> qt/guiutil"
|
|
"qt/guiutil -> qt/qvalidatedlineedit -> qt/guiutil"
|
|
"core_io -> evo/cbtx -> evo/simplifiedmns -> core_io"
|
|
"evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> evo/simplifiedmns"
|
|
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsessionhandler -> llmq/dkgsession"
|
|
"logging -> util/system -> sync -> logging"
|
|
"logging -> util/system -> stacktraces -> logging"
|
|
"logging -> util/system -> util/getuniquepath -> random -> logging"
|
|
"coinjoin/client -> coinjoin/util -> wallet/wallet -> coinjoin/client"
|
|
"coinjoin/client -> net_processing -> coinjoin/context -> coinjoin/client"
|
|
"coinjoin/context -> coinjoin/server -> net_processing -> coinjoin/context"
|
|
"qt/appearancewidget -> qt/guiutil -> qt/optionsdialog -> qt/appearancewidget"
|
|
"qt/guiutil -> qt/optionsdialog -> qt/optionsmodel -> qt/guiutil"
|
|
|
|
"bloom -> evo/assetlocktx -> llmq/quorums -> net -> bloom"
|
|
"banman -> bloom -> evo/assetlocktx -> llmq/quorums -> net -> banman"
|
|
"banman -> bloom -> evo/assetlocktx -> llmq/quorums -> net_processing -> banman"
|
|
"bloom -> evo/assetlocktx -> llmq/quorums -> net_processing -> merkleblock -> bloom"
|
|
|
|
"coinjoin/client -> net_processing -> coinjoin/client"
|
|
"llmq/quorums -> net_processing -> llmq/quorums"
|
|
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsession"
|
|
"llmq/chainlocks -> validation -> llmq/chainlocks"
|
|
"coinjoin/coinjoin -> llmq/chainlocks -> net -> coinjoin/coinjoin"
|
|
"evo/deterministicmns -> llmq/utils -> net -> evo/deterministicmns"
|
|
"policy/policy -> policy/settings -> policy/policy"
|
|
"evo/specialtxman -> validation -> evo/specialtxman"
|
|
"consensus/tx_verify -> evo/assetlocktx -> validation -> consensus/tx_verify"
|
|
"consensus/tx_verify -> evo/assetlocktx -> llmq/quorums -> net_processing -> txmempool -> consensus/tx_verify"
|
|
"evo/assetlocktx -> llmq/quorums -> net_processing -> txmempool -> evo/assetlocktx"
|
|
|
|
"evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> llmq/snapshot -> evo/simplifiedmns"
|
|
"llmq/blockprocessor -> net_processing -> llmq/context -> llmq/blockprocessor"
|
|
"llmq/blockprocessor -> net_processing -> llmq/snapshot -> llmq/blockprocessor"
|
|
"llmq/chainlocks -> net_processing -> llmq/context -> llmq/chainlocks"
|
|
"llmq/context -> llmq/dkgsessionmgr -> net_processing -> llmq/context"
|
|
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/quorums -> llmq/dkgsession"
|
|
"llmq/dkgsessionmgr -> llmq/quorums -> llmq/dkgsessionmgr"
|
|
"llmq/snapshot -> llmq/utils -> llmq/snapshot"
|
|
"spork -> validation -> spork"
|
|
"governance/governance -> validation -> governance/governance"
|
|
"evo/deterministicmns -> validationinterface -> governance/vote -> evo/deterministicmns"
|
|
"governance/object -> validationinterface -> governance/object"
|
|
"governance/vote -> validation -> validationinterface -> governance/vote"
|
|
"llmq/signing -> masternode/node -> validationinterface -> llmq/signing"
|
|
"llmq/debug -> llmq/dkgsessionhandler -> llmq/debug"
|
|
"llmq/debug -> llmq/dkgsessionhandler -> llmq/dkgsession -> llmq/debug"
|
|
)
|
|
|
|
EXIT_CODE=0
|
|
|
|
CIRCULAR_DEPENDENCIES=()
|
|
|
|
IFS=$'\n'
|
|
for CIRC in $(cd src && ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp} | sed -e 's/^Circular dependency: //'); do
|
|
CIRCULAR_DEPENDENCIES+=( "$CIRC" )
|
|
IS_EXPECTED_CIRC=0
|
|
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do
|
|
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then
|
|
IS_EXPECTED_CIRC=1
|
|
break
|
|
fi
|
|
done
|
|
if [[ ${IS_EXPECTED_CIRC} == 0 ]]; then
|
|
echo "A new circular dependency in the form of \"${CIRC}\" appears to have been introduced."
|
|
echo
|
|
EXIT_CODE=1
|
|
fi
|
|
done
|
|
|
|
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do
|
|
IS_PRESENT_EXPECTED_CIRC=0
|
|
for CIRC in "${CIRCULAR_DEPENDENCIES[@]}"; do
|
|
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then
|
|
IS_PRESENT_EXPECTED_CIRC=1
|
|
break
|
|
fi
|
|
done
|
|
if [[ ${IS_PRESENT_EXPECTED_CIRC} == 0 ]]; then
|
|
echo "Good job! The circular dependency \"${EXPECTED_CIRC}\" is no longer present."
|
|
echo "Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in $0"
|
|
echo "to make sure this circular dependency is not accidentally reintroduced."
|
|
echo
|
|
EXIT_CODE=1
|
|
fi
|
|
done
|
|
|
|
exit ${EXIT_CODE}
|