From 621c634b7fe14fbf151cd222eeaade3505059249 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Tue, 24 Dec 2024 15:55:22 +0100 Subject: [PATCH 1/6] rpc: Extend scope of validation mutex in generateblock The mutex (required by TestBlockValidity) must be held after creating the block, until TestBlockValidity is called. Otherwise, it is possible that the chain advances in the meantime and leads to a crash in TestBlockValidity: Assertion failed: pindexPrev && pindexPrev == chainstate.m_chain.Tip() (validation.cpp: TestBlockValidity: 4338) The diff can be reviewed with the git options --ignore-all-space --function-context Github-Pull: 31563 Rebased-From: fa62c8b1f04a5386ffa171aeff713d55bd874cbe --- src/rpc/mining.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 3c41e136eca..445fd8c3447 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2022 The Bitcoin Core developers +// Copyright (c) 2009-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -370,20 +370,21 @@ static RPCHelpMan generateblock() ChainstateManager& chainman = EnsureChainman(node); { - std::unique_ptr blocktemplate{miner.createNewBlock(coinbase_script, {.use_mempool = false})}; - if (!blocktemplate) { - throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); + LOCK(chainman.GetMutex()); + { + std::unique_ptr blocktemplate{miner.createNewBlock(coinbase_script, {.use_mempool = false})}; + if (!blocktemplate) { + throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); + } + block = blocktemplate->block; } - block = blocktemplate->block; - } - CHECK_NONFATAL(block.vtx.size() == 1); + CHECK_NONFATAL(block.vtx.size() == 1); - // Add transactions - block.vtx.insert(block.vtx.end(), txs.begin(), txs.end()); - RegenerateCommitments(block, chainman); + // Add transactions + block.vtx.insert(block.vtx.end(), txs.begin(), txs.end()); + RegenerateCommitments(block, chainman); - { BlockValidationState state; if (!miner.testBlockValidity(block, /*check_merkle_root=*/false, state)) { throw JSONRPCError(RPC_VERIFY_ERROR, strprintf("testBlockValidity failed: %s", state.ToString())); From 05cd448e3328181d3fe1662bcd7af82cb51833a7 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 25 Dec 2024 04:45:56 +0100 Subject: [PATCH 2/6] test: generateblocks called by multiple threads Co-Authored-By: David Gumberg Github-Pull: 31563 Rebased-From: fa63b8232f38e78d3c6413fa7d51809f376de75c --- test/functional/rpc_generate.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/functional/rpc_generate.py b/test/functional/rpc_generate.py index 68de9006644..1f0d6c546c7 100755 --- a/test/functional/rpc_generate.py +++ b/test/functional/rpc_generate.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 -# Copyright (c) 2020-2022 The Bitcoin Core developers +# Copyright (c) 2020-present The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test generate* RPCs.""" +from concurrent.futures import ThreadPoolExecutor + from test_framework.test_framework import BitcoinTestFramework from test_framework.wallet import MiniWallet from test_framework.util import ( @@ -83,6 +85,13 @@ class RPCGenerateTest(BitcoinTestFramework): txid = block['tx'][1] assert_equal(node.getrawtransaction(txid=txid, verbose=False, blockhash=hash), rawtx) + # Ensure that generateblock can be called concurrently by many threads. + self.log.info('Generate blocks in parallel') + generate_50_blocks = lambda n: [n.generateblock(output=address, transactions=[]) for _ in range(50)] + rpcs = [node.cli for _ in range(6)] + with ThreadPoolExecutor(max_workers=len(rpcs)) as threads: + list(threads.map(generate_50_blocks, rpcs)) + self.log.info('Fail to generate block with out of order txs') txid1 = miniwallet.send_self_transfer(from_node=node)['txid'] utxo1 = miniwallet.get_utxo(txid=txid1) From 5b368f88a9fddd0cd48fb014ff9694c555129996 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 14 Dec 2024 20:32:38 +0000 Subject: [PATCH 3/6] depends: Fix CXXFLAGS on NetBSD This change corrects an issue where CXXFLAGS were mistakenly overridden by CFLAGS. Github-Pull: 31502 Rebased-From: a10bb400e8cb0da0030114ee59f2e7c8494aef42 --- depends/hosts/netbsd.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/depends/hosts/netbsd.mk b/depends/hosts/netbsd.mk index f33b2d28895..6e0fa9e12fb 100644 --- a/depends/hosts/netbsd.mk +++ b/depends/hosts/netbsd.mk @@ -7,8 +7,6 @@ netbsd_NM = $(host_toolchain)gcc-nm netbsd_RANLIB = $(host_toolchain)gcc-ranlib endif -netbsd_CXXFLAGS=$(netbsd_CFLAGS) - netbsd_release_CFLAGS=-O2 netbsd_release_CXXFLAGS=$(netbsd_release_CFLAGS) From 6a68ef9bfb39b27d480d4091b60d1c7f9f2d8690 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 30 Dec 2024 12:51:05 -0500 Subject: [PATCH 4/6] build: bump to 28.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 057f8c8cddf..86d5e5e2148 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.69]) define(_CLIENT_VERSION_MAJOR, 28) define(_CLIENT_VERSION_MINOR, 1) define(_CLIENT_VERSION_BUILD, 0) -define(_CLIENT_VERSION_RC, 2) +define(_CLIENT_VERSION_RC, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2024) define(_COPYRIGHT_HOLDERS,[The %s developers]) From 58910279dcfd989a1712b3dc39a272ff3fbe1136 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 30 Dec 2024 12:55:32 -0500 Subject: [PATCH 5/6] doc: generate 28.1 manpages --- doc/man/bitcoin-cli.1 | 6 +++--- doc/man/bitcoin-qt.1 | 6 +++--- doc/man/bitcoin-tx.1 | 6 +++--- doc/man/bitcoin-util.1 | 6 +++--- doc/man/bitcoin-wallet.1 | 6 +++--- doc/man/bitcoind.1 | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/man/bitcoin-cli.1 b/doc/man/bitcoin-cli.1 index 52f6e123fc0..d355289372b 100644 --- a/doc/man/bitcoin-cli.1 +++ b/doc/man/bitcoin-cli.1 @@ -1,7 +1,7 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH BITCOIN-CLI "1" "December 2024" "bitcoin-cli v28.1.0rc2" "User Commands" +.TH BITCOIN-CLI "1" "December 2024" "bitcoin-cli v28.1.0" "User Commands" .SH NAME -bitcoin-cli \- manual page for bitcoin-cli v28.1.0rc2 +bitcoin-cli \- manual page for bitcoin-cli v28.1.0 .SH SYNOPSIS .B bitcoin-cli [\fI\,options\/\fR] \fI\, \/\fR[\fI\,params\/\fR] \fI\,Send command to Bitcoin Core\/\fR @@ -15,7 +15,7 @@ bitcoin-cli \- manual page for bitcoin-cli v28.1.0rc2 .B bitcoin-cli [\fI\,options\/\fR] \fI\,help Get help for a command\/\fR .SH DESCRIPTION -Bitcoin Core RPC client version v28.1.0rc2 +Bitcoin Core RPC client version v28.1.0 .SH OPTIONS .HP \-? diff --git a/doc/man/bitcoin-qt.1 b/doc/man/bitcoin-qt.1 index c8f1f5ae5da..fe76cd970b1 100644 --- a/doc/man/bitcoin-qt.1 +++ b/doc/man/bitcoin-qt.1 @@ -1,12 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH BITCOIN-QT "1" "December 2024" "bitcoin-qt v28.1.0rc2" "User Commands" +.TH BITCOIN-QT "1" "December 2024" "bitcoin-qt v28.1.0" "User Commands" .SH NAME -bitcoin-qt \- manual page for bitcoin-qt v28.1.0rc2 +bitcoin-qt \- manual page for bitcoin-qt v28.1.0 .SH SYNOPSIS .B bitcoin-qt [\fI\,command-line options\/\fR] [\fI\,URI\/\fR] .SH DESCRIPTION -Bitcoin Core version v28.1.0rc2 +Bitcoin Core version v28.1.0 .PP Optional URI is a Bitcoin address in BIP21 URI format. .SH OPTIONS diff --git a/doc/man/bitcoin-tx.1 b/doc/man/bitcoin-tx.1 index 81fc86c8711..26cbd9bff78 100644 --- a/doc/man/bitcoin-tx.1 +++ b/doc/man/bitcoin-tx.1 @@ -1,7 +1,7 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH BITCOIN-TX "1" "December 2024" "bitcoin-tx v28.1.0rc2" "User Commands" +.TH BITCOIN-TX "1" "December 2024" "bitcoin-tx v28.1.0" "User Commands" .SH NAME -bitcoin-tx \- manual page for bitcoin-tx v28.1.0rc2 +bitcoin-tx \- manual page for bitcoin-tx v28.1.0 .SH SYNOPSIS .B bitcoin-tx [\fI\,options\/\fR] \fI\, \/\fR[\fI\,commands\/\fR] \fI\,Update hex-encoded bitcoin transaction\/\fR @@ -9,7 +9,7 @@ bitcoin-tx \- manual page for bitcoin-tx v28.1.0rc2 .B bitcoin-tx [\fI\,options\/\fR] \fI\,-create \/\fR[\fI\,commands\/\fR] \fI\,Create hex-encoded bitcoin transaction\/\fR .SH DESCRIPTION -Bitcoin Core bitcoin\-tx utility version v28.1.0rc2 +Bitcoin Core bitcoin\-tx utility version v28.1.0 .SH OPTIONS .HP \-? diff --git a/doc/man/bitcoin-util.1 b/doc/man/bitcoin-util.1 index a88d6109312..415e6d04b1e 100644 --- a/doc/man/bitcoin-util.1 +++ b/doc/man/bitcoin-util.1 @@ -1,12 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH BITCOIN-UTIL "1" "December 2024" "bitcoin-util v28.1.0rc2" "User Commands" +.TH BITCOIN-UTIL "1" "December 2024" "bitcoin-util v28.1.0" "User Commands" .SH NAME -bitcoin-util \- manual page for bitcoin-util v28.1.0rc2 +bitcoin-util \- manual page for bitcoin-util v28.1.0 .SH SYNOPSIS .B bitcoin-util [\fI\,options\/\fR] [\fI\,commands\/\fR] \fI\,Do stuff\/\fR .SH DESCRIPTION -Bitcoin Core bitcoin\-util utility version v28.1.0rc2 +Bitcoin Core bitcoin\-util utility version v28.1.0 .SH OPTIONS .HP \-? diff --git a/doc/man/bitcoin-wallet.1 b/doc/man/bitcoin-wallet.1 index 94d90494417..a0431292ae7 100644 --- a/doc/man/bitcoin-wallet.1 +++ b/doc/man/bitcoin-wallet.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH BITCOIN-WALLET "1" "December 2024" "bitcoin-wallet v28.1.0rc2" "User Commands" +.TH BITCOIN-WALLET "1" "December 2024" "bitcoin-wallet v28.1.0" "User Commands" .SH NAME -bitcoin-wallet \- manual page for bitcoin-wallet v28.1.0rc2 +bitcoin-wallet \- manual page for bitcoin-wallet v28.1.0 .SH DESCRIPTION -Bitcoin Core bitcoin\-wallet version v28.1.0rc2 +Bitcoin Core bitcoin\-wallet version v28.1.0 .PP bitcoin\-wallet is an offline tool for creating and interacting with Bitcoin Core wallet files. By default bitcoin\-wallet will act on wallets in the default mainnet wallet directory in the datadir. diff --git a/doc/man/bitcoind.1 b/doc/man/bitcoind.1 index 34bc48acd84..1acb2dfa0a3 100644 --- a/doc/man/bitcoind.1 +++ b/doc/man/bitcoind.1 @@ -1,12 +1,12 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. -.TH BITCOIND "1" "December 2024" "bitcoind v28.1.0rc2" "User Commands" +.TH BITCOIND "1" "December 2024" "bitcoind v28.1.0" "User Commands" .SH NAME -bitcoind \- manual page for bitcoind v28.1.0rc2 +bitcoind \- manual page for bitcoind v28.1.0 .SH SYNOPSIS .B bitcoind [\fI\,options\/\fR] \fI\,Start Bitcoin Core\/\fR .SH DESCRIPTION -Bitcoin Core version v28.1.0rc2 +Bitcoin Core version v28.1.0 .SH OPTIONS .HP \-? From 36314b8da2ee65afd5636fa830d436c5c22bd260 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 2 Jan 2025 14:24:10 +0100 Subject: [PATCH 6/6] doc: Update 28.1 release notes --- doc/release-notes.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/release-notes.md b/doc/release-notes.md index cdddade43a6..e134dcce439 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -1,6 +1,6 @@ -Bitcoin Core version 28.1rc1 is now available from: +Bitcoin Core version 28.1 is now available from: - + This release includes new features, various bug fixes and performance improvements, as well as updated translations. @@ -68,12 +68,14 @@ Notable changes ### Build - #31013 depends: For mingw cross compile use `-gcc-posix` to prevent library conflict +- #31502 depends: Fix CXXFLAGS on NetBSD ### Test - #31016 test: add missing sync to feature_fee_estimation.py - #31448 fuzz: add cstdlib to FuzzedDataProvider - #31419 test: fix MIN macro redefinition +- #31563 rpc: Extend scope of validation mutex in generateblock ### Doc @@ -92,6 +94,7 @@ Credits ======= - fanquake +- Hennadii Stepanov - laanwj - MarcoFalke - Martin Zumsande