Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Proposed `funding_cancelled` message

15 messages, Jan 8 to 22, 2018. Started by ZmnSCPxj.

ZmnSCPxj (8), Matt Corallo (4), 7riw77 (2), Pierre

Permalink First message in the Wayback Machine

ZmnSCPxj permalink original

Good morning Lightning world,

https://github.com/lightningnetwork/lightning-rfc/pull/349

I propose in the above pull request a new `funding_cancelled` message intended to inform the fundee node that the funder node is definitely sure that the channel funding transaction can never confirm.

This thread is intended to open a discussion for this proposed message, to be added to v1.1 spec.

The reason for including this message is the below:

1.  Implementing this message should not be onerous, if the node software already implements code to forget the channel after a timeout. We simply trigger this code if the channel funding transaction times out or if this message is received.
2.  It allows replace-by-fee funding transactions. To replace an RBF funding transaction, the funder simply re-initiates the opening protocol from `open_channel` -> `acccept_channel` -> `funding_created` -> `funding_signed`, then broadcasts the replacement funding transaction.  Then both funder and fundee wait for either the old or the new funding transaction to confirm (miners might reject replacements, or the new funding transactions might simply not have propagated to the miner at the time of mining a new block), and once one of the transactions is confirmed deeply enough, the funder cancels the other funding transaction via `funding_cancelled`.
3.  It allows multi-channel funding transactions.  To fund multiple channels from a single transaction, the funder initiates the opening protocol to each node separately.  However, the funder must not boradcast the funding transaction until all fundees reply `funding_signed`.  If some fundees complete the protocol up to `funding_signed` but some fundees time out or fail/cannot contact, then the funder cannot safely broadcast the funding transaction at all. The funder node can then send `funding_cancelled` to each fundee that completed up to `funding_signed` to free resources of those nodes.

In principle the message is unnecessary if funding timeout is implemented by the fundee node. However, this message lets the funder node free up resources on the fundee node.

Admittedly, implementing RBF funding transactions and multi-channel funding transactions is more involved than implementing `funding_cancelled`,

Regards, ZmnSCPxj

Matt Corallo in reply to ZmnSCPxj permalink original

I have to say I'm rather not a fan of this idea. Adding messages which do not result in different node behavior other then waiting for the timeout with little overhead on the node to simply keep watching for the funding transaction is a recipe for ending up with a needlessly complex protocol and misimplementation.

On January 8, 2018 3:26:23 AM UTC, ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> wrote:

Quoted text (47 lines)
>Good morning Lightning world,
>
>https://github.com/lightningnetwork/lightning-rfc/pull/349
>
>I propose in the above pull request a new `funding_cancelled` message
>intended to inform the fundee node that the funder node is definitely
>sure that the channel funding transaction can never confirm.
>
>This thread is intended to open a discussion for this proposed message,
>to be added to v1.1 spec.
>
>The reason for including this message is the below:
>
>1.  Implementing this message should not be onerous, if the node
>software already implements code to forget the channel after a timeout.
>We simply trigger this code if the channel funding transaction times
>out or if this message is received.
>2.  It allows replace-by-fee funding transactions. To replace an RBF
>funding transaction, the funder simply re-initiates the opening
>protocol from `open_channel` -> `acccept_channel` -> `funding_created`
>-> `funding_signed`, then broadcasts the replacement funding
>transaction.  Then both funder and fundee wait for either the old or
>the new funding transaction to confirm (miners might reject
>replacements, or the new funding transactions might simply not have
>propagated to the miner at the time of mining a new block), and once
>one of the transactions is confirmed deeply enough, the funder cancels
>the other funding transaction via `funding_cancelled`.
>3.  It allows multi-channel funding transactions.  To fund multiple
>channels from a single transaction, the funder initiates the opening
>protocol to each node separately.  However, the funder must not
>boradcast the funding transaction until all fundees reply
>`funding_signed`.  If some fundees complete the protocol up to
>`funding_signed` but some fundees time out or fail/cannot contact, then
>the funder cannot safely broadcast the funding transaction at all. The
>funder node can then send `funding_cancelled` to each fundee that
>completed up to `funding_signed` to free resources of those nodes.
>
>In principle the message is unnecessary if funding timeout is
>implemented by the fundee node. However, this message lets the funder
>node free up resources on the fundee node.
>
>Admittedly, implementing RBF funding transactions and multi-channel
>funding transactions is more involved than implementing
>`funding_cancelled`,
>
>Regards,
>ZmnSCPxj
Pierre in reply to ZmnSCPxj permalink original

Hello,

Quoted text (1 line)
> intended to inform the fundee node that the funder node is definitely sure that the channel funding transaction can never confirm

If the deprecated tx initially sent funds to the fundee via push_msat, then the fundee may not want to trust the funder on this. One way to do it trustlessly would be for the funder to attach the actual deprecated funding tx (not necessarily signed, but still could be big) to the `funding_cancelled` message, then the fundee would be able to verify that its inputs have indeed been spent by the overriding tx.

Cheers,

Pierre

ZmnSCPxj in reply to Matt Corallo permalink original

Good morning Matt,

Quoted text (8 lines)
> -------- Original Message --------
> Subject: Re: [Lightning-dev] [1.1] Proposed `funding_cancelled` message
> Local Time: January 8, 2018 10:42 PM
> UTC Time: January 8, 2018 2:42 PM
> From: lf-lists at mattcorallo.com
> To: ZmnSCPxj <ZmnSCPxj at protonmail.com>, lightning-dev\\@lists.linuxfoundation.org <lightning-dev at lists.linuxfoundation.org>
>
> I have to say I'm rather not a fan of this idea. Adding messages which do not result in different node behavior other then waiting for the timeout with little overhead on the node to simply keep watching for the funding transaction is a recipe for ending up with a needlessly complex protocol and misimplementation.

There is no specified timeout for funding transactions, and thus a fundee node may keep track of funding transactions until end-of-life. This is a concern since replaceable funding transactions require that all versions be monitored on the blockchain - there is always the possibility that the winning miner got older versions of the funding transaction.

To my mind, a sketch of an implementation for `funding_cancelled` requires only to delete an entry in a database of transactions to be watched.

Implementing replacable funding transactions require an implementation to keep track of all versions of the funding transaction, as well as the state ("waiting for accept_channel", "waiting for funding_signed", "waiting for confirmation") of each funding transaction version. You would also link all those versions together - for example you might have a separate table containing an ID column that you allocate for each channel open attempt, and separate this from the funding transaction table (which would have a foreign key to the openings table). If one funding transaction confirms "deeply enough", then you send `funding_cancelled` for each other funding transaction.

Note that the complexity here for replace-by-fee funding transactions is due solely to the fact that miners have the choice of mining any version of the transaction. It is possible that a miner deliberately chooses an older version, or (more realistically) that a race condition occurs where you broadcast the replacement but the miner has already won a block before the replacement propagated to it. Thus the funder (who initially owns all coins in the channel) needs to keep track of all versions of the funding transaction it broadcast, regardless. But of course it will want to not consume its own resources watching for transactions that can never confirm if another transaction has deeply confirmed, and it will delete such entries from its database; sending `funding_cancelled` in this case is simply "being nice", and the fundee ignores this at its own detriment, wasting resources each block to check for a transaction that logically can never confirm.

In any case, how would you implement replace-by-fee funding transactions?

Regards, ZmnSCPxj

ZmnSCPxj in reply to Pierre permalink original

Good morning,

Quoted text (18 lines)
> -------- Original Message --------
> Subject: Re: [Lightning-dev] [1.1] Proposed `funding_cancelled` message
> Local Time: January 9, 2018 2:28 AM
> UTC Time: January 8, 2018 6:28 PM
> From: pm+lists at acinq.fr
> To: ZmnSCPxj <ZmnSCPxj at protonmail.com>
> lightning-dev\\@lists.linuxfoundation.org <lightning-dev at lists.linuxfoundation.org>
>
> Hello,
>
>> intended to inform the fundee node that the funder node is definitely sure that the channel funding transaction can never confirm
>
> If the deprecated tx initially sent funds to the fundee via push_msat,
> then the fundee may not want to trust the funder on this. One way to
> do it trustlessly would be for the funder to attach the actual
> deprecated funding tx (not necessarily signed, but still could be big)
> to the funding_cancelled message, then the fundee would be able to
> verify that its inputs have indeed been spent by the overriding tx.

This will not work easily for the multi-channel funding transaction case.

Suppose the funder node A wants to make two channels to two other nodes B and C using a single funding transaction.

1.  In parallel, it initiates the open_channel on both B and C.
2.  B and C respond with accept_channel.  A can now create the funding transaction.
3.  In parallel, it sends the funding_created to both B and C.
4.  B responds with funding_signed.  However, C suddenly disconnects instead of responding with funding_signed.
5.  A cannot safely broadcast the funding transaction.  So it does funding_cancelled to B instead.

It is not safe for A to send the funding transaction to B, because B can turn around and broadcast the funding transaction itself (for example, B and C can be in cahoots with each other, and force A to push_msat more funds to C). In the above case there is no replacement created - the intent is not to increase the fees to speed up opening the channel, the intent is to create a single funding transaction that can be used to anchor A<->B and A<->C channels.

Of course, A can simply double-spend the inputs it used for the multi-channel funding transaction to an address it controls solely, but that just adds an otherwise-unnecessary transaction with the cost paid by A. A would prefer to simply silently forget the A<->B and A<->C channels and let B waste its resources hopelessly scanning each block for a transaction that A will never want to broadcast.

The important part to remember for this proposal is that the current 1.0 spec already allow both replace-by-fee and muilti-channel funding transactions, but at the cost of wasting resources on the fundee side, while only the funder side gets the benefit (either faster channel opens or cheaper channel opens). Remember that the protocols for both replace-by-fee funding transactions and multi-channel funding transactions simply require implementation on the funder side, with the fundee side using the same protocol as the simple single-channel non-replaceable funding transaction case. To prevent this, a fundee node might restrict the number of pending channel opening attempts that a peer can have with it; implementing `funding_cancelled` lets the funder free up this imposed resource limit on the fundee side.

(one could say that the c-lightning one-channel-one-peer is an example of this limiting of the resources an external node can consume, for example; of course, my understanding is that this limit will be lifted later on)

Regards, ZmnSCPxj

Matt Corallo in reply to ZmnSCPxj permalink original

Sounds to me like the lack of a protocol-required minimum timeout is the issue. Because the cost of tracking an unopened channel is relatively trivial, I see limited reason to bother notifying the peer that a channel has timed out. However, due to potentially radically different concepts for what is and isn't an acceptable wait time, it's likely useful to have something like "a receiving node MUST keep a channel ready to be used for at least a week prior to funding transaction confirmation. Thus, a node creating a funding transaction SHOULD double-spend and make unconfirmable a funding transaction which has not confirmed prior to a week."

Note that obviously a node can keep the initial commitment transaction around and just wait forever and if the funding transaction ever confirms it can go broadcast the initial commitment transaction then, but it's much nicer to be able to simply double spend via RBF.

Given the relative simplicity on the receiving end, this could even be slipped in to the spec today prior to v1.1.

Cue bikeshedding.

On January 9, 2018 5:25:29 AM UTC, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (60 lines)
>Good morning Matt,
>
>> -------- Original Message --------
>> Subject: Re: [Lightning-dev] [1.1] Proposed `funding_cancelled`
>message
>> Local Time: January 8, 2018 10:42 PM
>> UTC Time: January 8, 2018 2:42 PM
>> From: lf-lists at mattcorallo.com
>> To: ZmnSCPxj <ZmnSCPxj at protonmail.com>,
>lightning-dev\\@lists.linuxfoundation.org
><lightning-dev at lists.linuxfoundation.org>
>>
>> I have to say I'm rather not a fan of this idea. Adding messages
>which do not result in different node behavior other then waiting for
>the timeout with little overhead on the node to simply keep watching
>for the funding transaction is a recipe for ending up with a needlessly
>complex protocol and misimplementation.
>
>There is no specified timeout for funding transactions, and thus a
>fundee node may keep track of funding transactions until end-of-life.
>This is a concern since replaceable funding transactions require that
>all versions be monitored on the blockchain - there is always the
>possibility that the winning miner got older versions of the funding
>transaction.
>
>To my mind, a sketch of an implementation for `funding_cancelled`
>requires only to delete an entry in a database of transactions to be
>watched.
>
>Implementing replacable funding transactions require an implementation
>to keep track of all versions of the funding transaction, as well as
>the state ("waiting for accept_channel", "waiting for funding_signed",
>"waiting for confirmation") of each funding transaction version. You
>would also link all those versions together - for example you might
>have a separate table containing an ID column that you allocate for
>each channel open attempt, and separate this from the funding
>transaction table (which would have a foreign key to the openings
>table).  If one funding transaction confirms "deeply enough", then you
>send `funding_cancelled` for each other funding transaction.
>
>Note that the complexity here for replace-by-fee funding transactions
>is due solely to the fact that miners have the choice of mining any
>version of the transaction.  It is possible that a miner deliberately
>chooses an older version, or (more realistically) that a race condition
>occurs where you broadcast the replacement but the miner has already
>won a block before the replacement propagated to it.  Thus the funder
>(who initially owns all coins in the channel) needs to keep track of
>all versions of the funding transaction it broadcast, regardless.  But
>of course it will want to not consume its own resources watching for
>transactions that can never confirm if another transaction has deeply
>confirmed, and it will delete such entries from its database; sending
>`funding_cancelled` in this case is simply "being nice", and the fundee
>ignores this at its own detriment, wasting resources each block to
>check for a transaction that logically can never confirm.
>
>In any case, how would you implement replace-by-fee funding
>transactions?
>
>Regards,
>ZmnSCPxj
ZmnSCPxj in reply to Matt Corallo permalink original

Good morning Matt,

Sent with [ProtonMail](https://protonmail.com) Secure Email.

Quoted text (9 lines)
> -------- Original Message --------
> Subject: Re: [Lightning-dev] [1.1] Proposed `funding_cancelled` message
> Local Time: January 15, 2018 9:00 AM
> UTC Time: January 15, 2018 1:00 AM
> From: lf-lists at mattcorallo.com
> To: ZmnSCPxj <ZmnSCPxj at protonmail.com>
> lightning-dev\\\\@lists.linuxfoundation.org <lightning-dev at lists.linuxfoundation.org>
>
> Sounds to me like the lack of a protocol-required minimum timeout is the issue. Because the cost of tracking an unopened channel is relatively trivial, I see limited reason to bother notifying the peer that a channel has timed out. However, due to potentially radically different concepts for what is and isn't an acceptable wait time, it's likely useful to have something like "a receiving node MUST keep a channel ready to be used for at least a week prior to funding transaction confirmation. Thus, a node creating a funding transaction SHOULD double-spend and make unconfirmable a funding transaction which has not confirmed prior to a week."

Though the cost may be trivial for single channels, the cost can be made arbitrarily high by a malicious node that just keeps sending `open_channel` -> `funding_created` with random numbers for transaction ID. It seems sensible for a node implementation to allow limiting the number of pending channel opens for each peer to avoid this (e.g. c-lightning currently limits one-channel-one-peer, even at opening). The intent of `funding_cancelled` is: an honest party can free up the limited resource "number of pending channel opens" by using this message, without having to wait for the timeout, whatever the timeout is defined to be.

Regards, ZmnSCPxj

Matt Corallo in reply to ZmnSCPxj permalink original

I can't imagine the constants add up that fast... Allow 25 channels per peer and limit your peers reasonably and the cost should be low enough. Really not sure why something like a 25 channel limit should limit any usage or reasonably burden a node, what am I missing?

On January 15, 2018 2:14:57 AM UTC, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (38 lines)
>Good morning Matt,
>
>Sent with [ProtonMail](https://protonmail.com) Secure Email.
>
>> -------- Original Message --------
>> Subject: Re: [Lightning-dev] [1.1] Proposed `funding_cancelled`
>message
>> Local Time: January 15, 2018 9:00 AM
>> UTC Time: January 15, 2018 1:00 AM
>> From: lf-lists at mattcorallo.com
>> To: ZmnSCPxj <ZmnSCPxj at protonmail.com>
>> lightning-dev\\\\@lists.linuxfoundation.org
><lightning-dev at lists.linuxfoundation.org>
>>
>> Sounds to me like the lack of a protocol-required minimum timeout is
>the issue. Because the cost of tracking an unopened channel is
>relatively trivial, I see limited reason to bother notifying the peer
>that a channel has timed out. However, due to potentially radically
>different concepts for what is and isn't an acceptable wait time, it's
>likely useful to have something like "a receiving node MUST keep a
>channel ready to be used for at least a week prior to funding
>transaction confirmation. Thus, a node creating a funding transaction
>SHOULD double-spend and make unconfirmable a funding transaction which
>has not confirmed prior to a week."
>
>Though the cost may be trivial for single channels, the cost can be
>made arbitrarily high by a malicious node that just keeps sending
>`open_channel` -> `funding_created` with random numbers for transaction
>ID.  It seems sensible for a node implementation to allow limiting the
>number of pending channel opens for each peer to avoid this (e.g.
>c-lightning currently limits one-channel-one-peer, even at opening).
>The intent of `funding_cancelled` is: an honest party can free up the
>limited resource "number of pending channel opens" by using this
>message, without having to wait for the timeout, whatever the timeout
>is defined to be.
>
>Regards,
>ZmnSCPxj
ZmnSCPxj in reply to Matt Corallo permalink original

Good morning Matt,

Quoted text (1 line)
> I can't imagine the constants add up that fast... Allow 25 channels per peer and limit your peers reasonably and the cost should be low enough. Really not sure why something like a 25 channel limit should limit any usage or reasonably burden a node, what am I missing?

You impose this 25 channels per peer. I start opening a channel to you. Because I did not check mempool or because my fee-estimation algo is bad, I pay too low a fee. I become impatient and bump it up, which you perceive as another open (so it is now 2/25 channels). Unfortunately I only bumped my fee by a tiny amount, because reasons. I bump the fees upwards for example five more times, each of which you perceive as another channel open, so from your side it looks like I am consuming 7/25 channels. Finally the funding transaction confirms, but the 6 previous transactions are perceived by you as unconfirmed channel opens, so you will still keep the 6 channels accounted in your 25-channel-limit.

Suppose in a few days (i.e. much less than a week) I decide to have three more channels to you. If I go through all that (starting with low fee, bumping up fee, etc) then I may very well run out of the available 25 channels to you, even though I only really have 1 channel already opened and am trying to make an additional 3 channels only.

Granted this is somewhat contrived, but it shows what I wish to avoid with `funding_cancelled`.

Regards, ZmnSCPxj

Matt Corallo in reply to ZmnSCPxj permalink original

Ok, so limit things to 100 channels... Still don't see why the constants get into unreasonable load here...

On January 15, 2018 2:53:07 AM UTC, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (30 lines)
>Good morning Matt,
>
>> I can't imagine the constants add up that fast... Allow 25 channels
>per peer and limit your peers reasonably and the cost should be low
>enough. Really not sure why something like a 25 channel limit should
>limit any usage or reasonably burden a node, what am I missing?
>
>You impose this 25 channels per peer.  I start opening a channel to
>you.  Because I did not check mempool or because my fee-estimation algo
>is bad, I pay too low a fee.  I become impatient and bump it up, which
>you perceive as another open (so it is now 2/25 channels).
>Unfortunately I only bumped my fee by a tiny amount, because reasons.
>I bump the fees upwards for example five more times, each of which you
>perceive as another channel open, so from your side it looks like I am
>consuming 7/25 channels.  Finally the funding transaction confirms, but
>the 6 previous transactions are perceived by you as unconfirmed channel
>opens, so you will still keep the 6 channels accounted in your
>25-channel-limit.
>
>Suppose in a few days (i.e. much less than a week) I decide to have
>three more channels to you.  If I go through all that (starting with
>low fee, bumping up fee, etc) then I may very well run out of the
>available 25 channels to you, even though I only really have 1 channel
>already opened and am trying to make an additional 3 channels only.
>
>Granted this is somewhat contrived, but it shows what I wish to avoid
>with `funding_cancelled`.
>
>Regards,
>ZmnSCPxj
7riw77 in reply to Matt Corallo permalink original
Quoted text (4 lines)
> 	You impose this 25 channels per peer.  I start opening a channel to
> you.  Because I did not check mempool or because my fee-estimation algo is
> bad, I pay too low a fee.  I become impatient and bump it up, which you
> perceive as another open (so it is now 2/25 channels).

It seems, to me, that this example could be pretty easily extended to 1000, or 2000, or -- pretty much anything. In fact, this brings up an important'ish point, possibly. If every channel I "try to open," and then fail to, counts as resources of any kind on the receiver, we've just added a perfect attack surface for a denial of service. However this is arranged, it needs to be arranged in a way that does not have (or at least has a minimal number of) fixed pool of resources/magic numbers of any kind that can be exhausted, after which things "no longer work." To do otherwise is to practically invite someone taking the entire network down with a well-planned/executed process that exhausts this resource across a large number of critical nodes (and there will be critical nodes -- it's just a part of graph theory that this will happen).

😊 /r

ZmnSCPxj in reply to 7riw77 permalink original

As mentioned in the text, this is imposed by you on each peer that connects to you. The point is to prevent a single peer from consuming all your memory and CPU and prevent you from servicing legitimate peers- i.e. it prevents denial of service using a single peer and forces attackers to use a *distributed* denial of service.

Regards, ZmnSCPxj

Sent with [ProtonMail](https://protonmail.com) Secure Email.

-------- Original Message -------- On January 18, 2018 7:03 PM, <7riw77 at gmail.com> wrote:

Quoted text (10 lines)
>
>
>> You impose this 25 channels per peer. I start opening a channel to
>> you. Because I did not check mempool or because my fee-estimation algo is
>> bad, I pay too low a fee. I become impatient and bump it up, which you
>> perceive as another open (so it is now 2/25 channels).
>
> It seems, to me, that this example could be pretty easily extended to 1000, or 2000, or -- pretty much anything. In fact, this brings up an important'ish point, possibly. If every channel I "try to open," and then fail to, counts as resources of any kind on the receiver, we've just added a perfect attack surface for a denial of service. However this is arranged, it needs to be arranged in a way that does not have (or at least has a minimal number of) fixed pool of resources/magic numbers of any kind that can be exhausted, after which things "no longer work." To do otherwise is to practically invite someone taking the entire network down with a well-planned/executed process that exhausts this resource across a large number of critical nodes (and there will be critical nodes -- it's just a part of graph theory that this will happen).
>
> 😊 /r
7riw77 in reply to ZmnSCPxj permalink original
Quoted text (4 lines)
> Yes, but it still limits how much damage each peer can do to the node.
> And I think you overstate the ease of distributed denial of service attacks,
> and the relative resource consumption differences on an attacker simulating
> multiple nodes versus one simulating a single node.

So assume the following situation: Someone has gotten a "bum deal" on their pizza (or thinks they have), and they want to take down their pizza provider. They note the lightning node the pizza provider uses happens to be some particular address, so they hire out a 10k node botnet (rather small in the real world), and ask each bot to open as many transactions as possible, as fast as possible, without completing any of them, with the ip address of the node in question. The server eventually says "I'm not accepting any more connections, because I have too many outstanding connections right now," which effectively takes it off line for new transactions, blocking anyone who uses that node from any sort of transaction. How long can this last? So long as the botnet continues asking for new connections.

There are ways around this on the network side -- specifically using anycast, like DNS does, to spread the attack around -- but I'm not certain anycast would work in this case because of the state issues involved in lightning.

When I was at Verisign, we figured a 100g link was enough to block any sort of DDoS against the DNS root servers. The attack against Krebs shows just how silly this line of thinking is today.

There is no perfect defense, but it might be useful to think about these things, and how to solve them, now, rather than once they happen, particularly when the trust of the overall network is in play. This might mean several things, such as --

1. The closer you can come to stateless on the server side during session setup, before you know the request is going to be followed through/is legitimate, the less chance this sort of thing will happen
2. The more you have the ability to shift a transaction from one server to another without losing some essential state, the more a network of devices can be designed to handle such problems

There may be other solutions, as well; just throwing some ideas out there.

😊 /r

ZmnSCPxj in reply to 7riw77 permalink original

I do not see the relevance of the example. The limit I propose that nodes will impose is a limit imposed on *each* *peer*, not a limit imposed on all peers in total. Indeed, imposing the limit on each peer reduces the actual CPU, bandwidth, and storage resources that each peer can consume on the attacked node. If it did not limit each peer, then each attacking peer can consume significantly more resources (CPU, bandwidth, storage) that other, legitimate peers would want to use. By limiting each peer to some maximum number of channel open attempts, it allows the server to serve more peers, and possibly shrug off a 10k or 100k attack (depending on the actual CPU/bandwidth/storage resources it has) that it otherwise would be unable to service if each peer could consume an arbitrary amount of resources on the server.

In any case this has diverged from "propose `funding_cancelled` message". Obviously only cooperative, non-attacking peers will use `funding_canclled`, but only cooperative non-attacking peers will start an `open_channel` sequence and broadcast a valid funding tx to the blockchain network anyway.

Regards, ZmnSCPxj

Sent with [ProtonMail](https://protonmail.com) Secure Email.

-------- Original Message -------- On January 21, 2018 8:57 PM, <7riw77 at gmail.com> wrote:

Quoted text (21 lines)
>
>
>> Yes, but it still limits how much damage each peer can do to the node.
>> And I think you overstate the ease of distributed denial of service attacks,
>> and the relative resource consumption differences on an attacker simulating
>> multiple nodes versus one simulating a single node.
>
> So assume the following situation: Someone has gotten a "bum deal" on their pizza (or thinks they have), and they want to take down their pizza provider. They note the lightning node the pizza provider uses happens to be some particular address, so they hire out a 10k node botnet (rather small in the real world), and ask each bot to open as many transactions as possible, as fast as possible, without completing any of them, with the ip address of the node in question. The server eventually says "I'm not accepting any more connections, because I have too many outstanding connections right now," which effectively takes it off line for new transactions, blocking anyone who uses that node from any sort of transaction. How long can this last? So long as the botnet continues asking for new connections.
>
> There are ways around this on the network side -- specifically using anycast, like DNS does, to spread the attack around -- but I'm not certain anycast would work in this case because of the state issues involved in lightning.
>
> When I was at Verisign, we figured a 100g link was enough to block any sort of DDoS against the DNS root servers. The attack against Krebs shows just how silly this line of thinking is today.
>
> There is no perfect defense, but it might be useful to think about these things, and how to solve them, now, rather than once they happen, particularly when the trust of the overall network is in play. This might mean several things, such as --
>
> - The closer you can come to stateless on the server side during session setup, before you know the request is going to be followed through/is legitimate, the less chance this sort of thing will happen
> - The more you have the ability to shift a transaction from one server to another without losing some essential state, the more a network of devices can be designed to handle such problems
>
> There may be other solutions, as well; just throwing some ideas out there.
>
> 😊 /r
ZmnSCPxj in reply to ZmnSCPxj permalink original

Good morning all,

Looking at BOLT#1, there is an `error` message which is supposed to "fail the channel". At a first glance, it seems to be what is basically a superpowered version of `funding_cancelled`, since it only fails the channel (and in particular does not indicate to fail the peer or fail the connection).

I will need to check exactly how each implementation reacts to an `error` message while awaiting lockin, but it looks like `funding_cancelled` is unnecessary for RBF and multi-funding/coinjoined funding transactions.

Regards, ZmnSCPxj