doc: warn that CheckBlock() underestimates sigops

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

This should not be a problem. There are 2 call sites:

1. ConnectBlock(): this checks all sigops
2. TestBlockValidity() used by getblocktemplate: this also calls ConnectBlock()
3. AcceptBlock(): this performs limited checks before storing a block on disk
4. ProcessNewBlock(): calls AcceptBlock()
4. VerifyDB(): disconnects the block at level 3, which results in ConnectBlock()
This commit is contained in:
Sjors Provoost 2023-04-06 19:21:10 +02:00
parent 4facb94a48
commit 8a2509e21a
No known key found for this signature in database
GPG key ID: 57FF9BDBCC301009

View file

@ -4047,6 +4047,7 @@ 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 the witness:
unsigned int nSigOps = 0;
for (const auto& tx : block.vtx)
{