p2p/simulations: Various fixes#15198
Conversation
|
@fjl please advise on this. what should happen with the HACK commit? |
|
Sorry, I was super busy. I don't like the HACK commit. |
|
Some thoughts from a discussion in the orange-lounge gitter channel about replacing the "hack" commit with something better: The hive code currently tries to dial peers which it should be connected to but isn't currently, and it does this by calling What we want is a More longer term, we would really like to have what is outlined in #2254. |
* refactor simulations/network connection getters to support avoiding simultaneous dials between two peers If two peers dial simultaneously, the connection will be dropped to help avoid that, we essentially lock the connection object with a timestamp which serves as a ban on dialing for a period of time (dialBanTimeout). * The connection getter InitConn can be wrapped and passed to the nodes via adapters.NodeConfig#Reachable field and then used by the respective services when they initiate connections. This massively stablise the emerging connectivity when running with hundreds of nodes bootstrapping a network * introduce EnableMsgEvents boolean field in NodeConfig
rlpx tries to send discreason to disconnected peer if the connection is net.Pipe (in-memory simulation) it hangs forever, since net.Pipe does not implement a write deadline. This commit adds error checking on the SetWriteDeadline call and only tries to send the disconnect reason message if there is no error
To support debugging in-memory network simulations when multiple peers are logging
* SetupConn now returns error * dial checks the error and calls resolve on failed dial only
the server refuses to redial static peers if using dialstate.addstatic call instead the dialtask is directly appended to the queue this fixes the no redial problem but is clearly a hack
|
There are a few todos on this PR:
I will look into addressing these. |
This reverts commit 955a90c.
2ff442e to
331e154
Compare
|
Rebased on |
|
I have addressed the TODOs mentioned above in the following way:
|
Taken from ethersphere/swarm#119.
This PR includes a hack to force a re-dial when adding static peers (9184728), as sometimes re-dials don't happen in large simulations.
This was discussed between me, @zelig and @fjl where I proposed adding a separate
DialPeerfunction to thep2p.Serverbut after attempting to do so it seems to be more work than originally thought. We need to make a decision on whether this hack can be merged as is, and if not then decide how to proceed.