Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BIP62 rules 2, 3 and 4 #5065

Merged
merged 7 commits into from Oct 28, 2014
Merged

Implement BIP62 rules 2, 3 and 4 #5065

merged 7 commits into from Oct 28, 2014

Conversation

sipa
Copy link
Member

@sipa sipa commented Oct 9, 2014

No description provided.

@sipa sipa force-pushed the bip62b branch 2 times, most recently from b1d99c5 to c839843 Compare October 9, 2014 01:57
@@ -156,6 +156,29 @@ bool static CheckPubKeyEncoding(const valtype &vchSig, unsigned int flags) {
return true;
}

bool static CheckMinimalPush(const valtype& data, opcodetype opcode) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking, why you and Gavin like to use

void foo() {
...
}

over

void foo()
{
...
}

AFAIK the clang style will change it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will.

But whenever I write code I try to mimick the style of the code around it. Once we effectively apply clang-format, that will be the same style everywhere.

@sipa sipa force-pushed the bip62b branch 3 times, most recently from 4bb9a47 to 6a1f425 Compare October 10, 2014 05:51
@TheBlueMatt
Copy link
Contributor

Made a few small comments on the commits d54b8e40908b3e9ca33d728d8f0ab921f856e1dc and 6a1f425942701b916bb5fe39e5ec76b2b5585b40. Other than those, LGTM

@petertodd
Copy link
Contributor

I made some minor improvements to this: https://github.com/petertodd/bitcoin/tree/bip62b-improvements

Better comments for CScriptNum(), OP_PUSHDATA4 handling, changed the invalid unittests to make them more likely to pass, and added bunch of unit tests to get ~100% coverage, and clearly separated them into PUSHDATA and numeric argument categories.

That said, other than those minor improvements, I can't find anything wrong with this patch after a few hours of thinking about it; strong ACK.

Also, I found out something really odd while tearing it apart: if we hadn't disabled OP_RIGHT you could have this valid pair of redeemScript's and scriptSigs:

redeemScript: OP_RIGHT (0x81)
scriptSig: 1 0 OP_1NEGATE

This works because OP_1NEGATE pushes 0x81 to the stack, which happens to also be a perfectly valid redeemScript!

@laanwj laanwj added the Tests label Oct 22, 2014
sipa and others added 7 commits October 25, 2014 03:03
Also use the new flag as a standard rule, and replace the IsCanonicalPush
standardness check with it (as it is more complete).
Edited-by: Pieter Wuille <pieter.wuille@gmail.com>
Removes the need for the 'negated' versions of the tests, and ensures
other failures don't mask what we're trying to test.
@sipa
Copy link
Member Author

sipa commented Oct 25, 2014

Rebased and included some of @petertodd's commits (fixed typo's in the comment improvement, and skipped the PUSHDATA4 one, because it looks controversial).

@sipa
Copy link
Member Author

sipa commented Oct 25, 2014

Added another test.

EDIT: nevermind; petertodd's cases already cover this.

@gavinandresen
Copy link
Contributor

utACK.

@TheBlueMatt
Copy link
Contributor

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

utACK commithash 16d78bd68e1488a2a84e368b50bf511c77392d2e
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJUTuuqAAoJEIm7uGY+LmXOV1oQAJYu8QNCcxs9XkCkmgxnqc7v
ahhN52JRPx037WdH/pHFUCif0ZFnOXCNuhh/vHEZI8M6hVrSyb051nkzioRqPQYx
TYzDqzzcsCGbDuLuJfNkXgEbipgluodvCI6ktgiEBgLkl0rxLKNJR3Li7qSFrUxq
q8TAHi5k+amNfGfejyeFT5HEJ0N/hwteExnTuGX0xH5yLYD3O1+W/geYTimU21WT
ed444EcgG8nIDB/VIQ/3i2j8w1RkMY30v5uG0/FDAzaPRIM2x3nEQ/tsWMRgTVN4
2zqYITmgHvH5167SkIbmj3L5XoJhn0eu861rMDSE7AWhzbpQEzKoz/ws1EopK4KJ
WPkgAP9bGUhTDqwBdKAnMQFN3wG0UY3PE1iXK81xNQAwH1YghTJTO/zDJ+YIakuD
7ApHR9BQwh4tGGuBpsByyIw9xwnLs/lQsWhOVJqjiGfAOi1apUu2lvFk91menUHz
bRmBQWCEUMMNrEPal/q+ipLNe3JAB/Evam7/6nYRAZvb9NgD3Mx3KMrsTjdnlIZ+
5MbXsFq1WqbodsfSJY1LrF65jkBDHsznqnX1YA1HDvDux+Bgcs+1na2SrxptJ489
B9fXmAQ7BvoCHcTyx96h2/gTxjiqc2swwOaBYJGKm8dfD9gpXJQbRSdGkuJp5Nbm
78iHeo9dkcd9s0F7QmWy
=Z6yq
-----END PGP SIGNATURE-----

@laanwj laanwj merged commit 16d78bd into bitcoin:master Oct 28, 2014
laanwj added a commit that referenced this pull request Oct 28, 2014
16d78bd Add valid invert of invalid every numeric opcode tests (Peter Todd)
2b62e17 Clearly separate PUSHDATA and numeric argument MINIMALDATA tests (Peter Todd)
dfeec18 Test every numeric-accepting opcode for correct handling of the numeric minimal encoding rule (Peter Todd)
554147a Ensure MINIMALDATA invalid tests can only fail one way (Peter Todd)
6004e77 Improve CScriptNum() comment (Peter Todd)
698c6ab Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4) (Pieter Wuille)
d752ba8 Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2) (Pieter Wuille)
@laanwj laanwj mentioned this pull request Oct 29, 2014
@petertodd
Copy link
Contributor

@sipa FWIW I wasn't actually expecting you to add in all those commits individually; if you had wanted to squash them all or whatever that'd be fine by me. I just had it all split out to make it easy for you to review. But equally, totally ok for you to just pull them in directly too.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants