Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Feb 27, 2024
2 parents 933de20 + 6a7ed5e commit 9588fb9
Show file tree
Hide file tree
Showing 92 changed files with 577 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ persistent_worker_template: &PERSISTENT_WORKER_TEMPLATE
base_template: &BASE_TEMPLATE
merge_base_script:
# Unconditionally install git (used in fingerprint_script).
- bash -c "$PACKAGE_MANAGER_INSTALL git"
- git --version || bash -c "$PACKAGE_MANAGER_INSTALL git"
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
- git fetch --depth=1 $CIRRUS_REPO_CLONE_URL "pull/${CIRRUS_PR}/merge"
- git checkout FETCH_HEAD # Use merged changes to detect silent merge conflicts
Expand Down
4 changes: 2 additions & 2 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ testing compared to other parts of the codebase. If you want to keep the work tr
system in a virtual machine with a Linux operating system of your choice.

To allow for a wide range of tested environments, but also ensure reproducibility to some extent, the test stage
requires `bash`, `docker`, and `python3` to be installed. To install all requirements on Ubuntu, run
requires `bash`, `docker`, and `python3` to be installed. To run on different architectures than the host `qemu` is also required. To install all requirements on Ubuntu, run

```
sudo apt install bash docker.io python3
sudo apt install bash docker.io python3 qemu-user-static
```

It is recommended to run the ci system in a clean env. To run the test stage
Expand Down
3 changes: 2 additions & 1 deletion ci/lint/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ export PATH=$PWD/ci/retry:$PATH

${CI_RETRY_EXE} apt-get update
# Lint dependencies:
# - automake pkg-config libtool (for lint_includes_build_config)
# - curl/xz-utils (to install shellcheck)
# - git (used in many lint scripts)
# - gpg (used by verify-commits)
${CI_RETRY_EXE} apt-get install -y curl xz-utils git gpg
${CI_RETRY_EXE} apt-get install -y automake pkg-config libtool curl xz-utils git gpg

PYTHON_PATH="/python_build"
if [ ! -d "${PYTHON_PATH}/bin" ]; then
Expand Down
8 changes: 5 additions & 3 deletions ci/test/02_run_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ set -ex
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# Export all env vars to avoid missing some.
# Though, exclude those with newlines to avoid parsing problems.
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee /tmp/env
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
# System-dependent env vars must be kept as is. So read them from the container.
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append /tmp/env
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
DOCKER_BUILDKIT=1 docker build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
Expand Down Expand Up @@ -44,6 +44,8 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# When detecting podman-docker, `--external` should be added.
docker image prune --force --filter "label=$CI_IMAGE_LABEL"

# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
# to allow support starting multiple runs simultaneously by the same user.
# shellcheck disable=SC2086
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
--mount "type=bind,src=$BASE_READ_ONLY_DIR,dst=$BASE_READ_ONLY_DIR,readonly" \
Expand All @@ -52,7 +54,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
--mount "type=volume,src=${CONTAINER_NAME}_depends_sources,dst=$DEPENDS_DIR/sources" \
--mount "type=volume,src=${CONTAINER_NAME}_depends_SDKs_android,dst=$DEPENDS_DIR/SDKs/android" \
--mount "type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR" \
--env-file /tmp/env \
--env-file /tmp/env-$USER-$CONTAINER_NAME \
--name "$CONTAINER_NAME" \
"$CONTAINER_NAME")
export CI_CONTAINER_ID
Expand Down
8 changes: 4 additions & 4 deletions ci/test/03_test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export HOST=${HOST:-$("$BASE_ROOT_DIR/depends/config.guess")}
# CI, so as a temporary minimal fix to work around UB and CI failures, leave
# bytes_written unmodified.
# See https://github.com/bitcoin/bitcoin/pull/28359#issuecomment-1698694748
echo 'diff --git a/src/leveldb/db/db_impl.cc b/src/leveldb/db/db_impl.cc
index 65e31724bc..f61b471953 100644
# Tee patch to stdout to make it clear CI is testing modified code.
tee >(patch -p1) <<'EOF'
--- a/src/leveldb/db/db_impl.cc
+++ b/src/leveldb/db/db_impl.cc
@@ -1028,9 +1028,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
Expand All @@ -49,8 +49,8 @@ index 65e31724bc..f61b471953 100644
- }
mutex_.Lock();
stats_[compact->compaction->level() + 1].Add(stats);' | patch -p1
git diff
stats_[compact->compaction->level() + 1].Add(stats);
EOF
)

mkdir -p "${BASE_SCRATCH_DIR}/sanitizer-output/"
Expand Down
4 changes: 2 additions & 2 deletions contrib/devtools/test_utxo_snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ echo "-- Initial state of the client:"
client_rpc getchainstates

echo
echo "-- Loading UTXO snapshot into client..."
client_rpc loadtxoutset "$UTXO_DAT_FILE"
echo "-- Loading UTXO snapshot into client. Calling RPC in a loop..."
while ! client_rpc loadtxoutset "$UTXO_DAT_FILE" ; do sleep 10; done

watch -n 0.3 "( tail -n 14 $CLIENT_DATADIR/debug.log ; echo ; ./src/groestlcoin-cli -rpcport=$CLIENT_RPC_PORT -datadir=$CLIENT_DATADIR getchainstates) | cat"

Expand Down
1 change: 0 additions & 1 deletion depends/packages/bdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ $(package)_config_opts_android=--with-pic
$(package)_cflags+=-Wno-error=implicit-function-declaration -Wno-error=format-security -Wno-error=implicit-int
$(package)_cppflags_freebsd=-D_XOPEN_SOURCE=600 -D__BSD_VISIBLE=1
$(package)_cppflags_netbsd=-D_XOPEN_SOURCE=600
$(package)_cppflags_openbsd=-D_XOPEN_SOURCE=600
$(package)_cppflags_mingw32=-DUNICODE -D_UNICODE
endef

Expand Down
4 changes: 3 additions & 1 deletion doc/build-openbsd.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenBSD Build Guide

**Updated for OpenBSD [7.3](https://www.openbsd.org/73.html)**
**Updated for OpenBSD [7.4](https://www.openbsd.org/74.html)**

This guide describes how to build groestlcoind, command-line utilities, and GUI on OpenBSD.

Expand Down Expand Up @@ -43,6 +43,8 @@ BerkeleyDB is only required to support legacy wallets.
It is recommended to use Berkeley DB 5.3. You cannot use the BerkeleyDB library
from ports. However you can build it yourself, [using depends](/depends).

Refer to [depends/README.md](/depends/README.md) for detailed instructions.

```bash
gmake -C depends NO_BOOST=1 NO_LIBEVENT=1 NO_QT=1 NO_SQLITE=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1
...
Expand Down
6 changes: 4 additions & 2 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ code.
between integer types, use functional casts such as `int(x)` or `int{x}`
instead of `(int) x`. When casting between more complex types, use `static_cast`.
Use `reinterpret_cast` and `const_cast` as appropriate.
- Prefer [`list initialization ({})`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-list) where possible.
For example `int x{0};` instead of `int x = 0;` or `int x(0);`

For function calls a namespace should be specified explicitly, unless such functions have been declared within it.
Otherwise, [argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl), also known as ADL, could be
Expand All @@ -138,7 +140,7 @@ int main()
Block style example:
```c++
int g_count = 0;
int g_count{0};
namespace foo {
class Class
Expand All @@ -150,7 +152,7 @@ public:
{
// Comment summarising what this section of code does
for (int i = 0; i < n; ++i) {
int total_sum = 0;
int total_sum{0};
// When something fails, return early
if (!Something()) return false;
...
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.bench.include
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ bench_bench_bitcoin_SOURCES += bench/wallet_balance.cpp
bench_bench_bitcoin_SOURCES += bench/wallet_create.cpp
bench_bench_bitcoin_SOURCES += bench/wallet_loading.cpp
bench_bench_bitcoin_SOURCES += bench/wallet_create_tx.cpp
bench_bench_bitcoin_SOURCES += bench/wallet_ismine.cpp

bench_bench_bitcoin_LDADD += $(BDB_LIBS) $(SQLITE_LIBS)
endif

Expand Down
4 changes: 4 additions & 0 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <addrdb.h>

#include <addrman.h>
Expand Down
4 changes: 4 additions & 0 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <addrman.h>
#include <addrman_impl.h>

Expand Down
4 changes: 4 additions & 0 deletions src/bench/verify_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <bench/bench.h>
#include <key.h>
#if defined(HAVE_CONSENSUS_LIB)
Expand Down
4 changes: 4 additions & 0 deletions src/bench/wallet_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <bench/bench.h>
#include <node/context.h>
#include <random.h>
Expand Down
77 changes: 77 additions & 0 deletions src/bench/wallet_ismine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) 2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif // HAVE_CONFIG_H
#include <bench/bench.h>
#include <interfaces/chain.h>
#include <key.h>
#include <key_io.h>
#include <node/context.h>
#include <test/util/setup_common.h>
#include <util/translation.h>
#include <validationinterface.h>
#include <wallet/context.h>
#include <wallet/test/util.h>
#include <wallet/wallet.h>
#include <wallet/walletutil.h>

namespace wallet {
static void WalletIsMine(benchmark::Bench& bench, bool legacy_wallet, int num_combo = 0)
{
const auto test_setup = MakeNoLogFileContext<TestingSetup>();

WalletContext context;
context.args = &test_setup->m_args;
context.chain = test_setup->m_node.chain.get();

// Setup the wallet
// Loading the wallet will also create it
uint64_t create_flags = 0;
if (!legacy_wallet) {
create_flags = WALLET_FLAG_DESCRIPTORS;
}
auto database = CreateMockableWalletDatabase();
auto wallet = TestLoadWallet(std::move(database), context, create_flags);

// For a descriptor wallet, fill with num_combo combo descriptors with random keys
// This benchmarks a non-HD wallet migrated to descriptors
if (!legacy_wallet && num_combo > 0) {
LOCK(wallet->cs_wallet);
for (int i = 0; i < num_combo; ++i) {
CKey key;
key.MakeNewKey(/*fCompressed=*/true);
FlatSigningProvider keys;
std::string error;
std::unique_ptr<Descriptor> desc = Parse("combo(" + EncodeSecret(key) + ")", keys, error, /*require_checksum=*/false);
WalletDescriptor w_desc(std::move(desc), /*creation_time=*/0, /*range_start=*/0, /*range_end=*/0, /*next_index=*/0);
auto spkm = wallet->AddWalletDescriptor(w_desc, keys, /*label=*/"", /*internal=*/false);
assert(spkm);
}
}

const CScript script = GetScriptForDestination(DecodeDestination(ADDRESS_BCRT1_UNSPENDABLE));

bench.run([&] {
LOCK(wallet->cs_wallet);
isminetype mine = wallet->IsMine(script);
assert(mine == ISMINE_NO);
});

TestUnloadWallet(std::move(wallet));
}

#ifdef USE_BDB
static void WalletIsMineLegacy(benchmark::Bench& bench) { WalletIsMine(bench, /*legacy_wallet=*/true); }
BENCHMARK(WalletIsMineLegacy, benchmark::PriorityLevel::LOW);
#endif

#ifdef USE_SQLITE
static void WalletIsMineDescriptors(benchmark::Bench& bench) { WalletIsMine(bench, /*legacy_wallet=*/false); }
static void WalletIsMineMigratedDescriptors(benchmark::Bench& bench) { WalletIsMine(bench, /*legacy_wallet=*/false, /*num_combo=*/2000); }
BENCHMARK(WalletIsMineDescriptors, benchmark::PriorityLevel::LOW);
BENCHMARK(WalletIsMineMigratedDescriptors, benchmark::PriorityLevel::LOW);
#endif
} // namespace wallet
4 changes: 4 additions & 0 deletions src/bench/wallet_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <bench/bench.h>
#include <interfaces/chain.h>
#include <node/context.h>
Expand Down
4 changes: 4 additions & 0 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <clientversion.h>
#include <util/translation.h>

Expand Down
4 changes: 4 additions & 0 deletions src/common/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <common/system.h>

#include <logging.h>
Expand Down
4 changes: 0 additions & 4 deletions src/compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#ifndef BITCOIN_COMPAT_COMPAT_H
#define BITCOIN_COMPAT_COMPAT_H

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

// Windows defines FD_SETSIZE to 64 (see _fd_types.h in mingw-w64),
// which is too small for our usage, but allows us to redefine it safely.
// We redefine it to be 1024, to match glibc, see typesizes.h.
Expand Down
4 changes: 4 additions & 0 deletions src/crypto/chacha20poly1305.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <crypto/chacha20poly1305.h>

#include <crypto/common.h>
Expand Down
4 changes: 0 additions & 4 deletions src/crypto/muhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#ifndef BITCOIN_CRYPTO_MUHASH_H
#define BITCOIN_CRYPTO_MUHASH_H

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <serialize.h>
#include <uint256.h>

Expand Down
4 changes: 4 additions & 0 deletions src/crypto/sha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <crypto/sha256.h>
#include <crypto/common.h>

Expand Down
4 changes: 0 additions & 4 deletions src/netaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#ifndef BITCOIN_NETADDRESS_H
#define BITCOIN_NETADDRESS_H

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <compat/compat.h>
#include <crypto/siphash.h>
#include <prevector.h>
Expand Down
4 changes: 0 additions & 4 deletions src/netbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#ifndef BITCOIN_NETBASE_H
#define BITCOIN_NETBASE_H

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <compat/compat.h>
#include <netaddress.h>
#include <serialize.h>
Expand Down
4 changes: 0 additions & 4 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <qt/addressbookpage.h>
#include <qt/forms/ui_addressbookpage.h>

Expand Down
Loading

0 comments on commit 9588fb9

Please sign in to comment.