Skip to content

Commit

Permalink
Have compact block FillBlock give more verbose log printing when
Browse files Browse the repository at this point in the history
encountering failures.
  • Loading branch information
instagibbs committed Oct 10, 2019
1 parent fe8e6df commit d70cb06
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/blockencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
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)
if (vtx_missing.size() <= tx_missing_offset) {
LogPrint(BCLog::CMPCTBLOCK, "Transactions missing arg mismatches offset in loop: %zu %zu\n", vtx_missing.size(), tx_missing_offset);
return READ_STATUS_INVALID;
}
block.vtx[i] = vtx_missing[tx_missing_offset++];
} else
block.vtx[i] = std::move(txn_available[i]);
Expand All @@ -200,17 +202,23 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
header.SetNull();
txn_available.clear();

if (vtx_missing.size() != tx_missing_offset)
if (vtx_missing.size() != tx_missing_offset) {
LogPrint(BCLog::CMPCTBLOCK, "Transactions missing arg mismatches offset: %zu %zu\n", vtx_missing.size(), tx_missing_offset);
return READ_STATUS_INVALID;
}

CValidationState state;
if (!CheckBlock(block, state, Params().GetConsensus(), check_pow)) {
// TODO: We really want to just check merkle tree manually here,
// but that is expensive, and CheckBlock caches a block's
// "checked-status" (in the CBlock?). CBlock should be able to
// check its own merkle root and cache that check.
if (state.CorruptionPossible())
if (state.CorruptionPossible()) {
LogPrint(BCLog::CMPCTBLOCK, "Corrupted compact block? Possible shortid collision: %s\n", state.GetRejectReason());
return READ_STATUS_FAILED; // Possible Short ID collision
}

LogPrint(BCLog::CMPCTBLOCK, "CheckBlock fail: %s\n", state.GetRejectReason());
return READ_STATUS_CHECKBLOCK_FAILED;
}

Expand Down

0 comments on commit d70cb06

Please sign in to comment.