<oembed><type>rich</type><version>1.0</version><author_name>npub17fjkngg0s0mfx4uhhz6n4puhflwvrhn2h5c78vdr5xda4mvqx89swntr0s</author_name><author_url>https://nostr.ae/npub17fjkngg0s0mfx4uhhz6n4puhflwvrhn2h5c78vdr5xda4mvqx89swntr0s</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-10-22&#xA;📝 Original message:&#xA;Good morning list,&#xA;&#xA;Sorry in advance for the lengthy email, but I think it&#39;s worth detailing my&#xA;hybrid proposal&#xA;(bidirectional upfront payments), it feels to me like a workable solution&#xA;that builds on&#xA;previous proposals. You can safely ignore the details at the end of the&#xA;email and focus only on&#xA;the high-level mechanism at first.&#xA;&#xA;Let&#39;s consider the following route: A -----&gt; B -----&gt; C -----&gt; D&#xA;&#xA;We add a `hold_grace_period_delta` field to `channel_update` (in seconds).&#xA;We add two new fields in the tlv extension of `update_add_htlc`:&#xA;&#xA;* `hold_grace_period` (seconds)&#xA;* `hold_fees` (msat)&#xA;&#xA;We add an `outgoing_hold_grace_period` field in the onion per-hop payload.&#xA;&#xA;When nodes receive an `update_add_htlc`, they verify that:&#xA;&#xA;* `hold_fees` is not unreasonable large&#xA;* `hold_grace_period` is not unreasonably small or large&#xA;* `hold_grace_period` - `outgoing_hold_grace_period` &gt;=&#xA;`hold_grace_period_delta`&#xA;&#xA;Otherwise they immediately fail the HTLC instead of relaying it.&#xA;&#xA;For the example we assume all nodes use `hold_grace_period_delta = 10`.&#xA;&#xA;We add a forward upfront payment of 1 msat (fixed) that is paid&#xA;unconditionally when offering an HTLC.&#xA;We add a backwards upfront payment of `hold_fees` that is paid when&#xA;receiving an HTLC, but refunded&#xA;if the HTLC is settled before the `hold_grace_period` ends (see footnotes&#xA;about this).&#xA;&#xA;* A sends an HTLC to B:&#xA;* `hold_grace_period = 100 sec`&#xA;* `hold_fees = 5 msat`&#xA;* `next_hold_grace_period = 90 sec`&#xA;* forward upfront payment: 1 msat is deduced from A&#39;s main output and added&#xA;to B&#39;s main output&#xA;* backwards upfront payment: 5 msat are deduced from B&#39;s main output and&#xA;added to A&#39;s main output&#xA;* B forwards the HTLC to C:&#xA;* `hold_grace_period = 90 sec`&#xA;* `hold_fees = 6 msat`&#xA;* `next_hold_grace_period = 80 sec`&#xA;* forward upfront payment: 1 msat is deduced from B&#39;s main output and added&#xA;to C&#39;s main output&#xA;* backwards upfront payment: 6 msat are deduced from C&#39;s main output and&#xA;added to B&#39;s main output&#xA;* C forwards the HTLC to D:&#xA;* `hold_grace_period = 80 sec`&#xA;* `hold_fees = 7 msat`&#xA;* `next_hold_grace_period = 70 sec`&#xA;* forward upfront payment: 1 msat is deduced from C&#39;s main output and added&#xA;to D&#39;s main output&#xA;* backwards upfront payment: 7 msat are deduced from D&#39;s main output and&#xA;added to C&#39;s main output&#xA;&#xA;* Scenario 1: D settles the HTLC quickly:&#xA;* all backwards upfront payments are refunded (returned to the respective&#xA;main outputs)&#xA;* only the forward upfront payments have been paid (to protect against&#xA;`uncontrolled spam`)&#xA;&#xA;* Scenario 2: D settles the HTLC after the grace period:&#xA;* D&#39;s backwards upfront payment is not refunded&#xA;* If C and B relay the settlement upstream quickly (before&#xA;`hold_grace_period_delta`) their backwards&#xA;upfront payments are refunded&#xA;* all the forward upfront payments have been paid (to protect against&#xA;`uncontrolled spam`)&#xA;&#xA;* Scenario 3: C delays the HTLC:&#xA;* D settles before its `grace_period`, so its backwards upfront payment is&#xA;refunded by C&#xA;* C delays before settling upstream: it can ensure B will not get refunded,&#xA;but C will not get&#xA;refunded either so B gains the difference in backwards upfront payments&#xA;(which protects against&#xA;`controlled spam`)&#xA;* all the forward upfront payments have been paid (to protect against&#xA;`uncontrolled spam`)&#xA;&#xA;* Scenario 4: the channel B &lt;-&gt; C closes:&#xA;* D settles before its `grace_period`, so its backwards upfront payment is&#xA;refunded by C&#xA;* for whatever reason (malicious or not) the B &lt;-&gt; C channel closes&#xA;* this ensures that C&#39;s backwards upfront payment is paid to B&#xA;* if C publishes an HTLC-fulfill quickly, B may have his backwards upfront&#xA;payment refunded by A&#xA;* if B is forced to wait for his HTLC-timeout, his backwards upfront&#xA;payment will not be refunded&#xA;but it&#39;s ok because B got C&#39;s backwards upfront payment&#xA;* all the forward upfront payments have been paid (to protect against&#xA;`uncontrolled spam`)&#xA;&#xA;If done naively, this mechanism may allow intermediate nodes to deanonymize&#xA;sender/recipient.&#xA;If the base `grace_period` and `hold_fees` are randomized, I believe this&#xA;attack vector disappears,&#xA;but it&#39;s worth exploring in more details.&#xA;&#xA;The most painful part of this proposal will be handling the `grace_period`:&#xA;&#xA;* when do you start counting: when you send/receive `update_add_htlc`,&#xA;`commit_sig` or&#xA;`revoke_and_ack`?&#xA;* what happens if there is a disconnection (how do you account for the&#xA;delay of reconnecting)?&#xA;* what happens if the remote settles after the `grace_period`, but refunds&#xA;himself when sending his&#xA;`commit_sig` (making it look like from his point of view he settled before&#xA;the `grace_period`)?&#xA;I think in that case the behavior should be to give your peers some leeway&#xA;and let them get away&#xA;with it, but record it. If they&#39;re doing it too often, close channels and&#xA;ban them; stealing&#xA;upfront fees should never be worth losing channels.&#xA;&#xA;I chose to make the backwards upfront payment fixed instead of scaling it&#xA;based on the time an HTLC&#xA;is left pending; it&#39;s slightly less penalizing for spammers, but is less&#xA;complex and introduces less&#xA;potential griefing against honest nodes. With the scaling approach, an&#xA;honest node that has its&#xA;channel unilaterally closed is too heavily penalized IMHO (because it has&#xA;to pay for the maximum&#xA;hold duration).&#xA;&#xA;I also chose to make the forward upfront payment constant (1 msat). Is it&#xA;going to be a pain to&#xA;bikeshed this constant? Do we need to add a mechanism to upgrade it? We&#xA;don&#39;t want to make this&#xA;more complex than it should.&#xA;&#xA;Before we dive into the specifics (addressing the implementation concerns),&#xA;can you all please take&#xA;a bit of time to figure out whether the proposed mechanisms would mitigate&#xA;spam or not, and whether&#xA;it introduces griefing attacks against honest nodes. I think it would be a&#xA;waste of your time to&#xA;bikeshed the nuts and bolts details if the proposal is fundamentally&#xA;broken...&#xA;&#xA;Answering to previous emails below.&#xA;&#xA;Your proposal to add a small upfront payment, wouldn&#39;t that allow the&#xA;&gt; (arbitrary) grace period to be removed?&#xA;&#xA;&#xA;I think we need a `grace_period` for the backwards upfront payment, to&#xA;encourage nodes to settle&#xA;quickly (otherwise I believe it&#39;s too easy to grief honest nodes because&#xA;the backwards upfront payment&#xA;will be bigger than the forward one - because `uncontrolled spam` is based&#xA;on volume so it doesn&#39;t&#xA;need a huge fee to mitigate).&#xA;&#xA;Would my inane incremental routing idea also be in scope here?&#xA;&#xA;&#xA;It could potentially be easier to integrate spam mitigation inside&#xA;incremental routing, indeed.&#xA;But I think this proposal is unfortunately very costly in terms of&#xA;latency...&#xA;&#xA;Thanks everyone,&#xA;Bastien&#xA;&#xA;Le mer. 21 oct. 2020 à 05:21, ZmnSCPxj &lt;ZmnSCPxj at protonmail.com&gt; a écrit :&#xA;&#xA;&gt; Good morning t-bast,&#xA;&gt;&#xA;&gt; &gt;&#xA;&gt; &gt; I&#39;ve started summarizing proposals, attacks and threat models on github&#xA;&gt; [1].&#xA;&gt; &gt; I&#39;m hoping it will help readers get up-to-speed and avoid falling in the&#xA;&gt; same pitfalls we already&#xA;&gt; &gt; fell into with previous proposals.&#xA;&gt;&#xA;&gt; Would my inane incremental routing idea also be in scope here?&#xA;&gt; https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-October/002811.html&#xA;&gt;&#xA;&gt;&#xA;&gt; Regards,&#xA;&gt; ZmnSCPxj&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20201022/4a7c0856/attachment.html&gt;</html></oembed>