mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
[validation] include all logged information in BlockValidationState
This commit is contained in:
parent
7b267c034f
commit
b49df703f0
1 changed files with 11 additions and 6 deletions
|
@ -2596,7 +2596,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
for (size_t o = 0; o < tx->vout.size(); o++) {
|
||||
if (view.HaveCoin(COutPoint(tx->GetHash(), o))) {
|
||||
LogPrintf("ERROR: ConnectBlock(): tried to overwrite transaction\n");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-BIP30");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-BIP30",
|
||||
"tried to overwrite transaction");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2646,14 +2647,16 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
if (!Consensus::CheckTxInputs(tx, tx_state, view, pindex->nHeight, txfee)) {
|
||||
// Any transaction validation failure in ConnectBlock is a block consensus failure
|
||||
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
|
||||
tx_state.GetRejectReason(), tx_state.GetDebugMessage());
|
||||
tx_state.GetRejectReason(),
|
||||
tx_state.GetDebugMessage() + " in transaction " + tx.GetHash().ToString());
|
||||
LogError("%s: Consensus::CheckTxInputs: %s, %s\n", __func__, tx.GetHash().ToString(), state.ToString());
|
||||
return false;
|
||||
}
|
||||
nFees += txfee;
|
||||
if (!MoneyRange(nFees)) {
|
||||
LogPrintf("ERROR: %s: accumulated fee in the block out of range.\n", __func__);
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-accumulated-fee-outofrange");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-accumulated-fee-outofrange",
|
||||
"accumulated fee in the block out of range");
|
||||
}
|
||||
|
||||
// Check that transaction is BIP68 final
|
||||
|
@ -2666,7 +2669,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
|
||||
if (!SequenceLocks(tx, nLockTimeFlags, prevheights, *pindex)) {
|
||||
LogPrintf("ERROR: %s: contains a non-BIP68-final transaction\n", __func__);
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-nonfinal");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-nonfinal",
|
||||
"contains a non-BIP68-final transaction " + tx.GetHash().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2677,7 +2681,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
nSigOpsCost += GetTransactionSigOpCost(tx, view, flags);
|
||||
if (nSigOpsCost > MAX_BLOCK_SIGOPS_COST) {
|
||||
LogPrintf("ERROR: ConnectBlock(): too many sigops\n");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-blk-sigops");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-blk-sigops", "too many sigops");
|
||||
}
|
||||
|
||||
if (!tx.IsCoinBase())
|
||||
|
@ -2712,7 +2716,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, params.GetConsensus());
|
||||
if (block.vtx[0]->GetValueOut() > blockReward) {
|
||||
LogPrintf("ERROR: ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)\n", block.vtx[0]->GetValueOut(), blockReward);
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-amount");
|
||||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-amount",
|
||||
strprintf("coinbase pays too much (actual=%d vs limit=%d)", block.vtx[0]->GetValueOut(), blockReward));
|
||||
}
|
||||
|
||||
auto parallel_result = control.Complete();
|
||||
|
|
Loading…
Reference in a new issue