units: add consolidate_feerate as cli arg - #77
Conversation
435f5b2 to
bac72d5
Compare
|
I added a commit to match more closely the conventions used in the core client (see commit message). |
|
For latent safety purposes would it make more sense to put the 10 sat/vB default at the ipc.rs boundary, with a named constant? |
Thanks for the suggestion, although, im not sure I fully understand. Clap allows default arguments, so in the CLI options, there needs to be something done if the option is not provided I believe. Are you suggesting changing the way the defaults are handled in cli.rs as well as the suggestion above? I think the other part of your suggestion is that if a value is provided, and the value is 0.0, that it should be changed to a default value instead? Not sure, I find that not so intuitive and maybe we should just error on a 0.0 consolidate_fee_rate. However, it looks like currently 0.0 for fee-rate is accepted, which I think is actually a problem since the network will never propagate a transaction with a 0.0 feerate. |
|
Right now 0 is accepted. My preference is to let the server own the default, which looks like how Core does it. Erroring on 0 makes sense but pulls the default back onto the CLI and capnp can't tell "sent 0" from "sent nothing," so once you reject 0 the client has to supply the value. That's what I was trying to avoid, so I lean server-side default. |
bac72d5 to
8792960
Compare
It sounds like a good idea to enforce the default on the server. However, I'm still a little unclear how the CLI should behave when it gets no argument, since it must then set a value which may as well be the default. Never the less, I have added your suggestion as a fixup even though this now means the default is being set twice. Please let me know if this is what you had in mind or what I am missing. |
58c48b9 to
eeeb968
Compare
|
If there's no further feedback I can autosquash the commits then. I don't think Github is smart enough to autosqush on merge. |
d43c27b to
6855449
Compare
| /// use more inputs than strictly necessary so that the wallet's UTXO | ||
| /// pool can be reduced (default: 10 sats/vB). Long term fee rate, | ||
| /// in satoshis per virtual byte. | ||
| consolidate_fee_rate_sat_per_vb: Option<f64>, |
There was a problem hiding this comment.
I'm still lost as to what this value is for. Can we explain how this interacts with the fee_rate_sat_per_vb here? I think that is what most users would care about
There was a problem hiding this comment.
To add a little more to the docs comment, the consolidation fee (also known as long_term_fee_rate) helps to determine if the current fee_rate is high or low. So, if fee_rate > consolidation_fee_rate, then the current fee_rate is high based on historical trends, and if consolidation_fee_rate > fee_rate then the current fee_rate level is considered cheap. The reason this matters is that BnB will select more inputs to build a transaction when fees are cheap to consolidate the utxo set. Likewise, if the current environment is a low fee_rate environment, BnB will try to find a solution with the least number of UTXOs possible.
There was a problem hiding this comment.
That is why hard_coding the long_term_fee_rate to 1.0 is bad, because it will direct the selection algorithms to think that we are always in a high fee environment, since it's fairly likely that fee_rate is greater than 1 sat/vB.
There was a problem hiding this comment.
Also, by adding this as a parameter, its possible you could do a curl or wget request from some external API to find this value.
There was a problem hiding this comment.
Ok much clearer now. Would you be able to condense that a bit and add that logic in the doc comment?
There was a problem hiding this comment.
Sure, done, with the caveat that this is how the bitcoin core selection works, as well as rust bitcoin coin-selection. However, I'm reasonably sure that's how bdk coin-select works as well. Although, as stated before, I'm not really as well versed on that project.
724e446 to
20556ca
Compare
The current behavior of hard-coding the long_term_fee_rate to be 1 can result in incorrect coin-selection behavior. In bitcoin-core, long-term-feerate is set on the command line using the flag consolidate_feerate, and then changed to long_term_fee_rate in spend.cpp before calling coin-selection algorithms [1]. The text was also copied verbatim (besides units) from the bitcoin-core client [2] and expanded. The default was set to match that of bitcoin-core (10 sats/vB) [3]. This is accomplished by setting a default value via the capnproto interface. [1] ref: https://github.com/bitcoin/bitcoin/blob/32ddfc92d9fdad40880f4c1aa3ad8884d3c8981a/src/wallet/spend.cpp#L1083 [2] ref: https://github.com/bitcoin/bitcoin/blob/32ddfc92d9fdad40880f4c1aa3ad8884d3c8981a/src/wallet/init.cpp#L52 [3] ref: https://github.com/bitcoin/bitcoin/blob/32ddfc92d9fdad40880f4c1aa3ad8884d3c8981a/src/wallet/init.cpp#L52
20556ca to
99c4ce8
Compare
The current behavior of hard-coding the long_term_fee_rate to be 1 can result in incorrect coin-selection behavior.