doc: warn that CheckBlock() underestimates sigops

Counting sigops in the witness and for p2sh requires
context that CheckBlock()  does not have, so it only
counts a subset of sigops.

The check here was introduced by Satoshi as a "cleanup" in
f1e1fb4bde. With the attempted
introduction of OP_EVAL, it was replaced by the check in
ConnectBlock(). Commit e679ec969c
marked this code as a placeholder for backward compatibility.

Then when P2SH replaced OP_EVAL in 922e8e2929
the phrase "compatibility-breaking" was replaced by a simple
observation that before v0.6 this is how sigops were counted.

It's unclear why the check was kept and there were no review comments
about it.
This commit is contained in:
Sjors Provoost
2025-05-08 18:37:49 +02:00
parent 66aa6a47bd
commit a04f17a188

View File

@@ -4094,6 +4094,8 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu
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;
for (const auto& tx : block.vtx)
{