Module agora.network.Clock

Contains a network-synchronized Clock implementation.

There are three goals that need to be achieved with regards to time synchronization:

1. Accuracy. This is the relative accuracy of each node's local clock compared to an external reference clock (NTP / World clock).

2. Precision. This is measured as the relative difference between all of the nodes' local clocks compared to each other in the network.

See also: https://en.wikipedia.org/wiki/File:Accuracy_and_precision.svg

An average computer's local clock is prone to time drift, usually in the order of several seconds per day. There are various factors which influence the clock's time drift such as the system's temperature.

More importantly, a computer may experience failure to contact NTP or have a misconfigured NTP configuration.

This module contains a Clock implementation which periodically synchronizes its time with the rest of the network - this allows validator nodes to continue being part of consensus even if their own clock time drifts. In case of a large drift, there should be a mechanism of alerting the node operator to fix their node computer's NTP settings.

Note that NTP can be prone to abuse (see https://en.wikipedia.org/wiki/NTP_server_misuse_and_abuse).

On Posix systems one can check their NTP server configuration with: $ cat /etc/ntp.conf

Resources

https

//ethresear.ch/t/network-adjusted-timestamps/4187

https

//hackmd.io/x6CaC2OXQ-OTnaobQp39yA

https

//hackmd.io/X-uvqwe8TkmR-CJqMdfn6Q

Classes

NameDescription
Clock Delegate used to calculate the time offset to apply in networkTime
MockClock

Aliases

NameTypeDescription
GetNetTimeOffset nothrow @safe bool delegate(out core.time.Duration) Delegate used to calculate the time offset to apply in networkTime