mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-15 16:38:23 +01:00
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" inf1e1fb4bde. With the attempted introduction of OP_EVAL, it was replaced by the check in ConnectBlock(). Commite679ec969cmarked this code as a placeholder for backward compatibility. Then when P2SH replaced OP_EVAL in922e8e2929the 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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user