-
Notifications
You must be signed in to change notification settings - Fork 416
Migrate to bitcoin::FeeRate #1216
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
Migrate to bitcoin::FeeRate #1216
Conversation
429b65c to
04a9643
Compare
|
After looking at some related work, I'm not totally opposed to displaying only whole numbers of fee rates. The difference between 99 and 100 sat/vb seems less significant than the difference between 1 and 2 sat/vb. Some other conveniences I think would be handy:
|
04a9643 to
d1bf88b
Compare
f781978 to
afeb4da
Compare
The fee and fee rate sanity check should be done in a new PR, I created bitcoindevkit/bdk_wallet#120 for this issue. |
1d43f8c to
553bdf9
Compare
|
Rebased to 553bdf9
|
553bdf9 to
5ade840
Compare
5ade840 to
2f39839
Compare
|
I think I have a controversial opinion about these changes. Because we plan to redo the entire tx building logic (after 1.0), and the current tx builder works okay as it is... Would this be worth the effort? |
|
This one needs a rebase after alpha.5 release. |
I think it's fair to have a deeper discussion about this. I don't have strong feelings either way. I think I lean toward making the change because 1) ease of maintainability by aligning with rust bitcoin, 2) the units of a feerate can always be converted to any unit you like. Granted I'm not as familiar with some of the long-standing design efforts of BDK, so I'm happy to get other opinions or hold off until everyone's in agreement. |
2f39839 to
737c954
Compare
storopoli
left a comment
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.
Some changes proposed.
Mostly important is to use from_vb instead of from_vb_unchecked in code and examples.
Tests are fine to use the unchecked version.
|
Thank you @storopoli , many good points brought up. I'm working through some of the comments now |
737c954 to
766cdda
Compare
storopoli
left a comment
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.
Just a minor thing.
|
Recent changes:
|
evanlinjin
left a comment
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.
Thanks for working on this, fee/weight calculations should be more accurate than before since the old FeeRate::fee_wu was rounding up virtual bytes to whole units, whereas the Mul<FeeRate> for Weight impl (which we are using now) is rounding up kilo-wus.
However, I think we should try our best to avoid these changes in the future. This took a long time to review for me as I had to revisit old code to understand the ramifications of these changes. If there is no bug, we should just leave it as is so we can focus our efforts on the new TxBuilder.
As a final nit, let's get rid of Vbytes and I will happily ACK this!
766cdda to
0118419
Compare
4ec57c4 to
9ffced2
Compare
|
|
@ValuedMammal rebase on master should fix it now! |
Adopt `bitcoin::FeeRate` throughout
This makes the helper `feerate_unchecked` now redundant but still usable.
Also modify a unit test `test_bump_fee_low_fee_rate` to additionally assert the expected error message
The only place this is being used is a unit test that is easily refactored. For size conversions prefer methods on e.g. `Weight`.
9ffced2 to
475a772
Compare
evanlinjin
left a comment
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 475a772
Description
This follows a similar approach to #1141 namely to remove
FeeRatefrombdk::typesand instead defer to the upstream implementation for all fee rates. The idea is that making the switch allows BDK to benefit from a higher level abstraction, leaving the implementation details largely hidden.As noted in #774, we should avoid extraneous conversions that can result in deviations in estimated transaction size and calculated fee amounts, etc. This would happen for example whenever calling a method like
FeeRate::to_sat_per_vb_ceil. The only exception I would make is if we must return a fee rate error to the user, we might prefer to display it in the more familiar sats/vb, but this would only be useful if the rate can be expressed as a float.Notes to the reviewers
bitcoin::FeeRateis an integer whose native unit is sats per kilo-weight unit. In order to facilitate the change, a helper methodfeerate_uncheckedis added and used only in wallet tests and psbt tests as necessary to convert existing fee rates to the new type. It's "unchecked" in the sense that we're not checking for integer overflow, because it's assumed we're passing a valid fee rate in a unit test.Potential follow-ups can include:
FeeRatefrom au64in all unit tests, and thus obviating the need for the helperfeerate_uncheckedgoing forward.Vbytes.TxBuilder::drain_tois within "standard" size limits.coin_selection::select_sorted_utxosto be efficient and readable.closes #1136
Changelog notice
FeeRatetype. All fee rates are now rust-bitcoinFeeRate.Vbytes.Checklists
All Submissions:
cargo fmtandcargo clippybefore committing