From 248b93dd9f7863ff382f1be2de4e3d40269efcba Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Fri, 1 Nov 2024 09:22:18 +0200 Subject: [PATCH 01/20] decodepsbt: add asset/assetcommitment to input.witness_utxo --- src/rpc/rawtransaction.cpp | 5 +++++ test/functional/rpc_psbt.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 1881bb12f7e..39494f32571 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1475,6 +1475,11 @@ static RPCHelpMan decodepsbt() } else { out.pushKV("amountcommitment", txout.nValue.GetHex()); } + if (txout.nAsset.IsExplicit()) { + out.pushKV("asset", txout.nAsset.GetAsset().GetHex()); + } else { + out.pushKV("assetcommitment", txout.nAsset.GetHex()); + } out.pushKV("scriptPubKey", o); in.pushKV("witness_utxo", out); diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 8aff333b42f..0365bc7d413 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -257,6 +257,10 @@ def run_basic_tests(self, confidential): decoded = self.nodes[1].decodepsbt(walletsignpsbt_out['psbt']) assert 'non_witness_utxo' in decoded['inputs'][0] assert 'witness_utxo' in decoded['inputs'][0] + if 'asset' in decoded['inputs'][0]['witness_utxo']: + assert_equal(decoded['inputs'][0]['witness_utxo']['asset'], 'b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23') + else: + assert 'assetcommitment' in decoded['inputs'][0]['witness_utxo'] # Check decodepsbt fee calculation (input values shall only be counted once per UTXO) #assert_equal(decoded['fee'], created_psbt['fee']) # ELEMENTS: we do not have this field. Should be fixed by #900 assert_equal(walletsignpsbt_out['complete'], True) From 86d740b5eb7b365648e8ee379819e1f8337cddc2 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 8 Feb 2025 16:05:13 +0000 Subject: [PATCH 02/20] fuzz: fix crash on null pointer in witness_program target --- src/test/fuzz/witness_program.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/fuzz/witness_program.cpp b/src/test/fuzz/witness_program.cpp index 04b0c96fda8..c6516b4f2ee 100644 --- a/src/test/fuzz/witness_program.cpp +++ b/src/test/fuzz/witness_program.cpp @@ -64,7 +64,7 @@ FUZZ_TARGET_INIT(witness_program, initialize_witness_program) if (fuzz_control & 1) { unsigned char hash_program[32]; - CSHA256().Write(&program[0], program.size()).Finalize(hash_program); + CSHA256().Write(program.data(), program.size()).Finalize(hash_program); CScript scriptPubKey = CScript{} << OP_0 << std::vector(hash_program, hash_program + sizeof(hash_program)); witness.stack.push_back(program); From f5ed4e4520550d43e84aacc828fef24fbfda8c92 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Mon, 10 Feb 2025 23:17:15 +0000 Subject: [PATCH 03/20] chain: make some integer conversions explicit We have an unsigned constant which we're bit-inverting, or'ing into a signed constant, then assigning back to the signed constant. We should make it explicit wth is going on here. --- src/chain.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chain.h b/src/chain.h index 119b3683a3b..6e023158d12 100644 --- a/src/chain.h +++ b/src/chain.h @@ -469,7 +469,7 @@ class CDiskBlockIndex : public CBlockIndex bool RemoveDynaFedMaskOnSerialize(bool for_read) { if (for_read) { bool is_dyna = nVersion < 0; - nVersion = ~CBlockHeader::DYNAFED_HF_MASK & nVersion; + nVersion = (int32_t) (~CBlockHeader::DYNAFED_HF_MASK & (uint32_t)nVersion); return is_dyna; } else { return is_dynafed_block(); From bd4ae1bcc405c3496c85c3af16c81a0768f82392 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 11 Feb 2025 00:12:35 +0000 Subject: [PATCH 04/20] rpc: fix crash in getcompactsketch This originates in 8723debb3d1f281f26bdc456868f3daaf7c6aa5a which has no PR associated with it. We've really gotta stop putting thousands of unreviewed commits into this project and rebasing the history away.. --- src/rpc/mining.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 193f2f5a757..dd5ae4af44b 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1527,6 +1527,10 @@ static RPCHelpMan getcompactsketch() CDataStream ssBlock(block_bytes, SER_NETWORK, PROTOCOL_VERSION); ssBlock >> block; + if (block.vtx.empty()) { + throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Cannot obtain sketch of empty block."); + } + CBlockHeaderAndShortTxIDs cmpctblock(block, true); CDataStream ssCompactBlock(SER_NETWORK, PROTOCOL_VERSION); From 3e46754507af7acce2c1cc49fa7c2ecbf2efb496 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 21 Mar 2022 11:37:17 +0100 Subject: [PATCH 05/20] Replace struct update_fee_delta with lambda Cherry-pick of https://github.com/bitcoin/bitcoin/pull/24625 (1/2) --- src/txmempool.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f84ffe4d232..5a737184e95 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -60,16 +60,6 @@ struct update_ancestor_state int64_t discountSize; }; -struct update_fee_delta -{ - explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { } - - void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); } - -private: - int64_t feeDelta; -}; - bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp) { AssertLockHeld(cs_main); @@ -520,7 +510,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces CAmount delta{0}; ApplyDelta(entry.GetTx().GetHash(), delta); if (delta) { - mapTx.modify(newit, update_fee_delta(delta)); + mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); } // Update cachedInnerUsage to include contained transaction's usage. @@ -1027,7 +1017,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD delta += nFeeDelta; txiter it = mapTx.find(hash); if (it != mapTx.end()) { - mapTx.modify(it, update_fee_delta(delta)); + mapTx.modify(it, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); // Now update all ancestors' modified fees with descendants setEntries setAncestors; uint64_t nNoLimit = std::numeric_limits::max(); From 371718bc99b6958c7a07954900c67c5859d98ff2 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 21 Mar 2022 11:57:21 +0100 Subject: [PATCH 06/20] Use CAmount for fee delta and modified fee Cherry-pick of fa84a49526fcf76e98b0b2f4d4b00b34a8dddf46 https://github.com/bitcoin/bitcoin/pull/24625 (2/2) --- src/node/miner.h | 2 +- src/txmempool.cpp | 2 +- src/txmempool.h | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node/miner.h b/src/node/miner.h index b0b48e375af..4fb31a859a1 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -46,7 +46,7 @@ struct CTxMemPoolModifiedEntry { nSigOpCostWithAncestors = entry->GetSigOpCostWithAncestors(); } - int64_t GetModifiedFee() const { return iter->GetModifiedFee(); } + CAmount GetModifiedFee() const { return iter->GetModifiedFee(); } uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; } uint64_t GetDiscountSizeWithAncestors() const { return discountSizeWithAncestors; } CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; } diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 5a737184e95..14bba2e4caf 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -98,7 +98,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee, discountSizeWithAncestors{GetDiscountTxSize()}, setPeginsSpent(_setPeginsSpent) {} -void CTxMemPoolEntry::UpdateFeeDelta(int64_t newFeeDelta) +void CTxMemPoolEntry::UpdateFeeDelta(CAmount newFeeDelta) { nModFeesWithDescendants += newFeeDelta - feeDelta; nModFeesWithAncestors += newFeeDelta - feeDelta; diff --git a/src/txmempool.h b/src/txmempool.h index edfe7be1ad2..e6e3afca5ab 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -102,7 +102,7 @@ class CTxMemPoolEntry const unsigned int entryHeight; //!< Chain height when entering the mempool const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase const int64_t sigOpCost; //!< Total sigop cost - int64_t feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block + CAmount feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block LockPoints lockPoints; //!< Track the height and time at which tx was final // Information about descendants of this transaction that are in the @@ -135,7 +135,7 @@ class CTxMemPoolEntry std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; } unsigned int GetHeight() const { return entryHeight; } int64_t GetSigOpCost() const { return sigOpCost; } - int64_t GetModifiedFee() const { return nFee + feeDelta; } + CAmount GetModifiedFee() const { return nFee + feeDelta; } size_t DynamicMemoryUsage() const { return nUsageSize; } const LockPoints& GetLockPoints() const { return lockPoints; } @@ -144,8 +144,8 @@ class CTxMemPoolEntry // Adjusts the ancestor state void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps, int64_t discountSize); // Updates the fee delta used for mining priority score, and the - // modified fees with descendants. - void UpdateFeeDelta(int64_t feeDelta); + // modified fees with descendants/ancestors. + void UpdateFeeDelta(CAmount newFeeDelta); // Update the LockPoints after a reorg void UpdateLockPoints(const LockPoints& lp); From b90ef387277d36070337b4f1ca088179414840e7 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 11 Feb 2025 03:00:36 +0000 Subject: [PATCH 07/20] ubsan: add suppression for simplicity --- test/sanitizer_suppressions/ubsan | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index 682ec7f60bc..a4f7f9822f9 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -81,3 +81,5 @@ implicit-integer-sign-change:primitives/confidential.cpp implicit-integer-sign-change:primitives/confidential.h shift-base:simplicity/sha256.c unsigned-integer-overflow:simplicity/sha256.c +# See comment in simplicity/primitive/elements/env.c line 303 +unsigned-integer-overflow:simplicity/primitive/elements/env.c From 363c5101c235d700a92f8963b44118b6edc813e6 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 11 Feb 2025 02:38:45 +0000 Subject: [PATCH 08/20] fuzz: change int to unsigned in witness_program Avoids a signed/unsigned integer conversion. --- src/test/fuzz/witness_program.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/fuzz/witness_program.cpp b/src/test/fuzz/witness_program.cpp index c6516b4f2ee..8cbabfd1d92 100644 --- a/src/test/fuzz/witness_program.cpp +++ b/src/test/fuzz/witness_program.cpp @@ -45,7 +45,7 @@ FUZZ_TARGET_INIT(witness_program, initialize_witness_program) CScriptWitness witness; int fuzz_control; - int flags; + unsigned flags; ds >> fuzz_control; ds >> witness.stack; ds >> flags; From 6043ab449ec0e815e742215c33b766427174ae75 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 2 Nov 2021 17:27:49 +0100 Subject: [PATCH 09/20] refactor: Replace feeDelta by m_modified_fee * feeDelta tracked the delta (to be applied on top of the actual fee) * m_modified_fee tracks the actual fee with the delta included * Instead of passing in the new total delta to the Updater, pass in by how much the total delta should be modified. This is needed for the next commit, but makes sense on its own because the same is done by UpdateDescendantState and UpdateAncestorState. Cherry-pick of fa52cf8e11b3af6e0a302d5d17aab6cea78899d5 https://github.com/bitcoin/bitcoin/pull/23418 (1/2) --- src/txmempool.cpp | 16 ++++++++++------ src/txmempool.h | 9 ++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 14bba2e4caf..145d58a127c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee, entryHeight{entry_height}, spendsCoinbase{spends_coinbase}, sigOpCost{sigops_cost}, + m_modified_fee{nFee}, lockPoints{lp}, nSizeWithDescendants{GetTxSize()}, nModFeesWithDescendants{nFee}, @@ -98,11 +100,11 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee, discountSizeWithAncestors{GetDiscountTxSize()}, setPeginsSpent(_setPeginsSpent) {} -void CTxMemPoolEntry::UpdateFeeDelta(CAmount newFeeDelta) +void CTxMemPoolEntry::UpdateModifiedFee(CAmount fee_diff) { - nModFeesWithDescendants += newFeeDelta - feeDelta; - nModFeesWithAncestors += newFeeDelta - feeDelta; - feeDelta = newFeeDelta; + nModFeesWithDescendants += fee_diff; + nModFeesWithAncestors += fee_diff; + m_modified_fee += fee_diff; } void CTxMemPoolEntry::UpdateLockPoints(const LockPoints& lp) @@ -509,8 +511,10 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces // into mapTx. CAmount delta{0}; ApplyDelta(entry.GetTx().GetHash(), delta); + // The following call to UpdateModifiedFee assumes no previous fee modifications + Assume(entry.GetFee() == entry.GetModifiedFee()); if (delta) { - mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); + mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); }); } // Update cachedInnerUsage to include contained transaction's usage. @@ -1017,7 +1021,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD delta += nFeeDelta; txiter it = mapTx.find(hash); if (it != mapTx.end()) { - mapTx.modify(it, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); + mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); }); // Now update all ancestors' modified fees with descendants setEntries setAncestors; uint64_t nNoLimit = std::numeric_limits::max(); diff --git a/src/txmempool.h b/src/txmempool.h index e6e3afca5ab..f93ae20919d 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -102,7 +102,7 @@ class CTxMemPoolEntry const unsigned int entryHeight; //!< Chain height when entering the mempool const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase const int64_t sigOpCost; //!< Total sigop cost - CAmount feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block + CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block LockPoints lockPoints; //!< Track the height and time at which tx was final // Information about descendants of this transaction that are in the @@ -135,7 +135,7 @@ class CTxMemPoolEntry std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; } unsigned int GetHeight() const { return entryHeight; } int64_t GetSigOpCost() const { return sigOpCost; } - CAmount GetModifiedFee() const { return nFee + feeDelta; } + CAmount GetModifiedFee() const { return m_modified_fee; } size_t DynamicMemoryUsage() const { return nUsageSize; } const LockPoints& GetLockPoints() const { return lockPoints; } @@ -143,9 +143,8 @@ class CTxMemPoolEntry void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount); // Adjusts the ancestor state void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps, int64_t discountSize); - // Updates the fee delta used for mining priority score, and the - // modified fees with descendants/ancestors. - void UpdateFeeDelta(CAmount newFeeDelta); + // Updates the modified fees with descendants/ancestors. + void UpdateModifiedFee(CAmount fee_diff); // Update the LockPoints after a reorg void UpdateLockPoints(const LockPoints& lp); From 56eec70de45a1437d360b47cfa316a05dd715929 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 2 Nov 2021 21:59:39 +0100 Subject: [PATCH 10/20] Fix signed integer overflow in prioritisetransaction RPC Cherry-pick of fa52cf8e11b3af6e0a302d5d17aab6cea78899d5 https://github.com/bitcoin/bitcoin/pull/23418 (2/2) --- src/txmempool.cpp | 13 +++++++------ test/sanitizer_suppressions/ubsan | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 145d58a127c..579259c7a47 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -102,9 +103,9 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee, void CTxMemPoolEntry::UpdateModifiedFee(CAmount fee_diff) { - nModFeesWithDescendants += fee_diff; - nModFeesWithAncestors += fee_diff; - m_modified_fee += fee_diff; + nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, fee_diff); + nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, fee_diff); + m_modified_fee = SaturatingAdd(m_modified_fee, fee_diff); } void CTxMemPoolEntry::UpdateLockPoints(const LockPoints& lp) @@ -459,7 +460,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe { nSizeWithDescendants += modifySize; assert(int64_t(nSizeWithDescendants) > 0); - nModFeesWithDescendants += modifyFee; + nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, modifyFee); nCountWithDescendants += modifyCount; assert(int64_t(nCountWithDescendants) > 0); } @@ -468,7 +469,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee, { nSizeWithAncestors += modifySize; assert(int64_t(nSizeWithAncestors) > 0); - nModFeesWithAncestors += modifyFee; + nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, modifyFee); nCountWithAncestors += modifyCount; assert(int64_t(nCountWithAncestors) > 0); nSigOpCostWithAncestors += modifySigOps; @@ -1018,7 +1019,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD { LOCK(cs); CAmount &delta = mapDeltas[hash]; - delta += nFeeDelta; + delta = SaturatingAdd(delta, nFeeDelta); txiter it = mapTx.find(hash); if (it != mapTx.end()) { mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); }); diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index a4f7f9822f9..5a12a9341c8 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -1,10 +1,10 @@ # -fsanitize=undefined suppressions # ================================= -# This would be `signed-integer-overflow:CTxMemPool::PrioritiseTransaction`, +# The suppressions would be `sanitize-type:ClassName::MethodName`, # however due to a bug in clang the symbolizer is disabled and thus no symbol # names can be used. # See https://github.com/google/sanitizers/issues/1364 -signed-integer-overflow:txmempool.cpp + # https://github.com/bitcoin/bitcoin/pull/21798#issuecomment-829180719 signed-integer-overflow:policy/feerate.cpp From 8a1500c63eddc22ae06b6e0dee9a9ac2e6a45fb2 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 10 Mar 2022 12:35:39 +0100 Subject: [PATCH 11/20] build: Fix Boost.Process detection on macOS arm64 Could be tested as follows: ``` % brew install boost@1.76 % ./autogen.sh % ./configure --with-boost='/opt/homebrew/opt/boost@1.76' ``` (cherry picked from commit 1d4157a42b77411579eb721b5c6fb533a357959d) --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index bb407ad850d..19c09d11121 100644 --- a/configure.ac +++ b/configure.ac @@ -1458,6 +1458,8 @@ if test "$use_external_signer" != "no"; then ;; *) AC_MSG_CHECKING([whether Boost.Process can be used]) + TEMP_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" TEMP_LDFLAGS="$LDFLAGS" dnl Boost 1.73 and older require the following workaround. LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS" @@ -1465,6 +1467,7 @@ if test "$use_external_signer" != "no"; then [have_boost_process="yes"], [have_boost_process="no"]) LDFLAGS="$TEMP_LDFLAGS" + CPPFLAGS="$TEMP_CPPFLAGS" AC_MSG_RESULT([$have_boost_process]) if test "$have_boost_process" = "yes"; then use_external_signer="yes" From f8b1bb70709490e3c420533c6857222e69e7157d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 22 Feb 2022 12:20:48 +0200 Subject: [PATCH 12/20] build: Fix Boost.Process test for Boost 1.78 (cherry picked from commit 532c64a7264dd3c7329e8839547837c57da7dbe8) --- configure.ac | 5 +++++ src/test/system_tests.cpp | 9 +++++++++ src/util/system.cpp | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/configure.ac b/configure.ac index 19c09d11121..e8ddab7d797 100644 --- a/configure.ac +++ b/configure.ac @@ -1458,6 +1458,10 @@ if test "$use_external_signer" != "no"; then ;; *) AC_MSG_CHECKING([whether Boost.Process can be used]) + TEMP_CXXFLAGS="$CXXFLAGS" + dnl Boost 1.78 requires the following workaround. + dnl See: https://github.com/boostorg/process/issues/235 + CXXFLAGS="$CXXFLAGS -Wno-error=narrowing" TEMP_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" TEMP_LDFLAGS="$LDFLAGS" @@ -1468,6 +1472,7 @@ if test "$use_external_signer" != "no"; then [have_boost_process="no"]) LDFLAGS="$TEMP_LDFLAGS" CPPFLAGS="$TEMP_CPPFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" AC_MSG_RESULT([$have_boost_process]) if test "$have_boost_process" = "yes"; then use_external_signer="yes" diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp index 9c6950f11f9..3f5353b5a2b 100644 --- a/src/test/system_tests.cpp +++ b/src/test/system_tests.cpp @@ -12,7 +12,16 @@ // For details see https://github.com/bitcoin/bitcoin/pull/22348. #define __kernel_entry #endif +#if defined(__GNUC__) +// Boost 1.78 requires the following workaround. +// See: https://github.com/boostorg/process/issues/235 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnarrowing" +#endif #include +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif #endif // ENABLE_EXTERNAL_SIGNER #include diff --git a/src/util/system.cpp b/src/util/system.cpp index e7a81da87f5..8ae29e23c4e 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -6,7 +6,16 @@ #include #ifdef ENABLE_EXTERNAL_SIGNER +#if defined(__GNUC__) +// Boost 1.78 requires the following workaround. +// See: https://github.com/boostorg/process/issues/235 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnarrowing" +#endif #include +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif #endif // ENABLE_EXTERNAL_SIGNER #include From f64aa1e6c637d7718072036f539f51118c0f39ce Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 19 Jan 2023 19:35:43 +0100 Subject: [PATCH 13/20] Add missing includes to fix gcc-13 compile error (cherry picked from commit fadeb6b103cb441e0e91ef506ef29febabb10715) --- src/support/lockedpool.cpp | 3 +++ src/support/lockedpool.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 6965f402536..2ad3161563f 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -22,6 +22,9 @@ #endif #include +#include +#include +#include #ifdef ARENA_DEBUG #include #include diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index 03e4e371a3a..66fbc218abf 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -5,11 +5,11 @@ #ifndef BITCOIN_SUPPORT_LOCKEDPOOL_H #define BITCOIN_SUPPORT_LOCKEDPOOL_H -#include +#include #include #include -#include #include +#include #include /** From 8251fc8162909569eb573eff0f873da9c5b5a836 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 20 Jan 2023 11:55:29 +0000 Subject: [PATCH 14/20] 23.x Add missing includes to fix gcc-13 compile error Additional include fixes are required to make the 23.x branch compile using GCC 13. (cherry picked from commit af862661654966d5de614755ab9bd1b5913e0959) --- src/util/bip32.h | 1 + src/util/string.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/util/bip32.h b/src/util/bip32.h index 8f86f2aaa64..b1d53616a4f 100644 --- a/src/util/bip32.h +++ b/src/util/bip32.h @@ -6,6 +6,7 @@ #define BITCOIN_UTIL_BIP32_H #include +#include #include #include diff --git a/src/util/string.h b/src/util/string.h index a3b8df8d78e..5f4859f1d79 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include From b703da11488a57f00ef58f0d363fd61317f8e006 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Tue, 11 Feb 2025 05:31:08 -0800 Subject: [PATCH 15/20] Fix build with gcc-15 --- src/chainparamsbase.h | 1 + src/node/ui_interface.h | 3 ++- src/zmq/zmqabstractnotifier.h | 1 + src/zmq/zmqpublishnotifier.h | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index 5ba4677ef3e..2ebf859d729 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_CHAINPARAMSBASE_H #define BITCOIN_CHAINPARAMSBASE_H +#include #include #include diff --git a/src/node/ui_interface.h b/src/node/ui_interface.h index d02238b549f..1a4efa4f24c 100644 --- a/src/node/ui_interface.h +++ b/src/node/ui_interface.h @@ -6,9 +6,10 @@ #ifndef BITCOIN_NODE_UI_INTERFACE_H #define BITCOIN_NODE_UI_INTERFACE_H +#include #include -#include #include +#include class CBlockIndex; enum class SynchronizationState; diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h index fa3944e32be..d29eaef9f39 100644 --- a/src/zmq/zmqabstractnotifier.h +++ b/src/zmq/zmqabstractnotifier.h @@ -6,6 +6,7 @@ #define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H +#include #include #include diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h index c1d66bddb1f..5a5ae6b3199 100644 --- a/src/zmq/zmqpublishnotifier.h +++ b/src/zmq/zmqpublishnotifier.h @@ -7,6 +7,8 @@ #include +#include + class CBlockIndex; class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier From 276e405ab01f0271e8716979fa3ecb1689d10db9 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Tue, 11 Feb 2025 05:29:42 -0800 Subject: [PATCH 16/20] CI: Cirrus: Avoid using -j3 in some jobs when elements has -j3 as the global limit --- .cirrus.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 2a289cdb461..11660b5006f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -224,7 +224,6 @@ task: env: << : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV FILE_ENV: "./ci/test/00_setup_env_native_msan.sh" - MAKEJOBS: "-j4" # Avoid excessive memory use due to MSan task: name: '[ASan + LSan + UBSan + integer, no depends] [jammy]' @@ -236,7 +235,6 @@ task: env: << : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV FILE_ENV: "./ci/test/00_setup_env_native_asan.sh" - MAKEJOBS: "-j4" # Avoid excessive memory use task: name: '[fuzzer,address,undefined,integer, no depends] [jammy]' From 04b114c148c7f86fdf1efefd6083a7f0ab081516 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Tue, 11 Feb 2025 05:30:13 -0800 Subject: [PATCH 17/20] CI: Cirrus: use -j2 in TSan to stabilize --- .cirrus.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.cirrus.yml b/.cirrus.yml index 11660b5006f..a91a82600bd 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -215,6 +215,7 @@ task: env: << : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV FILE_ENV: "./ci/test/00_setup_env_native_tsan.sh" + MAKEJOBS: "-j2" # Avoid excessive memory use due to MSan task: name: '[MSan, depends] [focal]' From 20f04f1584064df86dc18be83b5f2916d361a456 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Tue, 11 Feb 2025 06:17:21 -0800 Subject: [PATCH 18/20] Revert "ubsan: add suppression for simplicity" This reverts commit b90ef387277d36070337b4f1ca088179414840e7. --- test/sanitizer_suppressions/ubsan | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index 5a12a9341c8..c085942c864 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -81,5 +81,3 @@ implicit-integer-sign-change:primitives/confidential.cpp implicit-integer-sign-change:primitives/confidential.h shift-base:simplicity/sha256.c unsigned-integer-overflow:simplicity/sha256.c -# See comment in simplicity/primitive/elements/env.c line 303 -unsigned-integer-overflow:simplicity/primitive/elements/env.c From f1b445c903765460de5f81bdc40da2fe34e90e07 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Mon, 10 Feb 2025 20:47:40 -0800 Subject: [PATCH 19/20] Reapply "Merge pull request #1391 from apoelstra/2025-02--misc-fuzz-fixes" This reverts commit acbb8b595f61201f676597851b10bc04d6a9cdea. --- src/primitives/confidential.h | 5 +++++ src/primitives/transaction.h | 3 +++ src/test/fuzz/rbf.cpp | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/primitives/confidential.h b/src/primitives/confidential.h index a85703cca04..12d72f52c77 100644 --- a/src/primitives/confidential.h +++ b/src/primitives/confidential.h @@ -135,6 +135,11 @@ class CConfidentialValue : public CConfidentialCommitment<9, 8, 9> CConfidentialValue() { SetNull(); } CConfidentialValue(CAmount nAmount) { SetToAmount(nAmount); } + template + inline void Unserialize(Stream& s) { + CConfidentialCommitment::Unserialize(s); + } + /* An explicit value is called an amount. The first byte indicates it is * an explicit value, and the remaining 8 bytes is the value serialized as * a 64-bit big-endian integer. */ diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 6b7ecaf69ff..00f509454bb 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -295,6 +295,9 @@ class CTxOut s >> nAsset; s >> nValue; s >> nNonce; + if (nAsset.IsNull() || nValue.IsNull()) { + throw std::ios_base::failure("Confidential values may not be null"); + } } else { CAmount value; s >> value; diff --git a/src/test/fuzz/rbf.cpp b/src/test/fuzz/rbf.cpp index 8dcaa609b54..a3828b51f80 100644 --- a/src/test/fuzz/rbf.cpp +++ b/src/test/fuzz/rbf.cpp @@ -15,7 +15,13 @@ #include #include -FUZZ_TARGET(rbf) +void initialize_rbf(void) { + // ELEMENTS: our mempool needs Params() to be set for multiple reasons -- to check + // the discount CT rate, to figure out pegin policy, etc + SelectParams(CBaseChainParams::LIQUID1); +} + +FUZZ_TARGET_INIT(rbf, initialize_rbf) { FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); SetMockTime(ConsumeTime(fuzzed_data_provider)); From 42554a47e63a8a72f67577d83ac92265f82d6f93 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Tue, 11 Feb 2025 08:22:24 -0800 Subject: [PATCH 20/20] Bump version to 23.2.7-rc2 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index bf8322e26d5..2705d258a09 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.69]) define(_CLIENT_VERSION_MAJOR, 23) define(_CLIENT_VERSION_MINOR, 2) define(_CLIENT_VERSION_BUILD, 7) -define(_CLIENT_VERSION_RC, 1) +define(_CLIENT_VERSION_RC, 2) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2025) define(_COPYRIGHT_HOLDERS,[The %s developers])