-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
sweeper: lower the default max fee rate and make it configurable #7823
sweeper: lower the default max fee rate and make it configurable #7823
Conversation
45326c7
to
a28c696
Compare
lncfg/sweeper.go
Outdated
) | ||
|
||
//nolint:lll | ||
type Sweeper struct { | ||
BatchWindowDuration time.Duration `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input."` | ||
BatchWindowDuration time.Duration `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input."` | ||
MaxFeeRate chainfee.SatPerKWeight `long:"maxfeerate" description:"Maximum fee rate in sat/kw that the sweeper is allowed to pay."` |
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.
can this be in sat/vb? that way users don't need to do the conversion to sat/kw?
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.
yeah sat/vb
can be nice, tho one day we may want it to be decimal or use sat/kvb
instead in case bitcoin goes to 1m.
Thank you for the pull request. I agree with giving more control over the feerates for sweeps. However, I am cautious about the proposed minimum limit of 100 sat/vb. I would prefer to completely remove the limit and instead provide a clear warning message in the sample-lnd.conf and the help section, emphasizing that setting too low of a value could risk the funds. All Noderunners who still decide to modify the option despite the warning will presumably be aware of the potential risks. Even with 100 sat/vb, there is no guarantee that all funds will be safely swept. In early May, some cases required as much as 500 sat/vb. |
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.
All Noderunners who still decide to modify the option despite the warning will presumably be aware of the potential risks.
I'm getting very different feedback here. Tho I'm leaning towards making it purely determined by node runners, some sanity check here is necessary - you will only hit this number if the mempool is very congested, in which case you probably wanna have a higher fee rate. If we decide to remove the limits, I'd say we should remove it gradually. Plus in my mind, a better config for the sweeper is to limit by fees paid proportional to the input value, not fee rate, which is something I'm working on atm.
Even with 100 sat/vb, there is no guarantee that all funds will be safely swept. In early May, some cases required as much as 500 sat/vb.
Yeah that's why we have a default of 1000.
lncfg/sweeper.go
Outdated
) | ||
|
||
//nolint:lll | ||
type Sweeper struct { | ||
BatchWindowDuration time.Duration `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input."` | ||
BatchWindowDuration time.Duration `long:"batchwindowduration" description:"Duration of the sweep batch window. The sweep is held back during the batch window to allow more inputs to be added and thereby lower the fee per input."` | ||
MaxFeeRate chainfee.SatPerKWeight `long:"maxfeerate" description:"Maximum fee rate in sat/kw that the sweeper is allowed to pay."` |
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.
yeah sat/vb
can be nice, tho one day we may want it to be decimal or use sat/kvb
instead in case bitcoin goes to 1m.
e7a1418
to
804ed98
Compare
804ed98
to
a87a9fd
Compare
a87a9fd
to
32df3fb
Compare
cc @ziggie1984 |
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.
TACK. I think it is definitely worth decreasing the max fee rate giving node runners a piece of mind so that their sweep fees will not skyrock.
This fee limit relates to the effective feerate currently meaning that when we CPFP a transaction fees can even go higher and here I would suggest to limit the fee rate to the maximum fee rate of a transaction. CPFPing big parents (big commitment transaction) could overshoot this limit highly and I think users are not aware of this wdyt ?
I am in favour of setting a minimum and allow for a gradual change. Different inputs have different priorities in terms of getting confirmed so I highly recommend to add a limit so that node runners do not shoot themselves into the foot.
Reviewed 8 of 11 files at r1.
Reviewable status: 8 of 11 files reviewed, 8 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @yyforyongyu)
sample-lnd.conf
line 1785 at r1 (raw file):
; sweeper.batchwindowduration=30s ; The max fee rate in sat/vb can be used when sweeping funds. Setting this
... in sat/vb which can be ....
sample-lnd.conf
line 1787 at r1 (raw file):
; The max fee rate in sat/vb can be used when sweeping funds. Setting this ; value too low can result in transactions not being confirmed in time, causing ; HTLCs to expire.
... HTLCs to expire hence potentially losing funds.
docs/release-notes/release-notes-0.17.0.md
line 133 at r1 (raw file):
time, which could result in fund loss. Please note that the actual fee rate to be used is deteremined by the fee estimator used(for instance `bitcoind`), and this value is a cap on the max
I think it is worth pointing out, that the fee estimation is not really capped at the value 1000 but rather fee estimation fails completely when overestimating ?
sweep/sweeper.go
line 500 at r1 (raw file):
"rate %v, minimum is %v", feeRate, s.relayFeeRate) } if feeRate > s.cfg.MaxFeeRate.FeePerKWeight() {
What do you think about capping the value here instead of returning an error, rather publish a transaction with the capped limit than not publishing at all?
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.
Reviewable status: 8 of 11 files reviewed, 8 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @ziggie1984)
sample-lnd.conf
line 1785 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
... in sat/vb which can be ....
Done.
sample-lnd.conf
line 1787 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
... HTLCs to expire hence potentially losing funds.
Done.
docs/release-notes/release-notes-0.17.0.md
line 133 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
I think it is worth pointing out, that the fee estimation is not really capped at the value 1000 but rather fee estimation fails completely when overestimating ?
What do you mean fee estimation fails completely when overestimating ?
?
sweep/sweeper.go
line 500 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
What do you think about capping the value here instead of returning an error, rather publish a transaction with the capped limit than not publishing at all?
Yeah I like it, but let's do it in another PR to limit the scope.
32df3fb
to
2465732
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.
Reviewable status: 3 of 11 files reviewed, 8 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @yyforyongyu)
docs/release-notes/release-notes-0.17.0.md
line 133 at r1 (raw file):
Previously, yyforyongyu (Yong) wrote…
What do you mean
fee estimation fails completely when overestimating ?
?
meaning that we fail the fee-estimation when we overestimate rather than cap on the max, for me cap on the max means we cap it and return, relates to the comment where I suggest capping the value to the max fee instead of failing.
2465732
to
5c9b968
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.
Reviewable status: 3 of 11 files reviewed, 8 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @ziggie1984)
docs/release-notes/release-notes-0.17.0.md
line 133 at r1 (raw file):
Previously, ziggie1984 (ziggieXXX) wrote…
meaning that we fail the fee-estimation when we overestimate rather than cap on the max, for me cap on the max means we cap it and return, relates to the comment where I suggest capping the value to the max fee instead of failing.
gotya, yeah make sense. Added a commit to cap it instead as I think it'd be confusing if we change the behavior again and update the release notes. Will see the build results, hopefully it's a small change.
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.
I don't CPFP should or would go over the limit? We have a check here, https://github.com/lightningnetwork/lnd/blob/master/sweep/sweeper.go#L995
So we'd do CPFP only when the newly estimated fee rate exceeds the parent fee rate. But I do remember some issues related to the parent fee calculation, but yeah we shouldn't allow it to happen.
Reviewable status: 3 of 11 files reviewed, 8 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @ziggie1984)
29a3c2d
to
9fc40ed
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.
Really cool PR, I like that we also cap now the child transaction as well :)
Apart from the logging of feerates instead of absolute fees this PR ready to hit the road
Reviewed 2 of 11 files at r1, 1 of 11 files at r4.
Reviewable status: 6 of 20 files reviewed, 7 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @yyforyongyu)
-- commits
line 26 at r4:
Nit s/the/when/g
sweep/weight_estimator.go
line 136 at r4 (raw file):
maxFee := w.maxFeeRate.FeeForWeight(childWeight) if fee > maxFee { log.Warnf("Estimated fee %v exceeds max allowed fee %v, using "+
can we log the feer rates instead of the absolute fee values or maybe both ?
sweep/weight_estimator_test.go
line 107 at r4 (raw file):
require.NoError(t, w.add(&childInput)) // The child weight should be 322 bytes.
weight units rather than bytes ?
9fc40ed
to
4d75ac2
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.
LGTM
5b4644c
to
78da856
Compare
} | ||
|
||
// Clamp the fee to the max fee rate. | ||
maxFee := w.maxFeeRate.FeeForWeight(childWeight) |
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.
Not for this PR: I think we should be using a different function in the non-channel code because FeeForWeight
rounds down and is necessary to agree on a fee with your peer, but in the sweeper and other places you can round up
sweep/tx_input_set.go
Outdated
@@ -118,11 +121,12 @@ type txInputSet struct { | |||
} | |||
|
|||
// newTxInputSet constructs a new, empty input set. | |||
func newTxInputSet(wallet Wallet, feePerKW chainfee.SatPerKWeight, | |||
func newTxInputSet(wallet Wallet, feePerKW, maxFeeRrate chainfee.SatPerKWeight, |
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.
nit: maxFeeRate
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.
fixed
7a34cac
to
e895b48
Compare
@yyforyongyu, remember to re-request review from reviewers when ready |
This commit changes the DefaultMaxFeeRate from 10,120 sat/vb to 1,000 sat/vb.
78da856
to
89ec319
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.
one nit
89ec319
to
8f6d531
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.
Reviewed 1 of 17 files at r6, all commit messages.
Reviewable status: 4 of 21 files reviewed, 11 unresolved discussions (waiting on @Crypt-iQ, @feelancer21, and @yyforyongyu)
docs/release-notes/release-notes-0.18.0.md
line 32 at r8 (raw file):
time, which could result in fund loss. Please note that the actual fee rate to be used is deteremined by the fee estimator used(for instance `bitcoind`), and this value is a cap on the max
Nit: Space
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.
LGTM 🥨
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 two inputs from my end, other than that looks good!
This commit caps the estimated fee rate at the configged max fee rate instead of returning an error.
This commit updates the `fee()` method in `weightEstimator` to make sure when doing CPFP we are not exceeding the max allowed fee rate. In order to use the max fee rate, we need to modify several methods to pass the configured value to the estimator.
8f6d531
to
4622ea9
Compare
27aab00
into
lightningnetwork:0-18-staging
funds. The default value is 1000 sat/vb. Setting this value below 100 sat/vb | ||
is not allowed, as low fee rate can cause transactions not confirming in | ||
time, which could result in fund loss. | ||
Please note that the actual fee rate to be used is deteremined by the fee |
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.
deteremined -> determined
This PR decreases the max fee rate by 10x and makes it configurable.
This change is