Skip to content

computeBootstrapDelay should use timestamps to estimate the delay instead of epochs #964

Open
@Kubuxu

Description

@Kubuxu

If the node starts with EC state behind, it can wait for the bootstrap even though it is unnecessary.
Instead, we should use now() vs head.Timestamp() + (bootstrap - head.Epoch)* mani.EC.Period.

go-f3/f3.go

Lines 136 to 160 in 163115a

func (m *F3) computeBootstrapDelay() (time.Duration, error) {
manifest := m.manifest.Load()
if manifest == nil || manifest.Pause {
return 0, nil
}
ts, err := m.ec.GetHead(m.runningCtx)
if err != nil {
err := fmt.Errorf("failed to get the EC chain head: %w", err)
return 0, err
}
currentEpoch := ts.Epoch()
if currentEpoch >= manifest.BootstrapEpoch {
return 0, nil
}
epochDelay := manifest.BootstrapEpoch - currentEpoch
start := ts.Timestamp().Add(time.Duration(epochDelay) * manifest.EC.Period)
delay := m.clock.Until(start)
// Add additional delay to skip over null epochs. That way we wait the full 900 epochs.
if delay <= 0 {
delay = manifest.EC.Period + delay%manifest.EC.Period
}
return delay, nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions