<oembed><type>rich</type><version>1.0</version><author_name>npub1x54n25utwk7dzwzvk2v0aknptez5gxdwcyrxx2wgc0lnhgvwu72qmkqsqu</author_name><author_url>https://nostr.ae/npub1x54n25utwk7dzwzvk2v0aknptez5gxdwcyrxx2wgc0lnhgvwu72qmkqsqu</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2023-04-04&#xA;📝 Original message:&#xA;Hey,&#xA;&#xA;In testing the `splice_locked` workflow I discovered a race condition which&#xA;is critical we solve correctly. The core problem happens if any channel&#xA;activity occurs in the time after `splice_locked` is sent and before&#xA;`splice_locked` is received.&#xA;&#xA;`splice_locked` is defined as being locked once it is both sent and&#xA;received. It is fairly trivial to build a test case for this -- have a node&#xA;continually spamming payments while `splice_lock`ing is occurring and the&#xA;race condition will trigger relatively often.&#xA;&#xA;The race condition effects two messages in particular: `commitment_signed`&#xA;and `announcement_signatures`. Below is an example of how it occurs with&#xA;commitment but the flow is essentially the same for announcement:&#xA;&#xA;Legend:&#xA;Item -&gt; means sent&#xA;Item &lt;- means received&#xA;Chan X (implies a channel at block height X)&#xA;(Since these happen at different times)&#xA;Splice locked race condition example&#xA;Node A. Node B.&#xA;* Channel starts at block height 100&#xA;splice_locked -&gt;&#xA;&lt;- splice_locked&#xA;&lt;- commitments_signed (Chan 100)&#xA;-&gt; splice_locked&#xA;Node B now considers splice locked (Chan 106)&#xA;&lt;- commitments_signed (Chan 106)&#xA;splice_locked &lt;-&#xA;Node A now considers splice locked (Chan 106)&#xA;commitments_signed &lt;- (Chan 100)&#xA;commitments_signed &lt;- (Chan 106)&#xA;Node A considers the commitments_signed for Chan 100 invalid.&#xA;The commitments_signed for Chan 106 is, however, valid.&#xA;This example uses commitments_signed but remains a problem for any message&#xA;that depends on channel state.&#xA;&#xA;The solution requires the temporary storing of two items:&#xA;* [scid] last_short_channel_id (the pre-splice short channel id)&#xA;* [bool] splice_await_commitment_succcess&#xA;&#xA;After sending &amp; receiving `splice_locked` (so called &#39;mutual splice lock),&#xA;the last_short_channel_id should be set to the pre-splice short channel id&#xA;and splice_await_commitment_succcess should be flagged to true.&#xA;&#xA;If an `announcement_signatures` is received with an scid matching&#xA;`last_short_channel_id` the message should be ignored and the channel&#xA;connection should not be aborted (as it normally would).&#xA;&#xA;If a `commitment_signed` message is received with the&#xA;tlv splice_info-&gt;splice_channel_id set to something other than the&#xA;successfully confirmed splice channel_id, the message should be ignored.&#xA;&#xA;Once a revoke_and_ack is successfully sent OR received,&#xA;`last_short_channel_id` and `splice_await_commitment_succcess` should be&#xA;reset and normal validation of `announcement_signatures` and&#xA;`commitment_signed` should be resumed.&#xA;&#xA;This solves the race condition while preserving as strict a validation of&#xA;messages as possible and removes the need to add new fields to these&#xA;messages.&#xA;&#xA;Cheers,&#xA;Dusty&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20230404/15da6a65/attachment-0001.html&gt;</html></oembed>