Add limit for incoming connections from peers without channels#2601
Add limit for incoming connections from peers without channels#2601remyers merged 27 commits intoACINQ:masterfrom
Conversation
|
We should think about how this interacts with onion messages. Anyone can connect directly to us to send us a message (to request an invoice for an offer for instance) and we want to keep this behavior. We already have a limit to the number of onion message we accept per second (https://github.com/ACINQ/eclair/blob/master/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala#L182) but unless we are currently receiving a lot of messages, we want to continue accepting messages from strangers. Looking at your proposal, it seems that once we reach the maximum number of connections allowed we don't accept new connections (and thus don't accept onion messages), if it doesn't cause other problems I would prefer continuing accepting new connections but closing old idle ones to stay under the limit. |
Good point; onion messages are going to be a new source of connections from nodes without channels. I didn't see anything in the Onion Message PR about whether or not a connection should be kept open indefinitely after sending an onion message. This could lead to hitting the limit proposed by this PR and cause an unintentional DoS for both opening channels and receiving onion messages. Without any limit it could also lead to an ever increasing number of connections. As suggested, one approach is to track a timestamp for each connection without a channel and periodically close inactive connections. This would require adding a new data structures in |
|
This PR implements similar functionality to LDK PR #1988 wrt limiting incoming connections. |
- added new child actor to Switchboard to track peers with inbound connections - terminate peer with oldest inbound connection if tracked peers are over limit
- if the channel is killed while waiting to open, it will lead to sending PeerDisconnected if that is the last channel.
- this ensures new connections will succeed while waiting for the PeerDisconnected event - will need to handle an extra unnecessary PeerDisconnected event after disconnecting an old node
- clearer name and homage to similar LDK parameter
244a87a to
2cfe424
Compare
|
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2601 +/- ##
==========================================
- Coverage 85.69% 85.65% -0.05%
==========================================
Files 211 212 +1
Lines 16919 16962 +43
Branches 728 723 -5
==========================================
+ Hits 14499 14529 +30
- Misses 2420 2433 +13
|
t-bast
left a comment
There was a problem hiding this comment.
Concept ACK! We'll probably need to beef up the release notes with more details about DoS issues at various level, I believe this should help node operators configure their eclair node to make sure this new feature doesn't create more problems that it solves.
eclair-core/src/main/scala/fr/acinq/eclair/io/IncomingConnectionsTracker.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/io/IncomingConnectionsTracker.scala
Show resolved
Hide resolved
- why we don't count all child actors - why a DoS attack is against inbound liquidity is now possible
eclair-core/src/main/scala/fr/acinq/eclair/io/Switchboard.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/io/IncomingConnectionsTracker.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/io/IncomingConnectionsTracker.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/io/IncomingConnectionsTracker.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/io/IncomingConnectionsTracker.scala
Outdated
Show resolved
Hide resolved
- also add test to confirm actor terminates when sent an unhandled message
- prevent switchboard from sending an unhandled classic message if peer not found to disconnect
- peer can receive `Disconnect` before `Init`
t-bast
left a comment
There was a problem hiding this comment.
LGTM, I only have nits and we should be good to go 👍
Limit the number of incoming connections from nodes we don't have channels with.
switchboardchecks if we have channels with that peersync-whitelist, do not track itWe do not track peers we initiate outgoing channel connections to