package octez-shell-libs
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
    
    
  sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053
    
    
  doc/octez-shell-libs.shell/Tezos_shell/Synchronisation_heuristic/index.html
Module Tezos_shell.Synchronisation_heuristicSource
Synchronisation heuristic
The synchronisation heuristic module handles a heuristic to decide whether a node is synchronized with respect to its peers. This heuristic is parameterized by two variables:
- thresholdis the number of peers to take into account for the heuristic
- latencyis the timestamp drift (in seconds) expected for the- thresholdbest candidates (see below).
A node is either Not_synchronised or Synchronised. If the node is Synchronised the chain may be stuck (last block validated was a while ago). The heuristic needs to be updated every time a block is validated or if a peer sends a block which is already known as valid. In the following, we denote such a block as a `candidate`. The heuristic maintains a set of candidates such that there is at most one candidate per peer. Given a peer, the heuristic always keeps the most recent candidate.
The heuristic works as follows:
If t.threshold is negative then get_state t always returns Not_synchronised.
If t.threshold is 0 then get_state t always returns Synchronised {is_chain_stuck=false}.
Otherwise:
- The state is Synchronised {is_chain_stuck = false}if the set of candidates that are more recent than ``latency`` seconds from now has a cardinal equal or greater to ``threshold``.
- The state is Synchronised {is_chain_stuck = true}if all the following statements are respected:
1. threshold > 1
2. The ``threshold`` most recent candidates have the same timestamp.
3. There is no candidate more than ``latency`` seconds from now
- The state is Not_synchronisedotherwise.
Notice that if threshold is 1, the state is either Synchronised {is_chain_stuck=false} or Not_synchronised.
This heuristic should be used with a small threshold: Between 2 and 10. Other values should be used with care and are mostly here for testing or debugging purpose.
Following the separation of concerns principle, the heuristic exports two modules:
- The Coremodule contains all the logic behind the heuristic described above and can be used as such.
- The Bootstrappingmodule provides facility to register callbacks when the status of the heuristic changes, and in particular defines abootstrappedflag which is set totrueif the heuristic was synchronised at least once.