-
Notifications
You must be signed in to change notification settings - Fork 380
/
lint-circular-dependencies.sh
executable file
·95 lines (88 loc) · 4.14 KB
/
lint-circular-dependencies.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
#
# Copyright (c) 2018-2021 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"
"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/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog"
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"
"wallet/fees -> wallet/wallet -> wallet/fees"
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
"node/coinstats -> validation -> node/coinstats"
# ELEMENTs: introduced by https://github.com/ElementsProject/elements/pull/1270
"chain -> validation -> chain"
"chain -> validation -> consensus/tx_verify -> chain"
"dynafed -> validation -> dynafed"
"pegins -> validation -> pegins"
"chain -> node/context -> txmempool -> chain"
"chain -> validation -> deploymentstatus -> chain"
"chain -> validation -> index/blockfilterindex -> chain"
"chain -> validation -> primitives/pak -> chain"
"chain -> validation -> txdb -> chain"
"chain -> validation -> validationinterface -> chain"
"chain -> validation -> txdb -> pow -> chain"
"chain -> validation -> deploymentstatus -> versionbits -> chain"
"confidential_validation -> pegins -> validation -> confidential_validation"
"consensus/tx_verify -> pegins -> validation -> consensus/tx_verify"
"dynafed -> validation -> primitives/pak -> dynafed"
"pegins -> validation -> txmempool -> pegins"
"block_proof -> chain -> validation -> block_proof"
"block_proof -> chain -> validation -> txdb -> block_proof"
"chain -> node/context -> net_processing -> node/blockstorage -> chain"
"consensus/tx_verify -> pegins -> validation -> txmempool -> consensus/tx_verify"
"block_proof -> chain -> node/context -> net_processing -> node/blockstorage -> block_proof"
"core_io -> script/sign -> pegins -> validation -> signet -> core_io"
# ELEMENTS: will be fixed by blinding cleanup
"blindpsbt -> psbt -> blindpsbt"
# ELEMENTS: not so easy to fix, caused by us doing asset ID lookups in the
# wallet, from coin selection, to decide whether we are looking at a
# multi-asset transaction or not. Probably this check should be done in
# CreateTransaction instead.
"wallet/coinselection -> wallet/wallet -> wallet/coinselection"
)
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}