-
Notifications
You must be signed in to change notification settings - Fork 47
miniscript: correct the stack size check #77
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
bitcoind does not account for the witness script push when checking this: size_t sizeWitnessStack = tx.vin[i].scriptWitness.stack.size() - 1; if (sizeWitnessStack > MAX_STANDARD_P2WSH_STACK_ITEMS) return false; Reported-by: sanket1729 <[email protected]>
|
I think this is dependent on how we view miniscript. I view miniscript as a bare script and its usage in a descriptor would determine how the script is used. In other words, the wsh descriptor would add the +1 to the stack element count(required for fee estimation). In the case of I know that we are only dealing with |
|
@sanket1729 I agree; miniscript should just deal with the script side of things. Though, that does make the max stack size check a bit ugly - but I guess it's ok as that's restricted to sanity. |
|
I too view it this way, probably because i'm biased from diving into the Rust implem first :) However this implementation is really a
I don't get this, if you want to estimate fees you want the entire witness not just part of it? Also you want the size not the count? |
Ideally, we want to do this. However, doing this in the current codebase would require some re-architecture.
One of the other benefits of miniscript is that it allows reasoning for worst-case tx weight cost at script creation time. This can be helpful in setting a conservative fee to avoid second-party witness malleability to increase the overall tx weight. For this purpose, we need a 1) max satisfaction cost of script(not yet done in the c++ impl, but is fairly easy to do), 2) the worst-case stack size (to compute the size of varint that stores the number of elements in the stack) and 3) information about the descriptor to compute the final witness. Points 1) and 2) should be the responsibility of the miniscript module. and 3) should be done by descriptor code. All of this is to say that stack size calculation(GetStackSize()), IMO should not include the +1. The checks(CheckStackSize) should be adjusted accordingly. |
|
I'm sorry, i still don't think it's right.
> Plus, following this logic we should externalize all the P2WSH-specific checks?
Ideally, we want to do this. However, doing this in the current codebase would require some re-architecture.
Yeah, then better to keep everything in one place?
> I don't get this, if you want to estimate fees you want the entire witness not just part of it? Also you want the size, not the count?
One of the other benefits of miniscript is that it allows reasoning for worst-case tx weight cost at script creation time. This can be helpful in setting a conservative fee to avoid second-party witness malleability to increase the overall tx weight. For this purpose, we need a 1) max satisfaction cost of script(not yet done in the c++ impl, but is fairly easy to do), 2) the worst-case stack size (to compute the size of varint that stores the number of elements in the stack) and 3) information about the descriptor to compute the final witness.
- and 2) should be the responsibility of the miniscript module. and 3) should be done by descriptor code. All of this is to say that stack size calculation(GetStackSize()), IMO should not include the +1. The checks(CheckStackSize) should be adjusted accordingly.
I know. My point is that the witness script *is* a stack element. You couldn't do 1) and 2) in the miniscript module without taking it into account.
… —
You are receiving this because you authored the thread.
Reply to this email directly, [view it on GitHub](#77 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AFLK3F7HFIPAQFU6JFHFMRLUESKWDANCNFSM5E7F2OLA).
Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub).
|
|
Anyways i think it's a nit (an ugly one but still), i don't want to fight on this and be a blocker to our steady progress. Just that the arguments don't seem right. |
|
Agreed, let's move on to this. Let's keep rolling :) , once we have multiple descriptors supporting miniscript, we can clean up everything |
|
ACK c4b9c10 |
1 similar comment
|
ACK c4b9c10 |
bitcoind does not account for the witness script push when checking against
MAX_STANDARD_P2WSH_STACK_ITEMS