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 Dec 19, 2024
2 parents 4ada55f + c1252b1 commit 0a0ee6e
Show file tree
Hide file tree
Showing 83 changed files with 468 additions and 247 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ if(WIN32)
try_append_linker_flag("-Wl,--major-subsystem-version,6" TARGET core_interface)
try_append_linker_flag("-Wl,--minor-subsystem-version,2" TARGET core_interface)
endif()

# Workaround producing large object files, which cannot be handled by the assembler.
# More likely to happen with no, or lower levels of optimisation.
# See discussion in https://github.com/bitcoin/bitcoin/issues/28109.
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
try_append_cxx_flags("/bigobj" TARGET core_interface_debug SKIP_LINK)
else()
try_append_cxx_flags("-Wa,-mbig-obj" TARGET core_interface_debug SKIP_LINK)
endif()
endif()

# Use 64-bit off_t on 32-bit Linux.
Expand Down
6 changes: 3 additions & 3 deletions ci/test/00_setup_env_i686_centos.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# 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.

Expand All @@ -9,9 +9,9 @@ export LC_ALL=C.UTF-8
export HOST=i686-pc-linux-gnu
export CONTAINER_NAME=ci_i686_centos
export CI_IMAGE_NAME_TAG="quay.io/centos/amd64:stream9"
export CI_BASE_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc-devel.i686 libstdc++-devel.i686 ccache make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison e2fsprogs cmake"
export STREAM_GCC_V="12"
export CI_BASE_PACKAGES="gcc-toolset-${STREAM_GCC_V}-gcc-c++ glibc-devel.x86_64 gcc-toolset-${STREAM_GCC_V}-libstdc++-devel.x86_64 glibc-devel.i686 gcc-toolset-${STREAM_GCC_V}-libstdc++-devel.i686 ccache make git python3 python3-pip which patch lbzip2 xz procps-ng dash rsync coreutils bison e2fsprogs cmake"
export PIP_PACKAGES="pyzmq"
export GOAL="install"
export NO_WERROR=1 # Suppress error: #warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform [-Werror=cpp]
export GROESTLCOIN_CONFIG="-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON"
export CONFIG_SHELL="/bin/dash"
5 changes: 3 additions & 2 deletions ci/test/03_test_script.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ fi

if [ -z "$NO_DEPENDS" ]; then
if [[ $CI_IMAGE_NAME_TAG == *centos* ]]; then
# Use bash for GRS
SHELL_OPTS="CONFIG_SHELL=/bin/bash"
SHELL_OPTS="CONFIG_SHELL=/bin/dash"
# shellcheck disable=SC1090
source "/opt/rh/gcc-toolset-${STREAM_GCC_V}/enable"
else
SHELL_OPTS="CONFIG_SHELL="
fi
Expand Down
1 change: 1 addition & 0 deletions depends/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ work/
built/
sources/
x86_64*
amd64*
i686*
mips*
arm*
Expand Down
2 changes: 0 additions & 2 deletions depends/hosts/netbsd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions depends/packages/native_capnp.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package=native_capnp
$(package)_version=1.0.1
$(package)_version=1.0.2
$(package)_download_path=https://capnproto.org/
$(package)_download_file=capnproto-c++-$($(package)_version).tar.gz
$(package)_file_name=capnproto-cxx-$($(package)_version).tar.gz
$(package)_sha256_hash=0f7f4b8a76a2cdb284fddef20de8306450df6dd031a47a15ac95bc43c3358e09
$(package)_sha256_hash=9057dbc0223366b74bbeca33a05de164a229b0377927f1b7ef3828cdd8cb1d7e

define $(package)_set_vars
$(package)_config_opts := -DBUILD_TESTING=OFF
Expand Down
15 changes: 15 additions & 0 deletions doc/release-notes-31223.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
P2P and network changes
-----------------------
When the `-port` configuration option is used, the default onion listening port will now
be derived to be that port + 1 instead of being set to a fixed value (8334 on mainnet).
This re-allows setups with multiple local nodes using different `-port` and not using `-bind`,
which would lead to a startup failure in v28.0 due to a port collision.

Note that a `HiddenServicePort` manually configured in `torrc` may need adjustment if used in
connection with the `-port` option.
For example, if you are using `-port=5555` with a non-standard value and not using `-bind=...=onion`,
previously Bitcoin Core would listen for incoming Tor connections on `127.0.0.1:8334`.
Now it would listen on `127.0.0.1:5556` (`-port` plus one). If you configured the hidden service manually
in torrc now you have to change it from `HiddenServicePort 8333 127.0.0.1:8334` to `HiddenServicePort 8333
127.0.0.1:5556`, or configure bitcoind with `-bind=127.0.0.1:8334=onion` to get the previous behavior.
(#31223)
13 changes: 9 additions & 4 deletions src/bench/block_assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@
#include <memory>
#include <vector>

using node::BlockAssembler;

static void AssembleBlock(benchmark::Bench& bench)
{
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();

CScriptWitness witness;
witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
BlockAssembler::Options options;
options.coinbase_output_script = P2WSH_OP_TRUE;

// Collect some loose transactions that spend the coinbases of our mined blocks
constexpr size_t NUM_BLOCKS{200};
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
CMutableTransaction tx;
tx.vin.emplace_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
tx.vin.emplace_back(MineBlock(test_setup->m_node, options));
tx.vin.back().scriptWitness = witness;
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
Expand All @@ -48,19 +52,20 @@ static void AssembleBlock(benchmark::Bench& bench)
}

bench.run([&] {
PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE);
PrepareBlock(test_setup->m_node, options);
});
}
static void BlockAssemblerAddPackageTxns(benchmark::Bench& bench)
{
FastRandomContext det_rand{true};
auto testing_setup{MakeNoLogFileContext<TestChain100Setup>()};
testing_setup->PopulateMempool(det_rand, /*num_transactions=*/1000, /*submit=*/true);
node::BlockAssembler::Options assembler_options;
BlockAssembler::Options assembler_options;
assembler_options.test_block_validity = false;
assembler_options.coinbase_output_script = P2WSH_OP_TRUE;

bench.run([&] {
PrepareBlock(testing_setup->m_node, P2WSH_OP_TRUE, assembler_options);
PrepareBlock(testing_setup->m_node, assembler_options);
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const ChainType chain)
{
switch (chain) {
case ChainType::MAIN:
return std::make_unique<CBaseChainParams>("", 1441, 1444);
return std::make_unique<CBaseChainParams>("", 1441);
case ChainType::TESTNET:
return std::make_unique<CBaseChainParams>("testnet3", 17766, 17764);
return std::make_unique<CBaseChainParams>("testnet3", 17766);
case ChainType::TESTNET4:
return std::make_unique<CBaseChainParams>("testnet4", 41441, 41444);
return std::make_unique<CBaseChainParams>("testnet4", 41441);
case ChainType::SIGNET:
return std::make_unique<CBaseChainParams>("signet", 31441, 31444);
return std::make_unique<CBaseChainParams>("signet", 31441);
case ChainType::REGTEST:
return std::make_unique<CBaseChainParams>("regtest", 18443, 18445);
return std::make_unique<CBaseChainParams>("regtest", 18443);
}
assert(false);
}
Expand Down
6 changes: 2 additions & 4 deletions src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ class CBaseChainParams
public:
const std::string& DataDir() const { return strDataDir; }
uint16_t RPCPort() const { return m_rpc_port; }
uint16_t OnionServiceTargetPort() const { return m_onion_service_target_port; }

CBaseChainParams() = delete;
CBaseChainParams(const std::string& data_dir, uint16_t rpc_port, uint16_t onion_service_target_port)
: m_rpc_port(rpc_port), m_onion_service_target_port(onion_service_target_port), strDataDir(data_dir) {}
CBaseChainParams(const std::string& data_dir, uint16_t rpc_port)
: m_rpc_port(rpc_port), strDataDir(data_dir) {}

private:
const uint16_t m_rpc_port;
const uint16_t m_onion_service_target_port;
std::string strDataDir;
};

Expand Down
31 changes: 17 additions & 14 deletions src/consensus/merkle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <consensus/merkle.h>
#include <hash.h>
#include <util/check.h>

/* WARNING! If you're reading this because you're learning about crypto
and/or designing a new system that will use merkle trees, keep in mind
Expand Down Expand Up @@ -84,8 +85,10 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated)
}

/* This implements a constant-space merkle root/path calculator, limited to 2^32 leaves. */
static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) {
if (pbranch) pbranch->clear();
static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t leaf_pos, std::vector<uint256>* path)
{
if (path) path->clear();
Assume(leaves.size() <= UINT32_MAX);
if (leaves.size() == 0) {
if (pmutated) *pmutated = false;
if (proot) *proot = uint256();
Expand All @@ -105,18 +108,18 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
// First process all leaves into 'inner' values.
while (count < leaves.size()) {
uint256 h = leaves[count];
bool matchh = count == branchpos;
bool matchh = count == leaf_pos;
count++;
int level;
// For each of the lower bits in count that are 0, do 1 step. Each
// corresponds to an inner value that existed before processing the
// current leaf, and each needs a hash to combine it.
for (level = 0; !(count & ((uint32_t{1}) << level)); level++) {
if (pbranch) {
if (path) {
if (matchh) {
pbranch->push_back(inner[level]);
path->push_back(inner[level]);
} else if (matchlevel == level) {
pbranch->push_back(h);
path->push_back(h);
matchh = true;
}
}
Expand Down Expand Up @@ -144,8 +147,8 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
// If we reach this point, h is an inner value that is not the top.
// We combine it with itself (Bitcoin's special rule for odd levels in
// the tree) to produce a higher level one.
if (pbranch && matchh) {
pbranch->push_back(h);
if (path && matchh) {
path->push_back(h);
}
h = Hash(h, h);
// Increment count to the value it would have if two entries at this
Expand All @@ -154,11 +157,11 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
level++;
// And propagate the result upwards accordingly.
while (!(count & ((uint32_t{1}) << level))) {
if (pbranch) {
if (path) {
if (matchh) {
pbranch->push_back(inner[level]);
path->push_back(inner[level]);
} else if (matchlevel == level) {
pbranch->push_back(h);
path->push_back(h);
matchh = true;
}
}
Expand All @@ -171,18 +174,18 @@ static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot
if (proot) *proot = h;
}

static std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position) {
static std::vector<uint256> ComputeMerklePath(const std::vector<uint256>& leaves, uint32_t position) {
std::vector<uint256> ret;
MerkleComputation(leaves, nullptr, nullptr, position, &ret);
return ret;
}

std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position)
std::vector<uint256> TransactionMerklePath(const CBlock& block, uint32_t position)
{
std::vector<uint256> leaves;
leaves.resize(block.vtx.size());
for (size_t s = 0; s < block.vtx.size(); s++) {
leaves[s] = block.vtx[s]->GetHash();
}
return ComputeMerkleBranch(leaves, position);
return ComputeMerklePath(leaves, position);
}
4 changes: 2 additions & 2 deletions src/consensus/merkle.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ uint256 BlockWitnessMerkleRoot(const CBlock& block, bool* mutated = nullptr);
* Compute merkle path to the specified transaction
*
* @param[in] block the block
* @param[in] position transaction for which to calculate the merkle path, defaults to coinbase
* @param[in] position transaction for which to calculate the merkle path (0 is the coinbase)
*
* @return merkle path ordered from the deepest
*/
std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position = 0);
std::vector<uint256> TransactionMerklePath(const CBlock& block, uint32_t position);

#endif // BITCOIN_CONSENSUS_MERKLE_H
Loading

0 comments on commit 0a0ee6e

Please sign in to comment.