benchlist

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Benchable

type Benchable interface {
	// Mark that [validatorID] has been benched on the given chain
	Benched(chainID ids.ID, validatorID ids.ShortID)
	// Mark that [validatorID] has been unbenched from the given chain
	Unbenched(chainID ids.ID, validatorID ids.ShortID)
}

Benchable is notified when a validator is benched or unbenched from a given chain

type Benchlist

type Benchlist interface {
	// RegisterResponse registers the response to a query message
	RegisterResponse(validatorID ids.ShortID)
	// RegisterFailure registers that we didn't receive a response within the timeout
	RegisterFailure(validatorID ids.ShortID)
	// IsBenched returns true if messages to [validatorID]
	// should not be sent over the network and should immediately fail.
	IsBenched(validatorID ids.ShortID) bool
}

Therefore, nodes that consistently fail are "benched" such that queries to that node fail immediately to avoid waiting up to the full network timeout for a response.

func NewBenchlist

func NewBenchlist(
	chainID ids.ID,
	log logging.Logger,
	benchable Benchable,
	validators validators.Set,
	threshold int,
	minimumFailingDuration,
	duration time.Duration,
	maxPortion float64,
	registerer prometheus.Registerer,
) (Benchlist, error)

NewBenchlist returns a new Benchlist

type Config

type Config struct {
	Benchable              Benchable          `json:"-"`
	Validators             validators.Manager `json:"-"`
	StakingEnabled         bool               `json:"-"`
	Threshold              int                `json:"threshold"`
	MinimumFailingDuration time.Duration      `json:"minimumFailingDuration"`
	Duration               time.Duration      `json:"duration"`
	MaxPortion             float64            `json:"maxPortion"`
}

Config defines the configuration for a benchlist

type Manager

type Manager interface {
	// RegisterResponse registers that we receive a request response from [validatorID]
	// regarding [chainID] within the timeout
	RegisterResponse(chainID ids.ID, validatorID ids.ShortID)
	// RegisterFailure registers that a request to [validatorID] regarding
	// [chainID] timed out
	RegisterFailure(chainID ids.ID, validatorID ids.ShortID)
	// RegisterChain registers a new chain with metrics under [namespace]
	RegisterChain(ctx *snow.ConsensusContext) error
	// IsBenched returns true if messages to [validatorID] regarding chain [chainID]
	// should not be sent over the network and should immediately fail.
	// Returns false if such messages should be sent, or if the chain is unknown.
	IsBenched(validatorID ids.ShortID, chainID ids.ID) bool
	// GetBenched returns an array of chainIDs where the specified
	// [validatorID] is benched. If called on an id.ShortID that does
	// not map to a validator, it will return an empty array.
	GetBenched(validatorID ids.ShortID) []ids.ID
}

Manager provides an interface for a benchlist to register whether queries have been successful or unsuccessful and place validators with consistently failing queries on a benchlist to prevent waiting up to the full network timeout for their responses.

func NewManager

func NewManager(config *Config) Manager

NewManager returns a manager for chain-specific query benchlisting

func NewNoBenchlist

func NewNoBenchlist() Manager

NewNoBenchlist returns an empty benchlist that will never stop any queries

type TestBenchable

type TestBenchable struct {
	T *testing.T

	CantBenched, CantUnbenched bool
	BenchedF, UnbenchedF       func(chainID ids.ID, validatorID ids.ShortID)
}

func (*TestBenchable) Benched

func (b *TestBenchable) Benched(chainID ids.ID, validatorID ids.ShortID)

func (*TestBenchable) Default

func (b *TestBenchable) Default(cant bool)

Default set the default callable value to [cant]

func (*TestBenchable) Unbenched

func (b *TestBenchable) Unbenched(chainID ids.ID, validatorID ids.ShortID)

Jump to

Keyboard shortcuts

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