Skip to content

Commit b49df70

Browse files
committed
[validation] include all logged information in BlockValidationState
1 parent 7b267c0 commit b49df70

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/validation.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2596,7 +2596,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
25962596
for (size_t o = 0; o < tx->vout.size(); o++) {
25972597
if (view.HaveCoin(COutPoint(tx->GetHash(), o))) {
25982598
LogPrintf("ERROR: ConnectBlock(): tried to overwrite transaction\n");
2599-
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-BIP30");
2599+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-BIP30",
2600+
"tried to overwrite transaction");
26002601
}
26012602
}
26022603
}
@@ -2646,14 +2647,16 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
26462647
if (!Consensus::CheckTxInputs(tx, tx_state, view, pindex->nHeight, txfee)) {
26472648
// Any transaction validation failure in ConnectBlock is a block consensus failure
26482649
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
2649-
tx_state.GetRejectReason(), tx_state.GetDebugMessage());
2650+
tx_state.GetRejectReason(),
2651+
tx_state.GetDebugMessage() + " in transaction " + tx.GetHash().ToString());
26502652
LogError("%s: Consensus::CheckTxInputs: %s, %s\n", __func__, tx.GetHash().ToString(), state.ToString());
26512653
return false;
26522654
}
26532655
nFees += txfee;
26542656
if (!MoneyRange(nFees)) {
26552657
LogPrintf("ERROR: %s: accumulated fee in the block out of range.\n", __func__);
2656-
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-accumulated-fee-outofrange");
2658+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-accumulated-fee-outofrange",
2659+
"accumulated fee in the block out of range");
26572660
}
26582661

26592662
// Check that transaction is BIP68 final
@@ -2666,7 +2669,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
26662669

26672670
if (!SequenceLocks(tx, nLockTimeFlags, prevheights, *pindex)) {
26682671
LogPrintf("ERROR: %s: contains a non-BIP68-final transaction\n", __func__);
2669-
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-nonfinal");
2672+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-nonfinal",
2673+
"contains a non-BIP68-final transaction " + tx.GetHash().ToString());
26702674
}
26712675
}
26722676

@@ -2677,7 +2681,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
26772681
nSigOpsCost += GetTransactionSigOpCost(tx, view, flags);
26782682
if (nSigOpsCost > MAX_BLOCK_SIGOPS_COST) {
26792683
LogPrintf("ERROR: ConnectBlock(): too many sigops\n");
2680-
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-blk-sigops");
2684+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-blk-sigops", "too many sigops");
26812685
}
26822686

26832687
if (!tx.IsCoinBase())
@@ -2712,7 +2716,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
27122716
CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, params.GetConsensus());
27132717
if (block.vtx[0]->GetValueOut() > blockReward) {
27142718
LogPrintf("ERROR: ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)\n", block.vtx[0]->GetValueOut(), blockReward);
2715-
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-amount");
2719+
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-amount",
2720+
strprintf("coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0]->GetValueOut(), blockReward));
27162721
}
27172722

27182723
auto parallel_result = control.Complete();

0 commit comments

Comments
 (0)