2018-07-20 15:57:08 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
2023-08-16 19:27:31 +02:00
|
|
|
# Copyright (c) 2018-2020 The Bitcoin Core developers
|
2018-07-20 15:57:08 +02:00
|
|
|
# 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=(
|
2021-06-27 08:33:13 +02:00
|
|
|
"chainparamsbase -> util/system -> chainparamsbase"
|
2021-05-25 12:48:04 +02:00
|
|
|
"index/txindex -> validation -> index/txindex"
|
2023-07-24 20:42:13 +02:00
|
|
|
"node/blockstorage -> validation -> node/blockstorage"
|
|
|
|
"index/blockfilterindex -> node/blockstorage -> validation -> index/blockfilterindex"
|
|
|
|
"index/base -> validation -> index/blockfilterindex -> index/base"
|
2023-07-30 13:49:32 +02:00
|
|
|
"index/coinstatsindex -> node/coinstats -> index/coinstatsindex"
|
2018-07-20 15:57:08 +02:00
|
|
|
"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"
|
2023-06-01 16:57:52 +02:00
|
|
|
"node/coinstats -> validation -> node/coinstats"
|
2021-02-04 01:48:30 +01:00
|
|
|
# Dash
|
2021-10-01 21:19:08 +02:00
|
|
|
"coinjoin/server -> net_processing -> coinjoin/server"
|
2023-07-24 20:42:13 +02:00
|
|
|
"dsnotificationinterface -> llmq/chainlocks -> node/blockstorage -> dsnotificationinterface"
|
2021-02-04 01:48:30 +01:00
|
|
|
"evo/cbtx -> evo/simplifiedmns -> evo/cbtx"
|
2021-10-02 19:32:24 +02:00
|
|
|
"evo/deterministicmns -> llmq/commitment -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> llmq/utils -> evo/deterministicmns"
|
2021-02-04 01:48:30 +01:00
|
|
|
"evo/mnauth -> net_processing -> evo/mnauth"
|
2021-10-01 21:19:08 +02:00
|
|
|
"governance/classes -> governance/governance -> governance/classes"
|
|
|
|
"governance/governance -> governance/object -> governance/governance"
|
|
|
|
"governance/governance -> masternode/sync -> governance/governance"
|
2021-02-04 01:48:30 +01:00
|
|
|
"governance/governance -> net_processing -> governance/governance"
|
2021-10-01 21:19:08 +02:00
|
|
|
"governance/object -> governance/validators -> governance/object"
|
2021-10-02 19:32:24 +02:00
|
|
|
"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"
|
2021-06-27 08:33:13 +02:00
|
|
|
"logging -> util/system -> logging"
|
2021-10-01 21:19:08 +02:00
|
|
|
"masternode/payments -> validation -> masternode/payments"
|
refactor: begin to de-globalize masternodeSync (#5103)
<!--
*** Please remove the following help text before submitting: ***
Provide a general summary of your changes in the Title above
Pull requests without a rationale and clear improvement may be closed
immediately.
Please provide clear motivation for your patch and explain how it
improves
Dash Core user experience or Dash Core developer experience
significantly:
* Any test improvements or new tests that improve coverage are always
welcome.
* All other changes should have accompanying unit tests (see
`src/test/`) or
functional tests (see `test/`). Contributors should note which tests
cover
modified code. If no tests exist for a region of modified code, new
tests
should accompany the change.
* Bug fixes are most welcome when they come with steps to reproduce or
an
explanation of the potential issue as well as reasoning for the way the
bug
was fixed.
* Features are welcome, but might be rejected due to design or scope
issues.
If a feature is based on a lot of dependencies, contributors should
first
consider building the system outside of Dash Core, if possible.
-->
## Issue being fixed or feature implemented
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
minimizing global uses
## What was done?
<!--- Describe your changes in detail -->
Started the deglobalization, a future PR should be done to continue this
deglobalization
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
## Breaking Changes
<!--- Please describe any breaking changes your code introduces -->
none
## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e
tests
- [x] I have made corresponding changes to the documentation
**For repository code-owners and collaborators only**
- [x] I have assigned this pull request to a milestone
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2023-01-04 21:37:20 +01:00
|
|
|
"masternode/sync -> validation -> masternode/sync"
|
2021-02-04 01:48:30 +01:00
|
|
|
"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"
|
2021-10-02 19:32:24 +02:00
|
|
|
"evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> evo/simplifiedmns"
|
|
|
|
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsessionhandler -> llmq/dkgsession"
|
2021-06-27 08:33:13 +02:00
|
|
|
"logging -> util/system -> sync -> logging"
|
|
|
|
"logging -> util/system -> stacktraces -> logging"
|
2022-01-03 20:10:02 +01:00
|
|
|
"logging -> util/system -> util/getuniquepath -> random -> logging"
|
2021-10-01 21:19:08 +02:00
|
|
|
"coinjoin/client -> coinjoin/util -> wallet/wallet -> coinjoin/client"
|
refactor: subsume CoinJoin objects under CJContext, deglobalize coinJoin{ClientQueueManager,Server} (#5337)
## 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](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L1681-L1683),
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/src/init.cpp#L2253-L2255)
and
[here](https://github.com/dashpay/dash/blob/93f8df1c31fdce6a14f149acfdff22678c3f22ca/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>
2023-09-13 19:52:38 +02:00
|
|
|
"coinjoin/client -> net_processing -> coinjoin/context -> coinjoin/client"
|
|
|
|
"coinjoin/context -> coinjoin/server -> net_processing -> coinjoin/context"
|
2021-02-04 01:48:30 +01:00
|
|
|
"qt/appearancewidget -> qt/guiutil -> qt/optionsdialog -> qt/appearancewidget"
|
|
|
|
"qt/guiutil -> qt/optionsdialog -> qt/optionsmodel -> qt/guiutil"
|
2021-03-26 13:21:41 +01:00
|
|
|
|
2023-08-02 17:08:39 +02:00
|
|
|
"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"
|
|
|
|
|
2021-10-01 21:19:08 +02:00
|
|
|
"coinjoin/client -> net_processing -> coinjoin/client"
|
2021-04-16 05:41:16 +02:00
|
|
|
"llmq/quorums -> net_processing -> llmq/quorums"
|
2021-10-02 19:32:24 +02:00
|
|
|
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsession"
|
2022-04-05 09:22:15 +02:00
|
|
|
"llmq/chainlocks -> validation -> llmq/chainlocks"
|
2021-10-02 19:32:24 +02:00
|
|
|
"coinjoin/coinjoin -> llmq/chainlocks -> net -> coinjoin/coinjoin"
|
2021-10-25 15:55:34 +02:00
|
|
|
"evo/deterministicmns -> llmq/utils -> net -> evo/deterministicmns"
|
2022-01-03 20:10:02 +01:00
|
|
|
"policy/policy -> policy/settings -> policy/policy"
|
2022-01-24 15:20:50 +01:00
|
|
|
"evo/specialtxman -> validation -> evo/specialtxman"
|
2023-07-24 18:39:38 +02:00
|
|
|
"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"
|
2022-04-16 16:46:04 +02:00
|
|
|
|
|
|
|
"evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> llmq/snapshot -> evo/simplifiedmns"
|
2022-11-07 19:09:44 +01:00
|
|
|
"llmq/blockprocessor -> net_processing -> llmq/context -> llmq/blockprocessor"
|
2022-04-16 16:46:04 +02:00
|
|
|
"llmq/blockprocessor -> net_processing -> llmq/snapshot -> llmq/blockprocessor"
|
2022-11-07 19:09:44 +01:00
|
|
|
"llmq/chainlocks -> net_processing -> llmq/context -> llmq/chainlocks"
|
|
|
|
"llmq/context -> llmq/dkgsessionmgr -> net_processing -> llmq/context"
|
2022-04-16 16:46:04 +02:00
|
|
|
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/quorums -> llmq/dkgsession"
|
|
|
|
"llmq/dkgsessionmgr -> llmq/quorums -> llmq/dkgsessionmgr"
|
|
|
|
"llmq/snapshot -> llmq/utils -> llmq/snapshot"
|
2022-08-26 23:52:53 +02:00
|
|
|
"spork -> validation -> spork"
|
|
|
|
"governance/governance -> validation -> governance/governance"
|
2020-01-09 20:37:09 +01:00
|
|
|
"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"
|
2023-02-20 11:12:12 +01:00
|
|
|
"llmq/debug -> llmq/dkgsessionhandler -> llmq/debug"
|
|
|
|
"llmq/debug -> llmq/dkgsessionhandler -> llmq/dkgsession -> llmq/debug"
|
2023-10-03 16:32:53 +02:00
|
|
|
"llmq/utils -> validation -> llmq/utils"
|
2023-08-03 22:54:54 +02:00
|
|
|
"evo/mnhftx -> validation -> evo/mnhftx"
|
2023-11-16 19:36:46 +01:00
|
|
|
"evo/deterministicmns -> validation -> evo/deterministicmns"
|
2018-07-20 15:57:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
2019-07-05 03:00:44 +02:00
|
|
|
CIRCULAR_DEPENDENCIES+=( "$CIRC" )
|
2018-07-20 15:57:08 +02:00
|
|
|
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}
|