mempool-dumpster icon indicating copy to clipboard operation
mempool-dumpster copied to clipboard

Chainbound channel leak

Open estensen opened this issue 10 months ago • 0 comments

Starting a Chainbound connection

  1. Creates a channel A to receive transactions
  2. Spawns a goroutine to connect to Fiber
  3. Blocks reading from channel A

https://github.com/flashbots/mempool-dumpster/blob/84c076852252151ff6aef0174a94a778464af6b2/collector/node_conn_chainbound.go#L55-L69

If an error occurs either when first connecting to Fiber or from an error receiving a new tx a reconnect is triggered

https://github.com/flashbots/mempool-dumpster/blob/84c076852252151ff6aef0174a94a778464af6b2/collector/node_conn_chainbound.go#L95-L99

or

https://github.com/flashbots/mempool-dumpster/blob/84c076852252151ff6aef0174a94a778464af6b2/collector/node_conn_chainbound.go#L109-L114

The reconnect will call start and a new channel B will be created. Channel A will not be closed and leak. https://github.com/flashbots/mempool-dumpster/blob/84c076852252151ff6aef0174a94a778464af6b2/collector/node_conn_chainbound.go#L82

I'm not sure how much of a problem the leak is, but a more robust way to handle the connection lifecycle would be to create a centralized loop.

estensen avatar Apr 02 '25 10:04 estensen