Merge bitcoin/bitcoin#31624: doc: warn that CheckBlock() underestimates sigops

a04f17a188 doc: warn that CheckBlock() underestimates sigops (Sjors Provoost)

Pull request description:

  Counting sigops in the witness requires context that `CheckBlock()`  does not have, so it only counts sigops for non-segwit transactions.

  It's useful to document, but it should not be a problem.

  The commit message contains some historical context.

ACKs for top commit:
  ismaelsadeeq:
    ACK a04f17a188
  ryanofsky:
    Code review ACK a04f17a188

Tree-SHA512: 26528367a7f3cfa8540ef0b90f7aa912c8f0bc057428f20a1fd1d4e232dac77747bc20044f0fcb0ffab8a2e1fb3dbe3dab46be749553a917744ddc7a829025cb
This commit is contained in:
Ryan Ofsky
2025-05-14 09:09:34 -04:00

View File

@@ -4062,6 +4062,8 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu
strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), tx_state.GetDebugMessage())); strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), tx_state.GetDebugMessage()));
} }
} }
// This underestimates the number of sigops, because unlike ConnectBlock it
// does not count witness and p2sh sigops.
unsigned int nSigOps = 0; unsigned int nSigOps = 0;
for (const auto& tx : block.vtx) for (const auto& tx : block.vtx)
{ {