Skip to content

Commit 96c01bb

Browse files
committed
Merge branch 'bitcoin' into particl_dev
2 parents ad0b21a + 17cfa52 commit 96c01bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+737
-531
lines changed

.cirrus.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ task:
3232
folder: "/tmp/cirrus-ci-build/depends/built"
3333
install_script:
3434
- apt-get update
35-
- apt-get -y install git bash ccache libudev-dev
36-
- ccache --max-size=${CCACHE_SIZE}
35+
- apt-get -y install git bash libudev-dev
36+
=======
3737
ci_script:
3838
- ./ci/test_run_all.sh

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ linux-build
134134
win32-build
135135
test/config.ini
136136
test/cache/*
137+
test/.mypy_cache/
137138

138139
!src/leveldb*/Makefile
139140

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
FILE_ENV="./ci/test/00_setup_env_native_qt5.sh"
123123
124124
- stage: test
125-
name: 'x86_64 Linux [GOAL: install] [bionic] [no depends, only system libs, sanitizers: thread (TSan), no wallet]'
125+
name: 'x86_64 Linux [GOAL: install] [focal] [depends, sanitizers: thread (TSan), no gui]'
126126
# Not enough memory on travis machines, so feature_block is excluded for now
127127
env: >-
128128
TEST_RUNNER_EXTRA="--exclude feature_block"

ci/lint/04_install.sh

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export LC_ALL=C
99
travis_retry pip3 install codespell==1.15.0
1010
travis_retry pip3 install flake8==3.7.8
1111
travis_retry pip3 install yq
12+
travis_retry pip3 install mypy==0.700
1213

1314
SHELLCHECK_VERSION=v0.6.0
1415
curl -s "https://storage.googleapis.com/shellcheck/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/

ci/test/00_setup_env_native_fuzz.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export RUN_UNIT_TESTS=false
1414
export RUN_FUNCTIONAL_TESTS=false
1515
export RUN_FUZZ_TESTS=true
1616
export GOAL="install"
17-
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,address,undefined --enable-c++17 CC=clang CXX=clang++"
17+
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=clang CXX=clang++"

ci/test/00_setup_env_native_fuzz_with_valgrind.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export RUN_FUNCTIONAL_TESTS=false
1515
export RUN_FUZZ_TESTS=true
1616
export FUZZ_TESTS_CONFIG="--valgrind"
1717
export GOAL="install"
18-
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer --enable-c++17 CC=clang CXX=clang++"
18+
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer CC=clang CXX=clang++"

ci/test/00_setup_env_native_tsan.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_tsan
10-
export DOCKER_NAME_TAG=ubuntu:18.04
11-
export DEP_OPTS="PROTOBUF=1"
12-
export PACKAGES="clang-9 llvm-9 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libprotobuf-dev protobuf-compiler"
13-
export NO_DEPENDS=1
10+
export DOCKER_NAME_TAG=ubuntu:20.04
11+
export PACKAGES="clang llvm libc++abi-dev libc++-dev python3-zmq"
12+
export DEP_OPTS="PROTOBUF=1 CC=clang CXX='clang++ -stdlib=libc++'"
1413
export GOAL="install"
15-
export BITCOIN_CONFIG="--enable-zmq --disable-wallet --with-gui=qt5 CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' --with-sanitizers=thread --disable-hardening --disable-asm CC=clang-9 CXX=clang++-9"
14+
export BITCOIN_CONFIG="--enable-zmq --with-gui=no CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' --with-sanitizers=thread CC=clang CXX='clang++ -stdlib=libc++'"

ci/test/03_before_install.sh

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
export LC_ALL=C.UTF-8
88

9-
# Add llvm-symbolizer directory to PATH. Needed to get symbolized stack traces from the sanitizers.
10-
PATH=$PATH:/usr/lib/llvm-6.0/bin/
11-
export PATH
12-
139
BEGIN_FOLD () {
1410
echo ""
1511
CURRENT_FOLD_NAME=$1

ci/test/04_install.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mkdir -p "${PREVIOUS_RELEASES_DIR}"
2424

2525
export ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
2626
export LSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/lsan"
27-
export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:log_path=${BASE_SCRATCH_DIR}/sanitizer-output/tsan"
27+
export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:halt_on_error=1:log_path=${BASE_SCRATCH_DIR}/sanitizer-output/tsan"
2828
export UBSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1"
2929
env | grep -E '^(BITCOIN_CONFIG|BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|PREVIOUS_RELEASES_DIR)' | tee /tmp/env
3030
if [[ $HOST = *-mingw32 ]]; then
@@ -48,16 +48,14 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
4848
--env-file /tmp/env \
4949
--name $CONTAINER_NAME \
5050
$DOCKER_NAME_TAG)
51-
52-
DOCKER_EXEC () {
53-
docker exec $DOCKER_ID bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*"
54-
}
51+
export DOCKER_CI_CMD_PREFIX="docker exec $DOCKER_ID"
5552
else
5653
echo "Running on host system without docker wrapper"
57-
DOCKER_EXEC () {
58-
bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*"
59-
}
6054
fi
55+
56+
DOCKER_EXEC () {
57+
$DOCKER_CI_CMD_PREFIX bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $P_CI_DIR && $*"
58+
}
6159
export -f DOCKER_EXEC
6260

6361
if [ -n "$DPKG_ADD_ARCH" ]; then

ci/test/05_before_script.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ if [ -z "$NO_DEPENDS" ]; then
3333
else
3434
SHELL_OPTS="CONFIG_SHELL="
3535
fi
36-
DOCKER_EXEC $SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
36+
# Temporary workaround for https://github.com/bitcoin/bitcoin/issues/16368
37+
python3 -c 'import time; [print(".") or time.sleep(500) for _ in range(4)]' &
38+
( DOCKER_EXEC $SHELL_OPTS make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS ) &> /dev/null
3739
fi
3840
if [ -n "$PREVIOUS_RELEASES_TO_DOWNLOAD" ]; then
3941
BEGIN_FOLD previous-versions

configure.ac

+4-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ AC_ARG_ENABLE([c++17],
7171
[use_cxx17=no])
7272

7373
dnl Require C++11 or C++17 compiler (no GNU extensions)
74-
if test "x$use_cxx17" = xyes; then
74+
if test "x$use_cxx17" = xyes -o "x$enable_fuzz" = xyes ; then
7575
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
7676
else
7777
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
@@ -399,6 +399,7 @@ if test "x$enable_werror" = "xyes"; then
399399
dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010
400400
AX_CHECK_COMPILE_FLAG([-Werror=suggest-override],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=suggest-override"],,[[$CXXFLAG_WERROR]],
401401
[AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
402+
AX_CHECK_COMPILE_FLAG([-Werror=unreachable-code-loop-increment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]])
402403
fi
403404

404405
if test "x$CXXFLAGS_overridden" = "xno"; then
@@ -418,6 +419,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
418419
AX_CHECK_COMPILE_FLAG([-Wsign-compare],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsign-compare"],,[[$CXXFLAG_WERROR]])
419420
AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]],
420421
[AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
422+
AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]])
421423

422424
dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
423425
dnl unknown options if any other warning is produced. Test the -Wfoo case, and
@@ -1869,7 +1871,7 @@ echo " gprof enabled = $enable_gprof"
18691871
echo " werror = $enable_werror"
18701872
echo
18711873
echo " target os = $TARGET_OS"
1872-
echo " build os = $BUILD_OS"
1874+
echo " build os = $build_os"
18731875
echo
18741876
echo " CC = $CC"
18751877
echo " CFLAGS = $CFLAGS"

contrib/valgrind.supp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# Valgrind suppressions file for Bitcoin.
2-
#
3-
# Includes known Valgrind warnings in our dependencies that cannot be fixed
4-
# in-tree.
1+
# This valgrind suppressions file includes known Valgrind warnings in our
2+
# dependencies that cannot be fixed in-tree.
53
#
64
# Example use:
75
# $ valgrind --suppressions=contrib/valgrind.supp src/test/test_bitcoin
@@ -14,6 +12,9 @@
1412
# --error-limit=no src/test/test_bitcoin
1513
#
1614
# Note that suppressions may depend on OS and/or library versions.
15+
# Tested on:
16+
# * aarch64 (Ubuntu 20.04 system libs, without gui)
17+
# * x86_64 (Ubuntu 18.04 system libs, without gui)
1718
{
1819
Suppress libstdc++ warning - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65434
1920
Memcheck:Leak
@@ -47,8 +48,7 @@
4748
Suppress libdb warning
4849
Memcheck:Param
4950
pwrite64(buf)
50-
fun:pwrite
51-
fun:__os_io
51+
...
5252
obj:*/libdb_cxx-*.so
5353
}
5454
{

doc/fuzzing.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To quickly get started fuzzing Bitcoin Core using [libFuzzer](https://llvm.org/d
88
$ git clone https://github.com/bitcoin/bitcoin
99
$ cd bitcoin/
1010
$ ./autogen.sh
11-
$ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined --enable-c++17
11+
$ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined
1212
# macOS users: If you have problem with this step then make sure to read "macOS hints for
1313
# libFuzzer" on https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md#macos-hints-for-libfuzzer
1414
$ make
@@ -103,7 +103,7 @@ You may also need to take care of giving the correct path for `clang` and
103103
Full configure that was tested on macOS Catalina with `brew` installed `llvm`:
104104
105105
```sh
106-
./configure --enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ --disable-asm --enable-c++17
106+
./configure --enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ --disable-asm
107107
```
108108
109109
Read the [libFuzzer documentation](https://llvm.org/docs/LibFuzzer.html) for more information. This [libFuzzer tutorial](https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md) might also be of interest.
@@ -121,7 +121,7 @@ $ git clone https://github.com/google/afl
121121
$ make -C afl/
122122
$ make -C afl/llvm_mode/
123123
$ ./autogen.sh
124-
$ CC=$(pwd)/afl/afl-clang-fast CXX=$(pwd)/afl/afl-clang-fast++ ./configure --enable-fuzz --enable-c++17
124+
$ CC=$(pwd)/afl/afl-clang-fast CXX=$(pwd)/afl/afl-clang-fast++ ./configure --enable-fuzz
125125
$ make
126126
# For macOS you may need to ignore x86 compilation checks when running "make". If so,
127127
# try compiling using: AFL_NO_X86=1 make
@@ -148,7 +148,7 @@ $ git clone https://github.com/google/honggfuzz
148148
$ cd honggfuzz/
149149
$ make
150150
$ cd ..
151-
$ CC=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang CXX=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang++ ./configure --enable-fuzz --with-sanitizers=address,undefined --enable-c++17
151+
$ CC=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang CXX=$(pwd)/honggfuzz/hfuzz_cc/hfuzz-clang++ ./configure --enable-fuzz --with-sanitizers=address,undefined
152152
$ make
153153
$ mkdir -p inputs/
154154
$ honggfuzz/honggfuzz -i inputs/ -- src/test/fuzz/process_message

src/Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ BITCOIN_CORE_H = \
267267
versionbitsinfo.h \
268268
walletinitinterface.h \
269269
wallet/coincontrol.h \
270+
wallet/context.h \
270271
wallet/crypter.h \
271272
wallet/db.h \
272273
wallet/feebumper.h \
@@ -430,6 +431,7 @@ libparticl_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
430431
libparticl_wallet_a_SOURCES = \
431432
interfaces/wallet.cpp \
432433
wallet/coincontrol.cpp \
434+
wallet/context.cpp \
433435
wallet/crypter.cpp \
434436
wallet/db.cpp \
435437
wallet/feebumper.cpp \

src/index/txindex.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include <wallet/ismine.h>
1616
#include <key_io.h>
1717

18-
#include <boost/thread.hpp>
19-
2018
constexpr char DB_BEST_BLOCK = 'B';
2119
constexpr char DB_TXINDEX = 't';
2220
constexpr char DB_TXINDEX_BLOCK = 'T';
@@ -159,7 +157,6 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator&
159157
bool interrupted = false;
160158
std::unique_ptr<CDBIterator> cursor(block_tree_db.NewIterator());
161159
for (cursor->Seek(begin_key); cursor->Valid(); cursor->Next()) {
162-
boost::this_thread::interruption_point();
163160
if (ShutdownRequested()) {
164161
interrupted = true;
165162
break;

src/init.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,9 @@
8686
#include <sys/stat.h>
8787
#endif
8888

89-
#include <boost/algorithm/string/classification.hpp>
9089
#include <boost/algorithm/string/replace.hpp>
91-
#include <boost/algorithm/string/split.hpp>
9290
#include <boost/signals2/signal.hpp>
93-
#include <boost/thread.hpp>
91+
#include <boost/thread/thread.hpp>
9492

9593
#if ENABLE_ZMQ
9694
#include <zmq/zmqabstractnotifier.h>
@@ -1130,17 +1128,27 @@ bool AppInitParameterInteraction()
11301128

11311129
// also see: InitParameterInteraction()
11321130

1133-
// Warn if network-specific options (-addnode, -connect, etc) are
1131+
// Error if network-specific options (-addnode, -connect, etc) are
11341132
// specified in default section of config file, but not overridden
11351133
// on the command line or in this network's section of the config file.
11361134
std::string network = gArgs.GetChainName();
1135+
bilingual_str errors;
11371136
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
1138-
return InitError(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
1137+
errors += strprintf(_("Config setting for %s only applied on %s network when in [%s] section.") + Untranslated("\n"), arg, network, network);
1138+
}
1139+
1140+
if (!errors.empty()) {
1141+
return InitError(errors);
11391142
}
11401143

11411144
// Warn if unrecognized section name are present in the config file.
1145+
bilingual_str warnings;
11421146
for (const auto& section : gArgs.GetUnrecognizedSections()) {
1143-
InitWarning(strprintf(Untranslated("%s:%i ") + _("Section [%s] is not recognized."), section.m_file, section.m_line, section.m_name));
1147+
warnings += strprintf(Untranslated("%s:%i ") + _("Section [%s] is not recognized.") + Untranslated("\n"), section.m_file, section.m_line, section.m_name);
1148+
}
1149+
1150+
if (!warnings.empty()) {
1151+
InitWarning(warnings);
11441152
}
11451153

11461154
if (!fs::is_directory(GetBlocksDir())) {

src/interfaces/wallet.cpp

+21-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
#include <interfaces/handler.h>
1010
#include <policy/fees.h>
1111
#include <primitives/transaction.h>
12+
#include <rpc/server.h>
1213
#include <script/standard.h>
1314
#include <support/allocators/secure.h>
1415
#include <sync.h>
1516
#include <ui_interface.h>
1617
#include <uint256.h>
1718
#include <util/check.h>
19+
#include <util/ref.h>
1820
#include <util/system.h>
21+
#include <wallet/context.h>
1922
#include <wallet/feebumper.h>
2023
#include <wallet/fees.h>
2124
#include <wallet/ismine.h>
@@ -783,17 +786,27 @@ class WalletClientImpl : public ChainClient
783786
{
784787
public:
785788
WalletClientImpl(Chain& chain, std::vector<std::string> wallet_filenames)
786-
: m_chain(chain), m_wallet_filenames(std::move(wallet_filenames))
789+
: m_wallet_filenames(std::move(wallet_filenames))
787790
{
791+
m_context.chain = &chain;
788792
}
789793
void registerRpcs() override
790794
{
791-
g_rpc_chain = &m_chain;
792-
RegisterHDWalletRPCCommands(m_chain, m_rpc_handlers);
793-
return RegisterWalletRPCCommands(m_chain, m_rpc_handlers);
795+
for (const CRPCCommand& command : GetHDWalletRPCCommands()) {
796+
m_rpc_commands.emplace_back(command.category, command.name, [this, &command](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
797+
return command.actor({request, m_context}, result, last_handler);
798+
}, command.argNames, command.unique_id);
799+
m_rpc_handlers.emplace_back(m_context.chain->handleRpc(m_rpc_commands.back()));
800+
}
801+
for (const CRPCCommand& command : GetWalletRPCCommands()) {
802+
m_rpc_commands.emplace_back(command.category, command.name, [this, &command](const JSONRPCRequest& request, UniValue& result, bool last_handler) {
803+
return command.actor({request, m_context}, result, last_handler);
804+
}, command.argNames, command.unique_id);
805+
m_rpc_handlers.emplace_back(m_context.chain->handleRpc(m_rpc_commands.back()));
806+
}
794807
}
795-
bool verify() override { return VerifyWallets(m_chain, m_wallet_filenames); }
796-
bool load() override { return LoadWallets(m_chain, m_wallet_filenames); }
808+
bool verify() override { return VerifyWallets(*m_context.chain, m_wallet_filenames); }
809+
bool load() override { return LoadWallets(*m_context.chain, m_wallet_filenames); }
797810
void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
798811
void flush() override { return FlushWallets(); }
799812
void stop() override { return StopWallets(); }
@@ -808,9 +821,10 @@ class WalletClientImpl : public ChainClient
808821
}
809822
~WalletClientImpl() override { UnloadWallets(); }
810823

811-
Chain& m_chain;
824+
WalletContext m_context;
812825
std::vector<std::string> m_wallet_filenames;
813826
std::vector<std::unique_ptr<Handler>> m_rpc_handlers;
827+
std::list<CRPCCommand> m_rpc_commands;
814828
};
815829

816830
} // namespace

0 commit comments

Comments
 (0)