Skip to content

Conversation

@jl2012
Copy link
Contributor

@jl2012 jl2012 commented Aug 16, 2016

The argument for OP_IF/NOTIF should be exactly 0x01 or empty vector in P2WSH. Otherwise, a relay node may replace the argument with arbitrary data. This is now applied as a policy but eventually should become a softfork.

This is not applied to non-segwit scripts because people may have P2SH UTXOs that are not complying with the new rules.

Copy link
Member

Choose a reason for hiding this comment

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

Mention that it only applies to witness scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will fix in a squash commit later

@maflcko maflcko added this to the 0.13.1 milestone Aug 16, 2016
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to include any cases whose behaviour is not changed by minimalif.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what should(not) be tested. I want to show that the new rules are not applied to non segwit scripts by accident

@dcousens
Copy link
Contributor

concept ACK

@luke-jr
Copy link
Member

luke-jr commented Aug 27, 2016

Prefer to just have an OP_CASTTOBOOL added. This breaks conditionals on OP_DEPTH and OP_SIZE for example.

@jl2012
Copy link
Contributor Author

jl2012 commented Aug 28, 2016

OP_CASTTOBOOL can't solve the problem. CastToBool in OP_IF is exactly the source of malleability. We needs to turn a OP_NOP into OP_ISBOOLVERIFY.

In any case, that requires a softfork which can't be done any time soon. What we need now is a quick policy patch. An alternative is to make SIZE IF and DEPTH IF excluded from this policy

@NicolasDorier
Copy link
Contributor

NicolasDorier commented Aug 28, 2016

we did segwit so that we don't have to care about malleability in inputs, but now we care about malleability inside witness inputs? o_O

I would prefer to not touch that as DEPTH IF and SIZE IF are still useful. I'm not fan making special case either.

@btcdrak
Copy link
Contributor

btcdrak commented Aug 28, 2016

Relevant discussion https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2016-August/013014.html

@NicolasDorier
Copy link
Contributor

ok read the conversation, I like the proposition of @jl2012 of making it a relay rule for now and deciding whether to make it a SF later. Concept ACK.

@luke-jr
Copy link
Member

luke-jr commented Aug 28, 2016

No objection to a policy rule, just wanted to point that out here so it didn't get lost. :)

(OP_ISBOOLVERIFY could be policy-enforced just as well though...?)

@instagibbs
Copy link
Member

concept ACK as relay rule only

@jl2012
Copy link
Contributor Author

jl2012 commented Sep 1, 2016

@luke-jr , a "policy opcode" means we could never use that NOP for other purpose again, even if we abandon the softfork plan.

@luke-jr
Copy link
Member

luke-jr commented Sep 1, 2016

@jl2012 Not really. It simply means we'd need to wait a few releases from when it's policy-redefined to a straight-disallowed NOP, before it is safe to reuse. Along those lines, I wonder if it would make sense to redefine other unallocated opcodes as NOPs inside segwit now (although I doubt it will be useful in the long run).

@jl2012
Copy link
Contributor Author

jl2012 commented Sep 1, 2016

@luke-jr you can't redefine policy opcode because people are likely to have utxos with that.

and it won't make sense to create more NOPs. The use of NOPs is really limited as they can't manipulate the stack at all. For example, my most wanted code, OP_CAT, could not be done with and NOP

@josephpoon
Copy link

josephpoon commented Sep 1, 2016

Concept ACK. OK with either policy rule or consensus rule, finalized LN bitcoin scripts will be compatible.

To echo jl2012 's comment about having UTXOs, policy rules to an eventual SF is complicated because doing something as simple as OP_DUP OP_IF OP_SHA256 <PUSHDATA> OP_EQUAL
can invalidate scripts (you're computing on the same data in two places, one of which would be constrained in the SF when activated and the other constrained in the script itself). It is theoretically plausible to construct this kind of script for an actual useful purpose (e.g. if OP_FALSE as input, the other branch would compute on the next item on the stack, albeit it may be possible to construct those scripts more optimally without this problem in the first place, the possibility that it can happen with some kind of script is a concern).

Copy link
Contributor

@afk11 afk11 left a comment

Choose a reason for hiding this comment

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

Code review / tested ACK

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

utACK e0b94de0dfbec9b305964a594f2e4785de51655d

Copy link
Member

Choose a reason for hiding this comment

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

nit: put some () around the flag check for ease of reading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed with c72c5b1

@btcdrak
Copy link
Contributor

btcdrak commented Sep 27, 2016

utACK c72c5b1

@laanwj
Copy link
Member

laanwj commented Sep 27, 2016

Code-review ACK c72c5b1

@laanwj laanwj merged commit c72c5b1 into bitcoin:master Sep 27, 2016
laanwj added a commit that referenced this pull request Sep 27, 2016
…2WSH

c72c5b1 Make non-minimal OP_IF/NOTIF argument non-standard for P2WSH (Johnson Lau)
Copy link
Member

@sipa sipa left a comment

Choose a reason for hiding this comment

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

utACK c72c5b1

laanwj pushed a commit to laanwj/bitcoin that referenced this pull request Oct 13, 2016
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.