<oembed><type>rich</type><version>1.0</version><title>Rusty Russell [ARCHIVE] wrote</title><author_name>Rusty Russell [ARCHIVE] (npub1zw…hkhpx)</author_name><author_url>https://yabu.me/npub1zw7cc8z78v6s3grujfvcv3ckpvg6kr0w7nz9yzvwyglyg0qu5sjsqhkhpx</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2020-10-12&#xA;📝 Original message:&#xA;Hi all,&#xA;&#xA;        Our HTLC state machine is optimal, but complex[1]; the Lightning&#xA;Labs team recently did some excellent work finding another place the spec&#xA;is insufficient[2].  Also, the suggestion for more dynamic changes makes it&#xA;more difficult, usually requiring forced quiescence.&#xA;&#xA;The following protocol returns to my earlier thoughts, with cost of&#xA;latency in some cases.&#xA;&#xA;1. The protocol is half-duplex, with each side taking turns; opener first.&#xA;2. It&#39;s still the same form, but it&#39;s always one-direction so both sides&#xA;   stay in sync.&#xA;        update+-&gt; commitsig-&gt; &lt;-revocation &lt;-commitsig revocation-&gt;&#xA;3. A new message pair &#34;turn_request&#34; and &#34;turn_reply&#34; let you request&#xA;   when it&#39;s not your turn.&#xA;4. If you get an update in reply to your turn_request, you lost the race&#xA;   and have to defer your own updates until after peer is finished.&#xA;5. On reconnect, you send two flags: send-in-progress (if you have&#xA;   sent the initial commitsig but not the final revocation) and&#xA;   receive-in-progress (if you have received the initial commitsig&#xA;   not not received the final revocation).  If either is set,&#xA;   the sender (as indicated by the flags) retransmits the entire&#xA;   sequence.&#xA;   Otherwise, (arbitrarily) opener goes first again.&#xA;&#xA;Pros:&#xA;1. Way simpler.  There is only ever one pair of commitment txs for any&#xA;   given commitment index.&#xA;2. Fee changes are now deterministic.  No worrying about the case where&#xA;   the peer&#39;s changes are also in flight.&#xA;3. Dynamic changes can probably happen more simply, since we always&#xA;   negotiate both sides at once.&#xA;&#xA;Cons:&#xA;1. If it&#39;s not your turn, it adds 1 RTT latency.&#xA;&#xA;Unchanged:&#xA;1. Database accesses are unchanged; you need to commit when you send or&#xA;   receive a commitsig.&#xA;2. You can use the same state machine as before, but one day (when&#xA;   this would be compulsory) you&#39;ll be able signficantly simplify;&#xA;   you&#39;ll need to record the index at which HTLCs were changed&#xA;   (added/removed) in case peer wants you to rexmit though.&#xA;&#xA;Cheers,&#xA;Rusty.&#xA;&#xA;[1] This is my fault; I was persuaded early on that optimality was more&#xA;    important than simplicity in a classic nerd-snipe.&#xA;[2] https://github.com/lightningnetwork/lightning-rfc/issues/794</html></oembed>