Skip to content

Commit 14c16e8

Browse files
committed
Merge bitcoin#32582: log: Additional compact block logging
83df64d log: Stats when fulfilling GETBLOCKTXN (David Gumberg) 3733ed2 log: Size of missing tx'es when reconstructing compact block (David Gumberg) 36bcee0 log: Log start of compact block initialization. (David Gumberg) Pull request description: This PR adds some additional logging to help measure performance of compact block reconstruction. 1. Adds a message to the beginning of `PartiallyDownloadedBlock::InitData()` so that that the logs indicate the amount of time it takes to populate a compact block from mempool transactions. 2. Logs the size of the transactions which a node did not have in its mempool and was forced to request. 3. Logs the size and number of transactions that a node sends to it's peer in a `BLOCKTXN` to fulfill a compact block `GETBLOCKTXN` request. Relevant to this discussion on delving bitcoin: https://delvingbitcoin.org/t/stats-on-compact-block-reconstructions/1052 ACKs for top commit: instagibbs: reACK bitcoin@83df64d w0xlt: reACK bitcoin@83df64d 1440000bytes: ACK 83df64d Tree-SHA512: 92c3c7d55005dd47dad90ddb54e4127482260cea5390f7696e8b3b9defb337f5fb09166af6b12eb2ab8151d04dae08b0a570e3509a86509b0ab3151d84387e06
2 parents aad5938 + 83df64d commit 14c16e8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/blockencodings.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const Wtxid& wtxid) const {
4545
return SipHashUint256(shorttxidk0, shorttxidk1, wtxid) & 0xffffffffffffL;
4646
}
4747

48-
49-
5048
ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<CTransactionRef>& extra_txn) {
49+
LogDebug(BCLog::CMPCTBLOCK, "Initializing PartiallyDownloadedBlock for block %s using a cmpctblock of %u bytes\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock));
5150
if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefilledtxn.empty()))
5251
return READ_STATUS_INVALID;
5352
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT / MIN_SERIALIZABLE_TRANSACTION_WEIGHT)
@@ -167,7 +166,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
167166
break;
168167
}
169168

170-
LogDebug(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of size %lu\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock));
169+
LogDebug(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using a cmpctblock of %u bytes\n", cmpctblock.header.GetHash().ToString(), GetSerializeSize(cmpctblock));
171170

172171
return READ_STATUS_OK;
173172
}
@@ -188,12 +187,14 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
188187
block = header;
189188
block.vtx.resize(txn_available.size());
190189

190+
unsigned int tx_missing_size = 0;
191191
size_t tx_missing_offset = 0;
192192
for (size_t i = 0; i < txn_available.size(); i++) {
193193
if (!txn_available[i]) {
194194
if (vtx_missing.size() <= tx_missing_offset)
195195
return READ_STATUS_INVALID;
196196
block.vtx[i] = vtx_missing[tx_missing_offset++];
197+
tx_missing_size += block.vtx[i]->GetTotalSize();
197198
} else
198199
block.vtx[i] = std::move(txn_available[i]);
199200
}
@@ -217,7 +218,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
217218
return READ_STATUS_CHECKBLOCK_FAILED;
218219
}
219220

220-
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());
221+
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);
221222
if (vtx_missing.size() < 5) {
222223
for (const auto& tx : vtx_missing) {
223224
LogDebug(BCLog::CMPCTBLOCK, "Reconstructed block %s required tx %s\n", hash.ToString(), tx->GetHash().ToString());

src/net_processing.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,14 +2495,17 @@ uint32_t PeerManagerImpl::GetFetchFlags(const Peer& peer) const
24952495
void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, Peer& peer, const CBlock& block, const BlockTransactionsRequest& req)
24962496
{
24972497
BlockTransactions resp(req);
2498+
unsigned int tx_requested_size = 0;
24982499
for (size_t i = 0; i < req.indexes.size(); i++) {
24992500
if (req.indexes[i] >= block.vtx.size()) {
25002501
Misbehaving(peer, "getblocktxn with out-of-bounds tx indices");
25012502
return;
25022503
}
25032504
resp.txn[i] = block.vtx[req.indexes[i]];
2505+
tx_requested_size += resp.txn[i]->GetTotalSize();
25042506
}
25052507

2508+
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);
25062509
MakeAndPushMessage(pfrom, NetMsgType::BLOCKTXN, resp);
25072510
}
25082511

0 commit comments

Comments
 (0)