-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[Policy] Several transaction standardness rules #11423
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
Conversation
This is part of #8755 |
Strong Concept ACK. We do ML posts for new standardness rules, right? Probably doesn't matter given their lack of use. |
b8b8d48
to
98cea79
Compare
Any reason to support OP_CODESEPARATOR inside P2WSH? |
I'd prefer we be consistent. Especially if OP_CODESEPARATOR has no meaning in SegWit transactions we should just make it nonstandard everywhere.
…On September 29, 2017 6:18:36 PM EDT, Pieter Wuille ***@***.***> wrote:
Any reason to support OP_CODESEPARATOR inside P2WSH?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#11423 (comment)
|
@sipa I think @NicolasDorier has something that use CODESEPARATOR. I think it could make the size of some contracts smaller. This is actually part of the attempt to fix the pre-segwit quadratic sighash problem. A variable |
YES, I am using it for tumblebit, it saves 33 bytes per outputs. It allows you to sign a specific branch with one key instead of having separate public key per branch. Please do not do that until we have at least MAST. (only if signing in MAST requires the scriptCode to depends on the executed branch) OP_CODESEPARATOR is very useful, I am coupling it with SIGHASH_NONE. (The only case where SIGHASH_NONE is not similar to giving your private key) |
Just to explain my case here:
If ALICE_KEY_PAYMENT == ALICE_KEY_REDEEM, this would be no good, as BOB could use Alice signature to satisfy the REDEEM condition, and get the money without revealing the pre image. Now you can save 33 bytes this way. (untested, but it get the idea of what I do for TB)
Notice that Alice can just pass a SIGHASH_NONE signature for the first branch to Bob, so she does not have to know how bob will spend the txout, while still being sure she can get the preimage as soon as Bob try to cashout. Concept ACK for removing on non-segwit scripts, but it should be kept for segwit. |
src/script/interpreter.h
Outdated
@@ -106,6 +106,10 @@ enum | |||
// Public keys in segregated witness scripts must be compressed | |||
// | |||
SCRIPT_VERIFY_WITNESS_PUBKEYTYPE = (1U << 15), | |||
|
|||
// Making OP_CODESEPARATOR and FindAndDelete non-standard in non-segwit scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For correctness, may wish to note that if FindAndDelete matches in either SegWit or non-SegWit, the script fails, OP_CODESEPARATOR limitation only applies to non-SegWit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FindAndDelete
is not used anywhere in segwit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, indeed, missed the sigversion check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comments on script flags shouldnt reference standardness - this flag "Makes OP_CODESEPARATOR and FindAndDelete fail any non-segwit scripts", not just make them nonstandard.
src/script/interpreter.cpp
Outdated
@@ -301,6 +301,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& | |||
opcode == OP_RSHIFT) | |||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. | |||
|
|||
// OP_CODESEPARATOR in non-segwit transaction is invalid even in an unexecuted branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would have pushed that in the switch case for OP_CODESEPARATOR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The switch case wouldn't get reached if it's in an unexecuted branch...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, disregard what I said, it would not have worked.
concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 98cea79fd2161ce0b42bdef27befc6a23047975f
src/script/interpreter.h
Outdated
@@ -106,6 +106,10 @@ enum | |||
// Public keys in segregated witness scripts must be compressed | |||
// | |||
SCRIPT_VERIFY_WITNESS_PUBKEYTYPE = (1U << 15), | |||
|
|||
// Making OP_CODESEPARATOR and FindAndDelete non-standard in non-segwit scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comments on script flags shouldnt reference standardness - this flag "Makes OP_CODESEPARATOR and FindAndDelete fail any non-segwit scripts", not just make them nonstandard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/script/interpreter.cpp
Outdated
@@ -301,6 +301,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& | |||
opcode == OP_RSHIFT) | |||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. | |||
|
|||
// OP_CODESEPARATOR in non-segwit transaction is invalid even in an unexecuted branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The switch case wouldn't get reached if it's in an unexecuted branch...?
src/script/interpreter.cpp
Outdated
@@ -301,6 +301,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& | |||
opcode == OP_RSHIFT) | |||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. | |||
|
|||
// OP_CODESEPARATOR in non-segwit transaction is invalid even in an unexecuted branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Invalid" is the wrong term here, since it's just a policy rule (for now).
0eab289
to
effb6f9
Compare
utACK effb6f9568a92ad6fe0ebf9da308cb0237df327b. One interesting test-case you may consider adding is checking that a FindAndDelete does not match (and thus the script is valid, even with CONST_SCRIPTCODE) a push with a non-minimal push encoding. |
utACK 0575b1831cd52987c76320d304674a27a140fe1f
|
src/script/interpreter.cpp
Outdated
@@ -301,6 +301,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& | |||
opcode == OP_RSHIFT) | |||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. | |||
|
|||
// With SCRIPT_VERIFY_CONST_SCRIPTCODE, OP_CODESEPARATOR in non-segwit script is invalid even in an unexecuted branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps out of scope, but the word "invalid" is confusing. It's non-standard because this check is only part of STANDARD_SCRIPT_VERIFY_FLAGS
. A future soft fork could make it actually invalid depending on e.g. block height. Perhaps we should use a different word like "reject"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean it clearly indicates that "With SCRIPT_VERIFY_CONST_SCRIPTCODE", and in that case it is "invalid", same as any other invalid action.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not particularly concerned but I agree that 'rejected' would be slightly clearer here.
Relevant ML thread is at https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-November/015292.html |
Just to clarify, OP_CODESEP could be removed completely from segwit if there is another way to explicitely sign a script path. (MAST could allow that) |
effb6f9
to
6337539
Compare
rebased |
utACK 850c41c2a33efd73eff0bbdefc6ba2762901b60e |
6337539
to
441f75c
Compare
Rebase with comments fixed (s/invalid/rejected/) |
References: - bitcoin/bitcoin#11423 - bitcoin/bitcoin#12600 - bitcoin/bitcoin#12082 Trivial References: - bitcoin/bitcoin#12393 - bitcoin/bitcoin#6539 - bitcoin/bitcoin#10742 - bitcoin/bitcoin@ecb11f5
References: - bitcoin/bitcoin#11423 - bitcoin/bitcoin#12600 - bitcoin/bitcoin#12082 Trivial References: - bitcoin/bitcoin#12393 - bitcoin/bitcoin#6539 - bitcoin/bitcoin#10742 - bitcoin/bitcoin@ecb11f5
…closure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under #11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
Summary: Use a variable with a meaningful name to improve readability. See https://reviews.bitcoinabc.org/D8929#204886 This is a partial backport of Core [[bitcoin/bitcoin#11423 | PR11423]] 364bae5 Test Plan: test/functional/test_runner.py p2p_invalid_tx Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D8934
364bae5 qa: Pad scriptPubKeys to get minimum sized txs (MarcoFalke) 7485488 Policy to reject extremely small transactions (Johnson Lau) 0f8719b Add transaction tests for constant scriptCode (Johnson Lau) 9dabfe4 Add constant scriptCode policy in non-segwit scripts (Johnson Lau) Pull request description: This disables `OP_CODESEPARATOR` in non-segwit scripts (even in an unexecuted branch), and makes a positive `FindAndDelete` result invalid. This ensures that the `scriptCode` serialized in `SignatureHash` is always the same as the script passing to the `EvalScript`. Tree-SHA512: a0552cb920294d130251c48053fa2ff1fbdd26332e62b52147d918837852750f0ce35ce2cd1cbdb86588943312f8154ccb4925e850dbb7c2254bc353070cd5f8
364bae5 qa: Pad scriptPubKeys to get minimum sized txs (MarcoFalke) 7485488 Policy to reject extremely small transactions (Johnson Lau) 0f8719b Add transaction tests for constant scriptCode (Johnson Lau) 9dabfe4 Add constant scriptCode policy in non-segwit scripts (Johnson Lau) Pull request description: This disables `OP_CODESEPARATOR` in non-segwit scripts (even in an unexecuted branch), and makes a positive `FindAndDelete` result invalid. This ensures that the `scriptCode` serialized in `SignatureHash` is always the same as the script passing to the `EvalScript`. Tree-SHA512: a0552cb920294d130251c48053fa2ff1fbdd26332e62b52147d918837852750f0ce35ce2cd1cbdb86588943312f8154ccb4925e850dbb7c2254bc353070cd5f8
364bae5 qa: Pad scriptPubKeys to get minimum sized txs (MarcoFalke) 7485488 Policy to reject extremely small transactions (Johnson Lau) 0f8719b Add transaction tests for constant scriptCode (Johnson Lau) 9dabfe4 Add constant scriptCode policy in non-segwit scripts (Johnson Lau) Pull request description: This disables `OP_CODESEPARATOR` in non-segwit scripts (even in an unexecuted branch), and makes a positive `FindAndDelete` result invalid. This ensures that the `scriptCode` serialized in `SignatureHash` is always the same as the script passing to the `EvalScript`. Tree-SHA512: a0552cb920294d130251c48053fa2ff1fbdd26332e62b52147d918837852750f0ce35ce2cd1cbdb86588943312f8154ccb4925e850dbb7c2254bc353070cd5f8
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
…CVE disclosure c4b0c08 Update tx-size-small comment with relevant CVE disclosure (Gregory Sanders) Pull request description: Code first introduced under bitcoin#11423 with essentially no description and no discussion. ACKs for top commit: MarcoFalke: ACK c4b0c08 fanquake: ACK c4b0c08 Tree-SHA512: 95d5c92998b8b1e944c477dbaee265b62612b6e815099ab31d9ff580b4dff777abaf7f326a284644709f918aa1510412d62310689b1250ef6e64de7b19ca9f71
This disables
OP_CODESEPARATOR
in non-segwit scripts (even in an unexecuted branch), and makes a positiveFindAndDelete
result invalid. This ensures that thescriptCode
serialized inSignatureHash
is always the same as the script passing to theEvalScript
.