Empirical solution to sync problem
EDIT: I am actually amazed this works randomly, my current parameters are:
0.15 and 40
which translates to drop 15% of the peers every 40 seconds.
###########################################################
Hi all, as many are pointing out there are problems keeping up with the network, for some time I tried to understand why and how to overcome this problem with my own nodes.
I've been looking at the logs and noticed in times of network congestion a unusual amount of chain reorgs, that naturally slow down the sync process as the node thinks is on the right path but eventually discovers there is one longer than the one he is currently building on.
I dont know the exact reason of these chain reorgs, as there could be many reasons that at the moment may be beyond my understanding of blockchain behavoir.
Anyways I decided to try to make a script that would rotate the peers (in the hypotesis that not all the peers behave in the interest of the network), by rotating peers we want to have at disposal new peers that hopefully are good and are fully synced (it's random).
So if you are interested and want to try it out please do so.
Here is the code:
./geth --exec 'reset = function (){ for (i=0; i<admin.peers.length*0.4; i++) admin.removePeer(admin.peers[0]["enode"]) }; reset()' attach node/geth.ipc
Save this in a file called rotate_peers.sh
then in the terminal call:
watch -n 250 ./rotate_peers.sh
0.4 and 250, are the two parameters you want to regulate and find the best for you.
0.4 indicates the percentage of peers you want to get rid of. 250 indicates every x seconds run the rotate peers script.
Good luck
Please let me know in the comments if this betters the sync situation, and if anybody has any ideas to share them here.
@perfectcircle2020 Did this work for your nodes?
@havsar
It significatly reduced the number of blocks my nodes were behind the tip of the chain.
Many times my nodes were faster than bscscan, if that can be an indicator.
Hi all, as many are pointing out there are problems keeping up with the network, for some time I tried to understand why and how to overcome this problem with my own nodes.
I've been looking at the logs and noticed in times of network congestion a unusual amount of chain reorgs, that naturally slow down the sync process as the node thinks is on the right path but eventually discovers there is one longer than the one he is currently building on.
I dont know the exact reason of these chain reorgs, as there could be many reasons that at the moment may be beyond my understanding of blockchain behavoir.
Anyways I decided to try to make a script that would rotate the peers (in the hypotesis that not all the peers behave in the interest of the network), by rotating peers we want to have at disposal new peers that hopefully are good and are fully synced (it's random).
So if you are interested and want to try it out please do so.
Here is the code:
./geth --exec 'reset = function (){ for (i=0; i<admin.peers.length*0.4; i++) admin.removePeer(admin.peers[0]["enode"]) }; reset()' attach node/geth.ipcSave this in a file calledrotate_peers.shthen in the terminal call:
watch -n 250 ./rotate_peers.sh0.4 and 250, are the two parameters you want to regulate and find the best for you.
0.4 indicates the percentage of peers you want to get rid of. 250 indicates every x seconds run the rotate peers script.
Good luck
Please let me know in the comments if this betters the sync situation, and if anybody has any ideas to share them here.
Could you please share your config.toml and your geth parameters?
I don't understand how this is working if the process is random. There's an equal chance you will be removing good peers, or am I missing something?
@NullQubit Yes, it seems to be random.
@NullQubit Yeah its random because there is no attribute to check, if implemented (a list of attributes to classify the peers) the removal process could be much more efficient.
I've been trying to figure out for some time what are some attributes could be used to classify the peers operating in the network, so far at "geth level" it seems to me there is nothing we can use to make decicions about peers.
So what I was thinking is an index each node can have exposed, which is just a function of the pair (highestBlock, currentBlock), with this index what we want is to measure the performance of the node, one simple implementation of this could be:
f(currentBlock, highestBlock ) = currentBlock/highestBlock -> [0,1]
which would output the current percentage of processed blocks.
With this kind of index, a new peer that is not syncronized, while syncronizing would drop the peers that are far behind the tip of the chain and consider only the ones that are syncronized, if can make any sense.
Then as the peer is more syncronized the more it accepts unsynced peers so he can help other peers do the same.
What do you think?
Ideally we want the majority of the network to have all the nodes with INDEX as close as possible to 1
This way the health of the network can also be measured precisely and know instantly how it going
I have figured out that "difficulty" cloud be used to select which peers to remove and which not to remove.
Will investigate more and come up with some statistics.
I have figured out that "difficulty" cloud be used to select which peers to remove and which not to remove.
Will investigate more and come up with some statistics.
nice catch, but also that can be a double-edged sword, if it is used continuously, it can block new peers to join.
@mjohn Yeah it needs to be balanced, you cant do that always
@havsar
It significatly reduced the number of blocks my nodes were behind the tip of the chain.
Many times my nodes were faster than bscscan, if that can be an indicator.
Did you mean your node wasn't synced at all?
@DryDragon10 I mean my nodes where almost always in sync
@perfectcircle2020 did you continue to investigate how the "difficulty" could be used to determine which peers to remove?