Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Coding Enthusiast on May 24, 2020, 01:46:42 PM



Title: Does core not-fail on invalid OP codes while counting SigOps?
Post by: Coding Enthusiast on May 24, 2020, 01:46:42 PM
I've traced it all the way to this line:
https://github.com/bitcoin/bitcoin/blob/24f70290642c9c5108d3dc62dbe055f5d1bcff9d/src/script/script.cpp#L278
that is called by GetSigOpCount a bunch of lines above this which is called by GetTransactionSigOpCost from tx_verify.cpp
And to me it looks like a broken script such as
Code:
OP_2 OP_DIV 0xff OP_CheckMultiSig
is counted as 20 SigOps. Is my interpretation correct? (Obviously OP_DIV is disabled and 0xff is not an OP at all).

PS. SigOpCount tests of core needs a lot more cases, right now they seem to only test the elementary standard scripts only.


Title: Re: Does core not-fail on invalid OP codes while counting SigOps?
Post by: achow101 on May 25, 2020, 06:00:52 AM
is counted as 20 SigOps. Is my interpretation correct? (Obviously OP_DIV is disabled and 0xff is not an OP at all).
Yes.

PS. SigOpCount tests of core needs a lot more cases, right now they seem to only test the elementary standard scripts only.
Pull requests welcome. But there really aren't many cases to test. It's also fuzz tested and IIRC some functional tests too.


Title: Re: Does core not-fail on invalid OP codes while counting SigOps?
Post by: Coding Enthusiast on May 25, 2020, 06:17:36 AM
Pull requests welcome. But there really aren't many cases to test. It's also fuzz tested and IIRC some functional tests too.
That's in my TODO list (already have 1 issue that turned into a PR for a tiny fix), but first I'll have to go through all tests and familiarize myself more with core's code. Another issue is core being in c++ and me not knowing anything about the language.