koinos / koinos-p2p

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

Peer Sync #162

Closed mvandeberg closed 3 years ago

mvandeberg commented 3 years ago

For an individual peer:

If I have one peer, sync is straight forward.

This needs to be generalized to multiple peers and potentially multiple forks.

Let's not worry about syncing to a peer's minority fork. If the peer changes forks, the peer handler will catch this change and be able to make progress on the new fork. With many peers it is unlikely that we will miss a minority fork from all peers. If a minority fork takes over, peers will switch and we will begin to sync the fork.

Restructure the peer handler to be able to answer the questionm "Can make progress on this peer?" It is the responsibility of the peer handler to make progress on its peer. (This removes the need for the topology cache)

This simple design works and guarantees progress on all peer forks. It is inefficient in that peers can request duplicate blocks from one another. As an optimization, we can add in a management layer that coordinates work between peers to try to prevent duplicate requests. Duplicate requests are not the enemy. There should be a best effort to prevent them, but their total elimination is not a design goal.