From 36bcee05dc71e4166be7c5a917ea9757427cece5 Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Wed, 21 May 2025 18:35:04 -0700 Subject: [PATCH 1/3] log: Log start of compact block initialization. --- src/blockencodings.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index 5f4061a71dc..21e569a7cf5 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -45,9 +45,8 @@ uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const Wtxid& wtxid) const { return SipHashUint256(shorttxidk0, shorttxidk1, wtxid) & 0xffffffffffffL; } - - ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector& extra_txn) { + LogDebug(BCLog::CMPCTBLOCK, "Initializing PartiallyDownloadedBlock for block %s using a cmpctblock of %u bytes\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock)); if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty())) return READ_STATUS_INVALID; if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT / MIN_SERIALIZABLE_TRANSACTION_WEIGHT) @@ -167,7 +166,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c break; } - LogDebug(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock)); + LogDebug(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of %u bytes\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock)); return READ_STATUS_OK; } From 3733ed2dae3d8a6825af9f3dbc6495a238b455da Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Wed, 21 May 2025 18:35:42 -0700 Subject: [PATCH 2/3] log: Size of missing tx'es when reconstructing compact block --- src/blockencodings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index 21e569a7cf5..a65072eeacf 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -187,12 +187,14 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector< block = header; block.vtx.resize(txn_available.size()); + unsigned int tx_missing_size = 0; size_t tx_missing_offset = 0; for (size_t i = 0; i < txn_available.size(); i++) { if (!txn_available[i]) { if (vtx_missing.size() <= tx_missing_offset) return READ_STATUS_INVALID; block.vtx[i] = vtx_missing[tx_missing_offset++]; + tx_missing_size += block.vtx[i]->GetTotalSize(); } else block.vtx[i] = std::move(txn_available[i]); } @@ -216,7 +218,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector< return READ_STATUS_CHECKBLOCK_FAILED; } - LogDebug(BCLog::CMPCTBLOCK, "Successfully reconstructed block %s with %lu txn prefilled, %lu txn from mempool (incl at least %lu from extra pool) and %lu txn requested\n", hash.ToString(), prefilled_count, mempool_count, extra_count, vtx_missing.size()); + LogDebug(BCLog::CMPCTBLOCK, "Successfully reconstructed block %s with %u txn prefilled, %u txn from mempool (incl at least %u from extra pool) and %u txn (%u bytes) requested\n", hash.ToString(), prefilled_count, mempool_count, extra_count, vtx_missing.size(), tx_missing_size); if (vtx_missing.size() < 5) { for (const auto& tx : vtx_missing) { LogDebug(BCLog::CMPCTBLOCK, "Reconstructed block %s required tx %s\n", hash.ToString(), tx->GetHash().ToString()); From 83df64d7491b8271f7dfa2aea30f055102e3ff39 Mon Sep 17 00:00:00 2001 From: David Gumberg Date: Wed, 21 May 2025 18:36:21 -0700 Subject: [PATCH 3/3] log: Stats when fulfilling GETBLOCKTXN --- src/net_processing.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 78e97b66840..ead69f086df 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2495,14 +2495,17 @@ uint32_t PeerManagerImpl::GetFetchFlags(const Peer& peer) const void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, Peer& peer, const CBlock& block, const BlockTransactionsRequest& req) { BlockTransactions resp(req); + unsigned int tx_requested_size = 0; for (size_t i = 0; i < req.indexes.size(); i++) { if (req.indexes[i] >= block.vtx.size()) { Misbehaving(peer, "getblocktxn with out-of-bounds tx indices"); return; } resp.txn[i] = block.vtx[req.indexes[i]]; + tx_requested_size += resp.txn[i]->GetTotalSize(); } + LogDebug(BCLog::CMPCTBLOCK, "Peer %d sent us a GETBLOCKTXN for block %s, sending a BLOCKTXN with %u txns. (%u bytes)\n", pfrom.GetId(), block.GetHash().ToString(), resp.txn.size(), tx_requested_size); MakeAndPushMessage(pfrom, NetMsgType::BLOCKTXN, resp); }