Skip to content

Commit a04f17a

Browse files
committed
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 f1e1fb4. With the attempted introduction of OP_EVAL, it was replaced by the check in ConnectBlock(). Commit e679ec9 marked this code as a placeholder for backward compatibility. Then when P2SH replaced OP_EVAL in 922e8e2 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.
1 parent 66aa6a4 commit a04f17a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4094,6 +4094,8 @@ bool CheckBlock(const CBlock& block, BlockValidationState& state, const Consensu
40944094
strprintf("Transaction check failed (tx hash %s) %s", tx->GetHash().ToString(), tx_state.GetDebugMessage()));
40954095
}
40964096
}
4097+
// This underestimates the number of sigops, because unlike ConnectBlock it
4098+
// does not count witness and p2sh sigops.
40974099
unsigned int nSigOps = 0;
40984100
for (const auto& tx : block.vtx)
40994101
{

0 commit comments

Comments
 (0)