-
Notifications
You must be signed in to change notification settings - Fork 275
Add support for using last_funding_locked tlv in channel_reestablish #3007
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
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3007 +/- ##
==========================================
+ Coverage 86.02% 86.04% +0.01%
==========================================
Files 228 228
Lines 20452 20816 +364
Branches 846 865 +19
==========================================
+ Hits 17594 17911 +317
- Misses 2858 2905 +47
|
34209f2 to
5cd1827
Compare
|
Some things to note during review:
|
This TLV is relevant for splice funding txs only. When the `my_current_funding_locked_txid` TLV attribute confirms the latest funding tx we prune previous funding transaction similarly to receiving `splice_locked` from our peer for that txid. When we receive `your_last_funding_locked_txid` that does not match our latest confirmed funding tx, then we know our peer did not receive our last `splice_locked` and retransmit it. For public channels, nodes also retransmit `splice_locked` after `channel_reestablish` if they have not received `announcement_signatures` for the latest confirmed funding tx. This is needed to prompt our peer to also retransmit their own `splice_locked` and `announcement_signatures`. For public channels, nodes respond to splice_locked with their own splice_locked if it has already been received, but only once. If any announcement_signatures have been sent then we do not do this to prevent exchanging an endless loop of splice_locked messages. These changes ensures both sides will have exchanged `splice_locked` after a disconnect and will be relevant for simple taproot channels to exchange nonces. If the last_funding_locked tlv is not set then nodes always send splice_locked on reconnect to preserve previous behavior for retransmitting `splice_locked`. Note: Previous behavior was susceptible to a race condition if one node sent a channel update after `channel_reestablish`, but before receiving `splice_locked` from a peer that had confirmed the latest funding tx while offline. cf. lightning/bolts#1223
2633d17 to
c1ebbbc
Compare
|
In c1ebbbc I modified the PR to account for legacy |
eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/ChannelTlv.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/wire/protocol/LightningMessageTypes.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
Note: the special cases for the funding tx without locked remote commit will be simplified in another PR.
…l_ready When reconnecting in the Normal state, if a legacy channel does not have its remote funding status set to `Locked`, set and store it to migrate older channels. After reconnecting in other states, the remote funding status will be set to `Locked` and stored when receiving `channel_ready` or deferred if still waiting for the funding tx to be confirmed locally.
Ensure we do not respond to the splice_locked we sent after channel_reestablish with the same splice_locked. There can only be one signed channel announcement and so only one corresponding last splice_locked that could be re-sent after channel_reestablish.
4fc3cd2 to
c2ad77d
Compare
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/CommonFundingHandlers.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForChannelReadyStateSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
t-bast
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.
I finished reviewing the tests, they're really good!
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/test/scala/fr/acinq/eclair/channel/states/e/NormalSplicesStateSpec.scala
Outdated
Show resolved
Hide resolved
Implements suggestions from @t-bast - prevent races - do not re-send announcement sigs if already sent if we receive a redundant splice_locked - update tests to correctly handle receiving a redundant splice_locked - add missing comment about spec change
Implements suggestions from @t-bast - spliceLockedSent becomes a map - add code to trim spliceLockedSent to 10 entries
@t-bast version of this logic is easier to parse and decomposes the comments to make them easier to parse.
When alice receives splice_locked from bob, either before disconnect or after, sometimes alice does not send their announcement_signatures because announcementSigsSent contains the shortChannelId of fundingTx. Modified tests to prevent a race that caused these tests to fail. I suspect somehow after transitioning to the Normal state, the initial funding announcement could briefly be in announcementSigsSent and prevent sending the splice announcement when alice receives splice_locked.
It should not drop pending splices.. Great catch @t-bast !
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/fsm/Channel.scala
Outdated
Show resolved
Hide resolved
We only need to track the fundingTxIndex (not the msg) We should also add it everytime we send splice_locked.
t-bast
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.
LGTM 🚀 🔥
This TLV is relevant for splice funding txs only.
When the
my_current_funding_locked_txidTLV attribute confirms the latest funding tx we prune previous funding transaction similarly to receivingsplice_lockedfrom our peer for that txid.When we receive
your_last_funding_locked_txidthat does not match our latest confirmed funding tx, then we know our peer did not receive our lastsplice_lockedand retransmit it.For public channels, nodes also retransmit
splice_lockedafterchannel_reestablishif they have not receivedannouncement_signaturesfor the latest confirmed funding tx. This is needed to prompt our peer to also retransmit their ownsplice_lockedandannouncement_signatures.For public channels, nodes respond to
splice_lockedwith their ownsplice_lockedif it has already been received, but only once. If any announcement_signatures have been sent then we do not do this to prevent exchanging an endless loop ofsplice_lockedmessages.These changes ensures both sides will have exchanged
splice_lockedafter a disconnect and will be relevant for simple taproot channels to exchange nonces.If the
last_funding_lockedtlv is not set then nodes always sendsplice_lockedon reconnect to preserve previous behavior for retransmittingsplice_locked.Note: Previous behavior was susceptible to a race condition if one node sent a channel update after
channel_reestablish, but before receivingsplice_lockedfrom a peer that had confirmed the latest funding tx while offline.cf. lightning/bolts#1223