Author

Topic: script_invalid.json and MINIMALDATA test vectors (Read 940 times)

legendary
Activity: 2053
Merit: 1354
aka tonikt
November 09, 2015, 07:06:14 AM
#5
All right, seems that I'm good now Smiley

Thanks mate, it helped me a lot!
sr. member
Activity: 467
Merit: 266
They pass because the test driver sends the minimaldata flag. It's the last field of the test data.
Your implementation could do the same thing.
legendary
Activity: 2053
Merit: 1354
aka tonikt
Thank you.

So, as for the code on the master branch, these tests are not supposed to pass?

Are they being run for the release cycle?

Is there any way to find out which of the vectors are not supposed to pass with the code from the current head?

Reason I ask is because I am trying to keep my script parsing implementation in sync with the core's head.
Figured that passing the core's test vectors should be a good measure of the compatibility, but apparently it isn't.
sr. member
Activity: 467
Merit: 266
You can represent these numbers with single op_codes

Code:
["0x01 0x81"] = ["0x4f"]
["0x01 0x01"] = ["0x51"]
["0x01 0x02"] = ["0x52"]

You don't need PUSH_DATA1 for data <= 75 bytes
Code:
"0x4c 0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
= "0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"

They only fail if you pass the "MINIMALDATA" flag to the verification routine. I believe they are in to enforce BIP 62 (not yet in effect)

https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#push-operators


Implemented at:
https://github.com/bitcoin/bitcoin/blob/923c5e93a90a6eddde3ab8589fc393da95bbc489/src/script/interpreter.cpp#L215
legendary
Activity: 2053
Merit: 1354
aka tonikt
It's probably something I'm missing, but I haven't been able to figure out why certain test vectors with MINIMALDATA flag are expected to return FAIL, in the test suite.

I mean, I assume that all the script inside script_invalid.json are a failing ones - aren't they?

Because if so, can someone please explain me why e.g. these ones are supposed to fail:

Code:
["0x01 0x81", "DROP 1", "MINIMALDATA", "-1 minimally represented by OP_1NEGATE"],
["0x01 0x01", "DROP 1", "MINIMALDATA", "1 to 16 minimally represented by OP_1 to OP_16"],
["0x01 0x02", "DROP 1", "MINIMALDATA"],

Code:
["0x4c 0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "DROP 1", "MINIMALDATA",
 "PUSHDATA1 of 72 bytes minimally represented by direct push"],

Which specific code triggers these failures?
Jump to: