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 Aug 31, 2024
2 parents 3109136 + e96f657 commit 2db3505
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ jobs:
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
- run: |
sudo apt-get update
sudo apt-get install clang ccache build-essential cmake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
sudo apt-get install clang ccache build-essential cmake pkg-config python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
- name: Compile and run tests
run: |
# Run tests on commits after the last merge commit and before the PR head commit
# Use clang++, because it is a bit faster and uses less memory than g++
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_USDT=ON && cmake --build build -j $(nproc) && ctest --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_USDT=ON && cmake --build build -j $(nproc) && ctest --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
macos-native-x86_64:
name: 'macOS 13 native, x86_64, no depends, sqlite only, gui'
Expand Down
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Ubuntu 22.04 LTS Jammy Jellyfish, https://wiki.ubuntu.com/Releases, EOSS in June 2027:
# - CMake 3.22.1, https://packages.ubuntu.com/jammy/cmake
#
# Centos Stream 9, EOL in May 2027:
# Centos Stream 9, https://www.centos.org/cl-vs-cs/#end-of-life, EOL in May 2027:
# - CMake 3.26.5, https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/
cmake_minimum_required(VERSION 3.22)
if(POLICY CMP0141)
Expand Down Expand Up @@ -148,11 +148,6 @@ if(WITH_ZMQ)
# TODO: Switch to find_package(ZeroMQ) at some point in the future.
find_package(PkgConfig REQUIRED)
pkg_check_modules(libzmq REQUIRED IMPORTED_TARGET libzmq>=4)
# TODO: This command will be redundant once
# https://github.com/bitcoin/bitcoin/pull/30508 is merged.
target_link_libraries(PkgConfig::libzmq INTERFACE
$<$<PLATFORM_ID:Windows>:iphlpapi;ws2_32>
)
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ the pull request affects. Valid areas as:
- `test`, `qa` or `ci` for changes to the unit tests, QA tests or CI code
- `util` or `lib` for changes to the utils or libraries
- `wallet` for changes to the wallet code
- `build` for changes to the GNU Autotools or MSVC builds
- `build` for changes to CMake
- `guix` for changes to the GUIX reproducible builds

Examples:
Expand Down
3 changes: 1 addition & 2 deletions ci/lint/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ pushd "/"

${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 automake pkg-config libtool curl xz-utils git gpg
${CI_RETRY_EXE} apt-get install -y curl xz-utils git gpg

PYTHON_PATH="/python_build"
if [ ! -d "${PYTHON_PATH}/bin" ]; then
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
# The folder for previous release binaries.
# This folder exists only on the ci guest, and on the ci host as a volume.
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake}
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential libtool autotools-dev automake pkg-config curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake}
export GOAL=${GOAL:-install}
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_mac_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export HOST=x86_64-apple-darwin
# Therefore, `--break-system-packages` is needed.
export PIP_PACKAGES="--break-system-packages zmq"
export GOAL="install"
export GROESTLCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_MINIUPNPC=ON -DWITH_NATPMP=ON -DREDUCE_EXPORTS=ON"
export GROESTLCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DWITH_MINIUPNPC=ON -DWITH_NATPMP=ON -DREDUCE_EXPORTS=ON"
export CI_OS_NAME="macos"
export NO_DEPENDS=1
export OSX_SDK=""
Expand Down
5 changes: 3 additions & 2 deletions ci/test/00_setup_env_native_asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ export PACKAGES="systemtap-sdt-dev clang-18 llvm-18 libclang-rt-18-dev python3-z
export NO_DEPENDS=1
export GOAL="install"
export GROESTLCOIN_CONFIG="\
-DWITH_USDT=ON -DWITH_ZMQ=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=ON \
-DWITH_USDT=ON -DWITH_ZMQ=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=ON \
-DSANITIZERS=address,float-divide-by-zero,integer,undefined \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern -Wno-error=deprecated-declarations' \
-DAPPEND_CXXFLAGS='-std=c++23' \
-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' \
"
export CCACHE_MAXSIZE=300M
3 changes: 2 additions & 1 deletion ci/test/00_setup_env_native_tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export RUN_FUZZ_TESTS=false
export RUN_TIDY=true
export GOAL="install"
export GROESTLCOIN_CONFIG="\
-DWARN_INCOMPATIBLE_BDB=OFF -DENABLE_HARDENING=OFF \
-DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_USDT=ON -DWITH_BDB=ON -DWARN_INCOMPATIBLE_BDB=OFF \
-DENABLE_HARDENING=OFF \
-DCMAKE_C_COMPILER=clang-${TIDY_LLVM_V} \
-DCMAKE_CXX_COMPILER=clang++-${TIDY_LLVM_V} \
-DCMAKE_C_FLAGS_RELWITHDEBINFO='-O0 -g0' \
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export NO_DEPENDS=1
export GOAL="install"
# TODO enable GUI
export GROESTLCOIN_CONFIG="\
-DWITH_ZMQ=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=OFF \
-DWITH_ZMQ=ON -DWITH_BDB=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=OFF \
-DCMAKE_C_COMPILER=clang-16 \
-DCMAKE_CXX_COMPILER=clang++-16 \
"
2 changes: 1 addition & 1 deletion contrib/guix/libexec/prelude.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fi
time-machine() {
# shellcheck disable=SC2086
guix time-machine --url=https://git.savannah.gnu.org/git/guix.git \
--commit=7bf1d7aeaffba15c4f680f93ae88fbef25427252 \
--commit=53396a22afc04536ddf75d8f82ad2eafa5082725 \
--cores="$JOBS" \
--keep-failed \
--fallback \
Expand Down
17 changes: 1 addition & 16 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(use-modules (gnu packages)
(gnu packages autotools)
((gnu packages bash) #:select (bash-minimal))
(gnu packages bison)
((gnu packages certs) #:select (nss-certs))
Expand All @@ -22,7 +21,6 @@
((gnu packages tls) #:select (openssl))
((gnu packages version-control) #:select (git-minimal))
(guix build-system cmake)
(guix build-system gnu)
(guix build-system python)
(guix build-system trivial)
(guix download)
Expand Down Expand Up @@ -92,17 +90,7 @@ chain for " target " development."))
(home-page (package-home-page xgcc))
(license (package-license xgcc)))))

(define base-gcc
(package
(inherit gcc-12) ;; 12.3.0
(version "12.4.0")
(source (origin
(method url-fetch)
(uri (string-append "mirror://gnu/gcc/gcc-"
version "/gcc-" version ".tar.xz"))
(sha256
(base32
"0xcida8l2wykvvzvpcrcn649gj0ijn64gwxbplacpg6c0hk6akvh"))))))
(define base-gcc gcc-12) ;; 12.4.0

(define base-linux-kernel-headers linux-libre-headers-6.1)

Expand Down Expand Up @@ -522,9 +510,6 @@ inspecting signatures in Mach-O binaries.")
gcc-toolchain-12
cmake-minimal
gnu-make
libtool
autoconf-2.71
automake
pkg-config
;; Scripting
python-minimal ;; (3.10)
Expand Down
4 changes: 2 additions & 2 deletions doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For the default build type `RelWithDebInfo`, the default compile flags are

Finally, clang (often less resource hungry) can be used instead of gcc, which is used by default:

cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CC_COMPILER=clang
cmake -B build -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang

## Linux Distribution Specific Instructions

Expand All @@ -44,7 +44,7 @@ Finally, clang (often less resource hungry) can be used instead of gcc, which is

Build requirements:

sudo apt-get install build-essential cmake pkg-config bsdmainutils python3
sudo apt-get install build-essential cmake pkg-config python3

Now, you can either build from self-compiled [depends](#dependencies) or install the required dependencies:

Expand Down
3 changes: 1 addition & 2 deletions doc/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ You can find installation instructions in the `build-*.md` file for your platfor

| Dependency | Minimum required |
| --- | --- |
| [Autoconf](https://www.gnu.org/software/autoconf/) | [2.69](https://github.com/bitcoin/bitcoin/pull/17769) |
| [Automake](https://www.gnu.org/software/automake/) | [1.13](https://github.com/bitcoin/bitcoin/pull/18290) |
| [Clang](https://clang.llvm.org) | [16.0](https://github.com/bitcoin/bitcoin/pull/30263) |
| [CMake](https://cmake.org/) | [3.22](https://github.com/bitcoin/bitcoin/pull/30454) |
| [GCC](https://gcc.gnu.org) | [11.1](https://github.com/bitcoin/bitcoin/pull/29091) |
| [Python](https://www.python.org) (scripts, tests) | [3.9](https://github.com/bitcoin/bitcoin/pull/28211) |
| [systemtap](https://sourceware.org/systemtap/) ([tracing](tracing.md))| N/A |
Expand Down
12 changes: 6 additions & 6 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,28 +214,28 @@ int main()
To run clang-tidy on Ubuntu/Debian, install the dependencies:
```sh
apt install clang-tidy bear clang
apt install clang-tidy clang
```

Then, pass clang as compiler to configure, and use bear to produce the `compile_commands.json`:
Configure with clang as the compiler:

```sh
./autogen.sh && ./configure CC=clang CXX=clang++
make clean && bear --config src/.bear-tidy-config -- make -j $(nproc)
cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build -j $(nproc)
```

The output is denoised of errors from external dependencies.

To run clang-tidy on all source files:

```sh
( cd ./src/ && run-clang-tidy -j $(nproc) )
( cd ./src/ && run-clang-tidy -p ../build -j $(nproc) )
```

To run clang-tidy on the changed source lines:

```sh
git diff | ( cd ./src/ && clang-tidy-diff -p2 -j $(nproc) )
git diff | ( cd ./src/ && clang-tidy-diff -p2 -path ../build -j $(nproc) )
```

Coding Style (Python)
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct Params {
uint256 powLimit;
bool fPowAllowMinDifficultyBlocks;
/**
* Enfore BIP94 timewarp attack mitigation. On testnet4 this also enforces
* Enforce BIP94 timewarp attack mitigation. On testnet4 this also enforces
* the block storm mitigation.
*/
bool enforce_BIP94;
Expand Down
2 changes: 1 addition & 1 deletion src/test/util/cluster_linearize.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ struct DepGraphFormatter
// Ignore transactions which are already known to be ancestors.
if (depgraph.Descendants(dep_idx).Overlaps(written_parents)) continue;
if (depgraph.Ancestors(idx)[dep_idx]) {
// When an actual parent is encounted, encode how many non-parents were skipped
// When an actual parent is encountered, encode how many non-parents were skipped
// before it.
s << VARINT(diff);
diff = 0;
Expand Down
33 changes: 13 additions & 20 deletions test/functional/rpc_signrawtransactionwithkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test transaction signing using the signrawtransactionwithkey RPC."""

from test_framework.blocktools import (
COINBASE_MATURITY,
from test_framework.messages import (
COIN,
)
from test_framework.address import (
address_to_scriptpubkey,
Expand All @@ -16,7 +16,6 @@
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
find_vout_for_address,
)
from test_framework.script_util import (
key_to_p2pk_script,
Expand All @@ -26,6 +25,7 @@
)
from test_framework.wallet import (
getnewdestination,
MiniWallet,
)
from test_framework.wallet_util import (
generate_keypair,
Expand All @@ -46,16 +46,12 @@

class SignRawTransactionWithKeyTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2
self.num_nodes = 1

def send_to_address(self, addr, amount):
input = {"txid": self.nodes[0].getblock(self.block_hash[self.blk_idx])["tx"][0], "vout": 0}
output = {addr: amount}
self.blk_idx += 1
rawtx = self.nodes[0].createrawtransaction([input], output)
txid = self.nodes[0].sendrawtransaction(self.nodes[0].signrawtransactionwithkey(rawtx, [self.nodes[0].get_deterministic_priv_key().key])["hex"], 0)
return txid
script_pub_key = address_to_scriptpubkey(addr)
tx = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=script_pub_key, amount=int(amount * COIN))
return tx["txid"], tx["sent_vout"]

def assert_signing_completed_successfully(self, signed_tx):
assert 'errors' not in signed_tx
Expand All @@ -80,14 +76,12 @@ def witness_script_test(self):
self.log.info("Test signing transaction to P2SH-P2WSH addresses without wallet")
# Create a new P2SH-P2WSH 1-of-1 multisig address:
embedded_privkey, embedded_pubkey = generate_keypair(wif=True)
p2sh_p2wsh_address = self.nodes[1].createmultisig(1, [embedded_pubkey.hex()], "p2sh-segwit")
p2sh_p2wsh_address = self.nodes[0].createmultisig(1, [embedded_pubkey.hex()], "p2sh-segwit")
# send transaction to P2SH-P2WSH 1-of-1 multisig address
self.block_hash = self.generate(self.nodes[0], COINBASE_MATURITY + 1)
self.blk_idx = 0
self.send_to_address(p2sh_p2wsh_address["address"], 49.999)
self.generate(self.nodes[0], 1)
# Get the UTXO info from scantxoutset
unspent_output = self.nodes[1].scantxoutset('start', [p2sh_p2wsh_address['descriptor']])['unspents'][0]
unspent_output = self.nodes[0].scantxoutset('start', [p2sh_p2wsh_address['descriptor']])['unspents'][0]
spk = script_to_p2sh_p2wsh_script(p2sh_p2wsh_address['redeemScript']).hex()
unspent_output['witnessScript'] = p2sh_p2wsh_address['redeemScript']
unspent_output['redeemScript'] = script_to_p2wsh_script(unspent_output['witnessScript']).hex()
Expand All @@ -103,9 +97,9 @@ def witness_script_test(self):

def keyless_signing_test(self):
self.log.info("Test that keyless 'signing' of pay-to-anchor input succeeds")
funding_txid = self.send_to_address(p2a(), 49.999)
[txid, vout] = self.send_to_address(p2a(), 49.999)
spending_tx = self.nodes[0].createrawtransaction(
[{"txid": funding_txid, "vout": 0}],
[{"txid": txid, "vout": vout}],
[{getnewdestination()[2]: Decimal("49.998")}])
spending_tx_signed = self.nodes[0].signrawtransactionwithkey(spending_tx, [], [])
self.assert_signing_completed_successfully(spending_tx_signed)
Expand All @@ -124,9 +118,7 @@ def verify_txn_with_witness_script(self, tx_type):
addr = script_to_p2sh(redeem_script)
script_pub_key = address_to_scriptpubkey(addr).hex()
# Fund that address
txid = self.send_to_address(addr, 10)
vout = find_vout_for_address(self.nodes[0], txid, addr)
self.generate(self.nodes[0], 1)
[txid, vout] = self.send_to_address(addr, 10)
# Now create and sign a transaction spending that output on node[0], which doesn't know the scripts or keys
spending_tx = self.nodes[0].createrawtransaction([{'txid': txid, 'vout': vout}], {getnewdestination()[2]: Decimal("9.999")})
spending_tx_signed = self.nodes[0].signrawtransactionwithkey(spending_tx, [embedded_privkey], [{'txid': txid, 'vout': vout, 'scriptPubKey': script_pub_key, 'redeemScript': redeem_script, 'witnessScript': witness_script, 'amount': 10}])
Expand All @@ -149,6 +141,7 @@ def invalid_private_key_and_tx(self):
assert_raises_rpc_error(-22, "TX decode failed. Make sure the tx has at least one input.", self.nodes[0].signrawtransactionwithkey, tx + "00", privkeys)

def run_test(self):
self.wallet = MiniWallet(self.nodes[0])
self.successful_signing_test()
self.witness_script_test()
self.keyless_signing_test()
Expand Down
10 changes: 9 additions & 1 deletion test/functional/test_framework/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# Copyright (c) 2019-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.
import pathlib

from test_framework.test_framework import BitcoinTestFramework


class TestShell:
"""Wrapper Class for BitcoinTestFramework.
Expand Down Expand Up @@ -67,7 +69,13 @@ def __new__(cls):
# This implementation enforces singleton pattern, and will return the
# previously initialized instance if available
if not TestShell.instance:
TestShell.instance = TestShell.__TestShell()
# BitcoinTestFramework instances are supposed to be constructed with the path
# of the calling test in order to find shared data like configuration and the
# cache. Since TestShell is meant for interactive use, there is no concrete
# test; passing a dummy name is fine though, as only the containing directory
# is relevant for successful initialization.
tests_directory = pathlib.Path(__file__).resolve().parent.parent
TestShell.instance = TestShell.__TestShell(tests_directory / "testshell_dummy.py")
TestShell.instance.running = False
return TestShell.instance

Expand Down
Loading

0 comments on commit 2db3505

Please sign in to comment.