Skip to content

Commit d2a6c34

Browse files
Merge #6830: backport: Merge bitcoin#29541, 28569, 27464, 27278
df3de12 Merge bitcoin#27278: Log new headers (Andrew Chow) d6e9d97 Merge bitcoin#27464: fuzz: re-enable prioritisetransaction & analyzepsbt RPC (fanquake) cfb2165 Merge bitcoin#28569: log: Don't log cache rebalancing in absense of a snapshot chainstate (fanquake) 4103213 Merge bitcoin#29541: test: remove file-wide interpreter.cpp ubsan suppression (fanquake) Pull request description: Batch of simple backports ACKs for top commit: UdjinM6: utACK df3de12 Tree-SHA512: fb4e8323d1c89e68bc5b1817fd554f3fa1418d2adac836c4c7e969b4fa11212f17aa40002445edd812797e57b792009dc268fcff77bd0130309e7661fedbb21a
2 parents 4f9d601 + df3de12 commit d2a6c34

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

src/net_processing.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4706,6 +4706,7 @@ void PeerManagerImpl::ProcessMessage(
47064706
vRecv >> cmpctblock;
47074707

47084708
bool received_new_header = false;
4709+
const auto blockhash = cmpctblock.header.GetHash();
47094710

47104711
{
47114712
LOCK(cs_main);
@@ -4719,7 +4720,7 @@ void PeerManagerImpl::ProcessMessage(
47194720
return;
47204721
}
47214722

4722-
if (!m_chainman.m_blockman.LookupBlockIndex(cmpctblock.header.GetHash())) {
4723+
if (!m_chainman.m_blockman.LookupBlockIndex(blockhash)) {
47234724
received_new_header = true;
47244725
}
47254726
}
@@ -4733,6 +4734,11 @@ void PeerManagerImpl::ProcessMessage(
47334734
}
47344735
}
47354736

4737+
if (received_new_header) {
4738+
LogPrintfCategory(BCLog::NET, "Saw new cmpctblock header hash=%s peer=%d\n",
4739+
blockhash.ToString(), pfrom.GetId());
4740+
}
4741+
47364742
// When we succeed in decoding a block's txids from a cmpctblock
47374743
// message we typically jump to the BLOCKTXN handling code, with a
47384744
// dummy (empty) BLOCKTXN message, to re-use the logic there in
@@ -4775,7 +4781,7 @@ void PeerManagerImpl::ProcessMessage(
47754781
// We requested this block for some reason, but our mempool will probably be useless
47764782
// so we just grab the block via normal getdata
47774783
std::vector<CInv> vInv(1);
4778-
vInv[0] = CInv(MSG_BLOCK, cmpctblock.header.GetHash());
4784+
vInv[0] = CInv(MSG_BLOCK, blockhash);
47794785
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
47804786
}
47814787
return;
@@ -4810,7 +4816,7 @@ void PeerManagerImpl::ProcessMessage(
48104816
} else if (status == READ_STATUS_FAILED) {
48114817
// Duplicate txindexes, the block is now in-flight, so just request it
48124818
std::vector<CInv> vInv(1);
4813-
vInv[0] = CInv(MSG_BLOCK, cmpctblock.header.GetHash());
4819+
vInv[0] = CInv(MSG_BLOCK, blockhash);
48144820
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
48154821
return;
48164822
}
@@ -4823,7 +4829,7 @@ void PeerManagerImpl::ProcessMessage(
48234829
if (req.indexes.empty()) {
48244830
// Dirty hack to jump to BLOCKTXN code (TODO: move message handling into their own functions)
48254831
BlockTransactions txn;
4826-
txn.blockhash = cmpctblock.header.GetHash();
4832+
txn.blockhash = blockhash;
48274833
blockTxnMsg << txn;
48284834
fProcessBLOCKTXN = true;
48294835
} else {
@@ -4853,7 +4859,7 @@ void PeerManagerImpl::ProcessMessage(
48534859
// We requested this block, but its far into the future, so our
48544860
// mempool will probably be useless - request the block normally
48554861
std::vector<CInv> vInv(1);
4856-
vInv[0] = CInv(MSG_BLOCK, cmpctblock.header.GetHash());
4862+
vInv[0] = CInv(MSG_BLOCK, blockhash);
48574863
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
48584864
return;
48594865
} else {

src/test/fuzz/rpc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ const std::vector<std::string> RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
7070
"addconnection", // avoid DNS lookups
7171
"addnode", // avoid DNS lookups
7272
"addpeeraddress", // avoid DNS lookups
73-
"analyzepsbt", // avoid signed integer overflow in CFeeRate::GetFee(unsigned long) (https://github.com/bitcoin/bitcoin/issues/20607)
7473
"dumptxoutset", // avoid writing to disk
7574
"dumpwallet", // avoid writing to disk
7675
"echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.)
@@ -79,14 +78,14 @@ const std::vector<std::string> RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
7978
"gettxoutproof", // avoid prohibitively slow execution
8079
"importwallet", // avoid reading from disk
8180
"loadwallet", // avoid reading from disk
82-
"prioritisetransaction", // avoid signed integer overflow in CTxMemPool::PrioritiseTransaction(uint256 const&, long const&) (https://github.com/bitcoin/bitcoin/issues/20626)
8381
"savemempool", // disabled as a precautionary measure: may take a file path argument in the future
8482
"setban", // avoid DNS lookups
8583
"stop", // avoid shutdown state
8684
};
8785

8886
// RPC commands which are safe for fuzzing.
8987
const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
88+
"analyzepsbt",
9089
"clearbanned",
9190
"combinepsbt",
9291
"combinerawtransaction",
@@ -138,6 +137,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
138137
"getrpcinfo",
139138
"gettxout",
140139
"gettxoutsetinfo",
140+
"gettxspendingprevout",
141141
"help",
142142
"invalidateblock",
143143
"joinpsbts",
@@ -146,6 +146,7 @@ const std::vector<std::string> RPC_COMMANDS_SAFE_FOR_FUZZING{
146146
"mockscheduler",
147147
"ping",
148148
"preciousblock",
149+
"prioritisetransaction",
149150
"pruneblockchain",
150151
"reconsiderblock",
151152
"scantxoutset",

src/validation.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,9 +4217,25 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
42174217
if (ppindex)
42184218
*ppindex = pindex;
42194219

4220+
// Since this is the earliest point at which we have determined that a
4221+
// header is both new and valid, log here.
4222+
//
4223+
// These messages are valuable for detecting potential selfish mining behavior;
4224+
// if multiple displacing headers are seen near simultaneously across many
4225+
// nodes in the network, this might be an indication of selfish mining. Having
4226+
// this log by default when not in IBD ensures broad availability of this data
4227+
// in case investigation is merited.
4228+
const auto msg = strprintf(
4229+
"Saw new header hash=%s height=%d", hash.ToString(), pindex->nHeight);
4230+
4231+
if (ActiveChainstate().IsInitialBlockDownload()) {
4232+
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Debug, "%s\n", msg);
4233+
} else {
4234+
LogPrintf("%s\n", msg);
4235+
}
4236+
42204237
// Notify external listeners about accepted block header
42214238
GetMainSignals().AcceptedBlockHeader(pindex);
4222-
42234239
return true;
42244240
}
42254241

@@ -5931,8 +5947,8 @@ void ChainstateManager::MaybeRebalanceCaches()
59315947
{
59325948
AssertLockHeld(::cs_main);
59335949
if (m_ibd_chainstate && !m_snapshot_chainstate) {
5934-
LogPrintf("[snapshot] allocating all cache to the IBD chainstate\n");
5935-
// Allocate everything to the IBD chainstate.
5950+
// Allocate everything to the IBD chainstate. This will always happen
5951+
// when we are not using a snapshot
59365952
m_ibd_chainstate->ResizeCoinsCaches(m_total_coinstip_cache, m_total_coinsdb_cache);
59375953
}
59385954
else if (m_snapshot_chainstate && !m_ibd_chainstate) {

test/sanitizer_suppressions/ubsan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ unsigned-integer-overflow:hash.cpp
5151
unsigned-integer-overflow:policy/fees.cpp
5252
unsigned-integer-overflow:prevector.h
5353
unsigned-integer-overflow:pubkey.h
54-
unsigned-integer-overflow:script/interpreter.cpp
54+
unsigned-integer-overflow:EvalScript
5555
unsigned-integer-overflow:txmempool.cpp
5656
unsigned-integer-overflow:util/strencodings.cpp
5757
unsigned-integer-overflow:xoroshiro128plusplus.h

0 commit comments

Comments
 (0)