proposer

package
v1.36.17 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Overview

Package proposer is a generated GoMock package.

Index

Constants

View Source
const (
	MaxVerifyWindows  = 6
	MaxBuildWindows   = 60
	MaxLookAheadSlots = 720
)

Proposer list slot-COUNT constants (fixed; independent of the wall-clock window length).

Variables

View Source
var (
	WindowDuration = 5 * time.Second

	MaxVerifyDelay     = MaxVerifyWindows * WindowDuration  // 30s at the default
	MaxBuildDelay      = MaxBuildWindows * WindowDuration   // 5m at the default
	MaxLookAheadWindow = MaxLookAheadSlots * WindowDuration // 1h at the default
)

WindowDuration is the proposer-slot spacing: a validator's minimum build delay is its slot index times WindowDuration. Default 5s (the avalanchego mainnet value, tuned for large validator sets). It is a startup-configurable VAR — small local/dev networks shrink it via SetWindowDuration (proposervm Config → --proposer-window-duration) so block cadence is not floored at 5s per proposer slot. It is read by BOTH the windower's delay math AND TimeToSlot, so the two stay consistent by construction.

View Source
var (
	ErrAnyoneCanPropose         = errors.New("anyone can propose")
	ErrUnexpectedSamplerFailure = errors.New("unexpected sampler failure")
)

Functions

func SetWindowDuration added in v1.36.17

func SetWindowDuration(d time.Duration)

SetWindowDuration overrides the proposer-slot spacing. It MUST be called at startup, before any chain begins block production: WindowDuration is read by both the windower delay math and TimeToSlot, so changing it mid-flight would desynchronize the slot mapping across the fleet (a consensus fault). Values <= 0 are ignored, so an unset config leaves the safe 5s default in place.

func TimeToSlot

func TimeToSlot(start, now time.Time) uint64

Types

type MockWindower added in v1.1.11

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

MockWindower is a mock of Windower interface.

func NewMockWindower added in v1.1.11

func NewMockWindower(ctrl *gomock.Controller) *MockWindower

NewMockWindower creates a new mock instance.

func (*MockWindower) Delay added in v1.1.11

func (m *MockWindower) Delay(arg0 context.Context, arg1, arg2 uint64, arg3 ids.NodeID, arg4 int) (time.Duration, error)

Delay mocks base method.

func (*MockWindower) EXPECT added in v1.1.11

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWindower) ExpectedProposer added in v1.1.11

func (m *MockWindower) ExpectedProposer(arg0 context.Context, arg1, arg2, arg3 uint64) (ids.NodeID, error)

ExpectedProposer mocks base method.

func (*MockWindower) MinDelayForProposer added in v1.1.11

func (m *MockWindower) MinDelayForProposer(arg0 context.Context, arg1, arg2 uint64, arg3 ids.NodeID, arg4 uint64) (time.Duration, error)

MinDelayForProposer mocks base method.

func (*MockWindower) Proposers added in v1.1.11

func (m *MockWindower) Proposers(arg0 context.Context, arg1, arg2 uint64, arg3 int) ([]ids.NodeID, error)

Proposers mocks base method.

type MockWindowerMockRecorder added in v1.1.11

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

MockWindowerMockRecorder is the mock recorder for MockWindower.

func (*MockWindowerMockRecorder) Delay added in v1.1.11

func (mr *MockWindowerMockRecorder) Delay(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call

Delay indicates an expected call of Delay.

func (*MockWindowerMockRecorder) ExpectedProposer added in v1.1.11

func (mr *MockWindowerMockRecorder) ExpectedProposer(arg0, arg1, arg2, arg3 any) *gomock.Call

ExpectedProposer indicates an expected call of ExpectedProposer.

func (*MockWindowerMockRecorder) MinDelayForProposer added in v1.1.11

func (mr *MockWindowerMockRecorder) MinDelayForProposer(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call

MinDelayForProposer indicates an expected call of MinDelayForProposer.

func (*MockWindowerMockRecorder) Proposers added in v1.1.11

func (mr *MockWindowerMockRecorder) Proposers(arg0, arg1, arg2, arg3 any) *gomock.Call

Proposers indicates an expected call of Proposers.

type Windower

type Windower interface {
	// Proposers returns the proposer list for building a block at [blockHeight]
	// when the validator set is defined at [pChainHeight]. The list is returned
	// in order. The minimum delay of a validator is the index they appear times
	// [WindowDuration].
	Proposers(
		ctx context.Context,
		blockHeight,
		pChainHeight uint64,
		maxWindows int,
	) ([]ids.NodeID, error)

	// Delay returns the amount of time that [validatorID] must wait before
	// building a block at [blockHeight] when the validator set is defined at
	// [pChainHeight].
	Delay(
		ctx context.Context,
		blockHeight,
		pChainHeight uint64,
		validatorID ids.NodeID,
		maxWindows int,
	) (time.Duration, error)

	// In the current per-slot windowing scheme, every validator active at
	// [pChainHeight] gets specific slots it can propose in (instead of being
	// able to propose from a given time on as in the legacy time-window
	// scheme).
	// [ExpectedProposer] calculates which nodeID is scheduled to propose a
	// block of height [blockHeight] at [slot].
	// If no validators are currently available, [ErrAnyoneCanPropose] is
	// returned.
	ExpectedProposer(
		ctx context.Context,
		blockHeight,
		pChainHeight,
		slot uint64,
	) (ids.NodeID, error)

	// In the current per-slot windowing scheme, every validator active at
	// [pChainHeight] gets specific slots it can propose in (instead of being
	// able to propose from a given time on as in the legacy time-window
	// scheme).
	// [MinDelayForProposer] specifies how long [nodeID] needs to wait for its
	// slot to start. Delay is specified as starting from slot zero start.
	// (which is parent timestamp). For efficiency reasons, we cap the slot
	// search to [MaxLookAheadSlots].
	// If no validators are currently available, [ErrAnyoneCanPropose] is
	// returned.
	MinDelayForProposer(
		ctx context.Context,
		blockHeight,
		pChainHeight uint64,
		nodeID ids.NodeID,
		startSlot uint64,
	) (time.Duration, error)
}

func New

func New(state validators.State, netID, chainID ids.ID) Windower

Directories

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

Jump to

Keyboard shortcuts

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