-
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
htlcswitch: return inbound channel update #6967
base: master
Are you sure you want to change the base?
Conversation
7774d4d
to
2f3b228
Compare
Updated PR to not always return 1024 byte (padded) failure messages, because old senders would still choke on those. Currently it pads to 256 bytes. Longer messages aren't padded at all. |
I'm trying to test this against ACINQ/eclair#2455 and I'm seeing issues. First of all, I can't get lnd to send an error with a tlv stream: I do set tlv field 333 in the onion (the encoded tlv is: Secondly, I tried it the other way around: eclair adds a tlv stream at the end of
I believe lnd incorrectly assigns the tlv stream to the channel update, whereas the channel update is length-prefixed so it should be able to figure out that this tlv stream is outside of the channel update and belongs to the failure message. |
The encoded TLV looks good. But for inbound fees, an additional channel update is only returned in the case of a The other issue I will take a look at, thanks for reporting! |
2f3b228
to
13a7e03
Compare
Fixed the invalid channel update issue, fix pushed. |
Cool thanks for the details, I've done that and eclair was correctly able to deserialize the tlv stream sent by lnd 👍
It doesn't seem to be fixed as of 13a7e03
Here is the encoded failure message I'm sending:
Here is the detailed breakdown of the encoded failure:
I double-checked the lengths and they seem correct, so lnd should be able to separate the |
Got it, thanks for all those intermediate results. Turns out this bug exists for other messages that contain a channel update as well. Will fix. |
Channel update reader fixed in #7262 |
13a7e03
to
e9bbfd9
Compare
Thanks, I've re-run my cross-compat tests and everything looks good! |
In this commit, the tlv extension of a channel update message is parsed. If an inbound fee schedule is encountered, it is reported in the graph rpc calls.
Preparation for negative fees.
Ensure that negative fees are backwards compatible.
e9bbfd9
to
d03cef8
Compare
return err | ||
} | ||
|
||
types, err := tlvStream.DecodeWithParsedTypes(r) |
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 should be using DecodeWithParsedTypesP2P
to avoid a fake record with a maliciously long length
} | ||
|
||
var b bytes.Buffer | ||
if err := f.IncomingUpdate.Encode(&b, pver); err != nil { |
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.
b
isn't used again, so can remove these 4 lines?
case *lnwire.FailIncorrectCltvExpiry: | ||
update = &onionErr.Update | ||
case *lnwire.FailChannelDisabled: | ||
update = &onionErr.Update | ||
case *lnwire.FailTemporaryChannelFailure: | ||
if onionErr.Update == nil { |
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.
Curious, why was this added?
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.
IIRC, without this a nil
update would be appended to the new updates
list.
The main open question for this PR is whether we still need a signal from the sender that they support long failure messages. Maybe in the mean time the proliferation of lnd 0.16 (which includes #6913) is sufficient to just assume that support? |
To get a better idea about whether the signaling is needed, advertized feature bits of public nodes could be useful. Long failure message incompatibility is purely an lnd issue, other implementations have supported it from the start afaik. Feature 31 Feature 27 So it seems that nearly every lnd node on the network is 0.15.1 or above. Unfortunately no new feature bits have been added after that, so it is unclear what the proportion of nodes running 0.16+ is. |
Given that mitigation for replacement recycling attack was made available with version 0.16.1 onwards, can we assume that most lnd nodes on the network would've upgraded? Also, what would be the impact if a portion of the nodes are not supporting long failure message? |
Sounds reasonable.
A non-compatible sender isn't able to properly attribute the error to a (pair of) nodes and will penalize the full route, if I remember it correctly from #6913. |
This PR shows the changes required to return the inbound channel update in a
FeeInsufficient
failure too. This would be an extension of #6703. The goal is to let a subsequent payment attempt succeed also in the case that the sender didn't have an up to date channel policy for the incoming channel and was using outdated inbound fees.To remain backwards compatible, senders that are able to interpret long failure messages will signal this through onion tlv field
333
. Its value is a single byte indicating the failure message version that the sender supports. To receive long failures, the sender should set the value to1
.Builds on #6703.