Most includers just wanted to react to pending shutdown.
This isolates access to fRequestShutdown
and limits access to the shutdown api functions, including the new CancelShutdown
for setting it to false
.
Most includers just wanted to react to pending shutdown.
This isolates access to fRequestShutdown
and limits access to the shutdown api functions, including the new CancelShutdown
for setting it to false
.
Failures in bench_bitcoin in a few of the Travis builds:
0 CXXLD bench/bench_bitcoin
1libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)':
2wallet.cpp:(.text+0x5cea): undefined reference to `CConnman::NodeFullyConnected(CNode const*)'
3collect2: error: ld returned 1 exit status
4make[2]: *** [bench/bench_bitcoin] Error 1
shutdown.(cpp|h)
a few times as well. It seems we have too much non-initialization-related things in init. Concept ACK.
0@@ -0,0 +1,21 @@
1+// Copyright (c) 2009-2010 Satoshi Nakamoto
2+// Copyright (c) 2009-2017 The Bitcoin Core developers
3+// Distributed under the MIT software license, see the accompanying
4+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+#include <atomic>
7+
8+std::atomic<bool> fRequestShutdown(false);
0static std::atomic<bool> fRequestShutdown{false};
0@@ -0,0 +1,13 @@
1+// Copyright (c) 2009-2010 Satoshi Nakamoto
2+// Copyright (c) 2009-2017 The Bitcoin Core developers
11@@ -12,7 +12,7 @@
12 #include <uint256.h>
13 #include <util.h>
14 #include <ui_interface.h>
15-#include <init.h>
16+#include <shutdown.h>
clang-format
and run the https://github.com/bitcoin/bitcoin/tree/master/contrib/devtools#clang-format-diffpy script which fixes all white space and sorting issues
0@@ -0,0 +1,21 @@
1+// Copyright (c) 2009-2010 Satoshi Nakamoto
2+// Copyright (c) 2009-2017 The Bitcoin Core developers
3+// Distributed under the MIT software license, see the accompanying
4+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+#include <atomic>
#include <shutdown.h>
?
Concept ACK.
The PR suggests that the following dependencies wouldn’t exist:
0Circular dependency: init -> net_processing -> init
1Circular dependency: init -> validationinterface -> init
Also, I’ve removed the first 3 commits locally and it still compiles and reports the same dependencies as above. I wonder why are those commits included here.
Edit: oh this is rebased on #13239.
fRequestShutdown
staticclang-format
to sort includesThanks @promag / @MarcoFalke
Still has the following circular dependencies:
0Circular dependency: init -> net_processing -> init
1Circular dependency: init -> validationinterface -> init
Should these be removed in this PR?
@sipa yeah what I need to do is install linux so that I can repro the build failures locally (unfortunately the only system they’re not exhibiting on is Mac). The last commit 665bf42 is a half-finished effort to fix the build with feedback via CI but it would progress a lot faster if I had local failures to run against.
I’ll work on it a bit more in the same style, but failing that I’ll have to set up dual-boot or the like.
Ok, looks like an intermittent failure in 69b0e8a, ending in:
0make[1]: Entering directory '/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-apple-darwin11'
1make[1]: Nothing to be done for 'all-am'.
2make[1]: Leaving directory '/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-apple-darwin11'
3make -C src qt/bitcoin-qt
4make[1]: Entering directory '/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-apple-darwin11/src'
5make[1]: Leaving directory '/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-apple-darwin11/src'
6/bin/mkdir -p Bitcoin-Qt.app/Contents/MacOS
7STRIPPROG="/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../native/bin/x86_64-apple-darwin11-strip" /bin/bash /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-apple-darwin11/build-aux/install-sh -c -s src/qt/bitcoin-qt Bitcoin-Qt.app/Contents/MacOS/Bitcoin-Qt
8INSTALLNAMETOOL=/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../native/bin/x86_64-apple-darwin11-install_name_tool OTOOL=/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../native/bin/x86_64-apple-darwin11-otool STRIP=/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../native/bin/x86_64-apple-darwin11-strip /usr/bin/python3.6 ./contrib/macdeploy/macdeployqtplus Bitcoin-Qt.app -translations-dir=/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../translations -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -verbose 2
9+ Copying source bundle +
10+ Deploying frameworks +
11Warning: Could not find any external frameworks to deploy in dist/Bitcoin-Qt.app.
12+ Installing qt.conf +
13+ Adding Qt translations +
14+ Done +
15Warning: Could not detect Qt's path, skipping plugin deployment!
16/bin/mkdir -p dist/.background
17/usr/bin/tiffcp -c none dpi36.background.tiff dpi72.background.tiff dist/.background/background.tiff
18/usr/bin/python3.6 contrib/macdeploy/custom_dsstore.py "dist/.DS_Store" "Bitcoin-Core"
19/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../native/bin/genisoimage -no-cache-inodes -D -l -probe -V "Bitcoin-Core" -no-pad -r -dir-mode 0755 -apple -o Bitcoin-Core.dmg dist
20/home/travis/build/bitcoin/bitcoin/depends/x86_64-apple-darwin11/share/../native/bin/genisoimage: Warning: assuming PC Exchange cluster size of 512 bytes
21 30.79% done, estimate finish Thu Jun 14 09:33:16 2018
22 61.60% done, estimate finish Thu Jun 14 09:33:16 2018
23 92.30% done, estimate finish Thu Jun 14 09:33:16 2018
24Total translation table size: 0
25Total rockridge attributes bytes: 3197
26Total directory bytes: 13084
27Path table size(bytes): 118
28Max brk space used 0
2916257 extents written (31 MB)
https://travis-ci.org/bitcoin/bitcoin/jobs/392160315
Seems like it’s in master, given this is also failing: https://travis-ci.org/bitcoin/bitcoin/jobs/392060921
I don’t know if 57863ab is an actual fix, or just that the problem is intermittent / unrelated and just hasn’t presented itself yet.
Edit: Opened #13469 for this.
Ok, I think this is ready for re-review. @sipa thanks for the instigation.
circular-dependencies.py
output before, with removals in after indicated with strikethrough:
src$ ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp}
Circular dependency: chainparamsbase -> util -> chainparamsbase
Circular dependency: checkpoints -> validation -> checkpoints
Circular dependency: index/txindex -> init -> index/txindex
Circular dependency: index/txindex -> validation -> index/txindex
Circular dependency: init -> net_processing -> init
Circular dependency: init -> rpc/server -> init
Circular dependency: init -> txdb -> init
Circular dependency: init -> validation -> init
Circular dependency: init -> validationinterface -> init
Circular dependency: policy/fees -> txmempool -> policy/fees
Circular dependency: policy/policy -> validation -> policy/policy
Circular dependency: qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel
Circular dependency: qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel
Circular dependency: qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui
Circular dependency: qt/bitcoingui -> qt/walletframe -> qt/bitcoingui
Circular dependency: qt/bitcoingui -> qt/walletview -> qt/bitcoingui
Circular dependency: qt/clientmodel -> qt/peertablemodel -> qt/clientmodel
Circular dependency: qt/paymentserver -> qt/walletmodel -> qt/paymentserver
Circular dependency: qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel
Circular dependency: qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog
Circular dependency: qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel
Circular dependency: qt/walletmodel -> qt/walletmodeltransaction -> qt/walletmodel
Circular dependency: rpc/rawtransaction -> wallet/rpcwallet -> rpc/rawtransaction
Circular dependency: txmempool -> validation -> txmempool
Circular dependency: validation -> validationinterface -> validation
Circular dependency: wallet/coincontrol -> wallet/wallet -> wallet/coincontrol
Circular dependency: wallet/fees -> wallet/wallet -> wallet/fees
Circular dependency: wallet/rpcwallet -> wallet/wallet -> wallet/rpcwallet
Circular dependency: wallet/wallet -> wallet/walletdb -> wallet/wallet
Circular dependency: index/txindex -> init -> rpc/blockchain -> index/txindex
Circular dependency: policy/fees -> policy/policy -> validation -> policy/fees
Circular dependency: policy/rbf -> txmempool -> validation -> policy/rbf
Circular dependency: qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/addressbookpage
Circular dependency: qt/guiutil -> qt/walletmodel -> qt/optionsmodel -> qt/guiutil
Circular dependency: txmempool -> validation -> validationinterface -> txmempool
Circular dependency: qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/receivecoinsdialog -> qt/addressbookpage
Circular dependency: qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/signverifymessagedialog -> qt/addressbookpage
Circular dependency: qt/guiutil -> qt/walletmodel -> qt/optionsmodel -> qt/intro -> qt/guiutil
Circular dependency: qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/sendcoinsdialog -> qt/sendcoinsentry -> qt/addressbookpage
These were entirely unused, as based on successful compilation
and a grep for:
\bStartShutdown\(\)|\bShutdownRequested\(\)|\bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
Most includers just wanted to react to pending shutdown.
This isolates access to `fRequestShutdown` and limits access to the shutdown
api functions, including the new `AbortShutdown` for setting it to `false`.
Note I originally called `AbortShutdown` `CancelShutdown` but that name was
already taken by winuser.h
https://travis-ci.org/bitcoin/bitcoin/jobs/386913329
This change also triggered a build error in bench. Fixing it required moving LIBBITCOIN_SERVER after LIBBITCOIN_WALLET in bench_bench_bitcoin_LDADD To make
server definitions in src/net.cpp available to wallet methods in
src/wallet/wallet.cpp. Specifically, solving:
libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)':
wallet.cpp:(.text+0x3f0e): undefined reference to `CConnman::NodeFullyConnected(CNode const*)'
collect2: error: ld returned 1 exit status
https://travis-ci.org/bitcoin/bitcoin/jobs/392133581
Need for remaining init.h includes confirmed via a thorough search with a more
specific regex:
\bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
@Empact In your first commit you write “These were entirely unused, as based on successful compilation”. That’s not a sufficient argument - init.h could still be included indirectly through another header, while exported symbols from init.h are still used.
This doesn’t mean it wrong to remove them, just that “it compiles without them” isn’t a sufficient reason. Tools like iwyu
can help with this.
Oh btw I did manually check using this grep:
0 \bStartShutdown\(\)|\bShutdownRequested\(\)|\bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
But I’ll check again with the above and using iwyu
, which is probably more robust.
@practicalswift @jonasschnelli @promag could I get another look?
Alternatively I could split this into 2 PRS, the removal of the unnecessary includes and the shutdown.h extraction, if that would make review easier.