koinos / koinos-p2p

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

Drop to gossip mode automatically #64

Closed theoreticalbts closed 3 years ago

theoreticalbts commented 3 years ago

The --gossip flag currently does nothing. The intent of --gossip is to join gossip when "caught up" according to some metric. Some questions to answer:

Currently, as a workaround you can use the --force-gossip flag to drop to gossip mode immediately on startup.

theoreticalbts commented 3 years ago

What metric should be used?

Sort the peers by head height, take the height at some percentile. Call that value the peer head height metric (PHHM).

How do we check the metric?

Periodically recompute it, say once per second or so.

Can the metric trigger dropping out of gossip?

Yes, but we should have different thresholds (i.e. Schmidt trigger). So for example, we might have thresholds of 25 blocks and 50 blocks. Then we enter gossip when we're within 25 blocks of PHHM, but exit only when we fall 50 blocks behind PHHM.

If so, how do we check for going from "caught up" to "not caught up" (e.g. we're far behind due to hours-long internet outage)?

See above. We recompute PHHM, see it's below the lower threshold, then drop out of gossip.