Skip to content

Conversation

@wpaulino
Copy link
Contributor

@wpaulino wpaulino commented May 9, 2018

In this PR, we fix an issue where sometimes transactions wouldn't provide enough of a fee to be relayed by the backend node. This was caused due to bitcoind no longer using the minimum relay fee when estimating fees (see bitcoin/bitcoin@fd29d3d). This would especially cause issues when sweeping outputs after a contract breach, etc. Now, we'll fetch the minimum relay fee from the backend node and ensure it is set as a lower bound if the estimated fee ends up dipping below it.

We also enforce that the channel reserve is above the dust limit. The minimum channel size has also been modified to reflect this change. This allows us to avoid dust outputs from being created in the commitment transactions. This fixes some incompatibility issues between c-lightning and lnd, due tolnd not fully being BOLT-2 compliant.

Fixes #1030.

@Roasbeef Roasbeef added this to the 0.4.2-beta milestone May 9, 2018
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.

Nice! Only major comment is that we also need to bump up the reserve (before we send it to the remote party), if we detect that the value is below 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.

When would this fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't, but it doesn't hurt to check the error.

Copy link
Member

Choose a reason for hiding this comment

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

May be worth adding a debug logging statement here for future diagnostic purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

We also need to ensure that the reserve we propose is above the dust limit. If it is, then we should increase the reserve until it's safely above the dust limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Member

Choose a reason for hiding this comment

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

What's the rational for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you fetch the RelayFee in Start() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Re-reading BOLT#2 it looks like the reserve must be >= then both sides's dust limits.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • So when receiving an open_channel: make sure open_channel.reserve >= open_channel.dustlimit && open_channel.reserve >= ourDustlimit
  • When sending accept_channel: make sure accept_channel.reserve >= accept_channel.dustlimit && accept_channel.reserve >= open_channel.dustLimit

===============================

  • When sending an openChannel: make sure openChannel.reserve >= openChannel.dustLimit && openChannel.reserve >= ourDustlimit, if they reject because of low reserve, we must resend with higher reserve
  • When receiving accept_channel: make sure accept_channel.reserve >= accept_channel.dustlimit && accept_channel.reserve >= openChannel.dustLimit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this should be good to go now.

wpaulino added 3 commits May 14, 2018 14:20
In this commit, we fix an issue where sometimes transactions wouldn't
provide enough of a fee to be relayed by the backend node. This would
especially cause issues when sweeping outputs after a contract breach,
etc.

Now, we'll fetch the minimum relay fee from the backend node and ensure
it is set as a lower bound if the estimated fee ends up dipping below
it.
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 Roasbeef merged commit 321cc69 into lightningnetwork:master May 15, 2018
@wpaulino wpaulino deleted the fee-dust-adherence branch May 17, 2018 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lnd can create transaction below min fee rate

3 participants