benchlist

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: BSD-3-Clause Imports: 19 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.NodeID)
	// Mark that [validatorID] has been unbenched from the given chain
	Unbenched(chainID ids.ID, validatorID ids.NodeID)
}

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(nodeID ids.NodeID)
	// RegisterFailure registers that we didn't receive a response within the timeout
	RegisterFailure(nodeID ids.NodeID)
	// IsBenched returns true if messages to [validatorID]
	// should not be sent over the network and should immediately fail.
	IsBenched(nodeID ids.NodeID) 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:"-"`
	SybilProtectionEnabled 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 [nodeID]
	// regarding [chainID] within the timeout
	RegisterResponse(chainID ids.ID, nodeID ids.NodeID)
	// RegisterFailure registers that a request to [nodeID] regarding
	// [chainID] timed out
	RegisterFailure(chainID ids.ID, nodeID ids.NodeID)
	// RegisterChain registers a new chain with metrics under [namespace]
	RegisterChain(ctx *snow.ConsensusContext) error
	// IsBenched returns true if messages to [nodeID] 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(nodeID ids.NodeID, chainID ids.ID) bool
	// GetBenched returns an array of chainIDs where the specified
	// [nodeID] is benched. If called on an id.ShortID that does
	// not map to a validator, it will return an empty array.
	GetBenched(nodeID ids.NodeID) []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.NodeID)
}

func (*TestBenchable) Benched

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

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.NodeID)

Jump to

Keyboard shortcuts

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