-
Notifications
You must be signed in to change notification settings - Fork 141
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
Stack len for legacy max_satisfaction_weight
calculations
#474
Stack len for legacy max_satisfaction_weight
calculations
#474
Conversation
As per the definiton of `max_satisfaction_weight`, we should take into consideration the varint that records witness stack size. Even legacy spends may require this field if the tx has at least 1 segwit spend, so we should have it in our calculations.
Agreed. I seem to remember considering this but don't remember why I landed on the wrong behavior. |
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.
ACK 054313c
Concept NACK. I think the weight being accounted for here is not really "satisfaction weight". When considering the weight of adding an additional input there two kinds of costs to consider:
I think If we wanted to carry the logic of this PR forward then it should add an additional 2WU to every segwit input because that input might cause a witness header to be added. But this is still wrong. What if you have 100 legacy inputs already, and then you are considering adding a witness input. Isn't the 100WU cost for the 100 0x00 witness stack lengths for all the existing inputs actually being created by the new input. It seems bad that you can add a new input and add wayyyy more weight than what |
@LLFourn I agree with you on the fact that the current idea of However, if we go by the definition of
Also, the So in terms of the scope of the PR, I think what we have here is appropriate. |
Oops, I did not see this before merging #472. I can revert that if we decide not to go in this direction. Personally I have no strong feeling either way -- but we should document what our decision is very clearly. I have a weak preference for @evanlinjin's view -- that we should return the "difference of size of the satisfied TxIn vs the size of a TxIn with no witness" -- and I disagree that the witness flag is part of that calculation. (In general I can't think of a clean way for this library to assist people in accounting for the witness flag.) |
@apoelstra Did you mean #473 ?
Maybe a better definition would be "difference of size of the satisfied TxIn vs the TxIn with no satisfaction data"? So a non-satisfied So "satisfaction weight" will contain additional varint weight (if varints of scriptSig len and stack len increase over the 1 byte threshold), and also the This would make a lot more sense to me. I have attempted this in #476 |
Oops, I did mean #473. And yes, I believe we are saying the same thing -- I still consider the |
Woops sorry, I'm getting confused with all this |
I think #476 is good and |
Replaced by #476 |
7296f8e Introduce `max_weight_to_satisfy` (志宇) Pull request description: Replaces #474, refer to #474 (comment) This PR has two intentions: 1. Redefine `max_satisfaction_weight` to be the difference in `TxIn` weight between "satisfied" and "unsatisfied" states. In an "unsatisfied" state, we still need to include the `scriptSigLen` varint, as well as the `witnessStackLen` (for txs with at least one segwit spend). 2. Attempt further fixes to improve accuracy of `max_satisfaction_weight`. Comments, tests and examples have been updated to reflect the above intentions. ### Notes for reviewers The new definition of `max_satisfaction_weight` can be seen in this comment: https://github.com/rust-bitcoin/rust-miniscript/blob/08cff39fa862ff957c7ff96d17a0011dd6446f87/src/descriptor/mod.rs#L320-L339 ACKs for top commit: sanket1729: ACK 7296f8e Tree-SHA512: ecae8ff742198289b598aefde83ad66a4b7c7cb67da0625b4d84271df510331408c3da6fc8796fc234ce095af08a2f34a5beb5a10549d7ce20a9878b3ab6fd47
As per the definition of
max_satisfaction_weight
, we should take into consideration the varint that records witness stack size. Even legacy spends may require this field if the tx has at least 1 segwit spend, so we should add it.