Skip to content

multi: replace DefaultDustLimit with accurate dust limit#5781

Merged
Roasbeef merged 3 commits intolightningnetwork:masterfrom
Crypt-iQ:accurate_dust0922
Sep 29, 2021
Merged

multi: replace DefaultDustLimit with accurate dust limit#5781
Roasbeef merged 3 commits intolightningnetwork:masterfrom
Crypt-iQ:accurate_dust0922

Conversation

@Crypt-iQ
Copy link
Collaborator

Commit overview

  • multi: replace DefaultDustLimit with script-specific DustLimitForScript updates all call-sites to DustLimitForScript which takes a pkscript size and calculates the dust-limit. This also fixes the sendcoins CLI command to be able to send 294 satoshis to a p2wpkh output for example. With this commit, the previous 573 limit should no longer be in the lnd codebase.
  • funding+lnwallet: validate ChannelReserve is above DustLimit validates that both sides' ChannelReserve are above both sides' DustLimit. This is implied by BOLT#02 but should be made explicit. I will follow up with a patch to the spec to do this. We also implement Allowing dust limit below 546 sats lightning/bolts#905 along the way by ensuring we send a dust limit that other implementations accept. This dust limit is 354 satoshis by default (the dust limit for a maximally sized witness output with a 40-byte data push).

Q: Should DustLimitForScript take into account different back-end minimum relay fees? The underlying btcd.GetDustThreshold does not.

Fixes #3946

@Crypt-iQ Crypt-iQ added this to the v0.14.0 milestone Sep 23, 2021
@Crypt-iQ Crypt-iQ force-pushed the accurate_dust0922 branch 2 times, most recently from 1b1e6f1 to fa6d1f1 Compare September 23, 2021 21:40
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Main question is if this affects users running with different min relay fee settings. If the dust limit scales based on this, then it may not be possible for them to open channels as implementations may reject what they deem the dust limit.

Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline, I think it's somewhat safe to assume that users aren't changing this config value, as otherwise, they would find that their transactions wouldn't always propagate due to to standardness issues.

@Roasbeef
Copy link
Member

Can update the go.mod to point to the latest tagged versions for the btcwallet sub-modules: btcsuite/btcwallet#767

Copy link
Member

Choose a reason for hiding this comment

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

Why not just return an error here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

o/w the call-sites have to deal with an error, which can't be done with DefaultBtcChannelConstraints for example

Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline, I think it's somewhat safe to assume that users aren't changing this config value, as otherwise, they would find that their transactions wouldn't always propagate due to to standardness issues.

@Roasbeef Roasbeef requested a review from arshbot September 28, 2021 22:13
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🔫

@Roasbeef
Copy link
Member

Just needs a release notes entry, can you also make a new file in that folder for 0.13.3? Thanks

@arshbot
Copy link
Contributor

arshbot commented Sep 29, 2021

Should DustLimitForScript take into account different back-end minimum relay fees

What are those different fees? I'd say if it makes any kind of difference, we can get away with having a floor of the least minimum relay fee between the top 3 or so implementations

Copy link
Contributor

@arshbot arshbot left a comment

Choose a reason for hiding this comment

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

ACK, left a few minor nits

Copy link
Contributor

Choose a reason for hiding this comment

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

does this override manually set dust limits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what you mean by manually set dust limits? The channel acceptor's dust limit isn't currently used in the code and a user can't manually set the dust limit in lnd

@Crypt-iQ
Copy link
Collaborator Author

Should DustLimitForScript take into account different back-end minimum relay fees

What are those different fees? I'd say if it makes any kind of difference, we can get away with having a floor of the least minimum relay fee between the top 3 or so implementations

See comment by @Roasbeef above #5781 (comment)

This commit updates call-sites to use the proper dust limits for
various script types. This also updates the default dust limit used
in the funding flow to be 354 satoshis instead of 573 satoshis.
This is necessary and is implied by BOLT#02. Both ChannelReserve
parameters should be above both DustLimit parameters. Otherwise,
it is possible for one side to have nothing at stake.
@Crypt-iQ
Copy link
Collaborator Author

Currently the witness script sizes are different than non-witness. If that changes, then DustLimitForSize may need to be changed to take an actual pkscript or some enum denoting script type

Copy link
Contributor

@arshbot arshbot left a comment

Choose a reason for hiding this comment

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

LGTM

@Roasbeef Roasbeef merged commit aac824d into lightningnetwork:master Sep 29, 2021
@Crypt-iQ Crypt-iQ deleted the accurate_dust0922 branch September 30, 2021 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lnwallet: incorrect dust limit applied for p2wkh outputs

3 participants