Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Coding Enthusiast on April 12, 2020, 09:58:41 AM



Title: Is there any test data for SigOpCount?
Post by: Coding Enthusiast on April 12, 2020, 09:58:41 AM
I'm trying to make sense of how sigops are supposed to be counted and although I think I've figured it out but since it makes little sense I'd like to see some test vectors. Hopefully something like SignatureScript:Foo SigOpCount:m; PubkeyScript:Bar SigOpCount:n.

PS. Is there any limit (consensus-wise not standard-wise) per transaction or is the limit only per block?


Title: Re: Is there any test data for SigOpCount?
Post by: lucasholder on April 12, 2020, 11:13:28 AM
Those are the only tests I could find in bitcoin-core: https://github.com/bitcoin/bitcoin/blob/0.20/test/functional/feature_block.py#L250

Here's the sigop calculation function: https://github.com/bitcoin/bitcoin/blob/0.20/src/consensus/tx_verify.cpp#L138

Maybe you can try asking in the bitcoin core IRC channel.


Title: Re: Is there any test data for SigOpCount?
Post by: Coding Enthusiast on April 12, 2020, 11:31:24 AM
Those are the only tests I could find in bitcoin-core: https://github.com/bitcoin/bitcoin/blob/0.20/test/functional/feature_block.py#L250

That is only testing the case where number of SigOps exceeds the maximum with a very simple mock script.


Title: Re: Is there any test data for SigOpCount?
Post by: lucasholder on April 12, 2020, 11:41:17 AM
Indeed, unfortunately Bitcoin core's tests aren't that extensive but it has improved greatly over time (there used to be very few). I just found another test for segwit: https://github.com/bitcoin/bitcoin/blob/0.20/test/functional/p2p_segwit.py#L1918

Why are you looking for that if you don't mind?


Title: Re: Is there any test data for SigOpCount?
Post by: Coding Enthusiast on April 12, 2020, 12:39:51 PM
Why are you looking for that if you don't mind?

I'm currently refactoring the Script part of Bitcoin.Net library (https://github.com/Autarkysoft/Denovo/tree/master/Src/Autarkysoft.Bitcoin) and writing a BlockVerifier + TransactionVerifier classes and the SigOpCount method needs testing.


Title: Re: Is there any test data for SigOpCount?
Post by: achow101 on April 12, 2020, 04:40:44 PM
While not explicitly test vectors, there are some SigOp count tests in https://github.com/bitcoin/bitcoin/blob/master/src/test/sigopcount_tests.cpp

PS. Is there any limit (consensus-wise not standard-wise) per transaction or is the limit only per block?
There are limits per script.