Skip to content

Commit

Permalink
Merge branch 'auxpow'
Browse files Browse the repository at this point in the history
  • Loading branch information
domob1812 committed Nov 25, 2024
2 parents 12ef104 + 9b6a76a commit e2b4543
Show file tree
Hide file tree
Showing 55 changed files with 868 additions and 536 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ jobs:
run: |
# A workaround for "The `brew link` step did not complete successfully" error.
brew install --quiet python@3 || brew link --overwrite python@3
brew install --quiet coreutils ninja pkg-config gnu-getopt ccache boost libevent zeromq qt@5 qrencode
# Update to install pkgconf, once the GHA image has been updated.
brew install --quiet coreutils ninja gnu-getopt ccache boost libevent zeromq qt@5 qrencode
- name: Set Ccache directory
run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ else()
try_append_cxx_flags("-Wunreachable-code" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wdocumentation" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wself-assign" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wbidi-chars=any" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wundef" TARGET warn_interface SKIP_LINK)

# Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ list or changes that are
Some of them might no longer be applicable. So if you are interested, but
unsure, you might want to leave a comment on the issue first.

You may also participate in the weekly
[Bitcoin Core PR Review Club](https://bitcoincore.reviews/) meeting.
You may also participate in the [Bitcoin Core PR Review Club](https://bitcoincore.reviews/).

### Good First Issue Label

Expand Down
2 changes: 1 addition & 1 deletion contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ inspecting signatures in Mach-O binaries.")
gcc-toolchain-12
cmake-minimal
gnu-make
pkg-config
;; Scripting
python-minimal ;; (3.10)
;; Git
Expand All @@ -527,6 +526,7 @@ inspecting signatures in Mach-O binaries.")
osslsigncode))
((string-contains target "-linux-")
(list bison
pkg-config
(list gcc-toolchain-12 "static")
(make-bitcoin-cross-toolchain target)))
((string-contains target "darwin")
Expand Down
4 changes: 2 additions & 2 deletions depends/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ Most autotools projects can be properly staged using:
## Build outputs:

In general, the output of a depends package should not contain any libtool
archives. Instead, the package should output `.pc` (`pkg-config`) files where
possible.
archives or `.pc` (`pkg-config`) files. Instead, the package should output
`.cmake` (CMake) files where possible.

From the [Gentoo Wiki entry](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives):

Expand Down
2 changes: 1 addition & 1 deletion depends/packages/fontconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ define $(package)_stage_cmds
endef

define $(package)_postprocess_cmds
rm -rf var lib/*.la
rm -rf bin etc share var lib/*.la
endef
8 changes: 3 additions & 5 deletions depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ $(package)_linguist_tools = lrelease lupdate lconvert
$(package)_patches = qt.pro
$(package)_patches += qttools_src.pro
$(package)_patches += mac-qmake.conf
$(package)_patches += fix_qt_pkgconfig.patch
$(package)_patches += no-xlib.patch
$(package)_patches += dont_hardcode_pwd.patch
$(package)_patches += qtbase-moc-ignore-gcc-macro.patch
Expand Down Expand Up @@ -64,6 +63,7 @@ $(package)_config_opts += -no-mimetype-database
$(package)_config_opts += -no-mtdev
$(package)_config_opts += -no-openssl
$(package)_config_opts += -no-openvg
$(package)_config_opts += -no-pkg-config
$(package)_config_opts += -no-reduce-relocations
$(package)_config_opts += -no-schannel
$(package)_config_opts += -no-sctp
Expand All @@ -84,7 +84,6 @@ $(package)_config_opts += -nomake examples
$(package)_config_opts += -nomake tests
$(package)_config_opts += -nomake tools
$(package)_config_opts += -opensource
$(package)_config_opts += -pkg-config
$(package)_config_opts += -prefix $(host_prefix)
$(package)_config_opts += -qt-libpng
$(package)_config_opts += -qt-pcre
Expand Down Expand Up @@ -226,7 +225,6 @@ define $(package)_preprocess_cmds
cp $($(package)_patch_dir)/qttools_src.pro qttools/src/src.pro && \
patch -p1 -i $($(package)_patch_dir)/fix-macos-linker.patch && \
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_pwd.patch && \
patch -p1 -i $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \
patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
patch -p1 -i $($(package)_patch_dir)/memory_resource.patch && \
Expand Down Expand Up @@ -273,6 +271,6 @@ define $(package)_stage_cmds
endef

define $(package)_postprocess_cmds
rm -rf doc/ native/lib/ && \
rm -f lib/lib*.la
rm -rf doc/ native/lib/ lib/pkgconfig/ && \
rm -f lib/lib*.la lib/Qt5*.la
endef
1 change: 1 addition & 0 deletions depends/packages/sqlite.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ define $(package)_stage_cmds
endef

define $(package)_postprocess_cmds
rm -rf lib/pkgconfig && \
rm lib/*.la
endef
11 changes: 0 additions & 11 deletions depends/patches/qt/fix_qt_pkgconfig.patch

This file was deleted.

9 changes: 0 additions & 9 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
set(CMAKE_FRAMEWORK_PATH "@OSX_SDK@/System/Library/Frameworks")
endif()


# Customize pkg-config behaviour.
cmake_path(APPEND CMAKE_FIND_ROOT_PATH "lib" "pkgconfig" OUTPUT_VARIABLE pkg_config_path)
set(ENV{PKG_CONFIG_PATH} ${pkg_config_path})
set(ENV{PKG_CONFIG_LIBDIR} ${pkg_config_path})
unset(pkg_config_path)
set(PKG_CONFIG_ARGN --static)


# Set configuration options for the main build system.
set(qt_packages @qt_packages@)
if("${qt_packages}" STREQUAL "")
Expand Down
2 changes: 1 addition & 1 deletion doc/build-osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ See [dependencies.md](dependencies.md) for a complete overview.
To install, run the following from your terminal:

``` bash
brew install cmake boost pkg-config libevent
brew install cmake boost pkgconf libevent
```

### 4. Clone Namecoin repository
Expand Down
9 changes: 5 additions & 4 deletions doc/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ Arguments passed:
2. Replaced transaction virtual size as `int32`
3. Replaced transaction fee as `int64`
4. Replaced transaction mempool entry time (epoch) as `uint64`
5. Replacement transaction ID (hash) as `pointer to unsigned chars` (i.e. 32 bytes in little-endian)
5. Replacement transaction ID or package hash as `pointer to unsigned chars` (i.e. 32 bytes in little-endian)
6. Replacement transaction virtual size as `int32`
7. Replacement transaction fee as `int64`
8. `bool` indicating if the argument 5. is a transaction ID or package hash (true if it's a transaction ID)

Note: In cases where a single replacement transaction replaces multiple
Note: In cases where a replacement transaction or package replaces multiple
existing transactions in the mempool, the tracepoint is called once for each
replaced transaction, with data of the replacement transaction being the same
in each call.
replaced transaction, with data of the replacement transaction or package
being the same in each call.

#### Tracepoint `mempool:rejected`

Expand Down
3 changes: 2 additions & 1 deletion src/bench/mempool_ephemeral_spends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <util/check.h>

Expand All @@ -28,7 +29,7 @@ static void AddTx(const CTransactionRef& tx, CTxMemPool& pool) EXCLUSIVE_LOCKS_R
unsigned int sigOpCost{4};
uint64_t fee{0};
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntry(
AddToMempool(pool, CTxMemPoolEntry(
tx, fee, nTime, nHeight, sequence,
spendsCoinbase, sigOpCost, lp));
}
Expand Down
3 changes: 2 additions & 1 deletion src/bench/mempool_eviction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <util/check.h>

Expand All @@ -26,7 +27,7 @@ static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& po
bool spendsCoinbase = false;
unsigned int sigOpCost = 4;
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntry(
AddToMempool(pool, CTxMemPoolEntry(
tx, nFee, nTime, nHeight, sequence,
spendsCoinbase, sigOpCost, lp));
}
Expand Down
3 changes: 2 additions & 1 deletion src/bench/mempool_stress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <validation.h>

Expand All @@ -28,7 +29,7 @@ static void AddTx(const CTransactionRef& tx, CTxMemPool& pool) EXCLUSIVE_LOCKS_R
bool spendsCoinbase = false;
unsigned int sigOpCost = 4;
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntry(tx, 1000, nTime, nHeight, sequence, spendsCoinbase, sigOpCost, lp));
AddToMempool(pool, CTxMemPoolEntry(tx, 1000, nTime, nHeight, sequence, spendsCoinbase, sigOpCost, lp));
}

struct Available {
Expand Down
3 changes: 2 additions & 1 deletion src/bench/rpc_mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <script/script.h>
#include <sync.h>
#include <test/util/setup_common.h>
#include <test/util/txmempool.h>
#include <txmempool.h>
#include <univalue.h>
#include <util/check.h>
Expand All @@ -21,7 +22,7 @@
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
{
LockPoints lp;
pool.addUnchecked(CTxMemPoolEntry(tx, fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
AddToMempool(pool, CTxMemPoolEntry(tx, fee, /*time=*/0, /*entry_height=*/1, /*entry_sequence=*/0, /*spends_coinbase=*/false, /*sigops_cost=*/4, lp));
}

static void RpcMempool(benchmark::Bench& bench)
Expand Down
19 changes: 10 additions & 9 deletions src/ipc/capnp/mining.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ interface Mining $Proxy.wrap("interfaces::Mining") {
}

interface BlockTemplate $Proxy.wrap("interfaces::BlockTemplate") {
getBlockHeader @0 (context: Proxy.Context) -> (result: Data);
getBlock @1 (context: Proxy.Context) -> (result: Data);
getTxFees @2 (context: Proxy.Context) -> (result: List(Int64));
getTxSigops @3 (context: Proxy.Context) -> (result: List(Int64));
getCoinbaseTx @4 (context: Proxy.Context) -> (result: Data);
getCoinbaseCommitment @5 (context: Proxy.Context) -> (result: Data);
getWitnessCommitmentIndex @6 (context: Proxy.Context) -> (result: Int32);
getCoinbaseMerklePath @7 (context: Proxy.Context) -> (result: List(Data));
submitSolution@8 (context: Proxy.Context, version: UInt32, timestamp: UInt32, nonce: UInt32, coinbase :Data) -> (result: Bool);
destroy @0 (context :Proxy.Context) -> ();
getBlockHeader @1 (context: Proxy.Context) -> (result: Data);
getBlock @2 (context: Proxy.Context) -> (result: Data);
getTxFees @3 (context: Proxy.Context) -> (result: List(Int64));
getTxSigops @4 (context: Proxy.Context) -> (result: List(Int64));
getCoinbaseTx @5 (context: Proxy.Context) -> (result: Data);
getCoinbaseCommitment @6 (context: Proxy.Context) -> (result: Data);
getWitnessCommitmentIndex @7 (context: Proxy.Context) -> (result: Int32);
getCoinbaseMerklePath @8 (context: Proxy.Context) -> (result: List(Data));
submitSolution @9 (context: Proxy.Context, version: UInt32, timestamp: UInt32, nonce: UInt32, coinbase :Data) -> (result: Bool);
}

struct BlockCreateOptions $Proxy.wrap("node::BlockCreateOptions") {
Expand Down
8 changes: 2 additions & 6 deletions src/policy/rbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,10 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,
return std::nullopt;
}

std::optional<std::pair<DiagramCheckError, std::string>> ImprovesFeerateDiagram(CTxMemPool& pool,
const CTxMemPool::setEntries& direct_conflicts,
const CTxMemPool::setEntries& all_conflicts,
CAmount replacement_fees,
int64_t replacement_vsize)
std::optional<std::pair<DiagramCheckError, std::string>> ImprovesFeerateDiagram(CTxMemPool::ChangeSet& changeset)
{
// Require that the replacement strictly improves the mempool's feerate diagram.
const auto chunk_results{pool.CalculateChunksForRBF(replacement_fees, replacement_vsize, direct_conflicts, all_conflicts)};
const auto chunk_results{changeset.CalculateChunksForRBF()};

if (!chunk_results.has_value()) {
return std::make_pair(DiagramCheckError::UNCALCULABLE, util::ErrorString(chunk_results).original);
Expand Down
14 changes: 2 additions & 12 deletions src/policy/rbf.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,9 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,

/**
* The replacement transaction must improve the feerate diagram of the mempool.
* @param[in] pool The mempool.
* @param[in] direct_conflicts Set of in-mempool txids corresponding to the direct conflicts i.e.
* input double-spends with the proposed transaction
* @param[in] all_conflicts Set of mempool entries corresponding to all transactions to be evicted
* @param[in] replacement_fees Fees of proposed replacement package
* @param[in] replacement_vsize Size of proposed replacement package
* @param[in] changeset The changeset containing proposed additions/removals
* @returns error type and string if mempool diagram doesn't improve, otherwise std::nullopt.
*/
std::optional<std::pair<DiagramCheckError, std::string>> ImprovesFeerateDiagram(CTxMemPool& pool,
const CTxMemPool::setEntries& direct_conflicts,
const CTxMemPool::setEntries& all_conflicts,
CAmount replacement_fees,
int64_t replacement_vsize)
EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
std::optional<std::pair<DiagramCheckError, std::string>> ImprovesFeerateDiagram(CTxMemPool::ChangeSet& changeset);

#endif // BITCOIN_POLICY_RBF_H
2 changes: 1 addition & 1 deletion src/test/auxpow_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ BOOST_FIXTURE_TEST_CASE (auxpow_miner_blockRegeneration, TestChain100Setup)
mtx.vout.emplace_back (1234, scriptPubKey);
{
LOCK2 (cs_main, m_node.mempool->cs);
m_node.mempool->addUnchecked (entry.FromTx (mtx));
AddToMempool (*m_node.mempool, entry.FromTx (mtx));
}

/* We should still get back the cached block, for now. */
Expand Down
8 changes: 4 additions & 4 deletions src/test/blockencodings_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
CBlock block(BuildBlockTestCase(rand_ctx));

LOCK2(cs_main, pool.cs);
pool.addUnchecked(entry.FromTx(block.vtx[2]));
AddToMempool(pool, entry.FromTx(block.vtx[2]));
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);

// Do a simple ShortTxIDs RT
Expand Down Expand Up @@ -157,7 +157,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
CBlock block(BuildBlockTestCase(rand_ctx));

LOCK2(cs_main, pool.cs);
pool.addUnchecked(entry.FromTx(block.vtx[2]));
AddToMempool(pool, entry.FromTx(block.vtx[2]));
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);

uint256 txhash;
Expand Down Expand Up @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
CBlock block(BuildBlockTestCase(rand_ctx));

LOCK2(cs_main, pool.cs);
pool.addUnchecked(entry.FromTx(block.vtx[1]));
AddToMempool(pool, entry.FromTx(block.vtx[1]));
BOOST_CHECK_EQUAL(pool.get(block.vtx[1]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);

uint256 txhash;
Expand Down Expand Up @@ -328,7 +328,7 @@ BOOST_AUTO_TEST_CASE(ReceiveWithExtraTransactions) {
extra_txn.resize(10);

LOCK2(cs_main, pool.cs);
pool.addUnchecked(entry.FromTx(block.vtx[2]));
AddToMempool(pool, entry.FromTx(block.vtx[2]));
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);
// Ensure the non_block_tx is actually not in the block
for (const auto &block_tx : block.vtx) {
Expand Down
5 changes: 4 additions & 1 deletion src/test/fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ add_executable(fuzz
tx_pool.cpp
txorphan.cpp
txrequest.cpp
utxo_snapshot.cpp
# Visual Studio 2022 version 17.12 introduced a bug
# that causes an internal compiler error.
# See: https://github.com/bitcoin/bitcoin/issues/31303
$<$<VERSION_LESS:${MSVC_VERSION},1942>:utxo_snapshot.cpp>
utxo_total_supply.cpp
validation_load_mempool.cpp
vecdeque.cpp
Expand Down
5 changes: 3 additions & 2 deletions src/test/fuzz/fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ __AFL_FUZZ_INIT();

const std::function<void(const std::string&)> G_TEST_LOG_FUN{};

const std::function<std::string()> G_TEST_GET_FULL_NAME{};

/**
* A copy of the command line arguments that start with `--`.
* First `LLVMFuzzerInitialize()` is called, which saves the arguments to `g_args`.
Expand Down Expand Up @@ -80,6 +78,9 @@ void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target,
static std::string_view g_fuzz_target;
static const TypeTestOneInput* g_test_one_input{nullptr};

const std::function<std::string()> G_TEST_GET_FULL_NAME{[]{
return std::string{g_fuzz_target};
}};

#if defined(__clang__) && defined(__linux__)
extern "C" void __llvm_profile_reset_counters(void) __attribute__((weak));
Expand Down
4 changes: 2 additions & 2 deletions src/test/fuzz/mini_miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ FUZZ_TARGET(mini_miner, .init = initialize_miner)
TestMemPoolEntryHelper entry;
const CAmount fee{ConsumeMoney(fuzzed_data_provider, /*max=*/MAX_MONEY/100000)};
assert(MoneyRange(fee));
pool.addUnchecked(entry.Fee(fee).FromTx(tx));
AddToMempool(pool, entry.Fee(fee).FromTx(tx));

// All outputs are available to spend
for (uint32_t n{0}; n < num_outputs; ++n) {
Expand Down Expand Up @@ -154,7 +154,7 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner)
TestMemPoolEntryHelper entry;
const CAmount fee{ConsumeMoney(fuzzed_data_provider, /*max=*/MAX_MONEY/100000)};
assert(MoneyRange(fee));
pool.addUnchecked(entry.Fee(fee).FromTx(tx));
AddToMempool(pool, entry.Fee(fee).FromTx(tx));
transactions.push_back(tx);
}
std::vector<COutPoint> outpoints;
Expand Down
Loading

0 comments on commit e2b4543

Please sign in to comment.