-
Notifications
You must be signed in to change notification settings - Fork 312
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
fix: remove deprecated max_satisfaction_weight #1345
fix: remove deprecated max_satisfaction_weight #1345
Conversation
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.
Thank you for having a go at this, however the approach here is incorrect.
First off, it's incorrect to add 4WU to only segwit inputs.
Looking at the docs of max_weight_to_satisfy
, we need to change the definition of our TX_IN_BASE_WEIGHT
to be TxIn::default().segwit_weight()
.
After that, to make the tests pass, we need to change P2WPKH_SATISFACTION_SIZE
to take in to account the scriptSigLen
and witnessLen
.
I think it's okay to assume all transactions are segwit transactions for now? Unless if someone can figure out how to take away the witness len elegantly (for non-segwit txs).
crates/bdk/src/wallet/mod.rs
Outdated
let segwit_add = match is_segwit { | ||
true => 4, | ||
false => 0, | ||
}; |
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.
Is the intention here to include the scriptSigLen
weight? If so, please name the variable appropriately.
However, non-segwit inputs also have this field. Wouldn't it be correct to always have this addition?
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.
Ignore the comment above. Just remove this and add the extra weights to TX_IN_BASE_WEIGHT
.
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.
Great, sorry for the missundestanding.
I think I've fixed this in 52d6283
e397896
to
8d6764d
Compare
Can I please have some input on my statement here? Thanks!
|
8e91886
to
52d6283
Compare
I agree. We currently don't test any non-segwit tx anyways... |
Because we already assume this: So I think it is okay. |
@storopoli can we please rebase the two commits into one and I'll ACK it. |
52d6283
to
6d0f282
Compare
Done, thanks mate! |
crates/bdk/src/wallet/tx_builder.rs
Outdated
let satisfaction_weight = { | ||
let is_segwit = wallet | ||
.get_descriptor_for_keychain(utxo.keychain) | ||
.is_witness() | ||
|| wallet | ||
.get_descriptor_for_keychain(utxo.keychain) | ||
.is_taproot(); | ||
let segwit_add = match is_segwit { | ||
true => 4, | ||
false => 0, | ||
}; | ||
descriptor.max_weight_to_satisfy().unwrap() + segwit_add | ||
}; |
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.
This is still wrong.
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.
Sorry about that. Should be good now.
6d0f282
to
482e16c
Compare
482e16c
to
9078957
Compare
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.
Approach ACK.
For simplicity I think it's fair to assume segwit weight everywhere. Unless someone is doing legacy transactions with hundreds of inputs (which is certainly possible), I don't think you'd notice a difference. We could consider carving out a special case for legacy-only transactions in a future iteration of tx building.
To the note on testing legacy descriptors I don't have an immediate comment on it.
a02230c
to
9f05e63
Compare
@storopoli sorry can you do a rebase on master? thanks |
446acd2
to
73aacda
Compare
Don't worry man. Sure, rebased to master :) |
1bf5bcf
to
d2b8e66
Compare
- Change deprecated `max_satisfaction_weight` to `max_weight_to_satisfy` - Remove `#[allow(deprecated)]` flags - updates the calculations in TXIN_BASE_WEIGHT and P2WPKH_SATISFACTION_SIZE Update crates/bdk/src/wallet/coin_selection.rs Co-authored-by: ValuedMammal <valuedmammal@protonmail.com>
d2b8e66
to
798ed8c
Compare
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 798ed8c
Description
Continuation of #1115.
Closes #1036.
max_satisfaction_weight
tomax_weight_to_satisfy
#[allow(deprecated)]
flagsNotes to the reviewers
I've changed all
max_satisfaction_weight()
tomax_weight_to_satisfy()
inWallet.get_available_utxo()
andWallet.build_fee_bump()
. Checking the docs on theminiscript
crate formax_weight_to_satisfy
has the following note:We are testing if the underlying descriptor
is.segwit()
or.is_taproot
,then adding 4WU if true or leaving as it is otherwise.
Another thing, we are not testing in BDK tests for legacy (pre-segwit) descriptors.
Should I also add them to this PR?
Changelog notice
Fixed
Replace the deprecated
max_satisfaction_weight
fromrust-miniscript
tomax_weight_to_satisfy
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: