From e2fe1a222b6480b2900a5a2be934d2061b232834 Mon Sep 17 00:00:00 2001
From: Konstantin Akimov <knstqq@gmail.com>
Date: Tue, 7 Nov 2023 00:57:10 +0700
Subject: [PATCH 01/13] fix: follow-up missing changes from Merge #20413:
 build: Require C++17 compiler

---
 ci/test/00_setup_env_native_fuzz.sh               | 2 +-
 ci/test/00_setup_env_native_fuzz_with_valgrind.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ci/test/00_setup_env_native_fuzz.sh b/ci/test/00_setup_env_native_fuzz.sh
index 92001c8860a1..edaaff34dd0a 100755
--- a/ci/test/00_setup_env_native_fuzz.sh
+++ b/ci/test/00_setup_env_native_fuzz.sh
@@ -17,4 +17,4 @@ export RUN_UNIT_TESTS=false
 export RUN_INTEGRATION_TESTS=false
 export RUN_FUZZ_TESTS=true
 export GOAL="install"
-export BITCOIN_CONFIG="--enable-zmq --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address,undefined --enable-c++17  --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"
+export BITCOIN_CONFIG="--enable-zmq --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address,undefined --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"
diff --git a/ci/test/00_setup_env_native_fuzz_with_valgrind.sh b/ci/test/00_setup_env_native_fuzz_with_valgrind.sh
index 9805ccf12b22..ad2937e84b21 100644
--- a/ci/test/00_setup_env_native_fuzz_with_valgrind.sh
+++ b/ci/test/00_setup_env_native_fuzz_with_valgrind.sh
@@ -15,4 +15,4 @@ export RUN_FUNCTIONAL_TESTS=false
 export RUN_FUZZ_TESTS=true
 export FUZZ_TESTS_CONFIG="--valgrind"
 export GOAL="install"
-export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer --enable-c++17 --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"
+export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"

From 0aa6f21149978385d0dcc9a89ae056f601556143 Mon Sep 17 00:00:00 2001
From: MarcoFalke <falke.marco@gmail.com>
Date: Thu, 7 May 2020 10:26:53 -0400
Subject: [PATCH 02/13] Merge #18905: travis: Remove s390x

8c705ff1291ef7876ab1a939e2c7312aacc3dc37 travis: Remove s390x (MarcoFalke)

Pull request description:

  Fixes #18868
  Fixes #18016

Top commit has no ACKs.

Tree-SHA512: 1007b761c7e01dd2b75aa34e92e01a92a84a100c0a3a53863c755d93b2438a74601e3f2083919b8a9cfc92fb104d0c8415fad3f6c9504c76b02ad2e9712660c0
---
 .travis.yml                        | 20 --------------------
 ci/test/00_setup_env_s390x_host.sh | 14 --------------
 2 files changed, 34 deletions(-)
 delete mode 100644 ci/test/00_setup_env_s390x_host.sh

diff --git a/.travis.yml b/.travis.yml
index b95eb317ae06..7dc9136fda43 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -209,26 +209,6 @@ after_success:
         FILE_ENV="./ci/test/00_setup_env_arm.sh"
         QEMU_USER_CMD=""
 
-    - stage: test
-      name: 's390x native BE [GOAL: install] [bionic] [no depends, no GUI]'
-      arch: s390x
-      dist: bionic
-      addons:
-        apt:
-          packages:
-            - bsdmainutils
-            - libboost-filesystem-dev
-            - libboost-system-dev
-            - libboost-test-dev
-            - libboost-thread-dev
-            - libdb++-dev
-            - libdb-dev
-            - libevent-dev
-      env: >-
-        DANGER_RUN_CI_ON_HOST=true
-        CI_USE_APT_INSTALL=no
-        FILE_ENV="./ci/test/00_setup_env_s390x_host.sh"
-
 # s390 build was disabled temporarily because of disk space issues on the Travis VM
 #
 #    - stage: test
diff --git a/ci/test/00_setup_env_s390x_host.sh b/ci/test/00_setup_env_s390x_host.sh
deleted file mode 100644
index 3e31867f2f07..000000000000
--- a/ci/test/00_setup_env_s390x_host.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-#
-# Copyright (c) 2019-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.
-
-export LC_ALL=C.UTF-8
-
-export HOST=s390x-linux-gnu
-export NO_DEPENDS=1
-export BITCOIN_CONFIG="--with-incompatible-bdb --enable-reduce-exports"
-export RUN_UNIT_TESTS=true
-export RUN_FUNCTIONAL_TESTS=true
-export GOAL="install"

From 62553fe2260c2726b67436578bf3d0bea49e89a8 Mon Sep 17 00:00:00 2001
From: fanquake <fanquake@gmail.com>
Date: Mon, 11 May 2020 11:33:42 +0800
Subject: [PATCH 03/13] Merge #18216: test, build: Enable -Werror=sign-compare

68537275bd91d1dc14a69609ae443f955bfdbd64 build: Enable -Werror=sign-compare (Ben Woosley)
eac6a3080d38cfd4eb7204ecd327df213958e51a refactor: Rework asmap Interpret to avoid ptrdiff_t (Ben Woosley)
df37377e30678ac9b8338ea920e50b7296da6bd5 test: Fix outstanding -Wsign-compare errors (Ben Woosley)

Pull request description:

  Disallowing sign-comparison mismatches can help to prevent the introduction of overflow and interpretation bugs.

  In this case, ~all~ most existing violations are in the tests, and most simply required annotating the literal as unsigned for comparison.

  This was previously prevented by violations in leveldb which were fixed upstream and merged in #17398. You can test that by building this branch against: 22d11187ee3c7abfe9d43c9eb68f102498cc2b9a vs 75fb37ce68289eb7e00e2ccdd2ef7f9271332545

ACKs for top commit:
  fjahr:
    re-ACK 68537275bd91d1dc14a69609ae443f955bfdbd64
  practicalswift:
    ACK 68537275bd91d1dc14a69609ae443f955bfdbd64

Tree-SHA512: 14b5daa38c496fb51548feb30fb4dd179e6f76a8d355f52bc8e2a18f2f9340f0bc98dcf36d8b3d6521045d013891c3103749a4eda88ceef00202a6a0cf93f73c
---
 configure.ac                         |  2 ++
 src/evo/assetlocktx.cpp              |  2 +-
 src/evo/cbtx.cpp                     |  8 ++---
 src/llmq/quorums.cpp                 |  4 +--
 src/test/blockfilter_index_tests.cpp |  9 +++---
 src/test/blockfilter_tests.cpp       | 10 +++---
 src/test/bloom_tests.cpp             |  4 +--
 src/test/compress_tests.cpp          | 16 +++++-----
 src/test/descriptor_tests.cpp        |  2 +-
 src/test/flatfile_tests.cpp          | 16 +++++-----
 src/test/netbase_tests.cpp           |  2 +-
 src/test/random_tests.cpp            |  2 +-
 src/test/streams_tests.cpp           | 46 ++++++++++++++--------------
 src/test/util_tests.cpp              | 26 ++++++++--------
 src/test/util_threadnames_tests.cpp  |  2 +-
 src/test/validation_flush_tests.cpp  |  4 +--
 src/txmempool.cpp                    |  2 +-
 src/txmempool.h                      |  2 +-
 src/util/asmap.cpp                   |  6 ++--
 src/wallet/test/wallet_tests.cpp     |  8 ++---
 src/wallet/wallet.cpp                |  2 +-
 21 files changed, 90 insertions(+), 85 deletions(-)

diff --git a/configure.ac b/configure.ac
index b01cf5af8da9..d3ff134a0255 100644
--- a/configure.ac
+++ b/configure.ac
@@ -433,6 +433,7 @@ if test "x$enable_werror" = "xyes"; then
   AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]])
+  AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]])
   dnl -Wsuggest-override is broken with GCC before 9.2
   dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010
   AX_CHECK_COMPILE_FLAG([-Werror=suggest-override],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=suggest-override"],,[[$CXXFLAG_WERROR]],
@@ -457,6 +458,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
   AX_CHECK_COMPILE_FLAG([-Wunused-member-function],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-member-function"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]])
+  AX_CHECK_COMPILE_FLAG([-Wsign-compare],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsign-compare"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]],
                         [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
   AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]])
diff --git a/src/evo/assetlocktx.cpp b/src/evo/assetlocktx.cpp
index 88ce8708a4a3..2908432f663b 100644
--- a/src/evo/assetlocktx.cpp
+++ b/src/evo/assetlocktx.cpp
@@ -123,7 +123,7 @@ bool CAssetUnlockPayload::VerifySig(const uint256& msgHash, gsl::not_null<const
         return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-not-active-quorum");
     }
 
-    if (pindexTip->nHeight < requestedHeight || pindexTip->nHeight >= getHeightToExpiry()) {
+    if (static_cast<uint32_t>(pindexTip->nHeight) < requestedHeight || pindexTip->nHeight >= getHeightToExpiry()) {
         LogPrint(BCLog::CREDITPOOL, "Asset unlock tx %d with requested height %d could not be accepted on height: %d\n",
                 index, requestedHeight, pindexTip->nHeight);
         return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-assetunlock-too-late");
diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp
index 8bfe14ab500a..8f96d5f2b067 100644
--- a/src/evo/cbtx.cpp
+++ b/src/evo/cbtx.cpp
@@ -398,8 +398,8 @@ bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, co
         }
 
         // We check if our best CL is newer than the one from previous block Coinbase
-        auto curCLHeight = best_clsig.getHeight();
-        auto prevCLHeight = static_cast<uint32_t>(pindexPrev->nHeight) - prevBlockCoinbaseChainlock->second - 1;
+        int curCLHeight = best_clsig.getHeight();
+        int prevCLHeight = pindexPrev->nHeight - static_cast<int>(prevBlockCoinbaseChainlock->second) - 1;
         if (curCLHeight < prevCLHeight) {
             // Our best CL isn't newer: inserting CL from previous block
             bestCLHeightDiff = prevBlockCoinbaseChainlock->second + 1;
@@ -407,7 +407,7 @@ bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, co
         }
         else {
             // Our best CL is newer
-            bestCLHeightDiff = static_cast<uint32_t>(pindexPrev->nHeight) - best_clsig.getHeight();
+            bestCLHeightDiff = pindexPrev->nHeight - best_clsig.getHeight();
             bestCLSignature = best_clsig.getSig();
         }
 
@@ -423,7 +423,7 @@ bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, co
         }
 
         // Inserting our best CL
-        bestCLHeightDiff = static_cast<uint32_t>(pindexPrev->nHeight) - best_clsig.getHeight();
+        bestCLHeightDiff = pindexPrev->nHeight - best_clsig.getHeight();
         bestCLSignature = chainlock_handler.GetBestChainLock().getSig();
 
         return true;
diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp
index 0e392a9643f1..bb32fb0e3690 100644
--- a/src/llmq/quorums.cpp
+++ b/src/llmq/quorums.cpp
@@ -572,7 +572,7 @@ std::vector<CQuorumCPtr> CQuorumManager::ScanQuorums(Consensus::LLMQType llmqTyp
     for (auto& pQuorumBaseBlockIndex : pQuorumBaseBlockIndexes) {
         assert(pQuorumBaseBlockIndex);
         // populate cache for keepOldConnections most recent quorums only
-        bool populate_cache = vecResultQuorums.size() < llmq_params_opt->keepOldConnections;
+        bool populate_cache = vecResultQuorums.size() < static_cast<size_t>(llmq_params_opt->keepOldConnections);
         auto quorum = GetQuorum(llmqType, pQuorumBaseBlockIndex, populate_cache);
         assert(quorum != nullptr);
         vecResultQuorums.emplace_back(quorum);
@@ -1077,7 +1077,7 @@ void CQuorumManager::StartCleanupOldQuorumDataThread(const CBlockIndex* pIndex)
                 uint256 quorum_key;
                 if (cache.get(pindex_loop->GetBlockHash(), quorum_key)) {
                     quorum_keys.insert(quorum_key);
-                    if (quorum_keys.size() >= params.keepOldKeys) break; // extra safety belt
+                    if (quorum_keys.size() >= static_cast<size_t>(params.keepOldKeys)) break; // extra safety belt
                 }
                 pindex_loop = pindex_loop->pprev;
             }
diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp
index dbd95b107fa0..a2bab832a81c 100644
--- a/src/test/blockfilter_index_tests.cpp
+++ b/src/test/blockfilter_index_tests.cpp
@@ -50,8 +50,8 @@ static bool CheckFilterLookups(BlockFilterIndex& filter_index, const CBlockIndex
     BOOST_CHECK(filter_index.LookupFilterHashRange(block_index->nHeight, block_index,
                                                    filter_hashes));
 
-    BOOST_CHECK_EQUAL(filters.size(), 1);
-    BOOST_CHECK_EQUAL(filter_hashes.size(), 1);
+    BOOST_CHECK_EQUAL(filters.size(), 1U);
+    BOOST_CHECK_EQUAL(filter_hashes.size(), 1U);
 
     BOOST_CHECK_EQUAL(filter.GetHash(), expected_filter.GetHash());
     BOOST_CHECK_EQUAL(filter_header, expected_filter.ComputeHeader(last_header));
@@ -257,8 +257,9 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
     BOOST_CHECK(filter_index.LookupFilterRange(0, tip, filters));
     BOOST_CHECK(filter_index.LookupFilterHashRange(0, tip, filter_hashes));
 
-    BOOST_CHECK_EQUAL(filters.size(), tip->nHeight + 1);
-    BOOST_CHECK_EQUAL(filter_hashes.size(), tip->nHeight + 1);
+    assert(tip->nHeight >= 0);
+    BOOST_CHECK_EQUAL(filters.size(), tip->nHeight + 1U);
+    BOOST_CHECK_EQUAL(filter_hashes.size(), tip->nHeight + 1U);
 
     filters.clear();
     filter_hashes.clear();
diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp
index 1e0c30f317cb..5e418ba9e2d5 100644
--- a/src/test/blockfilter_tests.cpp
+++ b/src/test/blockfilter_tests.cpp
@@ -42,14 +42,14 @@ BOOST_AUTO_TEST_CASE(gcsfilter_test)
 BOOST_AUTO_TEST_CASE(gcsfilter_default_constructor)
 {
     GCSFilter filter;
-    BOOST_CHECK_EQUAL(filter.GetN(), 0);
-    BOOST_CHECK_EQUAL(filter.GetEncoded().size(), 1);
+    BOOST_CHECK_EQUAL(filter.GetN(), 0U);
+    BOOST_CHECK_EQUAL(filter.GetEncoded().size(), 1U);
 
     const GCSFilter::Params& params = filter.GetParams();
-    BOOST_CHECK_EQUAL(params.m_siphash_k0, 0);
-    BOOST_CHECK_EQUAL(params.m_siphash_k1, 0);
+    BOOST_CHECK_EQUAL(params.m_siphash_k0, 0U);
+    BOOST_CHECK_EQUAL(params.m_siphash_k1, 0U);
     BOOST_CHECK_EQUAL(params.m_P, 0);
-    BOOST_CHECK_EQUAL(params.m_M, 1);
+    BOOST_CHECK_EQUAL(params.m_M, 1U);
 }
 
 BOOST_AUTO_TEST_CASE(blockfilter_basic_test)
diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp
index 2d8df1658343..620299922911 100644
--- a/src/test/bloom_tests.cpp
+++ b/src/test/bloom_tests.cpp
@@ -574,7 +574,7 @@ BOOST_AUTO_TEST_CASE(rolling_bloom)
             ++nHits;
     }
     // Expect about 100 hits
-    BOOST_CHECK_EQUAL(nHits, 75);
+    BOOST_CHECK_EQUAL(nHits, 75U);
 
     BOOST_CHECK(rb1.contains(data[DATASIZE-1]));
     rb1.reset();
@@ -602,7 +602,7 @@ BOOST_AUTO_TEST_CASE(rolling_bloom)
             ++nHits;
     }
     // Expect about 5 false positives
-    BOOST_CHECK_EQUAL(nHits, 6);
+    BOOST_CHECK_EQUAL(nHits, 6U);
 
     // last-1000-entry, 0.01% false positive:
     CRollingBloomFilter rb2(1000, 0.001);
diff --git a/src/test/compress_tests.cpp b/src/test/compress_tests.cpp
index 4bc301f583f3..7b661a0d1da9 100644
--- a/src/test/compress_tests.cpp
+++ b/src/test/compress_tests.cpp
@@ -70,14 +70,14 @@ BOOST_AUTO_TEST_CASE(compress_script_to_ckey_id)
     CPubKey pubkey = key.GetPubKey();
 
     CScript script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
-    BOOST_CHECK_EQUAL(script.size(), 25);
+    BOOST_CHECK_EQUAL(script.size(), 25U);
 
     CompressedScript out;
     bool done = CompressScript(script, out);
     BOOST_CHECK_EQUAL(done, true);
 
     // Check compressed script
-    BOOST_CHECK_EQUAL(out.size(), 21);
+    BOOST_CHECK_EQUAL(out.size(), 21U);
     BOOST_CHECK_EQUAL(out[0], 0x00);
     BOOST_CHECK_EQUAL(memcmp(&out[1], &script[3], 20), 0); // compare the 20 relevant chars of the CKeyId in the script
 }
@@ -87,14 +87,14 @@ BOOST_AUTO_TEST_CASE(compress_script_to_cscript_id)
     // case CScriptID
     CScript script, redeemScript;
     script << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
-    BOOST_CHECK_EQUAL(script.size(), 23);
+    BOOST_CHECK_EQUAL(script.size(), 23U);
 
     CompressedScript out;
     bool done = CompressScript(script, out);
     BOOST_CHECK_EQUAL(done, true);
 
     // Check compressed script
-    BOOST_CHECK_EQUAL(out.size(), 21);
+    BOOST_CHECK_EQUAL(out.size(), 21U);
     BOOST_CHECK_EQUAL(out[0], 0x01);
     BOOST_CHECK_EQUAL(memcmp(&out[1], &script[2], 20), 0); // compare the 20 relevant chars of the CScriptId in the script
 }
@@ -105,14 +105,14 @@ BOOST_AUTO_TEST_CASE(compress_script_to_compressed_pubkey_id)
     key.MakeNewKey(true); // case compressed PubKeyID
 
     CScript script = CScript() << ToByteVector(key.GetPubKey()) << OP_CHECKSIG; // COMPRESSED_PUBLIC_KEY_SIZE (33)
-    BOOST_CHECK_EQUAL(script.size(), 35);
+    BOOST_CHECK_EQUAL(script.size(), 35U);
 
     CompressedScript out;
     bool done = CompressScript(script, out);
     BOOST_CHECK_EQUAL(done, true);
 
     // Check compressed script
-    BOOST_CHECK_EQUAL(out.size(), 33);
+    BOOST_CHECK_EQUAL(out.size(), 33U);
     BOOST_CHECK_EQUAL(memcmp(&out[0], &script[1], 1), 0);
     BOOST_CHECK_EQUAL(memcmp(&out[1], &script[2], 32), 0); // compare the 32 chars of the compressed CPubKey
 }
@@ -122,14 +122,14 @@ BOOST_AUTO_TEST_CASE(compress_script_to_uncompressed_pubkey_id)
     CKey key;
     key.MakeNewKey(false); // case uncompressed PubKeyID
     CScript script =  CScript() << ToByteVector(key.GetPubKey()) << OP_CHECKSIG; // PUBLIC_KEY_SIZE (65)
-    BOOST_CHECK_EQUAL(script.size(), 67);                   // 1 char code + 65 char pubkey + OP_CHECKSIG
+    BOOST_CHECK_EQUAL(script.size(), 67U);                   // 1 char code + 65 char pubkey + OP_CHECKSIG
 
     CompressedScript out;
     bool done = CompressScript(script, out);
     BOOST_CHECK_EQUAL(done, true);
 
     // Check compressed script
-    BOOST_CHECK_EQUAL(out.size(), 33);
+    BOOST_CHECK_EQUAL(out.size(), 33U);
     BOOST_CHECK_EQUAL(memcmp(&out[1], &script[2], 32), 0); // first 32 chars of CPubKey are copied into out[1:]
     BOOST_CHECK_EQUAL(out[0], 0x04 | (script[65] & 0x01)); // least significant bit (lsb) of last char of pubkey is mapped into out[0]
 }
diff --git a/src/test/descriptor_tests.cpp b/src/test/descriptor_tests.cpp
index 9f23dea8c31c..f2430c5f72db 100644
--- a/src/test/descriptor_tests.cpp
+++ b/src/test/descriptor_tests.cpp
@@ -233,7 +233,7 @@ void DoCheck(const std::string& prv, const std::string& pub, int flags, const st
                 std::vector<CScript> spks_inferred;
                 FlatSigningProvider provider_inferred;
                 BOOST_CHECK(inferred->Expand(0, provider_inferred, spks_inferred, provider_inferred));
-                BOOST_CHECK_EQUAL(spks_inferred.size(), 1);
+                BOOST_CHECK_EQUAL(spks_inferred.size(), 1U);
                 BOOST_CHECK(spks_inferred[0] == spks[n]);
                 BOOST_CHECK_EQUAL(IsSolvable(provider_inferred, spks_inferred[0]), !(flags & UNSOLVABLE));
                 BOOST_CHECK(provider_inferred.origins == script_provider.origins);
diff --git a/src/test/flatfile_tests.cpp b/src/test/flatfile_tests.cpp
index 9bb0b3ef02ba..be7484cd0b41 100644
--- a/src/test/flatfile_tests.cpp
+++ b/src/test/flatfile_tests.cpp
@@ -93,16 +93,16 @@ BOOST_AUTO_TEST_CASE(flatfile_allocate)
 
     bool out_of_space;
 
-    BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 0), 1, out_of_space), 100);
-    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 0))), 100);
+    BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 0), 1, out_of_space), 100U);
+    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 0))), 100U);
     BOOST_CHECK(!out_of_space);
 
-    BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 1, out_of_space), 0);
-    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 100);
+    BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 1, out_of_space), 0U);
+    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 100U);
     BOOST_CHECK(!out_of_space);
 
-    BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 2, out_of_space), 101);
-    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 200);
+    BOOST_CHECK_EQUAL(seq.Allocate(FlatFilePos(0, 99), 2, out_of_space), 101U);
+    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 99))), 200U);
     BOOST_CHECK(!out_of_space);
 }
 
@@ -116,11 +116,11 @@ BOOST_AUTO_TEST_CASE(flatfile_flush)
 
     // Flush without finalize should not truncate file.
     seq.Flush(FlatFilePos(0, 1));
-    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 100);
+    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 100U);
 
     // Flush with finalize should truncate file.
     seq.Flush(FlatFilePos(0, 1), true);
-    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 1);
+    BOOST_CHECK_EQUAL(fs::file_size(seq.FileName(FlatFilePos(0, 1))), 1U);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp
index 77250c6bb902..2e76f2d24c4c 100644
--- a/src/test/netbase_tests.cpp
+++ b/src/test/netbase_tests.cpp
@@ -547,7 +547,7 @@ BOOST_AUTO_TEST_CASE(netpermissions_test)
     BOOST_CHECK(NetWhitelistPermissions::TryParse("bloom,forcerelay,noban,relay,mempool@1.2.3.4/32", whitelistPermissions, error));
 
     const auto strings = NetPermissions::ToStrings(PF_ALL);
-    BOOST_CHECK_EQUAL(strings.size(), 7);
+    BOOST_CHECK_EQUAL(strings.size(), 7U);
     BOOST_CHECK(std::find(strings.begin(), strings.end(), "bloomfilter") != strings.end());
     BOOST_CHECK(std::find(strings.begin(), strings.end(), "forcerelay") != strings.end());
     BOOST_CHECK(std::find(strings.begin(), strings.end(), "relay") != strings.end());
diff --git a/src/test/random_tests.cpp b/src/test/random_tests.cpp
index 40a2378fe9ee..258a3eafeff9 100644
--- a/src/test/random_tests.cpp
+++ b/src/test/random_tests.cpp
@@ -151,7 +151,7 @@ BOOST_AUTO_TEST_CASE(shuffle_stat_test)
     }
     BOOST_CHECK(chi_score > 58.1411); // 99.9999% confidence interval
     BOOST_CHECK(chi_score < 210.275);
-    BOOST_CHECK_EQUAL(sum, 12000);
+    BOOST_CHECK_EQUAL(sum, 12000U);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp
index 7aa4d9b3c3b1..af6e302878f0 100644
--- a/src/test/streams_tests.cpp
+++ b/src/test/streams_tests.cpp
@@ -72,28 +72,28 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
     std::vector<unsigned char> vch = {1, 255, 3, 4, 5, 6};
 
     VectorReader reader(SER_NETWORK, INIT_PROTO_VERSION, vch, 0);
-    BOOST_CHECK_EQUAL(reader.size(), 6);
+    BOOST_CHECK_EQUAL(reader.size(), 6U);
     BOOST_CHECK(!reader.empty());
 
     // Read a single byte as an unsigned char.
     unsigned char a;
     reader >> a;
     BOOST_CHECK_EQUAL(a, 1);
-    BOOST_CHECK_EQUAL(reader.size(), 5);
+    BOOST_CHECK_EQUAL(reader.size(), 5U);
     BOOST_CHECK(!reader.empty());
 
     // Read a single byte as a signed char.
     signed char b;
     reader >> b;
     BOOST_CHECK_EQUAL(b, -1);
-    BOOST_CHECK_EQUAL(reader.size(), 4);
+    BOOST_CHECK_EQUAL(reader.size(), 4U);
     BOOST_CHECK(!reader.empty());
 
     // Read a 4 bytes as an unsigned int.
     unsigned int c;
     reader >> c;
-    BOOST_CHECK_EQUAL(c, 100992003); // 3,4,5,6 in little-endian base-256
-    BOOST_CHECK_EQUAL(reader.size(), 0);
+    BOOST_CHECK_EQUAL(c, 100992003U); // 3,4,5,6 in little-endian base-256
+    BOOST_CHECK_EQUAL(reader.size(), 0U);
     BOOST_CHECK(reader.empty());
 
     // Reading after end of byte vector throws an error.
@@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
     VectorReader new_reader(SER_NETWORK, INIT_PROTO_VERSION, vch, 0);
     new_reader >> d;
     BOOST_CHECK_EQUAL(d, 67370753); // 1,255,3,4 in little-endian base-256
-    BOOST_CHECK_EQUAL(new_reader.size(), 2);
+    BOOST_CHECK_EQUAL(new_reader.size(), 2U);
     BOOST_CHECK(!new_reader.empty());
 
     // Reading after end of byte vector throws an error even if the reader is
@@ -147,14 +147,14 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
     BOOST_CHECK_EQUAL(serialized_int2, (uint16_t)0x1072); // NOTE: Serialized as LE
 
     BitStreamReader<CDataStream> bit_reader(data_copy);
-    BOOST_CHECK_EQUAL(bit_reader.Read(1), 0);
-    BOOST_CHECK_EQUAL(bit_reader.Read(2), 2);
-    BOOST_CHECK_EQUAL(bit_reader.Read(3), 6);
-    BOOST_CHECK_EQUAL(bit_reader.Read(4), 11);
-    BOOST_CHECK_EQUAL(bit_reader.Read(5), 1);
-    BOOST_CHECK_EQUAL(bit_reader.Read(6), 32);
-    BOOST_CHECK_EQUAL(bit_reader.Read(7), 7);
-    BOOST_CHECK_EQUAL(bit_reader.Read(16), 30497);
+    BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(2), 2U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(3), 6U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(4), 11U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(5), 1U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(6), 32U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(7), 7U);
+    BOOST_CHECK_EQUAL(bit_reader.Read(16), 30497U);
     BOOST_CHECK_THROW(bit_reader.Read(8), std::ios_base::failure);
 }
 
@@ -247,7 +247,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
     BOOST_CHECK_EQUAL(i, 1);
 
     // After reading bytes 0 and 1, we're positioned at 2.
-    BOOST_CHECK_EQUAL(bf.GetPos(), 2);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 2U);
 
     // Rewind to offset 0, ok (within the 10 byte window).
     BOOST_CHECK(bf.SetPos(0));
@@ -274,18 +274,18 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
     // The default argument removes the limit completely.
     BOOST_CHECK(bf.SetLimit());
     // The read position should still be at 3 (no change).
-    BOOST_CHECK_EQUAL(bf.GetPos(), 3);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 3U);
 
     // Read from current offset, 3, forward until position 10.
     for (uint8_t j = 3; j < 10; ++j) {
         bf >> i;
         BOOST_CHECK_EQUAL(i, j);
     }
-    BOOST_CHECK_EQUAL(bf.GetPos(), 10);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 10U);
 
     // We're guaranteed (just barely) to be able to rewind to zero.
     BOOST_CHECK(bf.SetPos(0));
-    BOOST_CHECK_EQUAL(bf.GetPos(), 0);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 0U);
     bf >> i;
     BOOST_CHECK_EQUAL(i, 0);
 
@@ -295,12 +295,12 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
     BOOST_CHECK(bf.SetPos(10));
     bf >> i;
     BOOST_CHECK_EQUAL(i, 10);
-    BOOST_CHECK_EQUAL(bf.GetPos(), 11);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 11U);
 
     // Now it's only guaranteed that we can rewind to offset 1
     // (current read position, 11, minus rewind amount, 10).
     BOOST_CHECK(bf.SetPos(1));
-    BOOST_CHECK_EQUAL(bf.GetPos(), 1);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 1U);
     bf >> i;
     BOOST_CHECK_EQUAL(i, 1);
 
@@ -314,7 +314,7 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
             BOOST_CHECK_EQUAL(a[j], 11 + j);
         }
     }
-    BOOST_CHECK_EQUAL(bf.GetPos(), 40);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 40U);
 
     // We've read the entire file, the next read should throw.
     try {
@@ -328,11 +328,11 @@ BOOST_AUTO_TEST_CASE(streams_buffered_file)
     BOOST_CHECK(bf.eof());
 
     // Still at offset 40, we can go back 10, to 30.
-    BOOST_CHECK_EQUAL(bf.GetPos(), 40);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 40U);
     BOOST_CHECK(bf.SetPos(30));
     bf >> i;
     BOOST_CHECK_EQUAL(i, 30);
-    BOOST_CHECK_EQUAL(bf.GetPos(), 31);
+    BOOST_CHECK_EQUAL(bf.GetPos(), 31U);
 
     // We're too far to rewind to position zero.
     BOOST_CHECK(!bf.SetPos(0));
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 114fd4b8700f..d741c1bc259d 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -344,9 +344,9 @@ class CheckValueTest : public TestChain100Setup
         BOOST_CHECK_EQUAL(test.GetSetting("-value").write(), expect.setting.write());
         auto settings_list = test.GetSettingsList("-value");
         if (expect.setting.isNull() || expect.setting.isFalse()) {
-            BOOST_CHECK_EQUAL(settings_list.size(), 0);
+            BOOST_CHECK_EQUAL(settings_list.size(), 0U);
         } else {
-            BOOST_CHECK_EQUAL(settings_list.size(), 1);
+            BOOST_CHECK_EQUAL(settings_list.size(), 1U);
             BOOST_CHECK_EQUAL(settings_list[0].write(), expect.setting.write());
         }
 
@@ -2197,24 +2197,24 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector)
     BOOST_CHECK(t3.origin == &t3);
 
     auto v1 = Vector(t1);
-    BOOST_CHECK_EQUAL(v1.size(), 1);
+    BOOST_CHECK_EQUAL(v1.size(), 1U);
     BOOST_CHECK(v1[0].origin == &t1);
     BOOST_CHECK_EQUAL(v1[0].copies, 1);
 
     auto v2 = Vector(std::move(t2));
-    BOOST_CHECK_EQUAL(v2.size(), 1);
+    BOOST_CHECK_EQUAL(v2.size(), 1U);
     BOOST_CHECK(v2[0].origin == &t2);
     BOOST_CHECK_EQUAL(v2[0].copies, 0);
 
     auto v3 = Vector(t1, std::move(t2));
-    BOOST_CHECK_EQUAL(v3.size(), 2);
+    BOOST_CHECK_EQUAL(v3.size(), 2U);
     BOOST_CHECK(v3[0].origin == &t1);
     BOOST_CHECK(v3[1].origin == &t2);
     BOOST_CHECK_EQUAL(v3[0].copies, 1);
     BOOST_CHECK_EQUAL(v3[1].copies, 0);
 
     auto v4 = Vector(std::move(v3[0]), v3[1], std::move(t3));
-    BOOST_CHECK_EQUAL(v4.size(), 3);
+    BOOST_CHECK_EQUAL(v4.size(), 3U);
     BOOST_CHECK(v4[0].origin == &t1);
     BOOST_CHECK(v4[1].origin == &t2);
     BOOST_CHECK(v4[2].origin == &t3);
@@ -2223,7 +2223,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector)
     BOOST_CHECK_EQUAL(v4[2].copies, 0);
 
     auto v5 = Cat(v1, v4);
-    BOOST_CHECK_EQUAL(v5.size(), 4);
+    BOOST_CHECK_EQUAL(v5.size(), 4U);
     BOOST_CHECK(v5[0].origin == &t1);
     BOOST_CHECK(v5[1].origin == &t1);
     BOOST_CHECK(v5[2].origin == &t2);
@@ -2234,7 +2234,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector)
     BOOST_CHECK_EQUAL(v5[3].copies, 1);
 
     auto v6 = Cat(std::move(v1), v3);
-    BOOST_CHECK_EQUAL(v6.size(), 3);
+    BOOST_CHECK_EQUAL(v6.size(), 3U);
     BOOST_CHECK(v6[0].origin == &t1);
     BOOST_CHECK(v6[1].origin == &t1);
     BOOST_CHECK(v6[2].origin == &t2);
@@ -2243,7 +2243,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector)
     BOOST_CHECK_EQUAL(v6[2].copies, 1);
 
     auto v7 = Cat(v2, std::move(v4));
-    BOOST_CHECK_EQUAL(v7.size(), 4);
+    BOOST_CHECK_EQUAL(v7.size(), 4U);
     BOOST_CHECK(v7[0].origin == &t2);
     BOOST_CHECK(v7[1].origin == &t1);
     BOOST_CHECK(v7[2].origin == &t2);
@@ -2254,7 +2254,7 @@ BOOST_AUTO_TEST_CASE(test_tracked_vector)
     BOOST_CHECK_EQUAL(v7[3].copies, 0);
 
     auto v8 = Cat(std::move(v2), std::move(v3));
-    BOOST_CHECK_EQUAL(v8.size(), 3);
+    BOOST_CHECK_EQUAL(v8.size(), 3U);
     BOOST_CHECK(v8[0].origin == &t2);
     BOOST_CHECK(v8[1].origin == &t1);
     BOOST_CHECK(v8[2].origin == &t2);
@@ -2301,11 +2301,11 @@ BOOST_AUTO_TEST_CASE(test_Capitalize)
 BOOST_AUTO_TEST_CASE(test_CRanges)
 {
     std::mt19937 gen;
-    for (size_t test = 0; test < 17; ++test) {
+    for (int test = 0; test < 17; ++test) {
         std::uniform_int_distribution<uint64_t> dist_value(0, (1 << test));
         CRangesSet ranges;
         std::unordered_set<uint64_t> set_2;
-        for (size_t iter = 0; iter < (1 << test) * 2; ++iter) {
+        for (int iter = 0; iter < (1 << test) * 2; ++iter) {
             uint64_t value = dist_value(gen);
             BOOST_CHECK_EQUAL(ranges.Contains(value), !!set_2.count(value));
             if (!ranges.Contains(value)) {
@@ -2319,7 +2319,7 @@ BOOST_AUTO_TEST_CASE(test_CRanges)
             BOOST_CHECK_EQUAL(ranges.Size(), set_2.size());
         }
         if (test > 4) {
-            BOOST_CHECK(ranges.Size() > ((1 << test) / 4));
+            BOOST_CHECK(ranges.Size() > ((1u << test) / 4));
         }
     }
 }
diff --git a/src/test/util_threadnames_tests.cpp b/src/test/util_threadnames_tests.cpp
index 7b29b3383e66..f3f9fb2bffc2 100644
--- a/src/test/util_threadnames_tests.cpp
+++ b/src/test/util_threadnames_tests.cpp
@@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded)
 
     std::set<std::string> names = RenameEnMasse(100);
 
-    BOOST_CHECK_EQUAL(names.size(), 100);
+    BOOST_CHECK_EQUAL(names.size(), 100U);
 
     // Names "test_thread.[n]" should exist for n = [0, 99]
     for (int i = 0; i < 100; ++i) {
diff --git a/src/test/validation_flush_tests.cpp b/src/test/validation_flush_tests.cpp
index cea4ffe0457d..0b1c35a4be41 100644
--- a/src/test/validation_flush_tests.cpp
+++ b/src/test/validation_flush_tests.cpp
@@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
     // (prevector<28, unsigned char>) when assigned 56 bytes of data per above.
     //
     // See also: Coin::DynamicMemoryUsage().
-    constexpr int COIN_SIZE = is_64_bit ? 80 : 64;
+    constexpr unsigned int COIN_SIZE = is_64_bit ? 80 : 64;
 
     auto print_view_mem_usage = [](CCoinsViewCache& view) {
         BOOST_TEST_MESSAGE("CCoinsViewCache memory usage: " << view.DynamicMemoryUsage());
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
     }
 
     print_view_mem_usage(view);
-    BOOST_CHECK_EQUAL(view.DynamicMemoryUsage(), is_64_bit ? 32 : 16);
+    BOOST_CHECK_EQUAL(view.DynamicMemoryUsage(), is_64_bit ? 32U : 16U);
 
     // We should be able to add COINS_UNTIL_CRITICAL coins to the cache before going CRITICAL.
     // This is contingent not only on the dynamic memory usage of the Coins
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 5a363122e8fc..4c030fb623ac 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -987,7 +987,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
 /**
   * Called when a lenght of chain is increased. Removes from mempool expired asset-unlock transactions
   */
-void CTxMemPool::removeExpiredAssetUnlock(unsigned int nBlockHeight)
+void CTxMemPool::removeExpiredAssetUnlock(int nBlockHeight)
 {
     AssertLockHeld(cs);
     // items to removed should be firstly collected to independed list,
diff --git a/src/txmempool.h b/src/txmempool.h
index cfe66c96822c..a563133b9495 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -621,7 +621,7 @@ class CTxMemPool
     void removeProTxKeyChangedConflicts(const CTransaction &tx, const uint256& proTxHash, const uint256& newKeyHash) EXCLUSIVE_LOCKS_REQUIRED(cs);
     void removeProTxConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
     void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
-    void removeExpiredAssetUnlock(unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
+    void removeExpiredAssetUnlock(int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
 
     void clear();
     void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
diff --git a/src/util/asmap.cpp b/src/util/asmap.cpp
index 5ebbc0614583..ca9d41c09ea5 100644
--- a/src/util/asmap.cpp
+++ b/src/util/asmap.cpp
@@ -93,7 +93,8 @@ uint32_t Interpret(const std::vector<bool> &asmap, const std::vector<bool> &ip)
             jump = DecodeJump(pos, endpos);
             if (jump == INVALID) break; // Jump offset straddles EOF
             if (bits == 0) break; // No input bits left
-            if (jump >= endpos - pos) break; // Jumping past EOF
+            if (pos + jump < pos) break; // overflow
+            if (pos + jump >= endpos) break; // Jumping past EOF
             if (ip[ip.size() - bits]) {
                 pos += jump;
             }
@@ -155,7 +156,8 @@ bool SanityCheckASMap(const std::vector<bool>& asmap, int bits)
         } else if (opcode == Instruction::JUMP) {
             uint32_t jump = DecodeJump(pos, endpos);
             if (jump == INVALID) return false; // Jump offset straddles EOF
-            if (jump > endpos - pos) return false; // Jump out of range
+            if (pos + jump < pos) return false; // overflow
+            if (pos + jump > endpos) return false; // Jump out of range
             if (bits == 0) return false; // Consuming bits past the end of the input
             --bits;
             uint32_t jump_offset = pos - begin + jump;
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index dbe1350c0153..3fe6a8f633d1 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -1265,8 +1265,8 @@ BOOST_FIXTURE_TEST_CASE(CreateWalletFromFile, TestChain100Setup)
     BOOST_CHECK_EQUAL(addtx_count, 2);
     {
         LOCK(wallet->cs_wallet);
-        BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_tx.GetHash()), 1);
-        BOOST_CHECK_EQUAL(wallet->mapWallet.count(mempool_tx.GetHash()), 1);
+        BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_tx.GetHash()), 1U);
+        BOOST_CHECK_EQUAL(wallet->mapWallet.count(mempool_tx.GetHash()), 1U);
     }
 
 
@@ -1303,8 +1303,8 @@ BOOST_FIXTURE_TEST_CASE(CreateWalletFromFile, TestChain100Setup)
     BOOST_CHECK_EQUAL(addtx_count, 4);
     {
         LOCK(wallet->cs_wallet);
-        BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_tx.GetHash()), 1);
-        BOOST_CHECK_EQUAL(wallet->mapWallet.count(mempool_tx.GetHash()), 1);
+        BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_tx.GetHash()), 1U);
+        BOOST_CHECK_EQUAL(wallet->mapWallet.count(mempool_tx.GetHash()), 1U);
     }
 
     TestUnloadWallet(std::move(wallet));
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index ec79a82bd2d0..05090e954ed1 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3569,7 +3569,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
                         nBytes += GetSizeOfCompactSize(nExtraPayloadSize) + nExtraPayloadSize;
                     }
 
-                    if (nBytes > MAX_STANDARD_TX_SIZE) {
+                    if (static_cast<size_t>(nBytes) > MAX_STANDARD_TX_SIZE) {
                         // Do not create oversized transactions (bad-txns-oversize).
                         error = _("Transaction too large");
                         return false;

From 8bb8f59d32213ed0f36a4fd570e7ae50d62659a8 Mon Sep 17 00:00:00 2001
From: "Wladimir J. van der Laan" <laanwj@protonmail.com>
Date: Wed, 13 May 2020 22:20:05 +0200
Subject: [PATCH 04/13] Merge #18887: build: enable -Werror=gnu

a30b0a24e97eae7f6d1428c5bf339a579872f28e build: enable -Werror=gnu (Vasil Dimov)

Pull request description:

  Stop the build if a warning is emitted due to `-Wgnu` and
  `--enable-werror` has been used. As usual - this would help notice such
  a warning that is about to be introduced in new code.

  This is a followup to
  https://github.com/bitcoin/bitcoin/pull/18088 build: ensure we aren't using GNU extensions

ACKs for top commit:
  practicalswift:
    ACK a30b0a24e97eae7f6d1428c5bf339a579872f28e
  Empact:
    ACK https://github.com/bitcoin/bitcoin/pull/18887/commits/a30b0a24e97eae7f6d1428c5bf339a579872f28e

Tree-SHA512: f81b71cf3ee4db88b6f664c571075e0d30800a604f067f44273f256695a1dea533779db2ac859dd0a4cd8b66289c3e45f4aff1cfadfa160a1c354237167b05e2
---
 configure.ac                   |  1 +
 src/llmq/debug.cpp             | 22 +++++++++++-----------
 src/llmq/debug.h               |  4 ++--
 src/llmq/dkgsession.cpp        | 22 +++++++++++-----------
 src/llmq/dkgsessionhandler.cpp |  2 +-
 5 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/configure.ac b/configure.ac
index d3ff134a0255..ad96a2d1e1da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -424,6 +424,7 @@ if test "x$enable_werror" = "xyes"; then
     AC_MSG_ERROR("enable-werror set but -Werror is not usable")
   fi
   AX_CHECK_COMPILE_FLAG([-Werror=reorder],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=reorder"],,[[$CXXFLAG_WERROR]])
+  AX_CHECK_COMPILE_FLAG([-Werror=gnu],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=gnu"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Werror=shadow-field],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=shadow-field"],,[[$CXXFLAG_WERROR]])
   AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]])
diff --git a/src/llmq/debug.cpp b/src/llmq/debug.cpp
index 8f02c3d8d867..6e4e5677c2c6 100644
--- a/src/llmq/debug.cpp
+++ b/src/llmq/debug.cpp
@@ -36,11 +36,11 @@ UniValue CDKGDebugSessionStatus::ToJson(int quorumIndex, int detailLevel) const
     ret.pushKV("quorumHeight", (int)quorumHeight);
     ret.pushKV("phase", ToUnderlying(phase));
 
-    ret.pushKV("sentContributions", sentContributions);
-    ret.pushKV("sentComplaint", sentComplaint);
-    ret.pushKV("sentJustification", sentJustification);
-    ret.pushKV("sentPrematureCommitment", sentPrematureCommitment);
-    ret.pushKV("aborted", aborted);
+    ret.pushKV("sentContributions", statusBits.sentContributions);
+    ret.pushKV("sentComplaint", statusBits.sentComplaint);
+    ret.pushKV("sentJustification", statusBits.sentJustification);
+    ret.pushKV("sentPrematureCommitment", statusBits.sentPrematureCommitment);
+    ret.pushKV("aborted", statusBits.aborted);
 
     struct ArrOrCount {
         int count{0};
@@ -81,12 +81,12 @@ UniValue CDKGDebugSessionStatus::ToJson(int quorumIndex, int detailLevel) const
 
     for (const auto i : irange::range(members.size())) {
         const auto& m = members[i];
-        add(badMembers, i, m.bad);
-        add(weComplain, i, m.weComplain);
-        add(receivedContributions, i, m.receivedContribution);
-        add(receivedComplaints, i, m.receivedComplaint);
-        add(receivedJustifications, i, m.receivedJustification);
-        add(receivedPrematureCommitments, i, m.receivedPrematureCommitment);
+        add(badMembers, i, m.statusBits.bad);
+        add(weComplain, i, m.statusBits.weComplain);
+        add(receivedContributions, i, m.statusBits.receivedContribution);
+        add(receivedComplaints, i, m.statusBits.receivedComplaint);
+        add(receivedJustifications, i, m.statusBits.receivedJustification);
+        add(receivedPrematureCommitments, i, m.statusBits.receivedPrematureCommitment);
     }
     push(badMembers, "badMembers");
     push(weComplain, "weComplain");
diff --git a/src/llmq/debug.h b/src/llmq/debug.h
index 253faf13add3..6788bc7c60c6 100644
--- a/src/llmq/debug.h
+++ b/src/llmq/debug.h
@@ -37,7 +37,7 @@ class CDKGDebugMemberStatus
             bool receivedComplaint : 1;
             bool receivedJustification : 1;
             bool receivedPrematureCommitment : 1;
-        };
+        } statusBits;
         uint8_t statusBitset;
     };
 
@@ -65,7 +65,7 @@ class CDKGDebugSessionStatus
             bool sentPrematureCommitment : 1;
 
             bool aborted : 1;
-        };
+        } statusBits;
         uint8_t statusBitset;
     };
 
diff --git a/src/llmq/dkgsession.cpp b/src/llmq/dkgsession.cpp
index 2a0b888f20be..943c28c6435a 100644
--- a/src/llmq/dkgsession.cpp
+++ b/src/llmq/dkgsession.cpp
@@ -202,7 +202,7 @@ void CDKGSession::SendContributions(CDKGPendingMessages& pendingMessages)
     logger.Flush();
 
     dkgDebugManager.UpdateLocalSessionStatus(params.type, quorumIndex, [&](CDKGDebugSessionStatus& status) {
-        status.sentContributions = true;
+        status.statusBits.sentContributions = true;
         return true;
     });
 
@@ -285,7 +285,7 @@ void CDKGSession::ReceiveMessage(const CDKGContribution& qc, bool& retBan)
     RelayInvToParticipants(inv);
 
     dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, member->idx, [&](CDKGDebugMemberStatus& status) {
-        status.receivedContribution = true;
+        status.statusBits.receivedContribution = true;
         return true;
     });
 
@@ -325,7 +325,7 @@ void CDKGSession::ReceiveMessage(const CDKGContribution& qc, bool& retBan)
     if (complain) {
         member->weComplain = true;
         dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, member->idx, [&](CDKGDebugMemberStatus& status) {
-            status.weComplain = true;
+            status.statusBits.weComplain = true;
             return true;
         });
         return;
@@ -393,7 +393,7 @@ void CDKGSession::VerifyPendingContributions()
             logger.Batch("invalid contribution from %s. will complain later", m->dmn->proTxHash.ToString());
             m->weComplain = true;
             dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, m->idx, [&](CDKGDebugMemberStatus& status) {
-                status.weComplain = true;
+                status.statusBits.weComplain = true;
                 return true;
             });
         } else {
@@ -520,7 +520,7 @@ void CDKGSession::SendComplaint(CDKGPendingMessages& pendingMessages)
     logger.Flush();
 
     dkgDebugManager.UpdateLocalSessionStatus(params.type, quorumIndex, [&](CDKGDebugSessionStatus& status) {
-        status.sentComplaint = true;
+        status.statusBits.sentComplaint = true;
         return true;
     });
 
@@ -593,7 +593,7 @@ void CDKGSession::ReceiveMessage(const CDKGComplaint& qc, bool& retBan)
     RelayInvToParticipants(inv);
 
     dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, member->idx, [&](CDKGDebugMemberStatus& status) {
-        status.receivedComplaint = true;
+        status.statusBits.receivedComplaint = true;
         return true;
     });
 
@@ -714,7 +714,7 @@ void CDKGSession::SendJustification(CDKGPendingMessages& pendingMessages, const
     logger.Flush();
 
     dkgDebugManager.UpdateLocalSessionStatus(params.type, quorumIndex, [&](CDKGDebugSessionStatus& status) {
-        status.sentJustification = true;
+        status.statusBits.sentJustification = true;
         return true;
     });
 
@@ -804,7 +804,7 @@ void CDKGSession::ReceiveMessage(const CDKGJustification& qj, bool& retBan)
     RelayInvToParticipants(inv);
 
     dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, member->idx, [&](CDKGDebugMemberStatus& status) {
-        status.receivedJustification = true;
+        status.statusBits.receivedJustification = true;
         return true;
     });
 
@@ -1026,7 +1026,7 @@ void CDKGSession::SendCommitment(CDKGPendingMessages& pendingMessages)
     logger.Flush();
 
     dkgDebugManager.UpdateLocalSessionStatus(params.type, quorumIndex, [&](CDKGDebugSessionStatus& status) {
-        status.sentPrematureCommitment = true;
+        status.statusBits.sentPrematureCommitment = true;
         return true;
     });
 
@@ -1163,7 +1163,7 @@ void CDKGSession::ReceiveMessage(const CDKGPrematureCommitment& qc, bool& retBan
     RelayInvToParticipants(inv);
 
     dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, member->idx, [&](CDKGDebugMemberStatus& status) {
-        status.receivedPrematureCommitment = true;
+        status.statusBits.receivedPrematureCommitment = true;
         return true;
     });
 
@@ -1298,7 +1298,7 @@ void CDKGSession::MarkBadMember(size_t idx)
         return;
     }
     dkgDebugManager.UpdateLocalMemberStatus(params.type, quorumIndex, idx, [&](CDKGDebugMemberStatus& status) {
-        status.bad = true;
+        status.statusBits.bad = true;
         return true;
     });
     member->bad = true;
diff --git a/src/llmq/dkgsessionhandler.cpp b/src/llmq/dkgsessionhandler.cpp
index 3acc3539e180..4cbe4532b5a3 100644
--- a/src/llmq/dkgsessionhandler.cpp
+++ b/src/llmq/dkgsessionhandler.cpp
@@ -567,7 +567,7 @@ void CDKGSessionHandler::PhaseHandlerThread()
             HandleDKGRound();
         } catch (AbortPhaseException& e) {
             dkgDebugManager.UpdateLocalSessionStatus(params.type, quorumIndex, [&](CDKGDebugSessionStatus& status) {
-                status.aborted = true;
+                status.statusBits.aborted = true;
                 return true;
             });
             LogPrint(BCLog::LLMQ_DKG, "CDKGSessionHandler::%s -- %s qi[%d] - aborted current DKG session\n", __func__, params.name, quorumIndex);

From e02a0d8e5415b7b7dff516f0d8f495133c8cee73 Mon Sep 17 00:00:00 2001
From: MarcoFalke <falke.marco@gmail.com>
Date: Mon, 27 Apr 2020 20:36:37 -0400
Subject: [PATCH 05/13] Merge #18778: ci: Run functional tests on mac again

fac24dea00c54fe1e2dcc7625bb65ada8b97ac0c ci: Run functional tests on mac again (MarcoFalke)

Pull request description:

ACKs for top commit:
  hebasto:
    ACK fac24dea00c54fe1e2dcc7625bb65ada8b97ac0c, verified travis build log.

Tree-SHA512: 406282a7ac03e5c193830b727366c7b1350639f1850aff951bf7ddd4b0c3e3ffb396b950ccb3a64ddc59500fa2739766f3c34806b4d144bc4535bb2bd765b959
---
 ci/test/00_setup_env_mac_host.sh | 2 --
 1 file changed, 2 deletions(-)

diff --git a/ci/test/00_setup_env_mac_host.sh b/ci/test/00_setup_env_mac_host.sh
index 177c87e1ccaa..fad5ae2889da 100755
--- a/ci/test/00_setup_env_mac_host.sh
+++ b/ci/test/00_setup_env_mac_host.sh
@@ -9,8 +9,6 @@ export LC_ALL=C.UTF-8
 export CONTAINER_NAME=ci_macos
 export HOST=x86_64-apple-darwin
 export PIP_PACKAGES="zmq lief"
-export RUN_UNIT_TESTS=true
-export RUN_INTEGRATION_TESTS=false
 export RUN_SECURITY_TESTS="true"
 export GOAL="install"
 export BITCOIN_CONFIG="--enable-gui --enable-reduce-exports --disable-miner --enable-werror"

From 295c99c4cff17f89afc62139157716c5e1874be2 Mon Sep 17 00:00:00 2001
From: MarcoFalke <falke.marco@gmail.com>
Date: Tue, 28 Apr 2020 08:25:13 -0400
Subject: [PATCH 06/13] Merge #18799: ci: Document why tests can not be run on
 mac

fa72a751026d43e1d01ae30e26bcfd9b4cc0cf45 ci: Document why tests can not be run on mac (MarcoFalke)

Pull request description:

  Fixes #18794

Top commit has no ACKs.

Tree-SHA512: 297652eda412aa8cf7255e20a6f294d22773dad8637a3d7b5204f3b638e911ce5b2e40e85f81395a34c1b5a5b497665944c2d6ea17c70c30c0c9e0ab553f956e
---
 ci/test/00_setup_env_mac_host.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ci/test/00_setup_env_mac_host.sh b/ci/test/00_setup_env_mac_host.sh
index fad5ae2889da..47c896f773ad 100755
--- a/ci/test/00_setup_env_mac_host.sh
+++ b/ci/test/00_setup_env_mac_host.sh
@@ -12,6 +12,7 @@ export PIP_PACKAGES="zmq lief"
 export RUN_SECURITY_TESTS="true"
 export GOAL="install"
 export BITCOIN_CONFIG="--enable-gui --enable-reduce-exports --disable-miner --enable-werror"
+export TEST_RUNNER_EXTRA="wallet_disable"  # Only run wallet_disable as a smoke test, see https://github.com/bitcoin/bitcoin/pull/17240#issuecomment-546022121 why the other tests are disabled
 # Run without depends
 export NO_DEPENDS=1
 export OSX_SDK=""

From a5abf4b6b3d1223978ea9b6994f25bfe10373dab Mon Sep 17 00:00:00 2001
From: MarcoFalke <falke.marco@gmail.com>
Date: Tue, 12 May 2020 07:37:18 -0400
Subject: [PATCH 07/13] Merge #18929: ci: Pass down LD_LIBRARY_PATH and
 MAKEJOBS to fuzz test_runner

cbd661122e5852d543467090459d33cf8cb4a3c7 Set LD_LIBRARY_PATH consistently in travis tests (Russell Yanofsky)
fa35c34df781cf46bbd15522961f214f03b958bf Remove unused ci configs that have been moved elsewhere (MarcoFalke)
3333cb96994182bbdbb21174b691feb716858bc2 fuzz: Pass down MAKEJOBS to test_runner (MarcoFalke)

Pull request description:

  Just how `MAKEJOBS` is passed down to the functional test `test_runner`, do the same for the fuzz `test_runner`.

  Also includes a commit to remove unused config files, which have been moved elsewhere.

Top commit has no ACKs.

Tree-SHA512: 32557102c9e40599b432aeb004c8427e8fbb07cdf4048050cdc8241d1b029aaad306b1131007eeca8315a4f71c38a7efbb833310e056cd11b835676cd19b8902
---
 .cirrus.yml                             | 30 -------------------------
 .travis.yml                             |  1 -
 ci/dash/test_integrationtests.sh        |  2 +-
 ci/test/00_setup_env_native_valgrind.sh |  6 +----
 4 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 2dd109af6a1b..1e4b8303b65c 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,33 +1,3 @@
-task:
-  name: "FreeBsd 12.1 amd64  [GOAL: install]  [no depends, only system libs]"
-  freebsd_instance:
-    image_family: freebsd-12-1  # https://cirrus-ci.org/guide/FreeBSD/
-    cpu: 8
-    memory: 8G
-  timeout_in: 60m
-  env:
-    MAKEJOBS: "-j9"
-    CONFIGURE_OPTS: "--disable-dependency-tracking"
-    GOAL: "install"
-    TEST_RUNNER_PORT_MIN: "14000"  # Must be larger than 12321, which is used for the http cache. See https://cirrus-ci.org/guide/writing-tasks/#http-cache
-    CCACHE_SIZE: "200M"
-    CCACHE_COMPRESS: 1
-    CCACHE_DIR: "/tmp/ccache_dir"
-  ccache_cache:
-    folder: "/tmp/ccache_dir"
-  install_script:
-    - pkg install -y autoconf automake boost-libs git gmake libevent libtool pkgconf python3 ccache
-    - ./contrib/install_db4.sh $(pwd)
-    - ccache --max-size=${CCACHE_SIZE}
-  configure_script:
-    - ./autogen.sh
-    - ./configure ${CONFIGURE_OPTS} BDB_LIBS="-L$(pwd)/db4/lib -ldb_cxx-4.8" BDB_CFLAGS="-I$(pwd)/db4/include" || ( cat config.log && false)
-  make_script:
-    - gmake ${MAKEJOBS} ${GOAL} || ( echo "Build failure. Verbose build follows." && gmake ${GOAL} V=1 ; false )
-  check_script:
-    - gmake check ${MAKEJOBS} VERBOSE=1
-  functional_test_script:
-    - ./test/functional/test_runner.py --jobs 9 --ci --extended --exclude feature_dbcrash --combinedlogslen=1000 --quiet --failfast
 task:
   name: "x86_64 Linux  [GOAL: install]  [focal]  [Using ./ci/ system]"
   container:
diff --git a/.travis.yml b/.travis.yml
index 7dc9136fda43..40b1496554ad 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -74,7 +74,6 @@ builddocker: &builddocker
     # no need to run tests again here
     - if [ "$DOCKER_BUILD" = "true" ]; then $DOCKER_RUN_IN_BUILDER ./ci/dash/build_depends.sh && $DOCKER_RUN_IN_BUILDER ./ci/dash/build_src.sh && BUILD_DIR=build-ci/dashcore-$BUILD_TARGET ./ci/dash/build-docker.sh; fi
     - CI_RETRY_EXE="travis_retry"
-    - CI_WAIT="while sleep 500; do echo .; done"
     - CACHE_ERR_MSG="Error! Initial build successful, but not enough time remains to run later build stages and tests. See https://docs.travis-ci.com/user/customizing-the-build#build-timeouts . Please manually re-run this job by using the travis restart button. The next run should not time out because the build cache has been saved."
 before_install:
   - set -o errexit; source ./ci/test/00_setup_env.sh
diff --git a/ci/dash/test_integrationtests.sh b/ci/dash/test_integrationtests.sh
index faf354eeb8cf..707fbd9fde13 100755
--- a/ci/dash/test_integrationtests.sh
+++ b/ci/dash/test_integrationtests.sh
@@ -42,7 +42,7 @@ echo "Using socketevents mode: $SOCKETEVENTS"
 EXTRA_ARGS="--dashd-arg=-socketevents=$SOCKETEVENTS"
 
 set +e
-./test/functional/test_runner.py --ci --attempts=3 --ansi --combinedlogslen=4000 ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir=$(pwd)/testdatadirs $PASS_ARGS $EXTRA_ARGS
+LD_LIBRARY_PATH=$DEPENDS_DIR/$HOST/lib ./test/functional/test_runner.py --ci --attempts=3 --ansi --combinedlogslen=4000 ${TEST_RUNNER_EXTRA} --failfast --nocleanup --tmpdir=$(pwd)/testdatadirs $PASS_ARGS $EXTRA_ARGS
 RESULT=$?
 set -e
 
diff --git a/ci/test/00_setup_env_native_valgrind.sh b/ci/test/00_setup_env_native_valgrind.sh
index 9067e80df9ca..e558eb0fcec9 100644
--- a/ci/test/00_setup_env_native_valgrind.sh
+++ b/ci/test/00_setup_env_native_valgrind.sh
@@ -9,10 +9,6 @@ export LC_ALL=C.UTF-8
 export PACKAGES="valgrind clang llvm python3-zmq libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev"
 export USE_VALGRIND=1
 export NO_DEPENDS=1
-if [[ "${TRAVIS}" == "true" && "${TRAVIS_REPO_SLUG}" != "bitcoin/bitcoin" ]]; then
-  export TEST_RUNNER_EXTRA="wallet_disable"  # Only run wallet_disable as a smoke test to not hit the 50 min travis time limit
-else
-  export TEST_RUNNER_EXTRA="--exclude rpc_bind"  # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
-fi
+export TEST_RUNNER_EXTRA="--exclude rpc_bind"  # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
 export GOAL="install"
 export BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --with-gui=no --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"  # TODO enable GUI

From 4a51a754985ba72169435618ded43763ed310e2d Mon Sep 17 00:00:00 2001
From: fanquake <fanquake@gmail.com>
Date: Tue, 19 May 2020 15:48:39 +0800
Subject: [PATCH 08/13] Merge #19008: ci: tsan on clang-9

faf552117efdd456fb17b1d9490896de3b7d67a4 ci: Set DEBIAN_FRONTEND=noninteractive (MarcoFalke)
fa006caa136f05a18428c792802523637d2234ca ci: tsan on clang-9 (MarcoFalke)

Pull request description:

  Bump the compiler runtime library that includes the sanitizers from clang-8 to clang-9 to get a more recent version. Also, bump the system packages from xenial to bionic to test packages closer to what is commonly used in production.

  The second commit is needed to install the `tzdata` package, which is missing on some operating systems. See https://travis-ci.org/github/MarcoFalke/bitcoin-core/jobs/688455828#L1727

ACKs for top commit:
  hebasto:
    ACK faf552117efdd456fb17b1d9490896de3b7d67a4
  practicalswift:
    ACK faf552117efdd456fb17b1d9490896de3b7d67a4 -- patch looks correct and Travis is happy

Tree-SHA512: aa38fdae5f716966a83a21d5f7c121675cf7d663148ab3baa065142c8b3850bcd4bf88526d7da0fa51f5e08f2c317b537f950fcc9eb1e69fdacb0eac8863e1c6
---
 .travis.yml                          | 6 ++++--
 ci/test/00_setup_env.sh              | 2 ++
 ci/test/00_setup_env_native_tsan.sh  | 2 +-
 ci/test/00_setup_env_native_ubsan.sh | 2 +-
 ci/test/04_install.sh                | 2 +-
 5 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 40b1496554ad..07af403a577a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -228,10 +228,12 @@ after_success:
         FILE_ENV="./ci/test/00_setup_env_native_qt5.sh"
 # x86_64 Linux (xenial, no depends, only system libs, sanitizers: thread (TSan))
     - stage: test
-      name: 'x86_64 Linux  [GOAL: install]  [xenial]  [no depends, only system libs, sanitizers: thread (TSan), no wallet]'
+      name: 'x86_64 Linux  [GOAL: install]  [bionic]  [no depends, only system libs, sanitizers: thread (TSan), no wallet]'
+      # Not enough memory on travis machines, so feature_block is excluded for now
       env: >-
+        TEST_RUNNER_EXTRA="--exclude feature_block"
         FILE_ENV="./ci/test/00_setup_env_native_tsan.sh"
-        TEST_RUNNER_EXTRA="--exclude feature_block"  # Not enough memory on travis machines
+
 # x86_64 Linux (no depends, only system libs, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer)
     - stage: test
       name: 'x86_64 Linux  [GOAL: install]  [focal]  [no depends, only system libs, sanitizers: address/leak (ASan + LSan) + undefined (UBSan) + integer]'
diff --git a/ci/test/00_setup_env.sh b/ci/test/00_setup_env.sh
index fb003981cc4e..78a1d8058047 100755
--- a/ci/test/00_setup_env.sh
+++ b/ci/test/00_setup_env.sh
@@ -47,6 +47,8 @@ export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:focal}
 # Randomize test order.
 # See https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/utf_reference/rt_param_reference/random.html
 export BOOST_TEST_RANDOM=${BOOST_TEST_RANDOM:-1}
+# See man 7 debconf
+export DEBIAN_FRONTEND=noninteractive
 export HOST_CACHE_DIR=${HOST_CACHE_DIR:-$BASE_ROOT_DIR/ci-cache-$BUILD_TARGET}
 export CACHE_DIR=${CACHE_DIR:-$HOST_CACHE_DIR}
 export CCACHE_SIZE=${CCACHE_SIZE:-100M}
diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh
index 60b2eaab6b79..f85ed4aa533d 100755
--- a/ci/test/00_setup_env_native_tsan.sh
+++ b/ci/test/00_setup_env_native_tsan.sh
@@ -7,7 +7,7 @@
 export LC_ALL=C.UTF-8
 
 export CONTAINER_NAME=ci_native_tsan
-export PACKAGES="clang-8 llvm-8 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
+export PACKAGES="clang-15 llvm-15 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
 export DEP_OPTS="NO_UPNP=1 DEBUG=1"
 export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163)
 export GOAL="install"
diff --git a/ci/test/00_setup_env_native_ubsan.sh b/ci/test/00_setup_env_native_ubsan.sh
index f17852642fec..13d5d480d90c 100755
--- a/ci/test/00_setup_env_native_ubsan.sh
+++ b/ci/test/00_setup_env_native_ubsan.sh
@@ -7,7 +7,7 @@
 export LC_ALL=C.UTF-8
 
 export CONTAINER_NAME=ci_native_ubsan
-export PACKAGES="clang-8 llvm-8 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
+export PACKAGES="clang-15 llvm-15 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
 export DEP_OPTS="NO_UPNP=1 DEBUG=1"
 export GOAL="install"
 export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"
diff --git a/ci/test/04_install.sh b/ci/test/04_install.sh
index 61f7c5acdc43..be87b019a5ee 100755
--- a/ci/test/04_install.sh
+++ b/ci/test/04_install.sh
@@ -26,7 +26,7 @@ export ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=
 export LSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/lsan"
 export TSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/tsan"
 export UBSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1"
-env | grep -E '^(BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|TEST_PREVIOUS_RELEASES|PREVIOUS_RELEASES_DIR))' | tee /tmp/env
+env | grep -E '^(BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|TEST_PREVIOUS_RELEASES|PREVIOUS_RELEASES_DIR))' | tee /tmp/env
 if [[ $HOST = *-mingw32 ]]; then
   DOCKER_ADMIN="--cap-add SYS_ADMIN"
 elif [[ $BITCOIN_CONFIG = *--with-sanitizers=*address* ]]; then # If ran with (ASan + LSan), Docker needs access to ptrace (https://github.com/google/sanitizers/issues/764)

From eb2792a882fca7c9f734f5a1d70e15cced28f40f Mon Sep 17 00:00:00 2001
From: Konstantin Akimov <knstqq@gmail.com>
Date: Tue, 12 Dec 2023 03:16:50 +0700
Subject: [PATCH 09/13] chore: TODO to replace ubsan to asan that does same
 plus extra

---
 ci/test/00_setup_env_native_ubsan.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ci/test/00_setup_env_native_ubsan.sh b/ci/test/00_setup_env_native_ubsan.sh
index 13d5d480d90c..e935dc40dbd5 100755
--- a/ci/test/00_setup_env_native_ubsan.sh
+++ b/ci/test/00_setup_env_native_ubsan.sh
@@ -4,6 +4,7 @@
 # Distributed under the MIT software license, see the accompanying
 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
 
+# TODO: use config `asan` instead `ubsan` for `undefined` sanitizer to unify with bitcoin
 export LC_ALL=C.UTF-8
 
 export CONTAINER_NAME=ci_native_ubsan

From 2d95e9284c4032a7c19144afcecd51f1168540c8 Mon Sep 17 00:00:00 2001
From: MarcoFalke <falke.marco@gmail.com>
Date: Fri, 22 May 2020 06:29:09 -0400
Subject: [PATCH 10/13] Merge #19014: test: Replace TEST_PREVIOUS_RELEASES env
 var with test_framework option

fad798be76dd5e330463c837fda768477d536078 test: Default --previous-releases to false if dir is empty (MarcoFalke)
faf1c3cc58d14f86ba5364e6ee5c8ef29cac2e26 test: Replace TEST_PREVIOUS_RELEASES env var with test_framework option (MarcoFalke)

Pull request description:

  The "auto-detection" feature is kept in place, but making it an option allows to properly document it. For example, on my machine I get:

  ```
  $ ./test/functional/wallet_disable.py --help | grep previous-releases
    --previous-releases   Force test of previous releases (default: False)

ACKs for top commit:
  Sjors:
    re-tACK fad798b

Tree-SHA512: a7377d0d5378be0a50be278d76396cc403583617b5fc43467773eee706df698acf3f4e67651491183b9b43a8e1816b052e4c17b90272b7ec4b6ac134ad811400
---
 ci/test/00_setup_env.sh                       |  1 -
 ci/test/00_setup_env_native_qt5.sh            |  3 +--
 ci/test/04_install.sh                         |  2 +-
 .../test_framework/test_framework.py          | 23 ++++++++-----------
 4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/ci/test/00_setup_env.sh b/ci/test/00_setup_env.sh
index 78a1d8058047..eff442719e91 100755
--- a/ci/test/00_setup_env.sh
+++ b/ci/test/00_setup_env.sh
@@ -39,7 +39,6 @@ export USE_BUSY_BOX=${USE_BUSY_BOX:-false}
 export RUN_UNIT_TESTS=${RUN_UNIT_TESTS:-true}
 export RUN_INTEGRATION_TESTS=${RUN_INTEGRATION_TESTS:-true}
 export RUN_SECURITY_TESTS=${RUN_SECURITY_TESTS:-false}
-export TEST_PREVIOUS_RELEASES=${TEST_PREVIOUS_RELEASES:-false}
 export RUN_FUZZ_TESTS=${RUN_FUZZ_TESTS:-false}
 export RUN_SYMBOL_TESTS=${RUN_SYMBOL_TESTS:-true}
 export CONTAINER_NAME=${CONTAINER_NAME:-ci_unnamed}
diff --git a/ci/test/00_setup_env_native_qt5.sh b/ci/test/00_setup_env_native_qt5.sh
index 093835275341..d99dda71899c 100755
--- a/ci/test/00_setup_env_native_qt5.sh
+++ b/ci/test/00_setup_env_native_qt5.sh
@@ -10,10 +10,9 @@ export CONTAINER_NAME=ci_native_qt5
 export PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libdbus-1-dev libharfbuzz-dev"
 export DEP_OPTS="NO_UPNP=1 DEBUG=1"
 # TODO: we have few rpcs that aren't covered by any test, re-enable the line below once it's fixed
-# export TEST_RUNNER_EXTRA="--coverage --extended --exclude feature_pruning,feature_dbcrash"  # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
+# export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_pruning,feature_dbcrash"  # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash
 export RUN_UNIT_TESTS_SEQUENTIAL="true"
 export RUN_UNIT_TESTS="false"
 export GOAL="install"
-export TEST_PREVIOUS_RELEASES=true
 export PREVIOUS_RELEASES_TO_DOWNLOAD="v0.15.0.0 v0.16.1.1 v0.17.0.3 v18.2.2 v19.3.0 v20.0.1"
 export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --disable-fuzz-binary LDFLAGS=-static-libstdc++"
diff --git a/ci/test/04_install.sh b/ci/test/04_install.sh
index be87b019a5ee..8e25a65a510d 100755
--- a/ci/test/04_install.sh
+++ b/ci/test/04_install.sh
@@ -26,7 +26,7 @@ export ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=
 export LSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/lsan"
 export TSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/tsan"
 export UBSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1"
-env | grep -E '^(BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|TEST_PREVIOUS_RELEASES|PREVIOUS_RELEASES_DIR))' | tee /tmp/env
+env | grep -E '^(BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|PREVIOUS_RELEASES_DIR))' | tee /tmp/env
 if [[ $HOST = *-mingw32 ]]; then
   DOCKER_ADMIN="--cap-add SYS_ADMIN"
 elif [[ $BITCOIN_CONFIG = *--with-sanitizers=*address* ]]; then # If ran with (ASan + LSan), Docker needs access to ptrace (https://github.com/google/sanitizers/issues/764)
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 26cd793106c9..a0b26108d8ca 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -179,6 +179,7 @@ def main(self):
             sys.exit(exit_code)
 
     def parse_args(self):
+        previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
         parser = argparse.ArgumentParser(usage="%(prog)s [options]")
         parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true",
                             help="Leave dashds and test.* datadir on exit or error")
@@ -193,6 +194,9 @@ def parse_args(self):
                             help="Print out all RPC calls as they are made")
         parser.add_argument("--portseed", dest="port_seed", default=os.getpid(), type=int,
                             help="The seed to use for assigning port numbers (default: current process id)")
+        parser.add_argument("--previous-releases", dest="prev_releases", action="store_true",
+                            default=os.path.isdir(previous_releases_path) and bool(os.listdir(previous_releases_path)),
+                            help="Force test of previous releases (default: %(default)s)")
         parser.add_argument("--coveragedir", dest="coveragedir",
                             help="Write tested RPC commands into this directory")
         parser.add_argument("--configfile", dest="configfile",
@@ -216,6 +220,7 @@ def parse_args(self):
 
         self.add_options(parser)
         self.options = parser.parse_args()
+        self.options.previous_releases_path = previous_releases_path
 
         config = configparser.ConfigParser()
         config.read_file(open(self.options.configfile))
@@ -243,20 +248,18 @@ def setup(self):
         fname_bitcoind = os.path.join(
             config["environment"]["BUILDDIR"],
             "src",
-            "dashd" + config["environment"]["EXEEXT"]
+            "dashd" + config["environment"]["EXEEXT"],
         )
         fname_bitcoincli = os.path.join(
             config["environment"]["BUILDDIR"],
             "src",
-            "dash-cli" + config["environment"]["EXEEXT"]
+            "dash-cli" + config["environment"]["EXEEXT"],
         )
         self.options.bitcoind = os.getenv("BITCOIND", default=fname_bitcoind)
         self.options.bitcoincli = os.getenv("BITCOINCLI", default=fname_bitcoincli)
 
         self.extra_args_from_options = self.options.dashd_extra_args
 
-        self.options.previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
-
         os.environ['PATH'] = os.pathsep.join([
             os.path.join(config['environment']['BUILDDIR'], 'src'),
             os.path.join(config['environment']['BUILDDIR'], 'src', 'qt'), os.environ['PATH']
@@ -959,17 +962,11 @@ def skip_if_no_previous_releases(self):
 
     def has_previous_releases(self):
         """Checks whether previous releases are present and enabled."""
-        if os.getenv("TEST_PREVIOUS_RELEASES") == "false":
-            # disabled
-            return False
-
         if not os.path.isdir(self.options.previous_releases_path):
-            if os.getenv("TEST_PREVIOUS_RELEASES") == "true":
-                raise AssertionError("TEST_PREVIOUS_RELEASES=true but releases missing: {}".format(
+            if self.options.prev_releases:
+                raise AssertionError("Force test of previous releases but releases missing: {}".format(
                     self.options.previous_releases_path))
-            # missing
-            return False
-        return True
+        return self.options.prev_releases
 
     def is_cli_compiled(self):
         """Checks whether dash-cli was compiled."""

From ae97ed8a6fa6ef3401c476c9bd2c0687bb77a7ce Mon Sep 17 00:00:00 2001
From: "Wladimir J. van der Laan" <laanwj@protonmail.com>
Date: Wed, 1 Jul 2020 15:06:29 +0200
Subject: [PATCH 11/13] Merge #19368: test: improve functional tests
 compatibility with BSD/macOS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

3a7e79478ab41af7c53ce14d9fca9815bffe1f73 test: retry when write to a socket fails on macOS (Ivan Metlushko)
8cf9d15b823d91d2a74fc83832fccca2219342c9 test: use pgrep for better compatibility (Ivan Metlushko)

Pull request description:

  Rationale: a few minor changes to make experience of running tests on macOS a bit better
  1.`pidof` is not available on BSD/macOS, while `pgrep` is present on BSD, Linux and macOS
  2. Add retry as a workaround for a weird behavior when writing to a socket (https://bugs.python.org/issue33450). Stacktrace attached

  Man pages:
  https://www.freebsd.org/cgi/man.cgi?query=pgrep&apropos=0&sektion=1&manpath=FreeBSD+6.0-RELEASE&arch=default&format=html
  https://man7.org/linux/man-pages/man1/pgrep.1.html

  Related to #19281

  Stacktrace example:
  ```
  ...
  33/161 - feature_abortnode.py failed, Duration: 63 s

  stdout:
  2020-06-11T10:46:43.947000Z TestFramework (INFO): Initializing test directory /var/folders/2q/d5w9zh614r7g5c8r74ln3g400000gq/T/test_runner_₿_🏃_20200611_174102/feature_abortnode_128
  2020-06-11T10:46:45.199000Z TestFramework (INFO): Waiting for crash
  2020-06-11T10:47:15.921000Z TestFramework (INFO): Node crashed - now verifying restart fails
  2020-06-11T10:47:47.068000Z TestFramework (INFO): Stopping nodes
  [node 1] Cleaning up leftover process

  stderr:
  Traceback (most recent call last):
    File "/Users/xxx/Projects/bitcoin/test/functional/feature_abortnode.py", line 50, in <module>
      AbortNodeTest().main()
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/test_framework.py", line 142, in main
      exit_code = self.shutdown()
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/test_framework.py", line 266, in shutdown
      self.stop_nodes()
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/test_framework.py", line 515, in stop_nodes
      node.stop_node(wait=wait)
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/test_node.py", line 318, in stop_node
      self.stop(wait=wait)
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/coverage.py", line 47, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/authproxy.py", line 142, in __call__
      response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
    File "/Users/xxx/Projects/bitcoin/test/functional/test_framework/authproxy.py", line 107, in _request
      self.__conn.request(method, path, postdata, headers)
    File "/Users/xxx/.pyenv/versions/3.5.6/lib/python3.5/http/client.py", line 1107, in request
      self._send_request(method, url, body, headers)
    File "/Users/xxx/.pyenv/versions/3.5.6/lib/python3.5/http/client.py", line 1152, in _send_request
      self.endheaders(body)
    File "/Users/xxx/.pyenv/versions/3.5.6/lib/python3.5/http/client.py", line 1103, in endheaders
      self._send_output(message_body)
    File "/Users/xxx/.pyenv/versions/3.5.6/lib/python3.5/http/client.py", line 936, in _send_output
      self.send(message_body)
    File "/Users/xxx/.pyenv/versions/3.5.6/lib/python3.5/http/client.py", line 908, in send
      self.sock.sendall(data)
  OSError: [Errno 41] Protocol wrong type for socket
  ```

ACKs for top commit:
  laanwj:
    ACK 3a7e79478ab41af7c53ce14d9fca9815bffe1f73

Tree-SHA512: fefbe40ce94ab29f18bbbed2a434194b1384ffa5279b1d04db7a3708e3dd422bd9e450f1db3f95a1a851fac5a626ab533c6ebcfd7ede96f8ccae9e6f3e9fff92
---
 test/functional/test_framework/authproxy.py | 2 ++
 test/functional/test_runner.py              | 8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py
index 40df17e4e718..600fddb5640e 100644
--- a/test/functional/test_framework/authproxy.py
+++ b/test/functional/test_framework/authproxy.py
@@ -115,6 +115,8 @@ def _request(self, method, path, postdata):
         except OSError as e:
             retry = (
                 '[WinError 10053] An established connection was aborted by the software in your host machine' in str(e))
+            # Workaround for a bug on macOS. See https://bugs.python.org/issue33450
+            retry = retry or ('[Errno 41] Protocol wrong type for socket' in str(e))
             if retry:
                 self.__conn.close()
                 self.__conn.request(method, path, postdata, headers)
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 9165e008bae4..73623c9d5051 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -435,12 +435,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, attempts=1, enab
     args = args or []
 
     # Warn if dashd is already running
-    # pidof might fail or return an empty string if bitcoind is not running
     try:
-        pidof_output = subprocess.check_output(["pidof", "dashd"])
-        if not (pidof_output is None or pidof_output == b''):
+        # pgrep exits with code zero when one or more matching processes found
+        if subprocess.run(["pgrep", "-x", "dashd"], stdout=subprocess.DEVNULL).returncode == 0:
             print("%sWARNING!%s There is already a dashd process running on this system. Tests may fail unexpectedly due to resource contention!" % (BOLD[1], BOLD[0]))
-    except (OSError, subprocess.SubprocessError):
+    except OSError:
+        # pgrep not supported
         pass
 
     # Warn if there is a cache directory

From 3d980d4a6483387cf702e2a56d459228bca4baa5 Mon Sep 17 00:00:00 2001
From: MarcoFalke <falke.marco@gmail.com>
Date: Wed, 1 Jul 2020 20:35:07 -0400
Subject: [PATCH 12/13] Merge #19427: ci: Run all tests on native mac again

fa23fbb42fa710e6be405596e2abfc3a289d020d ci: Run all tests on native mac again (MarcoFalke)

Pull request description:

  They should pass again after f6072e601af68f3eee307478ad22ff3960680656

ACKs for top commit:
  practicalswift:
    ACK fa23fbb42fa710e6be405596e2abfc3a289d020d -- Travis is happy and so am I

Tree-SHA512: 49c16b6056d4e67d12a202744e1c56fee2788830213fe4a195955ad44c6b8ecce768a591463ffa0048821959a75b6fad4178629a8866c4a26799c4c8c13e933d
---
 ci/test/00_setup_env_mac_host.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ci/test/00_setup_env_mac_host.sh b/ci/test/00_setup_env_mac_host.sh
index 47c896f773ad..fad5ae2889da 100755
--- a/ci/test/00_setup_env_mac_host.sh
+++ b/ci/test/00_setup_env_mac_host.sh
@@ -12,7 +12,6 @@ export PIP_PACKAGES="zmq lief"
 export RUN_SECURITY_TESTS="true"
 export GOAL="install"
 export BITCOIN_CONFIG="--enable-gui --enable-reduce-exports --disable-miner --enable-werror"
-export TEST_RUNNER_EXTRA="wallet_disable"  # Only run wallet_disable as a smoke test, see https://github.com/bitcoin/bitcoin/pull/17240#issuecomment-546022121 why the other tests are disabled
 # Run without depends
 export NO_DEPENDS=1
 export OSX_SDK=""

From 4a753efa223a7e5517d23784ffd319ee6786861f Mon Sep 17 00:00:00 2001
From: Konstantin Akimov <knstqq@gmail.com>
Date: Tue, 12 Dec 2023 03:24:17 +0700
Subject: [PATCH 13/13] partial Merge #20182: ci: Build with --enable-werror by
 default, and document exceptions

It does not includes changes that actually enable werror by default.
But this backport is necessary to prevent compilation error on mac such as this one:

    In file included from mapport.cpp:26:
    In file included from /builds/dashpay/dash/depends/x86_64-apple-darwin/include/miniupnpc/miniupnpc.h:14:
    /builds/dashpay/dash/depends/x86_64-apple-darwin/include/miniupnpc/upnpdev.h:27:14: error: zero size arrays are an extension [-Werror,-Wzero-length-array]
            char buffer[0];
---
 ci/dash/build_src.sh                 | 2 +-
 ci/test/00_setup_env_native_cxx20.sh | 2 +-
 ci/test/00_setup_env_native_tsan.sh  | 2 +-
 ci/test/00_setup_env_native_ubsan.sh | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ci/dash/build_src.sh b/ci/dash/build_src.sh
index 8fd4e0da12e2..5b4ad1f039f6 100755
--- a/ci/dash/build_src.sh
+++ b/ci/dash/build_src.sh
@@ -37,7 +37,7 @@ if [ -n "$CONFIG_SHELL" ]; then
   export CONFIG_SHELL="$CONFIG_SHELL"
 fi
 
-BITCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$DEPENDS_DIR/$HOST --bindir=$BASE_OUTDIR/bin --libdir=$BASE_OUTDIR/lib"
+BITCOIN_CONFIG_ALL="--enable-suppress-external-warnings --disable-dependency-tracking --prefix=$DEPENDS_DIR/$HOST --bindir=$BASE_OUTDIR/bin --libdir=$BASE_OUTDIR/lib"
 
 ( test -n "$CONFIG_SHELL" && eval '"$CONFIG_SHELL" -c "./autogen.sh"' ) || ./autogen.sh
 
diff --git a/ci/test/00_setup_env_native_cxx20.sh b/ci/test/00_setup_env_native_cxx20.sh
index 6de18f16ee7b..6d7405b2f2e3 100755
--- a/ci/test/00_setup_env_native_cxx20.sh
+++ b/ci/test/00_setup_env_native_cxx20.sh
@@ -13,5 +13,5 @@ export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
 export PYZMQ=true
 export RUN_INTEGRATION_TESTS=false
 export GOAL="install"
-export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --enable-c++20 --enable-suppress-external-warnings --enable-werror"
+export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --enable-c++20 --enable-werror"
 
diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh
index f85ed4aa533d..9cdd91d46d0f 100755
--- a/ci/test/00_setup_env_native_tsan.sh
+++ b/ci/test/00_setup_env_native_tsan.sh
@@ -11,7 +11,7 @@ export PACKAGES="clang-15 llvm-15 python3-zmq qtbase5-dev qttools5-dev-tools lib
 export DEP_OPTS="NO_UPNP=1 DEBUG=1"
 export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163)
 export GOAL="install"
-export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --enable-suppress-external-warnings --with-sanitizers=thread"
+export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=thread"
 export BITCOIN_CONFIG="${BITCOIN_CONFIG} CC=clang-15 CXX=clang++-15 CXXFLAGS=-Werror=thread-safety"
 export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
 export PYZMQ=true
diff --git a/ci/test/00_setup_env_native_ubsan.sh b/ci/test/00_setup_env_native_ubsan.sh
index e935dc40dbd5..da979706a5ec 100755
--- a/ci/test/00_setup_env_native_ubsan.sh
+++ b/ci/test/00_setup_env_native_ubsan.sh
@@ -11,6 +11,6 @@ export CONTAINER_NAME=ci_native_ubsan
 export PACKAGES="clang-15 llvm-15 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
 export DEP_OPTS="NO_UPNP=1 DEBUG=1"
 export GOAL="install"
-export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined --enable-suppress-external-warnings CC=clang-15 CXX=clang++-15"
+export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined CC=clang-15 CXX=clang++-15"
 export PYZMQ=true
 export RUN_SYMBOL_TESTS=false
