{"type":"rich","version":"1.0","title":"Anthony Towns [ARCHIVE] wrote","author_name":"Anthony Towns [ARCHIVE] (npub17r…x9l2h)","author_url":"https://yabu.me/npub17rld56k4365lfphyd8u8kwuejey5xcazdxptserx03wc4jc9g24stx9l2h","provider_name":"njump","provider_url":"https://yabu.me","html":"📅 Original date posted:2020-02-23\n📝 Original message:\nOn Fri, Feb 21, 2020 at 12:35:20PM +1030, Rusty Russell wrote:\n\u003e \u003e I think the way it would end up working\n\u003e \u003e is that the further the route extends, the greater the payments are, so:\n\u003e \u003e   A -\u003e B   : B sends A 1msat per minute\n\u003e \u003e   A -\u003e B -\u003e C : C sends B 2msat per minute, B forwards 1msat/min to A\n\u003e \u003e   A -\u003e B -\u003e C -\u003e D : D sends C 3 msat, etc\n\u003e \u003e   A -\u003e B -\u003e C -\u003e D -\u003e E : E sends D 4 msat, etc\n\u003e \u003e so each node is receiving +1 msat/minute, except for the last one, who's\n\u003e \u003e paying n msat/minute, where n is the number of hops to have gotten up to\n\u003e \u003e the last one. There's the obvious privacy issue there, with fairly\n\u003e \u003e obvious ways to fudge around it, I think.\n\u003e Yes, it needs to scale with distance to work at all.  However, it has\n\u003e the same problems with other upfront schemes: how does E know to send\n\u003e 4msat per minute?\n\nD tells it \"if you want this HTLC, you'll need to pay 4msat/minute after\nthe grace period of 65 seconds\". Which also means A as the originator can\nalso choose whatever fees they like. The only consequence of choosing too\nhigh a fee is that it's more likely one of the intermediate nodes will\nsay \"screw that!\" and abort the HTLC before it gets to the destination.\n\n\u003e \u003e I think it might make sense for the payments to have a grace period --\n\u003e \u003e ie, \"if you keep this payment open longer than 20 seconds, you have to\n\u003e \u003e start paying me x msat/minute, but if it fulfills or cancels before\n\u003e \u003e then, it's all good\".\n\u003e But whatever the grace period, I can just rely on knowing that B is in\n\u003e Australia (with a 1 second HTLC commit time) to make that node bleed\n\u003e satoshis.  I can send A-\u003eB-\u003eC, and have C fail the htlc after 19\n\u003e seconds for free.  But B has to send 1msat to A.  B can't blame A or C,\n\u003e since this attack could come from further away, too.\n\nSo A gives B a grace period of 35 seconds, B deducts 5 seconds\nprocessing time and 10 seconds for latency, so gives C a grace period of\n20 seconds; C rejects after 19 seconds, and B still has 15 seconds to\nnotify A before he has to start paying fees. Same setup as decreasing\ntimelocks when forwarding HTLCs.\n\n\u003e And if there is a grace period, I can just gum up the network with lots\n\u003e of slow-but-not-slow-enough HTLCs.\n\nWell, it reduces the \"gum up the network for \u003ctimeout\u003e blocks\" to \"gum\nup the network for \u003cgrace period\u003e seconds\", which seems like a pretty\nbig win. I think if you had 20 hops each with a 1 minute grace period,\nand each channel had a max_accepted_htlcs of 30, you'd need 25 HTLCs per\nsecond to block 1000 channels (so 2.7% of the 36k channels 1ml reports),\nso at the very least, successfully performing this attack would be\ndemonstrating lightning's solved bitcoin's transactions-per-second\nlimitation?\n\nI think you could do better by having the acceptable grace period be\ndynamic: both (a) requiring a shorter grace period the more funds a HTLC\nlocks up, which stops a single HTLC from gumming up the channel, and (b) \nrequiring a shorter grace period the more active HTLCs you have (or, the\nmore active HTLCs you have that are in the grace period, perhaps). That\nway if the network is loaded, you're prioritising more efficient routes\n(or at least ones that are willing to pay their way), and if it's under\nattack, you're dynamically increasing the resources needed to maintain\nthe attack.\n\nAnyway, that's my hot take; not claiming it's a perfect solution or\nfinal answer, rather that this still seems worth brainstorming out.\n\nMy feeling is that this might interact nicely with the sender-initiated\nupfront fee. Like, you could replace a grace period of 30 seconds at\n2msat/minute by always charging 2msat/minute but doing a forward payment\nof 1msat. But at this point I can't keep it all in my head at once to\nfigure out something that really makes sense.\n\n\u003e \u003e Maybe this also implies a different protocol for HTLC forwarding,\n\u003e \u003e something like:\n\u003e \u003e   1. A sends the HTLC onion packet to B\n\u003e \u003e   2. B decrypts it, makes sure it makes sense\n\u003e \u003e   3. B sends a half-signed updated channel state back to A\n\u003e \u003e   4. A accepts it, and forwards the other half-signed channel update to B\n\u003e \u003e so that at any point before (4) Alice can say \"this is taking too long,\n\u003e \u003e I'll start losing money\" and safely abort the HTLC she was forwarding to\n\u003e \u003e Bob to avoid paying fees; while only after (4) can she start the time on\n\u003e \u003e expecting Bob to start paying fees that she'll forward back. That means\n\u003e \u003e 1.5 round-trips before Bob can really forward the HTLC on to Carol;\n\u003e \u003e but maybe it's parallelisable, so Bob/Carol could start at (1) as soon\n\u003e \u003e as Alice/Bob has finished (2).\n\u003e We added a ping-before-commit[1] to avoid the case where B has disconnected\n\u003e and we don't know yet; we have to assume an HTLC is stuck once we send\n\u003e commitment_signed.  This would be a formalization of that, but I don't\n\u003e think it's any better?\n\nI don't think it's any better as things stand, but with the \"B pays A\nholding fees\" I think it becomes necessary. If you've got a route\nA-\u003eB-\u003eC then from B's perspective I think it currently looks like:\n\n  A-\u003eB: here's a HTLC, locked in\n\n  B-\u003eC: ping\n  C-\u003eB: pong!\n  B-\u003eC: updated commitment with HTLC locked in\n\n  C-\u003eB: *silence*\n\nat which point the best B can do is unilaterally close the B/C channel\nwith their pre-HTLC commitment, but they still have to wait for that to\nconfirm before they can safely cancel the HTLC with A, and that will\nlikely take more than whatever the grace period is, so B will be losing\nmoney on holding fees.\n\nWhereas:\n\n  A-\u003eB: here's a HTLC, locked in\n\n  B-\u003eC: HTLC proposal\n  C-\u003eB: sure: updated commitment with HTLC locked in\n  B-\u003eC: great, corresponding updated commitment, plus revocation\n  C-\u003eB: revocation\n\nmeans that if C goes silent before B receives a new commitment, B can\ncancel the HTLC with A with no risk (B can publish the old commitment\nstill even if the new arrives later, and C can only publish the pre-HTLC\ncommitment), and if C goes silent after B receives the new commitment, B\ncan drop the new commitment to the blockchain and pay A's fees out of it.\n\n\u003e There's an old proposal to fast-fail HTLCs: Bob sends an new message \"I\n\u003e would fail this HTLC once it's committed, here's the error\" \n\nYeah, you could do \"B-\u003eC: proposal, C-\u003eB: no way!\" instead of \"sure\" to\nfast fail the above too. \n\nAnd I think something like that's necessary (at least with my view of how\nthis \"keep the HTLC open\" payment would work), otherwise B could send C a\n\"1 microsecond grace period, rate of 3e11 msat/minute, HTLC for 100 sat,\ntimeout of 2016 blocks\" and if C couldn't reject it immediately would\nowe B 50c per millisecond it took to cancel.\n\nCheers,\naj"}
