Closed SebastianElvis closed 3 years ago
The problem seems to be that the ports of endpoints inserted to the NodeTable are incorrect. These are outbound ports rather than the inbound one (i.e., the standard P2P port 8333)
This is the nodes.csv
file from parity-bitcoin. This should be the expected behaviour.
Format of nodes.csv
:
IP:Port Timestamp Supported_services Failures
See p2p/src/util/node_table.rs
Pretty sure it's because of the wrong ports. I print the addr
messages and here is the log. The port should be 8333
rather than 49588
.
I'll check how to fix this issue.
I think that's expected behavior. Even running pbtc in real network it shows the following ports if using - c
Node1 listening to all on 8333:
Node2 connecting to Node1, listening on 9997:
Node3 connecting to Node1, listening on 9999:
To me it's more like a bug of pbtc itself: a node doesn't announce its listening port to its peers.
This is consistent to my observation. I compared the p2p modules in both projects and found no difference in terms of the session/messaging protocols.
If this is the case, then
- How can we fix it? I guess for prototyping we can just enforce the default port
That will require a subprotocol. Let's use default port for experiment first.
- How can we fix it? I guess for prototyping we can just enforce the default port
That will require a subprotocol. Let's use default port for experiment first.
Agree. For future implementation perhaps we should check how other implementations deal with relevant messages.
For production, there is an alternate fix for this issue.
When initiating the p2p
object, the node inserts its address (IP+port) to the node table.
When accepting connections, nodes should not add other nodes' addresses to the node table, as at this stage nodes cannot know others' ports for inbound connections.
When in the addr protocol, nodes exchange their node tables, which include addresses of themselves.
For production, there is an alternate fix for this issue. When initiating the
p2p
object, the node inserts its address (IP+port) to the node table. When accepting connections, nodes should not add other nodes' addresses to the node table, as at this stage nodes cannot know others' ports for inbound connections. When in the addr protocol, nodes exchange their node tables, which include addresses of themselves.
Then in the addr protocol, we need to insert exchanged node table contents into local node table. However, we may still need to define a expiry mechanism for cleaning node table incase it bloats.
For production, there is an alternate fix for this issue. When initiating the
p2p
object, the node inserts its address (IP+port) to the node table. When accepting connections, nodes should not add other nodes' addresses to the node table, as at this stage nodes cannot know others' ports for inbound connections. When in the addr protocol, nodes exchange their node tables, which include addresses of themselves.Then in the addr protocol, we need to insert exchanged node table contents into local node table. However, we may still need to define a expiry mechanism for cleaning node table incase it bloats.
I guess this has been implemented. In the node table implementation, there is an item timestamp
specifying when the address is queried. Will double check
Description
Nodes exchange their known peers regularly. However, in the current implementation, given newly exchanged peers, a node cannot connect to them. The error message shows that
Connection refused (os error 111)
.Reproduction
In the
proto-dco
branch (commitf7d1e77714a49be87b523f1132fa8b8702dd6de8
), doand wait for a while.
Expectation
Screenshots
Please find the log below.
Environment
Additional context
OS error 111 means
Connection refused
, according to https://mariadb.com/kb/en/operating-system-error-codes/Resolution