koinos / koinos-p2p

The p2p microservice orchestrates the distribution of blocks and transactions between peers.
MIT License
6 stars 4 forks source link

[BUG]: Attempting to connect to already connected peer #278

Closed mvandeberg closed 4 months ago

mvandeberg commented 1 year ago

Is there an existing issue for this?

Current behavior

My node is attempting to connect to some peers (as seeds) that it is already connected to.

koinos-p2p-1                  | 2023-01-10 17:08:45.488757 (p2p.Koinos) [node/node.go:370] <info>: My address:
koinos-p2p-1                  | 2023-01-10 17:08:45.488892 (p2p.Koinos) [node/node.go:371] <info>:  - /ip4/172.21.0.10/tcp/8888/p2p/QmVtisC7RHeSqAaay2YMNFM3FxcqiYEDYDH1iRbzKB23GM
koinos-p2p-1                  | 2023-01-10 17:08:45.488908 (p2p.Koinos) [node/node.go:372] <info>: Connected peers:
koinos-p2p-1                  | 2023-01-10 17:08:45.488933 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/165.227.92.96/tcp/8888/p2p/QmZUNxrMibeW4tHgih72aouVpMp4oCgW5883qaNKNVJPeX
koinos-p2p-1                  | 2023-01-10 17:08:45.488947 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/135.181.131.87/tcp/8888/p2p/QmaFFAoozwHG9Ag4SSZkU9gKZbkhSUnM4BnqQBaNMH3gUG
koinos-p2p-1                  | 2023-01-10 17:08:45.488960 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/144.76.219.133/tcp/8888/p2p/QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze
koinos-p2p-1                  | 2023-01-10 17:08:45.488973 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/72.14.176.133/tcp/8888/p2p/QmRtQAWUN8YfMubQ2NJC33mFAcnViByuQ1YUetqR6Ff1Rc
koinos-p2p-1                  | 2023-01-10 17:08:45.488986 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/128.199.60.250/tcp/8888/p2p/QmcXhLC5FR1w41xjCPzq8C54H3c1V6vNckueqMGckU4cY3
koinos-p2p-1                  | 2023-01-10 17:08:45.488999 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/80.211.238.126/tcp/8888/p2p/QmXwHZ4kT86tmdzNUoGuXo1aP87SE5aGoCYKy6k4LPvzk7
koinos-p2p-1                  | 2023-01-10 17:08:45.489011 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/50.116.19.109/tcp/8888/p2p/Qmd2bkf65yCKVZb2PG3FiRQWzrYgKf47zGBFuoU5qdebEY
koinos-p2p-1                  | 2023-01-10 17:08:45.489025 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/173.88.191.234/tcp/8888/p2p/QmQWRLnne2zpcLDPRgrHJT7wMHyhEHtfKjQxWL9PCQyeXE
koinos-p2p-1                  | 2023-01-10 17:08:45.489037 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/95.216.2.248/tcp/8888/p2p/QmNjLXn2AhadFkjhqbh3Tsar1vdKpS62trvMNi4QhCxf77
koinos-p2p-1                  | 2023-01-10 17:08:45.489050 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/185.130.47.36/tcp/8888/p2p/QmZawwUG1CMAc9Ubmgujn7QSpszH1CtVRv8ayAzjjHMVFC
koinos-p2p-1                  | 2023-01-10 17:08:45.489064 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/45.79.37.18/tcp/8888/p2p/Qmbx3wCN7cAAq3rqx6DWxCchgKMFx3PdGnmSnSixJGQ1wq
koinos-p2p-1                  | 2023-01-10 17:08:45.489079 (p2p.Koinos) [node/node.go:374] <info>:  - /ip4/89.58.57.36/tcp/8888/p2p/QmcZcQAjgHM16bBVmV3MjcNaFzqdSvd9eL2twTFXvuiSQP
koinos-p2p-1                  | 2023-01-10 17:08:45.489089 (p2p.Koinos) [node/node.go:376] <info>:    and 9 more...
koinos-p2p-1                  | 2023-01-10 17:08:51.321088 (p2p.Koinos) [p2p/connection_manager.go:264] <info>: Attempting to connect to peer Qmd2bkf65yCKVZb2PG3FiRQWzrYgKf47zGBFuoU5qdebEY
koinos-p2p-1                  | 2023-01-10 17:08:51.321121 (p2p.Koinos) [p2p/connection_manager.go:264] <info>: Attempting to connect to peer QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze
koinos-p2p-1                  | 2023-01-10 17:08:51.321128 (p2p.Koinos) [p2p/connection_manager.go:264] <info>: Attempting to connect to peer QmYAC9nxqgVt2p8NvmxNFsoMpQS7c4zEBmsZndEBTRHNu4
koinos-p2p-1                  | 2023-01-10 17:08:51.321136 (p2p.Koinos) [p2p/connection_manager.go:264] <info>: Attempting to connect to peer QmcwsnczsFRxgkyYtTWK4dq6tbE5tpE48jtHp7nKAvy22V

Expected behavior

If I am connected to a peer, I should not be attempting to connect to them.

Steps to reproduce

No response

Environment

- OS: Ubuntu 22.04 (Docker)

Anything else?

No response

koinos-ci commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

mvandeberg commented 5 months ago

Part of the cause of this is that there are multiple loops attempting to reconnect to seed nodes. This needs to be refactored to 1) Have a single go routine attempting to reconnect to seed nodes and 2) Not try to connect to a seed node we are already connected to.