Documentation
¶
Overview ¶
Package proposer is a generated GoMock package.
Index ¶
- Constants
- Variables
- func SetWindowDuration(d time.Duration)
- func TimeToSlot(start, now time.Time) uint64
- func TimestampGranularity() time.Duration
- type MockWindower
- func (m *MockWindower) Delay(arg0 context.Context, arg1, arg2 uint64, arg3 ids.NodeID, arg4 int) (time.Duration, error)
- func (m *MockWindower) EXPECT() *MockWindowerMockRecorder
- func (m *MockWindower) ExpectedProposer(arg0 context.Context, arg1, arg2, arg3 uint64) (ids.NodeID, error)
- func (m *MockWindower) MinDelayForProposer(arg0 context.Context, arg1, arg2 uint64, arg3 ids.NodeID, arg4 uint64) (time.Duration, error)
- func (m *MockWindower) Proposers(arg0 context.Context, arg1, arg2 uint64, arg3 int) ([]ids.NodeID, error)
- type MockWindowerMockRecorder
- func (mr *MockWindowerMockRecorder) Delay(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call
- func (mr *MockWindowerMockRecorder) ExpectedProposer(arg0, arg1, arg2, arg3 any) *gomock.Call
- func (mr *MockWindowerMockRecorder) MinDelayForProposer(arg0, arg1, arg2, arg3, arg4 any) *gomock.Call
- func (mr *MockWindowerMockRecorder) Proposers(arg0, arg1, arg2, arg3 any) *gomock.Call
- type Windower
Constants ¶
const ( MaxVerifyWindows = 6 MaxBuildWindows = 60 MaxLookAheadSlots = 720 )
Proposer list slot-COUNT constants (fixed; independent of the wall-clock window length).
Variables ¶
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.
var ( ErrAnyoneCanPropose = errors.New("anyone can propose") ErrUnexpectedSamplerFailure = errors.New("unexpected sampler failure") )
Functions ¶
func SetWindowDuration ¶ added in v1.36.17
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 TimestampGranularity ¶ added in v1.36.18
TimestampGranularity is the resolution block timestamps are truncated to. It tracks WindowDuration so the proposer-slot clock (TimeToSlot = elapsed / WindowDuration) and the block-timestamp clock advance at the SAME rate: with a coarser 1s truncation, a sub-second WindowDuration would inflate slot numbers without finer time resolution, so blocks could not actually be produced faster than 1/s. Capped at 1s so mainnet (WindowDuration >= 1s) keeps the original 1-second block-time granularity exactly.
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
func (m *MockWindower) EXPECT() *MockWindowerMockRecorder
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.
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.
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)
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package proposermock is a generated GoMock package.
|
Package proposermock is a generated GoMock package. |