Skip to content

Conversation

@remyers
Copy link
Contributor

@remyers remyers commented Feb 14, 2025

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

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.04%. Comparing base (10edb42) to head (34209f2).
Report is 15 commits behind head on master.

❗ 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     
Files with missing lines Coverage Δ
...in/scala/fr/acinq/eclair/channel/Commitments.scala 96.36% <100.00%> (+0.06%) ⬆️
...in/scala/fr/acinq/eclair/channel/fsm/Channel.scala 83.90% <100.00%> (-0.17%) ⬇️
...ala/fr/acinq/eclair/wire/protocol/ChannelTlv.scala 100.00% <100.00%> (ø)
...q/eclair/wire/protocol/LightningMessageTypes.scala 99.19% <100.00%> (+0.04%) ⬆️

... and 7 files with indirect coverage changes

@remyers remyers force-pushed the 2502-current-funding-locked branch from 34209f2 to 5cd1827 Compare February 17, 2025 10:45
@remyers
Copy link
Contributor Author

remyers commented Feb 17, 2025

Some things to note during review:

1) The logic in Channel processing of the channel_reestablish message from our peer to determine whether or not to resend splice_locked has a second clause with the comment, "Resend if we have not received their remote announcement_signatures for our latest locked commitment". The logic here is as clear as I could make it, but could perhaps be made more clear. I'm open to suggestions. -- edit: hopefully fixed in force push to c1ebbbc.

  1. I defined lastFundingLockedTlv in Commitments rather than computing it inline in Channels because it's convenient for tests in the OfflineStateSpec tests.

@remyers remyers marked this pull request as ready for review February 17, 2025 10:51
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
@remyers remyers force-pushed the 2502-current-funding-locked branch from 2633d17 to c1ebbbc Compare February 17, 2025 21:20
@remyers
Copy link
Contributor Author

remyers commented Feb 17, 2025

In c1ebbbc I modified the PR to account for legacy channel_reestablish where the new last_funding_locked tlv is not set. I also made changes to prevent a potential splice_locked loop for public channels.

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.
@remyers remyers force-pushed the 2502-current-funding-locked branch from 4fc3cd2 to c2ad77d Compare February 25, 2025 10:36
Copy link
Member

@t-bast t-bast left a 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!

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 !
- moved lastLocalLocked_opt and lastRemoteLocked_opt to be after other vals.
We only need to track the fundingTxIndex (not the msg)

We should also add it everytime we send splice_locked.
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 🔥

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.

3 participants