validators

package
v1.7.17-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: BSD-3-Clause Imports: 23 Imported by: 3

Documentation

Overview

Package validators is a generated GoMock package.

Package validators is a generated GoMock package.

Package validators is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	Connected(id ids.NodeID, nodeVersion *version.Application) error
	Disconnected(id ids.NodeID) error
}

Connector represents a handler that is called when a connection is marked as connected or disconnected

type Manager

type Manager interface {
	fmt.Stringer

	// Set a subnet's validator set
	Set(ids.ID, Set) error

	// AddWeight adds weight to a given validator on the given subnet
	AddWeight(ids.ID, ids.NodeID, uint64) error

	// RemoveWeight removes weight from a given validator on a given subnet
	RemoveWeight(ids.ID, ids.NodeID, uint64) error

	// GetValidators returns the validator set for the given subnet
	// Returns false if the subnet doesn't exist
	GetValidators(ids.ID) (Set, bool)

	// MaskValidator hides the named validator from future samplings
	MaskValidator(ids.NodeID) error

	// RevealValidator ensures the named validator is not hidden from future
	// samplings
	RevealValidator(ids.NodeID) error

	// Contains returns true if there is a validator with the specified ID
	// currently in the set.
	Contains(ids.ID, ids.NodeID) bool
}

Manager holds the validator set of each subnet

func NewManager

func NewManager() Manager

NewManager returns a new, empty manager

type MockManager

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

MockManager is a mock of Manager interface.

func NewMockManager

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) AddStaker

func (m *MockManager) AddStaker(subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error

AddStaker mocks base method.

func (*MockManager) AddWeight

func (m *MockManager) AddWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error

AddWeight mocks base method.

func (*MockManager) Count

func (m *MockManager) Count(subnetID ids.ID) int

Count mocks base method.

func (*MockManager) EXPECT

func (m *MockManager) EXPECT() *MockManagerMockRecorder

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

func (*MockManager) GetMap

func (m *MockManager) GetMap(subnetID ids.ID) map[ids.NodeID]*GetValidatorOutput

GetMap mocks base method.

func (*MockManager) GetValidator

func (m *MockManager) GetValidator(subnetID ids.ID, nodeID ids.NodeID) (*Validator, bool)

GetValidator mocks base method.

func (*MockManager) GetValidatorIDs

func (m *MockManager) GetValidatorIDs(subnetID ids.ID) []ids.NodeID

GetValidatorIDs mocks base method.

func (*MockManager) GetWeight

func (m *MockManager) GetWeight(subnetID ids.ID, nodeID ids.NodeID) uint64

GetWeight mocks base method.

func (*MockManager) RegisterCallbackListener

func (m *MockManager) RegisterCallbackListener(subnetID ids.ID, listener SetCallbackListener)

RegisterCallbackListener mocks base method.

func (*MockManager) RemoveWeight

func (m *MockManager) RemoveWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error

RemoveWeight mocks base method.

func (*MockManager) Sample

func (m *MockManager) Sample(subnetID ids.ID, size int) ([]ids.NodeID, error)

Sample mocks base method.

func (*MockManager) String

func (m *MockManager) String() string

String mocks base method.

func (*MockManager) SubsetWeight

func (m *MockManager) SubsetWeight(subnetID ids.ID, validatorIDs set.Set[ids.NodeID]) (uint64, error)

SubsetWeight mocks base method.

func (*MockManager) TotalWeight

func (m *MockManager) TotalWeight(subnetID ids.ID) (uint64, error)

TotalWeight mocks base method.

type MockManagerMockRecorder

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

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) AddStaker

func (mr *MockManagerMockRecorder) AddStaker(subnetID, nodeID, pk, txID, weight any) *gomock.Call

AddStaker indicates an expected call of AddStaker.

func (*MockManagerMockRecorder) AddWeight

func (mr *MockManagerMockRecorder) AddWeight(subnetID, nodeID, weight any) *gomock.Call

AddWeight indicates an expected call of AddWeight.

func (*MockManagerMockRecorder) Count

func (mr *MockManagerMockRecorder) Count(subnetID any) *gomock.Call

Count indicates an expected call of Count.

func (*MockManagerMockRecorder) GetMap

func (mr *MockManagerMockRecorder) GetMap(subnetID any) *gomock.Call

GetMap indicates an expected call of GetMap.

func (*MockManagerMockRecorder) GetValidator

func (mr *MockManagerMockRecorder) GetValidator(subnetID, nodeID any) *gomock.Call

GetValidator indicates an expected call of GetValidator.

func (*MockManagerMockRecorder) GetValidatorIDs

func (mr *MockManagerMockRecorder) GetValidatorIDs(subnetID any) *gomock.Call

GetValidatorIDs indicates an expected call of GetValidatorIDs.

func (*MockManagerMockRecorder) GetWeight

func (mr *MockManagerMockRecorder) GetWeight(subnetID, nodeID any) *gomock.Call

GetWeight indicates an expected call of GetWeight.

func (*MockManagerMockRecorder) RegisterCallbackListener

func (mr *MockManagerMockRecorder) RegisterCallbackListener(subnetID, listener any) *gomock.Call

RegisterCallbackListener indicates an expected call of RegisterCallbackListener.

func (*MockManagerMockRecorder) RemoveWeight

func (mr *MockManagerMockRecorder) RemoveWeight(subnetID, nodeID, weight any) *gomock.Call

RemoveWeight indicates an expected call of RemoveWeight.

func (*MockManagerMockRecorder) Sample

func (mr *MockManagerMockRecorder) Sample(subnetID, size any) *gomock.Call

Sample indicates an expected call of Sample.

func (*MockManagerMockRecorder) String

func (mr *MockManagerMockRecorder) String() *gomock.Call

String indicates an expected call of String.

func (*MockManagerMockRecorder) SubsetWeight

func (mr *MockManagerMockRecorder) SubsetWeight(subnetID, validatorIDs any) *gomock.Call

SubsetWeight indicates an expected call of SubsetWeight.

func (*MockManagerMockRecorder) TotalWeight

func (mr *MockManagerMockRecorder) TotalWeight(subnetID any) *gomock.Call

TotalWeight indicates an expected call of TotalWeight.

type MockState

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

MockState is a mock of State interface.

func NewMockState

func NewMockState(ctrl *gomock.Controller) *MockState

NewMockState creates a new mock instance.

func (*MockState) EXPECT

func (m *MockState) EXPECT() *MockStateMockRecorder

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

func (*MockState) GetCurrentHeight

func (m *MockState) GetCurrentHeight(arg0 context.Context) (uint64, error)

GetCurrentHeight mocks base method.

func (*MockState) GetMinimumHeight

func (m *MockState) GetMinimumHeight(arg0 context.Context) (uint64, error)

GetMinimumHeight mocks base method.

func (*MockState) GetSubnetID

func (m *MockState) GetSubnetID(arg0 context.Context, arg1 ids.ID) (ids.ID, error)

GetSubnetID mocks base method.

func (*MockState) GetValidatorSet

func (m *MockState) GetValidatorSet(arg0 context.Context, arg1 uint64, arg2 ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)

GetValidatorSet mocks base method.

type MockStateMockRecorder

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

MockStateMockRecorder is the mock recorder for MockState.

func (*MockStateMockRecorder) GetCurrentHeight

func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call

GetCurrentHeight indicates an expected call of GetCurrentHeight.

func (*MockStateMockRecorder) GetMinimumHeight

func (mr *MockStateMockRecorder) GetMinimumHeight(arg0 any) *gomock.Call

GetMinimumHeight indicates an expected call of GetMinimumHeight.

func (*MockStateMockRecorder) GetSubnetID

func (mr *MockStateMockRecorder) GetSubnetID(arg0, arg1 any) *gomock.Call

GetSubnetID indicates an expected call of GetSubnetID.

func (*MockStateMockRecorder) GetValidatorSet

func (mr *MockStateMockRecorder) GetValidatorSet(arg0, arg1, arg2 any) *gomock.Call

GetValidatorSet indicates an expected call of GetValidatorSet.

type MockSubnetConnector

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

MockSubnetConnector is a mock of SubnetConnector interface.

func NewMockSubnetConnector

func NewMockSubnetConnector(ctrl *gomock.Controller) *MockSubnetConnector

NewMockSubnetConnector creates a new mock instance.

func (*MockSubnetConnector) ConnectedSubnet

func (m *MockSubnetConnector) ConnectedSubnet(arg0 context.Context, arg1 ids.NodeID, arg2 ids.ID) error

ConnectedSubnet mocks base method.

func (*MockSubnetConnector) EXPECT

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

type MockSubnetConnectorMockRecorder

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

MockSubnetConnectorMockRecorder is the mock recorder for MockSubnetConnector.

func (*MockSubnetConnectorMockRecorder) ConnectedSubnet

func (mr *MockSubnetConnectorMockRecorder) ConnectedSubnet(arg0, arg1, arg2 any) *gomock.Call

ConnectedSubnet indicates an expected call of ConnectedSubnet.

type Set

type Set interface {
	fmt.Stringer
	PrefixedString(string) string

	// Set removes all the current validators and adds all the provided
	// validators to the set.
	Set([]Validator) error

	// AddWeight to a staker.
	AddWeight(ids.NodeID, uint64) error

	// GetWeight retrieves the validator weight from the set.
	GetWeight(ids.NodeID) (uint64, bool)

	// SubsetWeight returns the sum of the weights of the validators.
	SubsetWeight(ids.NodeIDSet) (uint64, error)

	// RemoveWeight from a staker.
	RemoveWeight(ids.NodeID, uint64) error

	// Contains returns true if there is a validator with the specified ID
	// currently in the set.
	Contains(ids.NodeID) bool

	// Len returns the number of validators currently in the set.
	Len() int

	// List all the validators in this group
	List() []Validator

	// Weight returns the cumulative weight of all validators in the set.
	Weight() uint64

	// Sample returns a collection of validators, potentially with duplicates.
	// If sampling the requested size isn't possible, an error will be returned.
	Sample(size int) ([]Validator, error)

	// MaskValidator hides the named validator from future samplings
	MaskValidator(ids.NodeID) error

	// When a validator's weight changes, or a validator is added/removed,
	// this listener is called.
	RegisterCallbackListener(SetCallbackListener)

	RevealValidator(ids.NodeID) error
}

Set of validators that can be sampled

func NewBestSet

func NewBestSet(expectedSampleSize int) Set

NewBestSet returns a new, empty set of validators.

func NewSet

func NewSet() Set

NewSet returns a new, empty set of validators.

type SetCallbackListener

type SetCallbackListener interface {
	OnValidatorAdded(validatorID ids.NodeID, weight uint64)
	OnValidatorRemoved(validatorID ids.NodeID, weight uint64)
	OnValidatorWeightChanged(validatorID ids.NodeID, oldWeight, newWeight uint64)
}

func NewLogger

func NewLogger(
	log logging.Logger,
	subnetID ids.ID,
	nodeIDs ...ids.NodeID,
) SetCallbackListener

NewLogger returns a callback listener that will log validator set changes for the specified validators

type State

type State interface {
	// GetMinimumHeight returns the minimum height of the block still in the
	// proposal window.
	GetMinimumHeight() (uint64, error)
	// GetCurrentHeight returns the current height of the P-chain.
	GetCurrentHeight() (uint64, error)

	// GetValidatorSet returns the weights of the nodeIDs for the provided
	// subnet at the requested P-chain height.
	// The returned map should not be modified.
	GetValidatorSet(height uint64, subnetID ids.ID) (map[ids.NodeID]uint64, error)
}

State allows the lookup of validator sets on specified subnets at the requested P-chain height.

func NewLockedState

func NewLockedState(lock sync.Locker, s State) State

func NewNoValidatorsState

func NewNoValidatorsState(state State) State

func Trace

func Trace(s State, name string, tracer trace.Tracer) State

type SubnetConnector

type SubnetConnector interface {
	ConnectedSubnet(ctx context.Context, nodeID ids.NodeID, subnetID ids.ID) error
}

SubnetConnector represents a handler that is called when a connection is marked as connected to a subnet

var UnhandledSubnetConnector SubnetConnector = &unhandledSubnetConnector{}

type TestState

type TestState struct {
	T *testing.T

	CantGetMinimumHeight,
	CantGetCurrentHeight,
	CantGetValidatorSet bool

	GetMinimumHeightF func() (uint64, error)
	GetCurrentHeightF func() (uint64, error)
	GetValidatorSetF  func(height uint64, subnetID ids.ID) (map[ids.NodeID]uint64, error)
}

func (*TestState) GetCurrentHeight

func (vm *TestState) GetCurrentHeight() (uint64, error)

func (*TestState) GetMinimumHeight

func (vm *TestState) GetMinimumHeight() (uint64, error)

func (*TestState) GetValidatorSet

func (vm *TestState) GetValidatorSet(height uint64, subnetID ids.ID) (map[ids.NodeID]uint64, error)

type Validator

type Validator interface {
	// ID returns the node ID of this validator
	ID() ids.NodeID

	// Weight that can be used for weighted sampling. If this validator is
	// validating the primary network, returns the amount of AVAX staked.
	Weight() uint64
}

Validator is the minimal description of someone that can be sampled.

func GenerateRandomValidator

func GenerateRandomValidator(weight uint64) Validator

GenerateRandomValidator creates a random validator with the provided weight

func NewValidator

func NewValidator(
	nodeID ids.NodeID,
	weight uint64,
) Validator

NewValidator returns a validator object that implements the Validator interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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