Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare 23.2.7 rc2 #1405

Merged
merged 25 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
248b93d
decodepsbt: add asset/assetcommitment to input.witness_utxo
delta1 Nov 1, 2024
86d740b
fuzz: fix crash on null pointer in witness_program target
apoelstra Feb 8, 2025
f5ed4e4
chain: make some integer conversions explicit
apoelstra Feb 10, 2025
bd4ae1b
rpc: fix crash in getcompactsketch
apoelstra Feb 11, 2025
3e46754
Replace struct update_fee_delta with lambda
Mar 21, 2022
371718b
Use CAmount for fee delta and modified fee
Mar 21, 2022
b90ef38
ubsan: add suppression for simplicity
apoelstra Feb 11, 2025
363c510
fuzz: change int to unsigned in witness_program
apoelstra Feb 11, 2025
22089ac
Merge pull request #1372 from delta1/issues-1371
delta1 Feb 11, 2025
99c2ee7
Merge pull request #1399 from apoelstra/2025-02--fuzz-fixes
delta1 Feb 11, 2025
6043ab4
refactor: Replace feeDelta by m_modified_fee
Nov 2, 2021
56eec70
Fix signed integer overflow in prioritisetransaction RPC
Nov 2, 2021
8a1500c
build: Fix Boost.Process detection on macOS arm64
hebasto Mar 10, 2022
f8b1bb7
build: Fix Boost.Process test for Boost 1.78
hebasto Feb 22, 2022
f64aa1e
Add missing includes to fix gcc-13 compile error
Jan 19, 2023
8251fc8
23.x Add missing includes to fix gcc-13 compile error
fanquake Jan 20, 2023
b703da1
Fix build with gcc-15
psgreco Feb 11, 2025
276e405
CI: Cirrus: Avoid using -j3 in some jobs when elements has -j3 as the…
psgreco Feb 11, 2025
04b114c
CI: Cirrus: use -j2 in TSan to stabilize
psgreco Feb 11, 2025
d7efd31
Merge pull request #1400 from psgreco/master-fixbuild
delta1 Feb 11, 2025
d020546
Merge pull request #1401 from apoelstra/2025-02--fuzz-fixes-2
delta1 Feb 11, 2025
20f04f1
Revert "ubsan: add suppression for simplicity"
psgreco Feb 11, 2025
f1b445c
Reapply "Merge pull request #1391 from apoelstra/2025-02--misc-fuzz-f…
psgreco Feb 11, 2025
e6672a4
Merge branch 'master-nosimplicity' into elem-23.2.7rc2
psgreco Feb 11, 2025
42554a4
Bump version to 23.2.7-rc2
psgreco Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,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]'
Expand All @@ -232,7 +233,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]'
Expand All @@ -244,7 +244,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]'
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/chainparamsbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef BITCOIN_CHAINPARAMSBASE_H
#define BITCOIN_CHAINPARAMSBASE_H

#include <cstdint>
#include <memory>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion src/node/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 2 additions & 1 deletion src/node/ui_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#ifndef BITCOIN_NODE_UI_INTERFACE_H
#define BITCOIN_NODE_UI_INTERFACE_H

#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <vector>

class CBlockIndex;
enum class SynchronizationState;
Expand Down
5 changes: 5 additions & 0 deletions src/primitives/confidential.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class CConfidentialValue : public CConfidentialCommitment<9, 8, 9>
CConfidentialValue() { SetNull(); }
CConfidentialValue(CAmount nAmount) { SetToAmount(nAmount); }

template <typename Stream>
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. */
Expand Down
3 changes: 3 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,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);
Expand Down
8 changes: 7 additions & 1 deletion src/test/fuzz/rbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
#include <string>
#include <vector>

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));
Expand Down
4 changes: 2 additions & 2 deletions src/test/fuzz/witness_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<unsigned char>(hash_program, hash_program + sizeof(hash_program));
witness.stack.push_back(program);

Expand Down
33 changes: 14 additions & 19 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#include <policy/policy.h>
#include <policy/settings.h>
#include <reverse_iterator.h>
#include <util/check.h>
#include <util/moneystr.h>
#include <util/overflow.h>
#include <util/system.h>
#include <util/time.h>
#include <validationinterface.h>
Expand Down Expand Up @@ -60,16 +62,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);
Expand Down Expand Up @@ -99,6 +91,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},
Expand All @@ -108,11 +101,11 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
discountSizeWithAncestors{GetDiscountTxSize()},
setPeginsSpent(_setPeginsSpent) {}

void CTxMemPoolEntry::UpdateFeeDelta(int64_t newFeeDelta)
void CTxMemPoolEntry::UpdateModifiedFee(CAmount fee_diff)
{
nModFeesWithDescendants += newFeeDelta - feeDelta;
nModFeesWithAncestors += newFeeDelta - feeDelta;
feeDelta = newFeeDelta;
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)
Expand Down Expand Up @@ -467,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);
}
Expand All @@ -476,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;
Expand Down Expand Up @@ -519,8 +512,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, update_fee_delta(delta));
mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
}

// Update cachedInnerUsage to include contained transaction's usage.
Expand Down Expand Up @@ -1029,10 +1024,10 @@ 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, update_fee_delta(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<uint64_t>::max();
Expand Down
9 changes: 4 additions & 5 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
Expand Down Expand Up @@ -135,17 +135,16 @@ 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 m_modified_fee; }
size_t DynamicMemoryUsage() const { return nUsageSize; }
const LockPoints& GetLockPoints() const { return lockPoints; }

// Adjusts the descendant state.
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.
void UpdateFeeDelta(int64_t feeDelta);
// Updates the modified fees with descendants/ancestors.
void UpdateModifiedFee(CAmount fee_diff);
// Update the LockPoints after a reorg
void UpdateLockPoints(const LockPoints& lp);

Expand Down
1 change: 1 addition & 0 deletions src/zmq/zmqabstractnotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H


#include <cstdint>
#include <memory>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions src/zmq/zmqpublishnotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <zmq/zmqabstractnotifier.h>

#include <cstdint>

class CBlockIndex;

class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier
Expand Down
4 changes: 4 additions & 0 deletions test/functional/rpc_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,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)
Expand Down
4 changes: 2 additions & 2 deletions test/sanitizer_suppressions/ubsan
Original file line number Diff line number Diff line change
@@ -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

Expand Down