ethereum/trinity

AttributeError escaping from maybe_connect_more_peers

cburgdorf opened this issue · 1 comments

What is wrong?

�[1m�[31m   ERROR  2020-09-10 09:35:40,267           ETHPeerPool  unexpected error during peer connection
Traceback (most recent call last):
  File "/usr/src/app/trinity/trinity/protocol/common/peer.py", line 228, in maybe_connect_more_peers
    for backend in self.peer_backends
  File "/usr/src/app/trinity/p2p/peer_pool.py", line 223, in _add_peers_from_backend
    await self.connect_to_nodes(candidates)
  File "/usr/src/app/trinity/p2p/peer_pool.py", line 452, in connect_to_nodes
    await asyncio.gather(*(self.connect_to_node(node) for node in batch))
  File "/usr/src/app/trinity/p2p/peer_pool.py", line 498, in connect_to_node
    await peer.disconnect(DisconnectReason.TOO_MANY_PEERS)
  File "/usr/src/app/trinity/p2p/peer.py", line 338, in disconnect
    self.disconnect_nowait(reason)
  File "/usr/src/app/trinity/p2p/peer.py", line 349, in disconnect_nowait
    self._send_disconnect(reason)
  File "/usr/src/app/trinity/p2p/peer.py", line 353, in _send_disconnect
    self._p2p_api.disconnect(reason)
AttributeError: 'ETHPeer' object has no attribute '_p2p_api'�[0m

How can it be fixed

Need to investigate

We can only send a Disconnect msg from a running Peer instance because for that we need the Connection behaviors to be applied, which only happen once the peer is running. However, right now we only start a Peer when it is added to the pool, so we have a catch-22 here.