Documentation ¶
Index ¶
Constants ¶
const ( // MinSafeLookbackWindow is the minimum number allowed for lookbackWindow size MinSafeLookbackWindow = 3 // MaxSafeLookbackWindow is the maximum number allowed for lookbackWindow size MaxSafeLookbackWindow = 720 // BlocksToSkipAtEpochEnd represents the number of blocks to skip on the monitoring window from the end of the epoch // Currently we skip blocks: // lastBlock => its parentSeal is on firstBlock of next epoch // lastBlock - 1 => parentSeal is on lastBlockOfEpoch, but validatorScore is computed with lastBlockOfEpoch and before updating scores // (lastBlock-1 could be counted, but much harder to implement) BlocksToSkipAtEpochEnd = 2 )
Check CIP-21 Spec (https://github.com/celo-org/celo-proposals/blob/master/CIPs/cip-0021.md)
Variables ¶
This section is empty.
Functions ¶
func ComputeLookbackWindow ¶
func ComputeLookbackWindow(epochSize uint64, defaultLookbackWindow uint64, cip21 bool, getLookbackWindow func() (uint64, error)) uint64
ComputeLookbackWindow computes the lookbackWindow based on different required parameters. getLookbackWindow represents the way to obtain lookbackWindow from the smart contract
Types ¶
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is responsible for monitoring uptime by processing blocks
func NewMonitor ¶
NewMonitor creates a new uptime monitor
func (*Monitor) ComputeValidatorsUptime ¶
ComputeValidatorsUptime retrieves the uptime score for each validator for a given epoch
func (*Monitor) MonitoringWindow ¶
MonitoringWindow returns the monitoring window for the given epoch in the format [firstBlock, lastBlock] both inclusive
type Store ¶
type Store interface { ReadAccumulatedEpochUptime(epoch uint64) *Uptime WriteAccumulatedEpochUptime(epoch uint64, uptime *Uptime) }
Store provides a persistent storage for uptime entries
type Uptime ¶
type Uptime struct { LatestBlock uint64 Entries []UptimeEntry }
Uptime contains the latest block for which uptime metrics were accounted. It also contains an array of Entries where the `i`th entry represents the uptime statistics of the `i`th validator in the validator set for that epoch
type UptimeEntry ¶
type UptimeEntry struct { // Numbers of blocks validator is considered UP within monitored window UpBlocks uint64 LastSignedBlock uint64 }
UptimeEntry contains the uptime score of a validator during an epoch as well as the last block they signed on
func (*UptimeEntry) String ¶
func (u *UptimeEntry) String() string
type Window ¶
Window represents a block range related to uptime monitoring Block range goes from `Start` to `End` and it's inclusive
func MonitoringWindow ¶
func MonitoringWindow(epochNumber uint64, epochSize uint64, lookbackWindowSize uint64) (Window, error)
MonitoringWindow retrieves the block window where uptime is to be monitored for a given epoch.
func MustMonitoringWindow ¶
MustMonitoringWindow is a MonitoringWindow variant that panics on error