Skip to content
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

lnwallet/chancloser: remove the commit fee clamp, introduce max fee #6770

Merged

Conversation

Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Jul 26, 2022

In this commit, we stop clamping the ideal fee rate to the commitment fee of the channel. This catches us up to this PR of the spec: lightning/bolts#847.

We also do away with the old 3x ideal fee "max fee", and replace that with an explicit max fee. This new max fee will either be the default multiplier of the ideal fee, or a new user specified max fee value.

We also add a new max_fee field to the co-op close RPC which allow the caller to specify when we should bail out due to fees being too high. This field is only observed if it's set by the initiator however. Once we finish #5644, both sides will be able to properly set this field.

Fixes #6781

@Roasbeef Roasbeef added this to the v0.15.1 milestone Jul 26, 2022
@Roasbeef Roasbeef requested a review from Crypt-iQ July 26, 2022 23:46
@Roasbeef Roasbeef changed the title nwallet/chancloser: remove the commit fee clamp, introduce max fee lnwallet/chancloser: remove the commit fee clamp, introduce max fee Jul 26, 2022
@Roasbeef
Copy link
Member Author

cc @sputn1ck

@Roasbeef Roasbeef added channel closing Related to the closing of channels cooperatively and uncooperatively channel management The management of the nodes channels spec labels Jul 26, 2022
Roasbeef added 7 commits July 26, 2022 17:20
In this commit, we stop clamping the ideal fee rate to the commitment
fee of the channel. This catches us up to this PR of the spec:
lightning/bolts#847.

We also do away with the old 3x ideal fee "max fee", and replace that
with an explicit max fee. This new max fee will either be the default
multiplier of the ideal fee, or a new user specified max fee value.
This lets callers get the thaw height without needing to first obtain a
snapshot of the channel state.
…terface

In this commit, we remove the raw channel state machine pointer from the
chan closer and instead replace that with an interface that captures
*just* the methods we need in order to do the co-op close dance.

This is a preparatory refactoring for some upcoming unit tests.
In this commit, we add a new max_fee field that we'll use to decide when
to bail out of a co-op close dance as the initiator.
In this commit, we parse the new max fee field, and pass it through the
switch, all the way to the peer where it's ultimately passed into the
chan closer state machine.
@Roasbeef Roasbeef force-pushed the co-op-close-with-more-spec-innit branch from 62e9c6c to 046aa7f Compare July 27, 2022 00:23
// specified explicit max fee.
maxFee := idealFeeSat * defaultMaxFeeMultiplier
if cfg.MaxFee > 0 {
maxFee = cfg.Channel.CalcFee(cfg.MaxFee)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the ideal fee, the max fee isn't respected on restart

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think one way to resolve this would be to commit this information to disk when we call MarkCoopBroadcasted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we'd store persistently the preferences of the user at that point, and for the case where we're the responder (but still the initiator), we'd do something like base it off some (larger?) multiplier of the max commitment fee.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it should be stored in MarkCoopBroadcasted since #6760 will end up changing that function's usage. This is because the link may still need to be loaded, but we still want the user's preferences. I made a function called PersistDeliveryScript which could be extended to persist other information before calling MarkCoopBroadcasted

I also think we could check here that the ideal fee isn't greater than the max fee if one exists

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where we're the responder (but still the initiator), we'd do something like base it off some (larger?) multiplier of the max commitment fee.

and/or a config option?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So from my reading, we'll retain the "ideal" fee on restart, since we'll compute the "ideal" fee based on CoopCloseTargetConfs (defaults to 6 blocks). At this point, the req will be nil, so we'll then based the max fee off 3x this ideal fee.

So I think we can either leave it as is, persist it in #6760, or add a config option (yet another one, that ppl prob won't set tbh) to let ppl express what this max multiplier should be.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two ways the ideal fee is set:

  • through rpc if initiating the close
  • via EstimateFeePerKW on CoopCloseTargetConfs

The first case probably won't have the same fee on restart. The second may if the fee estimation doesn't change. I don't think this should be persisted in this PR. It could be done in #6760. But I think any persistence changes should be done in the same release so we don't have to check whether something is stored or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. I'd say a user's expectation would be for things to resume with their desired fee, so we should strive for that. Agree we can do it in another PR, though rn #6760 is marked for 0.16 (and in a draft state).

Copy link
Collaborator

@sputn1ck sputn1ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clear commit structure and easy to read PR!

Just found 2 small nits.

If possible It would probably be nice for users to retroactively change the maxfee in an initiated coop close.

lnwallet/chancloser/chancloser.go Show resolved Hide resolved
lnwallet/channel.go Show resolved Hide resolved
@Roasbeef
Copy link
Member Author

Roasbeef commented Aug 5, 2022

If possible It would probably be nice for users to retroactively change the maxfee in an initiated coop close.

Agreed, though I think it's outside the scope of this PR. Ideally we go ahead with the proposed overhaul of the co-op close in the protocol generally, which should really simplify all the code related to this.

@Roasbeef Roasbeef requested review from Crypt-iQ and sputn1ck August 5, 2022 00:35
@Roasbeef Roasbeef merged commit e4b5aa9 into lightningnetwork:master Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel closing Related to the closing of channels cooperatively and uncooperatively channel management The management of the nodes channels spec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to find compromise in restarted fee negotiation (coop close)?
3 participants