Documentation
¶
Index ¶
- Variables
- func AggregatePublicKeys(vdrs []*CanonicalValidator) (*bls.PublicKey, error)
- func NewManager() *manager
- func SetRoot(set map[ids.NodeID]*GetValidatorOutput) ids.ID
- func SumWeight(vdrs []*CanonicalValidator) (uint64, error)
- type CanonicalValidator
- type CanonicalValidatorSet
- type Connector
- type GetValidatorOutput
- type Manager
- type ManagerCallbackListener
- type Set
- type SetCallbackListener
- type Sortable
- type State
- type Validator
- type ValidatorImpl
- type WarpSet
- type WarpValidator
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownValidator = errors.New("unknown validator") ErrWeightOverflow = errors.New("weight overflowed") )
Functions ¶
func AggregatePublicKeys ¶
func AggregatePublicKeys(vdrs []*CanonicalValidator) (*bls.PublicKey, error)
AggregatePublicKeys returns the public key of the provided validators.
Invariant: All of the public keys in [vdrs] are valid.
func SetRoot ¶ added in v1.3.4
func SetRoot(set map[ids.NodeID]*GetValidatorOutput) ids.ID
SetRoot is the commitment to a weighted validator set: a SHA-256 over the validators sorted by node id, each written as
nodeID || light(8,BE) || len(pubkey)(8,BE) || pubkey
Sorting by node id and length-prefixing the key make the encoding canonical, so two nodes holding the same set compute the same root and a set that differs by one bit does not. The empty set commits to ids.Empty, which is the "unbound" answer every reader already expects.
This is the one definition of that encoding. A signer and an assembler that each carried their own would agree until they didn't.
func SumWeight ¶
func SumWeight(vdrs []*CanonicalValidator) (uint64, error)
SumWeight returns the total weight of the provided validators.
Types ¶
type CanonicalValidator ¶
type CanonicalValidator struct {
PublicKey *bls.PublicKey
PublicKeyBytes []byte // Uncompressed bytes for canonical ordering
Weight uint64
NodeIDs []ids.NodeID // Can have multiple NodeIDs with same public key
}
CanonicalValidator represents a single validator with BLS public key in canonical form
func FilterValidators ¶
func FilterValidators( indices set.Bits, vdrs []*CanonicalValidator, ) ([]*CanonicalValidator, error)
FilterValidators returns the validators in [vdrs] whose bit is set to 1 in [indices].
Returns an error if [indices] references an unknown validator.
func (*CanonicalValidator) Compare ¶
func (v *CanonicalValidator) Compare(o *CanonicalValidator) int
Compare implements utils.Sortable for canonical ordering
type CanonicalValidatorSet ¶
type CanonicalValidatorSet struct {
// Validators slice in canonical ordering of the validators that has public key
Validators []*CanonicalValidator
// The total weight of all the validators, including the ones that doesn't have a public key
TotalWeight uint64
}
CanonicalValidatorSet represents a validator set in canonical ordering
func FlattenValidatorSet ¶
func FlattenValidatorSet(vdrSet map[ids.NodeID]*GetValidatorOutput) (CanonicalValidatorSet, error)
FlattenValidatorSet converts the provided [vdrSet] into a canonical utils. Also returns the total weight of the validator set.
type Connector ¶
type Connector interface {
Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
Disconnected(ctx context.Context, nodeID ids.NodeID) error
}
Connector handles validator connections
type GetValidatorOutput ¶
type GetValidatorOutput struct {
NodeID ids.NodeID
PublicKey []byte // BLS public key (classical)
CoronaPubKey []byte // Corona public key (post-quantum)
Light uint64
Weight uint64 // Alias for Light for backward compatibility
TxID ids.ID // Transaction ID that added this validator
}
GetValidatorOutput provides validator information
func (*GetValidatorOutput) MarshalZAP ¶ added in v1.3.3
func (x *GetValidatorOutput) MarshalZAP() ([]byte, error)
MarshalZAP writes GetValidatorOutput from constant offsets.
func (*GetValidatorOutput) UnmarshalZAP ¶ added in v1.3.3
func (x *GetValidatorOutput) UnmarshalZAP(data []byte) error
UnmarshalZAP reads GetValidatorOutput out of the buffer that arrived.
type Manager ¶
type Manager interface {
GetValidators(netID ids.ID) (Set, error)
GetValidator(netID ids.ID, nodeID ids.NodeID) (*GetValidatorOutput, bool)
GetLight(netID ids.ID, nodeID ids.NodeID) uint64
GetWeight(netID ids.ID, nodeID ids.NodeID) uint64 // Deprecated: use GetLight
TotalLight(netID ids.ID) (uint64, error)
TotalWeight(netID ids.ID) (uint64, error) // Deprecated: use TotalLight
// Mutable operations
AddStaker(netID ids.ID, nodeID ids.NodeID, publicKey []byte, txID ids.ID, light uint64) error
AddWeight(netID ids.ID, nodeID ids.NodeID, light uint64) error
RemoveWeight(netID ids.ID, nodeID ids.NodeID, light uint64) error
NumNets() int
// Additional utility methods
Count(netID ids.ID) int
NumValidators(netID ids.ID) int // Alias for Count
Sample(netID ids.ID, size int) ([]ids.NodeID, error)
GetValidatorIDs(netID ids.ID) []ids.NodeID
SubsetWeight(netID ids.ID, nodeIDs set.Set[ids.NodeID]) (uint64, error)
GetMap(netID ids.ID) map[ids.NodeID]*GetValidatorOutput
RegisterCallbackListener(listener ManagerCallbackListener)
RegisterSetCallbackListener(netID ids.ID, listener SetCallbackListener)
}
Manager manages validator sets
type ManagerCallbackListener ¶
type ManagerCallbackListener interface {
OnValidatorAdded(netID ids.ID, nodeID ids.NodeID, light uint64)
OnValidatorRemoved(netID ids.ID, nodeID ids.NodeID, light uint64)
OnValidatorLightChanged(netID ids.ID, nodeID ids.NodeID, oldLight, newLight uint64)
}
ManagerCallbackListener listens to manager changes
type Set ¶
type Set interface {
Has(ids.NodeID) bool
Len() int
List() []Validator
Light() uint64
Sample(size int) ([]ids.NodeID, error)
}
Set represents a set of validators
type SetCallbackListener ¶
type SetCallbackListener interface {
OnValidatorAdded(nodeID ids.NodeID, light uint64)
OnValidatorRemoved(nodeID ids.NodeID, light uint64)
OnValidatorLightChanged(nodeID ids.NodeID, oldLight, newLight uint64)
}
SetCallbackListener listens to validator set changes
type State ¶
type State interface {
// GetValidatorSet returns validators at a specific height for a network
GetValidatorSet(ctx context.Context, height uint64, netID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)
// GetCurrentValidators returns current validators
GetCurrentValidators(ctx context.Context, height uint64, netID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)
// GetCurrentHeight returns the current height
GetCurrentHeight(ctx context.Context) (uint64, error)
// GetMinimumHeight returns the minimum acceptable height
GetMinimumHeight(ctx context.Context) (uint64, error)
// GetChainID returns the chain ID for a given network ID
GetChainID(netID ids.ID) (ids.ID, error)
// GetNetworkID returns the network ID for a given chain ID
GetNetworkID(chainID ids.ID) (ids.ID, error)
// GetWarpValidatorSets returns Warp validator sets for the requested heights and netIDs.
// Returns a map of netID -> height -> WarpSet containing BLS-enabled validators.
GetWarpValidatorSets(ctx context.Context, heights []uint64, netIDs []ids.ID) (map[ids.ID]map[uint64]*WarpSet, error)
// GetWarpValidatorSet returns the Warp validator set for a specific height and netID.
// Returns a WarpSet containing validators with BLS public keys for Warp signing.
GetWarpValidatorSet(ctx context.Context, height uint64, netID ids.ID) (*WarpSet, error)
}
State provides validator state management
type ValidatorImpl ¶
ValidatorImpl is a concrete implementation of Validator
func (*ValidatorImpl) Light ¶
func (v *ValidatorImpl) Light() uint64
Light returns the validator light
Directories
¶
| Path | Synopsis |
|---|---|
|
Package uptime provides uptime calculation functionality
|
Package uptime provides uptime calculation functionality |
|
uptimemock
Package uptimemock provides mock implementations for uptime tracking
|
Package uptimemock provides mock implementations for uptime tracking |
|
Package validatorsmock is a generated GoMock package.
|
Package validatorsmock is a generated GoMock package. |