<oembed><type>rich</type><version>1.0</version><title>Christian Decker [ARCHIVE] wrote</title><author_name>Christian Decker [ARCHIVE] (npub1wt…gtuyn)</author_name><author_url>https://yabu.me/npub1wtx5qvewc7pd6znlvwktq03mdld05mv3h5dkzfwd3dc30gdmsptsugtuyn</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2020-10-13&#xA;📝 Original message:&#xA;I wonder if we should just go the tried-and-tested leader-based&#xA;mechanism:&#xA;&#xA; 1. The node with the lexicographically lower node_id is determined to&#xA;    be the leader.&#xA; 2. The leader receives proposals for changes from itself and the peer&#xA;    and orders them into a logical sequence of changes&#xA; 3. The leader applies the changes locally and streams them to the peer.&#xA; 4. Either node can initiate a commitment by proposing a `flush` change.&#xA; 5. Upon receiving a `flush` the nodes compute the commitment&#xA;    transaction and exchange signatures.&#xA;&#xA;This is similar to your proposal, but does away with turn changes (it&#39;s&#xA;always the leader&#39;s turn), and therefore reduces the state we need to&#xA;keep track of (and re-negotiate on reconnect).&#xA;&#xA;The downside is that we add a constant overhead to one side&#39;s&#xA;operations, but since we pipeline changes, and are mostly synchronous&#xA;during the signing of the commitment tx today anyway, this comes out to&#xA;1 RTT for each commitment.&#xA;&#xA;On the other hand a token-passing approach (which I think is what you&#xA;propose) require a synchronous token handover whenever a the direction&#xA;of the updates changes. This is assuming I didn&#39;t misunderstand the turn&#xA;mechanics of your proposal :-)&#xA;&#xA;Cheers,&#xA;Christian&#xA;&#xA;Rusty Russell &lt;rusty at rustcorp.com.au&gt; writes:&#xA;&gt; Hi all,&#xA;&gt;&#xA;&gt;         Our HTLC state machine is optimal, but complex[1]; the Lightning&#xA;&gt; Labs team recently did some excellent work finding another place the spec&#xA;&gt; is insufficient[2].  Also, the suggestion for more dynamic changes makes it&#xA;&gt; more difficult, usually requiring forced quiescence.&#xA;&gt;&#xA;&gt; The following protocol returns to my earlier thoughts, with cost of&#xA;&gt; latency in some cases.&#xA;&gt;&#xA;&gt; 1. The protocol is half-duplex, with each side taking turns; opener first.&#xA;&gt; 2. It&#39;s still the same form, but it&#39;s always one-direction so both sides&#xA;&gt;    stay in sync.&#xA;&gt;         update+-&gt; commitsig-&gt; &lt;-revocation &lt;-commitsig revocation-&gt;&#xA;&gt; 3. A new message pair &#34;turn_request&#34; and &#34;turn_reply&#34; let you request&#xA;&gt;    when it&#39;s not your turn.&#xA;&gt; 4. If you get an update in reply to your turn_request, you lost the race&#xA;&gt;    and have to defer your own updates until after peer is finished.&#xA;&gt; 5. On reconnect, you send two flags: send-in-progress (if you have&#xA;&gt;    sent the initial commitsig but not the final revocation) and&#xA;&gt;    receive-in-progress (if you have received the initial commitsig&#xA;&gt;    not not received the final revocation).  If either is set,&#xA;&gt;    the sender (as indicated by the flags) retransmits the entire&#xA;&gt;    sequence.&#xA;&gt;    Otherwise, (arbitrarily) opener goes first again.&#xA;&gt;&#xA;&gt; Pros:&#xA;&gt; 1. Way simpler.  There is only ever one pair of commitment txs for any&#xA;&gt;    given commitment index.&#xA;&gt; 2. Fee changes are now deterministic.  No worrying about the case where&#xA;&gt;    the peer&#39;s changes are also in flight.&#xA;&gt; 3. Dynamic changes can probably happen more simply, since we always&#xA;&gt;    negotiate both sides at once.&#xA;&gt;&#xA;&gt; Cons:&#xA;&gt; 1. If it&#39;s not your turn, it adds 1 RTT latency.&#xA;&gt;&#xA;&gt; Unchanged:&#xA;&gt; 1. Database accesses are unchanged; you need to commit when you send or&#xA;&gt;    receive a commitsig.&#xA;&gt; 2. You can use the same state machine as before, but one day (when&#xA;&gt;    this would be compulsory) you&#39;ll be able signficantly simplify;&#xA;&gt;    you&#39;ll need to record the index at which HTLCs were changed&#xA;&gt;    (added/removed) in case peer wants you to rexmit though.&#xA;&gt;&#xA;&gt; Cheers,&#xA;&gt; Rusty.&#xA;&gt;&#xA;&gt; [1] This is my fault; I was persuaded early on that optimality was more&#xA;&gt;     important than simplicity in a classic nerd-snipe.&#xA;&gt; [2] https://github.com/lightningnetwork/lightning-rfc/issues/794&#xA;&gt; _______________________________________________&#xA;&gt; Lightning-dev mailing list&#xA;&gt; Lightning-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev</html></oembed>