Skip to content

Commit 71a1be1

Browse files
authored
Merge pull request #1405 from psgreco/elem-23.2.7rc2
Prepare 23.2.7 rc2
2 parents 58113a8 + 42554a4 commit 71a1be1

File tree

18 files changed

+60
-35
lines changed

18 files changed

+60
-35
lines changed

.cirrus.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ task:
223223
env:
224224
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
225225
FILE_ENV: "./ci/test/00_setup_env_native_tsan.sh"
226+
MAKEJOBS: "-j2" # Avoid excessive memory use due to MSan
226227

227228
task:
228229
name: '[MSan, depends] [focal]'
@@ -232,7 +233,6 @@ task:
232233
env:
233234
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
234235
FILE_ENV: "./ci/test/00_setup_env_native_msan.sh"
235-
MAKEJOBS: "-j4" # Avoid excessive memory use due to MSan
236236

237237
task:
238238
name: '[ASan + LSan + UBSan + integer, no depends] [jammy]'
@@ -244,7 +244,6 @@ task:
244244
env:
245245
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
246246
FILE_ENV: "./ci/test/00_setup_env_native_asan.sh"
247-
MAKEJOBS: "-j4" # Avoid excessive memory use
248247

249248
task:
250249
name: '[fuzzer,address,undefined,integer, no depends] [jammy]'

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AC_PREREQ([2.69])
22
define(_CLIENT_VERSION_MAJOR, 23)
33
define(_CLIENT_VERSION_MINOR, 2)
44
define(_CLIENT_VERSION_BUILD, 7)
5-
define(_CLIENT_VERSION_RC, 1)
5+
define(_CLIENT_VERSION_RC, 2)
66
define(_CLIENT_VERSION_IS_RELEASE, true)
77
define(_COPYRIGHT_YEAR, 2025)
88
define(_COPYRIGHT_HOLDERS,[The %s developers])

src/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class CDiskBlockIndex : public CBlockIndex
469469
bool RemoveDynaFedMaskOnSerialize(bool for_read) {
470470
if (for_read) {
471471
bool is_dyna = nVersion < 0;
472-
nVersion = ~CBlockHeader::DYNAFED_HF_MASK & nVersion;
472+
nVersion = (int32_t) (~CBlockHeader::DYNAFED_HF_MASK & (uint32_t)nVersion);
473473
return is_dyna;
474474
} else {
475475
return is_dynafed_block();

src/chainparamsbase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef BITCOIN_CHAINPARAMSBASE_H
66
#define BITCOIN_CHAINPARAMSBASE_H
77

8+
#include <cstdint>
89
#include <memory>
910
#include <string>
1011

src/node/miner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct CTxMemPoolModifiedEntry {
4646
nSigOpCostWithAncestors = entry->GetSigOpCostWithAncestors();
4747
}
4848

49-
int64_t GetModifiedFee() const { return iter->GetModifiedFee(); }
49+
CAmount GetModifiedFee() const { return iter->GetModifiedFee(); }
5050
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
5151
uint64_t GetDiscountSizeWithAncestors() const { return discountSizeWithAncestors; }
5252
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }

src/node/ui_interface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
#ifndef BITCOIN_NODE_UI_INTERFACE_H
77
#define BITCOIN_NODE_UI_INTERFACE_H
88

9+
#include <cstdint>
910
#include <functional>
10-
#include <memory>
1111
#include <string>
12+
#include <vector>
1213

1314
class CBlockIndex;
1415
enum class SynchronizationState;

src/primitives/confidential.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ class CConfidentialValue : public CConfidentialCommitment<9, 8, 9>
135135
CConfidentialValue() { SetNull(); }
136136
CConfidentialValue(CAmount nAmount) { SetToAmount(nAmount); }
137137

138+
template <typename Stream>
139+
inline void Unserialize(Stream& s) {
140+
CConfidentialCommitment::Unserialize(s);
141+
}
142+
138143
/* An explicit value is called an amount. The first byte indicates it is
139144
* an explicit value, and the remaining 8 bytes is the value serialized as
140145
* a 64-bit big-endian integer. */

src/primitives/transaction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ class CTxOut
295295
s >> nAsset;
296296
s >> nValue;
297297
s >> nNonce;
298+
if (nAsset.IsNull() || nValue.IsNull()) {
299+
throw std::ios_base::failure("Confidential values may not be null");
300+
}
298301
} else {
299302
CAmount value;
300303
s >> value;

src/rpc/mining.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,10 @@ static RPCHelpMan getcompactsketch()
15271527
CDataStream ssBlock(block_bytes, SER_NETWORK, PROTOCOL_VERSION);
15281528
ssBlock >> block;
15291529

1530+
if (block.vtx.empty()) {
1531+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Cannot obtain sketch of empty block.");
1532+
}
1533+
15301534
CBlockHeaderAndShortTxIDs cmpctblock(block, true);
15311535

15321536
CDataStream ssCompactBlock(SER_NETWORK, PROTOCOL_VERSION);

src/rpc/rawtransaction.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,11 @@ static RPCHelpMan decodepsbt()
14761476
} else {
14771477
out.pushKV("amountcommitment", txout.nValue.GetHex());
14781478
}
1479+
if (txout.nAsset.IsExplicit()) {
1480+
out.pushKV("asset", txout.nAsset.GetAsset().GetHex());
1481+
} else {
1482+
out.pushKV("assetcommitment", txout.nAsset.GetHex());
1483+
}
14791484
out.pushKV("scriptPubKey", o);
14801485

14811486
in.pushKV("witness_utxo", out);

src/test/fuzz/rbf.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
#include <string>
1616
#include <vector>
1717

18-
FUZZ_TARGET(rbf)
18+
void initialize_rbf(void) {
19+
// ELEMENTS: our mempool needs Params() to be set for multiple reasons -- to check
20+
// the discount CT rate, to figure out pegin policy, etc
21+
SelectParams(CBaseChainParams::LIQUID1);
22+
}
23+
24+
FUZZ_TARGET_INIT(rbf, initialize_rbf)
1925
{
2026
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
2127
SetMockTime(ConsumeTime(fuzzed_data_provider));

src/test/fuzz/witness_program.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FUZZ_TARGET_INIT(witness_program, initialize_witness_program)
4545

4646
CScriptWitness witness;
4747
int fuzz_control;
48-
int flags;
48+
unsigned flags;
4949
ds >> fuzz_control;
5050
ds >> witness.stack;
5151
ds >> flags;
@@ -64,7 +64,7 @@ FUZZ_TARGET_INIT(witness_program, initialize_witness_program)
6464

6565
if (fuzz_control & 1) {
6666
unsigned char hash_program[32];
67-
CSHA256().Write(&program[0], program.size()).Finalize(hash_program);
67+
CSHA256().Write(program.data(), program.size()).Finalize(hash_program);
6868
CScript scriptPubKey = CScript{} << OP_0 << std::vector<unsigned char>(hash_program, hash_program + sizeof(hash_program));
6969
witness.stack.push_back(program);
7070

src/txmempool.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <policy/policy.h>
1919
#include <policy/settings.h>
2020
#include <reverse_iterator.h>
21+
#include <util/check.h>
2122
#include <util/moneystr.h>
23+
#include <util/overflow.h>
2224
#include <util/system.h>
2325
#include <util/time.h>
2426
#include <validationinterface.h>
@@ -60,16 +62,6 @@ struct update_ancestor_state
6062
int64_t discountSize;
6163
};
6264

63-
struct update_fee_delta
64-
{
65-
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
66-
67-
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
68-
69-
private:
70-
int64_t feeDelta;
71-
};
72-
7365
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
7466
{
7567
AssertLockHeld(cs_main);
@@ -99,6 +91,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
9991
entryHeight{entry_height},
10092
spendsCoinbase{spends_coinbase},
10193
sigOpCost{sigops_cost},
94+
m_modified_fee{nFee},
10295
lockPoints{lp},
10396
nSizeWithDescendants{GetTxSize()},
10497
nModFeesWithDescendants{nFee},
@@ -108,11 +101,11 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
108101
discountSizeWithAncestors{GetDiscountTxSize()},
109102
setPeginsSpent(_setPeginsSpent) {}
110103

111-
void CTxMemPoolEntry::UpdateFeeDelta(int64_t newFeeDelta)
104+
void CTxMemPoolEntry::UpdateModifiedFee(CAmount fee_diff)
112105
{
113-
nModFeesWithDescendants += newFeeDelta - feeDelta;
114-
nModFeesWithAncestors += newFeeDelta - feeDelta;
115-
feeDelta = newFeeDelta;
106+
nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, fee_diff);
107+
nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, fee_diff);
108+
m_modified_fee = SaturatingAdd(m_modified_fee, fee_diff);
116109
}
117110

118111
void CTxMemPoolEntry::UpdateLockPoints(const LockPoints& lp)
@@ -467,7 +460,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
467460
{
468461
nSizeWithDescendants += modifySize;
469462
assert(int64_t(nSizeWithDescendants) > 0);
470-
nModFeesWithDescendants += modifyFee;
463+
nModFeesWithDescendants = SaturatingAdd(nModFeesWithDescendants, modifyFee);
471464
nCountWithDescendants += modifyCount;
472465
assert(int64_t(nCountWithDescendants) > 0);
473466
}
@@ -476,7 +469,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
476469
{
477470
nSizeWithAncestors += modifySize;
478471
assert(int64_t(nSizeWithAncestors) > 0);
479-
nModFeesWithAncestors += modifyFee;
472+
nModFeesWithAncestors = SaturatingAdd(nModFeesWithAncestors, modifyFee);
480473
nCountWithAncestors += modifyCount;
481474
assert(int64_t(nCountWithAncestors) > 0);
482475
nSigOpCostWithAncestors += modifySigOps;
@@ -519,8 +512,10 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
519512
// into mapTx.
520513
CAmount delta{0};
521514
ApplyDelta(entry.GetTx().GetHash(), delta);
515+
// The following call to UpdateModifiedFee assumes no previous fee modifications
516+
Assume(entry.GetFee() == entry.GetModifiedFee());
522517
if (delta) {
523-
mapTx.modify(newit, update_fee_delta(delta));
518+
mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); });
524519
}
525520

526521
// Update cachedInnerUsage to include contained transaction's usage.
@@ -1029,10 +1024,10 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
10291024
{
10301025
LOCK(cs);
10311026
CAmount &delta = mapDeltas[hash];
1032-
delta += nFeeDelta;
1027+
delta = SaturatingAdd(delta, nFeeDelta);
10331028
txiter it = mapTx.find(hash);
10341029
if (it != mapTx.end()) {
1035-
mapTx.modify(it, update_fee_delta(delta));
1030+
mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); });
10361031
// Now update all ancestors' modified fees with descendants
10371032
setEntries setAncestors;
10381033
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();

src/txmempool.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class CTxMemPoolEntry
102102
const unsigned int entryHeight; //!< Chain height when entering the mempool
103103
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
104104
const int64_t sigOpCost; //!< Total sigop cost
105-
int64_t feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block
105+
CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
106106
LockPoints lockPoints; //!< Track the height and time at which tx was final
107107

108108
// Information about descendants of this transaction that are in the
@@ -135,17 +135,16 @@ class CTxMemPoolEntry
135135
std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
136136
unsigned int GetHeight() const { return entryHeight; }
137137
int64_t GetSigOpCost() const { return sigOpCost; }
138-
int64_t GetModifiedFee() const { return nFee + feeDelta; }
138+
CAmount GetModifiedFee() const { return m_modified_fee; }
139139
size_t DynamicMemoryUsage() const { return nUsageSize; }
140140
const LockPoints& GetLockPoints() const { return lockPoints; }
141141

142142
// Adjusts the descendant state.
143143
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount);
144144
// Adjusts the ancestor state
145145
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps, int64_t discountSize);
146-
// Updates the fee delta used for mining priority score, and the
147-
// modified fees with descendants.
148-
void UpdateFeeDelta(int64_t feeDelta);
146+
// Updates the modified fees with descendants/ancestors.
147+
void UpdateModifiedFee(CAmount fee_diff);
149148
// Update the LockPoints after a reorg
150149
void UpdateLockPoints(const LockPoints& lp);
151150

src/zmq/zmqabstractnotifier.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H
77

88

9+
#include <cstdint>
910
#include <memory>
1011
#include <string>
1112

src/zmq/zmqpublishnotifier.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <zmq/zmqabstractnotifier.h>
99

10+
#include <cstdint>
11+
1012
class CBlockIndex;
1113

1214
class CZMQAbstractPublishNotifier : public CZMQAbstractNotifier

test/functional/rpc_psbt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ def run_basic_tests(self, confidential):
261261
decoded = self.nodes[1].decodepsbt(walletsignpsbt_out['psbt'])
262262
assert 'non_witness_utxo' in decoded['inputs'][0]
263263
assert 'witness_utxo' in decoded['inputs'][0]
264+
if 'asset' in decoded['inputs'][0]['witness_utxo']:
265+
assert_equal(decoded['inputs'][0]['witness_utxo']['asset'], 'b2e15d0d7a0c94e4e2ce0fe6e8691b9e451377f6e46e8045a86f7c4b5d4f0f23')
266+
else:
267+
assert 'assetcommitment' in decoded['inputs'][0]['witness_utxo']
264268
# Check decodepsbt fee calculation (input values shall only be counted once per UTXO)
265269
#assert_equal(decoded['fee'], created_psbt['fee']) # ELEMENTS: we do not have this field. Should be fixed by #900
266270
assert_equal(walletsignpsbt_out['complete'], True)

test/sanitizer_suppressions/ubsan

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -fsanitize=undefined suppressions
22
# =================================
3-
# This would be `signed-integer-overflow:CTxMemPool::PrioritiseTransaction`,
3+
# The suppressions would be `sanitize-type:ClassName::MethodName`,
44
# however due to a bug in clang the symbolizer is disabled and thus no symbol
55
# names can be used.
66
# See https://github.com/google/sanitizers/issues/1364
7-
signed-integer-overflow:txmempool.cpp
7+
88
# https://github.com/bitcoin/bitcoin/pull/21798#issuecomment-829180719
99
signed-integer-overflow:policy/feerate.cpp
1010

0 commit comments

Comments
 (0)