This is a tracking PR now, the commit will be pushed in smaller PRs based on concerns.
It is an optimization PR for GetSigOpCount
, covered heavily with new tests, benchmarks and small refactorings.
Context
Test coverage was thin for this code path that suddenly became popular for different reasons (https://github.com/bitcoin/bitcoin/pull/31624 and #32521 and #32533) highlighting the need for better code coverage.
The PR now splits out the common PUSHDATA
length/bounds reads and error checks and covers its corner cases with unit tests and benchmarks.
Testing
- added unit tests covering every standard script type (and a historical
OP_RETURN … OP_CHECKSIG
oddity); - added fuzz-style test that compares the refactored implementation against the exact legacy algorithm on random scripts - also ran it continuously for 25 hours without divergence;
- reindexed to height 897,000 comparing the outputs of the old and the new implementation without incidents.