-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Clearing and settling of HTLC's below the dust limit #48 #84
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
Conversation
Roasbeef
left a comment
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.
Nice work!
With this PR we explicitly say that we safely support micro-payments on the mainchain while adhering to dust-limits.
My comments are pretty minor so we should be able to get this in pretty quickly. It's also a nice step towards adherence to the v1 spec!
channeldb/channel.go
Outdated
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.
Minor nit: the variable name and the godoc comment don't match up. This should be changed to read IsDust.
channeldb/channel.go
Outdated
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.
Hmm, I need to check the spec, but we'll need to ensure that we're storing their value for the dust-limit. This is necessary since we modify their commitment transactions with updates and will need to ensure we adhere to their required dust limit. We don't care about what their dust-limit is as long as they respect our limit.
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.
As I described below I don't separate the dust limit on their and our , the dust limit which I store it is negotiated value and it should be identical for both sides.
channeldb/channel.go
Outdated
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.
Minor suggestion: we can eliminate some unnecessary nesting here if we modify the fragment to read:
if _, err := r.Read(scratch[:1]); err != nil {
retur nil, err
}
if scratch[0] == 1 {
h.Incoming = true
} else {
h.Incoming = false
}
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.
Same applies to the fragment below.
fundingmanager.go
Outdated
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.
We currently don't have a "default" configuration yet for values like the dust-limit, so can you add a TODO here to use the default dust-limit value (or perhaps query a dynamic indicator here?
As written now, this isn't strictly correct since it it just echoes back what they chose, but in practice it works currently.
lnwallet/channel.go
Outdated
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.
Hmm, so on second thought, I think we actually need to retain the state of the dust-limit of both sides since the state machine needs to decide separately for incoming/outgoing HTLC's. Otherwise we may run into a "commitment divergence" due to different decisions about if a HTLC constituted a dust value or not.
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.
As far as I understand we negotiate the dust limit on funding request/response messages. After that we have identical dust limit on both sides and may make the decision - should we include HTLC in commitment transaction or not - relaying on this negotiated dust limit, could you please elaborate why we need to have different dust limits for both sides?
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.
The dust limits aren't negotiated like the fees are within the current spec draft. Instead, both sides have their own distinct dust limits, as both sides ay have different degrees of concfomrat w.r.t to what they think a valid dust-limit is.
As a result, there needs to be two dust-limits, one which must be adhered to when the remote side adds HTLC's to our commitment transactions, and one which we need to be cognizant of where we're triggering updates to their commitment transaciton.
lnwallet/channel_test.go
Outdated
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.
The error here shouldn't be ignored.
lnwallet/channel_test.go
Outdated
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 additional assertion we can throw in is that if we obtain the current commitment transaction for both sides, the HTLC output shouldn't be present on either of them.
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 have a branch locally which starts to factor out paramter like this into a FundingConfig struct which includes all the parameters as are currently defined within the spec.
lnwallet/interface_test.go
Outdated
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.
Nice catch! I think one of my prior commits adding a new test-case accidentally removed this test.
lnwallet/reservation.go
Outdated
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.
Nice, happy to see this removed. This was left over from when we were toying around with a CLTV based channel construction (assuming there isn't a malleability fix).
c5c1092 to
0b388be
Compare
|
@Roasbeef With last commit a have added additional logic to properly negotiate the
|
de71bc9 to
1455220
Compare
Roasbeef
left a comment
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.
Alright, I think this is the final round of review changes.
I like the bit of refactoring that's taken place within the fundingManager in the latest set of commits!
lnwire/single_funding_request.go
Outdated
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.
Minor nit: can you drop the Our|Their prefix from the DustLimit fields here? The PoV context really doesn't apply here since these are wire messages rather than state which is stored locally.
lnwire/single_funding_response.go
Outdated
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.
Same comment here about dropping the prefix.
peer.go
Outdated
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.
Nice catch, this bit of code was unnecessary due to similar logic already residing within the fundingManager.handleErrorGeneric method.
1455220 to
6e9658f
Compare
lnwallet/channel_test.go
Outdated
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.
This line causes the travis build to fail:
--- FAIL: TestCheckDustLimit (0.01s)
channel_test.go:875: for this test to work bob dust limit should be bigger than alice dust limit at least on 2 satoshi
I don't think this line is needed. It seems that the value of the HTLC within the test simply needs to be above Alice's dust limit, but below Bob's dust limit .
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.
Aghhh... :) Thanks! Because of this multi-hop test I had started forget to check the reason of test failure...
I don't think this line is needed. It seems that the value of the HTLC within the test simply needs to be above Alice's dust limit, but below Bob's dust limit.
done
aa6b03d to
e7b55a4
Compare
92377cf to
599b547
Compare
Fixes #48.