roundtimer

package
v1.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QuickTimeoutThreshold = specqbft.Round(8)
	QuickTimeout          = 2 * time.Second
	SlowTimeout           = 2 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BeaconNetwork added in v1.1.0

type BeaconNetwork interface {
	GetSlotStartTime(slot phase0.Slot) time.Time
	SlotDurationSec() time.Duration
}

type OnRoundTimeoutF added in v1.1.0

type OnRoundTimeoutF func(round specqbft.Round)

type RoundTimer

type RoundTimer struct {
	// contains filtered or unexported fields
}

RoundTimer helps to manage current instance rounds.

func New

func New(pctx context.Context, beaconNetwork BeaconNetwork, role spectypes.BeaconRole, done OnRoundTimeoutF) *RoundTimer

New creates a new instance of RoundTimer.

func (*RoundTimer) OnTimeout

func (t *RoundTimer) OnTimeout(done OnRoundTimeoutF)

OnTimeout sets a function called on timeout.

func (*RoundTimer) Round

func (t *RoundTimer) Round() specqbft.Round

Round returns a round.

func (*RoundTimer) RoundTimeout added in v1.1.0

func (t *RoundTimer) RoundTimeout(height specqbft.Height, round specqbft.Round) time.Duration

RoundTimeout calculates the timeout duration for a specific role, height, and round.

Timeout Rules: - For roles BNRoleAttester and BNRoleSyncCommittee, the base timeout is 1/3 of the slot duration. - For roles BNRoleAggregator and BNRoleSyncCommitteeContribution, the base timeout is 2/3 of the slot duration. - For role BNRoleProposer, the timeout is either quickTimeout or slowTimeout, depending on the round.

Additional Timeout: - For rounds less than or equal to quickThreshold, the additional timeout is 'quick' seconds. - For rounds greater than quickThreshold, the additional timeout is 'slow' seconds.

SIP Reference: For more details, see SIP at https://github.com/bloxapp/SIPs/pull/22

TODO: Update SIP for Deterministic Round Timeout TODO: Decide if to make the proposer timeout deterministic

Synchronization Note: To ensure synchronized timeouts across instances, the timeout is based on the duty start time, which is calculated from the slot height. The base timeout is set based on the role, and the additional timeout is added based on the round number.

func (*RoundTimer) TimeoutForRound

func (t *RoundTimer) TimeoutForRound(height specqbft.Height, round specqbft.Round)

TimeoutForRound times out for a given round.

type TestQBFTTimer added in v1.1.0

type TestQBFTTimer struct {
	State TimerState
}

func (*TestQBFTTimer) TimeoutForRound added in v1.1.0

func (t *TestQBFTTimer) TimeoutForRound(height specqbft.Height, round specqbft.Round)

type TimeoutOptions added in v1.1.0

type TimeoutOptions struct {
	// contains filtered or unexported fields
}

type Timer added in v1.1.0

type Timer interface {
	// TimeoutForRound will reset running timer if exists and will start a new timer for a specific round
	TimeoutForRound(height specqbft.Height, round specqbft.Round)
}

Timer is an interface for a round timer, calling the UponRoundTimeout when times out

func NewTestingTimer added in v1.1.0

func NewTestingTimer() Timer

type TimerState added in v1.1.0

type TimerState struct {
	Timeouts int
	Round    specqbft.Round
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL