Documentation ¶
Index ¶
- Variables
- func NewHashValidatorsShuffler(args *NodesShufflerArgs) (*randHashShuffler, error)
- func NewIndexHashedNodesCoordinator(arguments ArgNodesCoordinator) (*indexHashedNodesCoordinator, error)
- func NewIndexHashedNodesCoordinatorWithRater(indexNodesCoordinator *indexHashedNodesCoordinator, ...) (*indexHashedNodesCoordinatorWithRater, error)
- func NewNodesCoordinatorRegistryFactory(marshaller marshal.Marshalizer, stakingV4Step2EnableEpoch uint32) (*nodesCoordinatorRegistryFactory, error)
- func NewSelectorExpandedList(weightList []uint32, hasher hashing.Hasher) (*selectorExpandedList, error)
- func NewSelectorWRS(weightList []uint32, hasher hashing.Hasher) (*selectorWRS, error)
- func NewValidator(pubKey []byte, chances uint32, index uint32) (*validator, error)
- func NodesInfoToValidators(nodesInfo map[uint32][]GenesisNodeInfoHandler) (map[uint32][]Validator, error)
- func SerializableValidatorsToValidators(nodeRegistryValidators map[string][]*SerializableValidator) (map[uint32][]Validator, error)
- type ArgNodesCoordinator
- type ArgsUpdateNodes
- type Cacher
- type ChanceComputer
- type CrossShardValidatorDistributor
- type EpochNotifier
- type EpochStartActionHandler
- type EpochStartEventNotifier
- type EpochValidators
- type EpochValidatorsHandler
- type EpochValidatorsHandlerWithAuction
- type EpochValidatorsWithAuction
- func (*EpochValidatorsWithAuction) Descriptor() ([]byte, []int)
- func (this *EpochValidatorsWithAuction) Equal(that interface{}) bool
- func (m *EpochValidatorsWithAuction) GetEligible() map[string]Validators
- func (m *EpochValidatorsWithAuction) GetEligibleValidators() map[string][]*SerializableValidator
- func (m *EpochValidatorsWithAuction) GetLeaving() map[string]Validators
- func (m *EpochValidatorsWithAuction) GetLeavingValidators() map[string][]*SerializableValidator
- func (m *EpochValidatorsWithAuction) GetLowWaitingList() bool
- func (m *EpochValidatorsWithAuction) GetShuffledOut() map[string]Validators
- func (m *EpochValidatorsWithAuction) GetShuffledOutValidators() map[string][]*SerializableValidator
- func (m *EpochValidatorsWithAuction) GetWaiting() map[string]Validators
- func (m *EpochValidatorsWithAuction) GetWaitingValidators() map[string][]*SerializableValidator
- func (this *EpochValidatorsWithAuction) GoString() string
- func (m *EpochValidatorsWithAuction) Marshal() (dAtA []byte, err error)
- func (m *EpochValidatorsWithAuction) MarshalTo(dAtA []byte) (int, error)
- func (m *EpochValidatorsWithAuction) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*EpochValidatorsWithAuction) ProtoMessage()
- func (m *EpochValidatorsWithAuction) Reset()
- func (m *EpochValidatorsWithAuction) Size() (n int)
- func (this *EpochValidatorsWithAuction) String() string
- func (m *EpochValidatorsWithAuction) Unmarshal(dAtA []byte) error
- func (m *EpochValidatorsWithAuction) XXX_DiscardUnknown()
- func (m *EpochValidatorsWithAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EpochValidatorsWithAuction) XXX_Merge(src proto.Message)
- func (m *EpochValidatorsWithAuction) XXX_Size() int
- func (m *EpochValidatorsWithAuction) XXX_Unmarshal(b []byte) error
- type EpochsConfigUpdateHandler
- type GenesisNodeInfoHandler
- type GenesisNodesSetupHandler
- type IntraShardValidatorDistributor
- type NodeTypeProviderHandler
- type NodesCoordinator
- type NodesCoordinatorHelper
- type NodesCoordinatorRegistry
- type NodesCoordinatorRegistryFactory
- type NodesCoordinatorRegistryHandler
- type NodesCoordinatorRegistryWithAuction
- func (*NodesCoordinatorRegistryWithAuction) Descriptor() ([]byte, []int)
- func (this *NodesCoordinatorRegistryWithAuction) Equal(that interface{}) bool
- func (m *NodesCoordinatorRegistryWithAuction) GetCurrentEpoch() uint32
- func (m *NodesCoordinatorRegistryWithAuction) GetEpochsConfig() map[string]EpochValidatorsHandler
- func (m *NodesCoordinatorRegistryWithAuction) GetEpochsConfigWithAuction() map[string]*EpochValidatorsWithAuction
- func (this *NodesCoordinatorRegistryWithAuction) GoString() string
- func (m *NodesCoordinatorRegistryWithAuction) Marshal() (dAtA []byte, err error)
- func (m *NodesCoordinatorRegistryWithAuction) MarshalTo(dAtA []byte) (int, error)
- func (m *NodesCoordinatorRegistryWithAuction) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*NodesCoordinatorRegistryWithAuction) ProtoMessage()
- func (m *NodesCoordinatorRegistryWithAuction) Reset()
- func (m *NodesCoordinatorRegistryWithAuction) SetCurrentEpoch(epoch uint32)
- func (m *NodesCoordinatorRegistryWithAuction) Size() (n int)
- func (this *NodesCoordinatorRegistryWithAuction) String() string
- func (m *NodesCoordinatorRegistryWithAuction) Unmarshal(dAtA []byte) error
- func (m *NodesCoordinatorRegistryWithAuction) XXX_DiscardUnknown()
- func (m *NodesCoordinatorRegistryWithAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *NodesCoordinatorRegistryWithAuction) XXX_Merge(src proto.Message)
- func (m *NodesCoordinatorRegistryWithAuction) XXX_Size() int
- func (m *NodesCoordinatorRegistryWithAuction) XXX_Unmarshal(b []byte) error
- type NodesShuffler
- type NodesShufflerArgs
- type PublicKeysSelector
- type RandomSelector
- type ResUpdateNodes
- type SelectionBasedProvider
- type SerializableValidator
- func (*SerializableValidator) Descriptor() ([]byte, []int)
- func (this *SerializableValidator) Equal(that interface{}) bool
- func (m *SerializableValidator) GetChances() uint32
- func (m *SerializableValidator) GetIndex() uint32
- func (m *SerializableValidator) GetPubKey() []byte
- func (this *SerializableValidator) GoString() string
- func (m *SerializableValidator) Marshal() (dAtA []byte, err error)
- func (m *SerializableValidator) MarshalTo(dAtA []byte) (int, error)
- func (m *SerializableValidator) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*SerializableValidator) ProtoMessage()
- func (m *SerializableValidator) Reset()
- func (m *SerializableValidator) Size() (n int)
- func (this *SerializableValidator) String() string
- func (m *SerializableValidator) Unmarshal(dAtA []byte) error
- func (m *SerializableValidator) XXX_DiscardUnknown()
- func (m *SerializableValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SerializableValidator) XXX_Merge(src proto.Message)
- func (m *SerializableValidator) XXX_Size() int
- func (m *SerializableValidator) XXX_Unmarshal(b []byte) error
- type ShuffledOutHandler
- type Validator
- type Validators
- func (*Validators) Descriptor() ([]byte, []int)
- func (this *Validators) Equal(that interface{}) bool
- func (m *Validators) GetData() []*SerializableValidator
- func (this *Validators) GoString() string
- func (m *Validators) Marshal() (dAtA []byte, err error)
- func (m *Validators) MarshalTo(dAtA []byte) (int, error)
- func (m *Validators) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Validators) ProtoMessage()
- func (m *Validators) Reset()
- func (m *Validators) Size() (n int)
- func (this *Validators) String() string
- func (m *Validators) Unmarshal(dAtA []byte) error
- func (m *Validators) XXX_DiscardUnknown()
- func (m *Validators) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Validators) XXX_Merge(src proto.Message)
- func (m *Validators) XXX_Size() int
- func (m *Validators) XXX_Unmarshal(b []byte) error
- type ValidatorsDistributor
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthNodesCoordinatorRegistryWithAuction = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowNodesCoordinatorRegistryWithAuction = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupNodesCoordinatorRegistryWithAuction = fmt.Errorf("proto: unexpected end of group") )
var ErrEpochNodesConfigDoesNotExist = errors.New("epoch nodes configuration does not exist")
ErrEpochNodesConfigDoesNotExist signals that the epoch nodes configuration is missing
var ErrInvalidConsensusGroupSize = errors.New("invalid consensus group size")
ErrInvalidConsensusGroupSize signals that the consensus size is invalid (e.g. value is negative)
var ErrInvalidNumberOfShards = errors.New("the number of shards must be greater than zero")
ErrInvalidNumberOfShards signals that an invalid number of shards was passed to the sharding registry
var ErrInvalidNumberPubKeys = errors.New("invalid number of public keys")
ErrInvalidNumberPubKeys signals that an invalid number of public keys was used
var ErrInvalidSampleSize = errors.New("invalid sample size")
ErrInvalidSampleSize signals that an invalid sample size was provided
var ErrInvalidShardId = errors.New("shard id must be smaller than the total number of shards")
ErrInvalidShardId signals that an invalid shard id was passed
var ErrInvalidWeight = errors.New("invalid weight")
ErrInvalidWeight signals an invalid weight was provided
var ErrKeyNotFoundInWaitingList = errors.New("key not found in waiting list")
ErrKeyNotFoundInWaitingList signals that the provided key has not been found in waiting list
var ErrMapSizeZero = errors.New("map size zero")
ErrMapSizeZero signals that there are no elements in the map
var ErrNilBlockBody = errors.New("nil block body")
ErrNilBlockBody signals that block body is nil
var ErrNilBootStorer = errors.New("nil boot storer provided")
ErrNilBootStorer signals that a nil boot storer was provided
var ErrNilCacher = errors.New("nil cacher")
ErrNilCacher signals that a nil cacher has been provided
var ErrNilChanceComputer = errors.New("nil chance computer")
ErrNilChanceComputer signals that a nil chance computer was provided
var ErrNilEnableEpochsHandler = errors.New("nil enable epochs handler")
ErrNilEnableEpochsHandler signals that a nil enable epochs handler has been provided
var ErrNilEpochNotifier = errors.New("nil epoch notifier provided")
ErrNilEpochNotifier signals that a nil EpochNotifier has been provided
var ErrNilGenesisNodesSetupHandler = errors.New("nil genesis nodes setup handler")
ErrNilGenesisNodesSetupHandler signals that a nil genesis nodes setup handler has been provided
var ErrNilHasher = errors.New("nil hasher")
ErrNilHasher signals that a nil hasher has been provided
var ErrNilInputNodesMap = errors.New("nil input nodes map")
ErrNilInputNodesMap signals that a nil nodes map was provided
var ErrNilMarshalizer = errors.New("nil marshalizer")
ErrNilMarshalizer signals that the marshalizer is nil
var ErrNilNodeShufflerArguments = errors.New("nil arguments for the creation of a node shuffler")
ErrNilNodeShufflerArguments signals that a nil argument pointer was provided for creating the nodes shuffler instance
var ErrNilNodeStopChannel = errors.New("nil node stop channel")
ErrNilNodeStopChannel signals that a nil node stop channel has been provided
var ErrNilNodeTypeProvider = errors.New("nil node type provider")
ErrNilNodeTypeProvider signals that a nil node type provider has been given
var ErrNilNodesCoordinator = errors.New("nil nodesCoordinator")
ErrNilNodesCoordinator signals that the nodesCoordinator is nil
var ErrNilNodesCoordinatorRegistryFactory = errors.New("nil nodes coordinator registry factory has been given")
ErrNilNodesCoordinatorRegistryFactory signals that a nil nodes coordinator registry factory has been given
var ErrNilOrEmptyDestinationForDistribute = errors.New("nil or empty destination list for distributeNodes")
ErrNilOrEmptyDestinationForDistribute signals that a nil or empty value was provided for destination of distributedNodes
var ErrNilPreviousEpochConfig = errors.New("nil previous epoch config")
ErrNilPreviousEpochConfig signals that the previous epoch config is nil
var ErrNilPubKey = errors.New("nil public key")
ErrNilPubKey signals that the public key is nil
var ErrNilRandomSelector = errors.New("nil selector")
ErrNilRandomSelector signals that a nil selector was provided
var ErrNilRandomness = errors.New("nil randomness source")
ErrNilRandomness signals that a nil randomness source has been provided
var ErrNilShuffledOutHandler = errors.New("nil shuffled out handler")
ErrNilShuffledOutHandler signals that a nil shuffled out handler has been provided
var ErrNilShuffler = errors.New("nil nodes shuffler provided")
ErrNilShuffler signals that a nil shuffler was provided
var ErrNilValidatorInfoCacher = errors.New("validator info cacher is nil")
ErrNilValidatorInfoCacher signals that a nil value for the validator info cacher has been provided
var ErrNilWeights = errors.New("nil weights")
ErrNilWeights signals that nil weights list was provided
var ErrNotImplemented = errors.New("feature not implemented")
ErrNotImplemented signals a call of a non implemented functionality
var ErrReceivedAuctionValidatorsBeforeStakingV4 = errors.New("should not have received selected nodes from auction in peer mini blocks, since staking v4 is not enabled yet")
ErrReceivedAuctionValidatorsBeforeStakingV4 signals that auction nodes have been received from peer mini blocks before enabling staking v4
var ErrSmallMetachainEligibleListSize = errors.New("small metachain eligible list size")
ErrSmallMetachainEligibleListSize signals that the eligible validators list's size is less than the consensus size
var ErrSmallShardEligibleListSize = errors.New("small shard eligible list size")
ErrSmallShardEligibleListSize signals that the eligible validators list's size is less than the consensus size
var ErrValidatorCannotBeFullArchive = errors.New("validator cannot be a full archive node")
ErrValidatorCannotBeFullArchive signals a configuration issue because a validator cannot be a full archive node
var ErrValidatorNotFound = errors.New("validator not found")
ErrValidatorNotFound signals that the validator has not been found
var ErrWrongTypeAssertion = errors.New("wrong type assertion")
ErrWrongTypeAssertion signals wrong type assertion error
Functions ¶
func NewHashValidatorsShuffler ¶
func NewHashValidatorsShuffler(args *NodesShufflerArgs) (*randHashShuffler, error)
NewHashValidatorsShuffler creates a validator shuffler that uses a hash between validator key and a given random number to do the shuffling
func NewIndexHashedNodesCoordinator ¶
func NewIndexHashedNodesCoordinator(arguments ArgNodesCoordinator) (*indexHashedNodesCoordinator, error)
NewIndexHashedNodesCoordinator creates a new index hashed group selector
func NewIndexHashedNodesCoordinatorWithRater ¶
func NewIndexHashedNodesCoordinatorWithRater( indexNodesCoordinator *indexHashedNodesCoordinator, chanceComputer ChanceComputer, ) (*indexHashedNodesCoordinatorWithRater, error)
NewIndexHashedNodesCoordinatorWithRater creates a new index hashed group selector
func NewNodesCoordinatorRegistryFactory ¶ added in v1.7.0
func NewNodesCoordinatorRegistryFactory( marshaller marshal.Marshalizer, stakingV4Step2EnableEpoch uint32, ) (*nodesCoordinatorRegistryFactory, error)
NewNodesCoordinatorRegistryFactory creates a nodes coordinator registry factory which will create a NodesCoordinatorRegistryHandler from a buffer depending on the epoch
func NewSelectorExpandedList ¶
func NewSelectorExpandedList(weightList []uint32, hasher hashing.Hasher) (*selectorExpandedList, error)
NewSelectorExpandedList creates a new selector initializing selection set to the given lists of validators and expanding it according to each validator weight.
func NewSelectorWRS ¶
NewSelectorWRS creates a new selector initializing selection set to the given lists of weights
func NewValidator ¶
NewValidator creates a new instance of a validator
func NodesInfoToValidators ¶
func NodesInfoToValidators(nodesInfo map[uint32][]GenesisNodeInfoHandler) (map[uint32][]Validator, error)
NodesInfoToValidators maps nodeInfo to validator interface
func SerializableValidatorsToValidators ¶
func SerializableValidatorsToValidators(nodeRegistryValidators map[string][]*SerializableValidator) (map[uint32][]Validator, error)
SerializableValidatorsToValidators creates the validator map from serializable validator map
Types ¶
type ArgNodesCoordinator ¶
type ArgNodesCoordinator struct { ShardConsensusGroupSize int MetaConsensusGroupSize int Marshalizer marshal.Marshalizer Hasher hashing.Hasher Shuffler NodesShuffler EpochStartNotifier EpochStartEventNotifier BootStorer storage.Storer ShardIDAsObserver uint32 NbShards uint32 EligibleNodes map[uint32][]Validator WaitingNodes map[uint32][]Validator SelfPublicKey []byte Epoch uint32 StartEpoch uint32 ConsensusGroupCache Cacher ShuffledOutHandler ShuffledOutHandler ChanStopNode chan endProcess.ArgEndProcess NodeTypeProvider NodeTypeProviderHandler IsFullArchive bool EnableEpochsHandler common.EnableEpochsHandler ValidatorInfoCacher epochStart.ValidatorInfoCacher GenesisNodesSetupHandler GenesisNodesSetupHandler NodesCoordinatorRegistryFactory NodesCoordinatorRegistryFactory }
ArgNodesCoordinator holds all dependencies required by the nodes coordinator in order to create new instances
type ArgsUpdateNodes ¶
type ArgsUpdateNodes struct { Eligible map[uint32][]Validator Waiting map[uint32][]Validator NewNodes []Validator UnStakeLeaving []Validator AdditionalLeaving []Validator Auction []Validator Rand []byte NbShards uint32 Epoch uint32 }
ArgsUpdateNodes holds the parameters required by the shuffler to generate a new nodes configuration
type Cacher ¶
type Cacher interface { // Clear is used to completely clear the cache. Clear() // Put adds a value to the cache. Returns true if an eviction occurred. Put(key []byte, value interface{}, sizeInBytes int) (evicted bool) // Get looks up a key's value from the cache. Get(key []byte) (value interface{}, ok bool) }
Cacher provides the capabilities needed to store and retrieve information needed in the NodesCoordinator
type ChanceComputer ¶
type ChanceComputer interface { // GetChance returns the chances for the rating GetChance(uint32) uint32 // IsInterfaceNil verifies if the interface is nil IsInterfaceNil() bool }
ChanceComputer provides chance computation capabilities based on a rating
type CrossShardValidatorDistributor ¶
type CrossShardValidatorDistributor struct{}
CrossShardValidatorDistributor - distributes validators from source to destination cross shards
func (*CrossShardValidatorDistributor) DistributeValidators ¶
func (vd *CrossShardValidatorDistributor) DistributeValidators( destination map[uint32][]Validator, source map[uint32][]Validator, rand []byte, balanced bool, ) error
DistributeValidators will handle the moving of the nodes to the map for cross shard validator distributor
func (*CrossShardValidatorDistributor) IsInterfaceNil ¶
func (vd *CrossShardValidatorDistributor) IsInterfaceNil() bool
IsInterfaceNil - verifies if the interface is nil
type EpochNotifier ¶ added in v1.7.0
type EpochNotifier interface { RegisterNotifyHandler(handler vmcommon.EpochSubscriberHandler) CurrentEpoch() uint32 CheckEpoch(header data.HeaderHandler) IsInterfaceNil() bool }
EpochNotifier can notify upon an epoch change and provide the current epoch
type EpochStartActionHandler ¶
type EpochStartActionHandler interface { EpochStartAction(hdr data.HeaderHandler) EpochStartPrepare(metaHdr data.HeaderHandler, body data.BodyHandler) NotifyOrder() uint32 }
EpochStartActionHandler defines the action taken on epoch start event
type EpochStartEventNotifier ¶
type EpochStartEventNotifier interface { RegisterHandler(handler epochStart.ActionHandler) UnregisterHandler(handler epochStart.ActionHandler) IsInterfaceNil() bool }
EpochStartEventNotifier provides Register and Unregister functionality for the end of epoch events
type EpochValidators ¶
type EpochValidators struct { EligibleValidators map[string][]*SerializableValidator `json:"eligibleValidators"` WaitingValidators map[string][]*SerializableValidator `json:"waitingValidators"` LeavingValidators map[string][]*SerializableValidator `json:"leavingValidators"` }
EpochValidators holds one epoch configuration for a nodes coordinator
func (*EpochValidators) GetEligibleValidators ¶ added in v1.7.0
func (ev *EpochValidators) GetEligibleValidators() map[string][]*SerializableValidator
GetEligibleValidators returns all eligible validators from all shards
func (*EpochValidators) GetLeavingValidators ¶ added in v1.7.0
func (ev *EpochValidators) GetLeavingValidators() map[string][]*SerializableValidator
GetLeavingValidators returns all leaving validators from all shards
func (*EpochValidators) GetWaitingValidators ¶ added in v1.7.0
func (ev *EpochValidators) GetWaitingValidators() map[string][]*SerializableValidator
GetWaitingValidators returns all waiting validators from all shards
type EpochValidatorsHandler ¶ added in v1.7.0
type EpochValidatorsHandler interface { GetEligibleValidators() map[string][]*SerializableValidator GetWaitingValidators() map[string][]*SerializableValidator GetLeavingValidators() map[string][]*SerializableValidator }
EpochValidatorsHandler defines what one epoch configuration for a nodes coordinator should hold
type EpochValidatorsHandlerWithAuction ¶ added in v1.7.0
type EpochValidatorsHandlerWithAuction interface { EpochValidatorsHandler GetShuffledOutValidators() map[string][]*SerializableValidator GetLowWaitingList() bool }
EpochValidatorsHandlerWithAuction defines what one epoch configuration for a nodes coordinator should hold + shuffled out validators
type EpochValidatorsWithAuction ¶ added in v1.7.0
type EpochValidatorsWithAuction struct { Eligible map[string]Validators `` /* 147-byte string literal not displayed */ Waiting map[string]Validators `` /* 145-byte string literal not displayed */ Leaving map[string]Validators `` /* 145-byte string literal not displayed */ ShuffledOut map[string]Validators `` /* 153-byte string literal not displayed */ LowWaitingList bool `protobuf:"varint,5,opt,name=LowWaitingList,proto3" json:"LowWaitingList,omitempty"` }
func (*EpochValidatorsWithAuction) Descriptor ¶ added in v1.7.0
func (*EpochValidatorsWithAuction) Descriptor() ([]byte, []int)
func (*EpochValidatorsWithAuction) Equal ¶ added in v1.7.0
func (this *EpochValidatorsWithAuction) Equal(that interface{}) bool
func (*EpochValidatorsWithAuction) GetEligible ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetEligible() map[string]Validators
func (*EpochValidatorsWithAuction) GetEligibleValidators ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetEligibleValidators() map[string][]*SerializableValidator
GetEligibleValidators returns all eligible validators from all shards
func (*EpochValidatorsWithAuction) GetLeaving ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetLeaving() map[string]Validators
func (*EpochValidatorsWithAuction) GetLeavingValidators ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetLeavingValidators() map[string][]*SerializableValidator
GetLeavingValidators returns all leaving validators from all shards
func (*EpochValidatorsWithAuction) GetLowWaitingList ¶ added in v1.7.11
func (m *EpochValidatorsWithAuction) GetLowWaitingList() bool
func (*EpochValidatorsWithAuction) GetShuffledOut ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetShuffledOut() map[string]Validators
func (*EpochValidatorsWithAuction) GetShuffledOutValidators ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetShuffledOutValidators() map[string][]*SerializableValidator
GetShuffledOutValidators returns all shuffled out validators from all shards
func (*EpochValidatorsWithAuction) GetWaiting ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetWaiting() map[string]Validators
func (*EpochValidatorsWithAuction) GetWaitingValidators ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) GetWaitingValidators() map[string][]*SerializableValidator
GetWaitingValidators returns all waiting validators from all shards
func (*EpochValidatorsWithAuction) GoString ¶ added in v1.7.0
func (this *EpochValidatorsWithAuction) GoString() string
func (*EpochValidatorsWithAuction) Marshal ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) Marshal() (dAtA []byte, err error)
func (*EpochValidatorsWithAuction) MarshalTo ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) MarshalTo(dAtA []byte) (int, error)
func (*EpochValidatorsWithAuction) MarshalToSizedBuffer ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*EpochValidatorsWithAuction) ProtoMessage ¶ added in v1.7.0
func (*EpochValidatorsWithAuction) ProtoMessage()
func (*EpochValidatorsWithAuction) Reset ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) Reset()
func (*EpochValidatorsWithAuction) Size ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) Size() (n int)
func (*EpochValidatorsWithAuction) String ¶ added in v1.7.0
func (this *EpochValidatorsWithAuction) String() string
func (*EpochValidatorsWithAuction) Unmarshal ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) Unmarshal(dAtA []byte) error
func (*EpochValidatorsWithAuction) XXX_DiscardUnknown ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) XXX_DiscardUnknown()
func (*EpochValidatorsWithAuction) XXX_Marshal ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EpochValidatorsWithAuction) XXX_Merge ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) XXX_Merge(src proto.Message)
func (*EpochValidatorsWithAuction) XXX_Size ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) XXX_Size() int
func (*EpochValidatorsWithAuction) XXX_Unmarshal ¶ added in v1.7.0
func (m *EpochValidatorsWithAuction) XXX_Unmarshal(b []byte) error
type EpochsConfigUpdateHandler ¶
type EpochsConfigUpdateHandler interface { NodesCoordinator SetNodesConfigFromValidatorsInfo(epoch uint32, randomness []byte, validatorsInfo []*state.ShardValidatorInfo) error IsEpochInConfig(epoch uint32) bool }
EpochsConfigUpdateHandler specifies the behaviour needed to update nodes config epochs
type GenesisNodeInfoHandler ¶
type GenesisNodeInfoHandler interface { AssignedShard() uint32 AddressBytes() []byte PubKeyBytes() []byte GetInitialRating() uint32 IsInterfaceNil() bool }
GenesisNodeInfoHandler defines the public methods for the genesis nodes info
type GenesisNodesSetupHandler ¶ added in v1.7.0
type GenesisNodesSetupHandler interface { MinShardHysteresisNodes() uint32 MinMetaHysteresisNodes() uint32 IsInterfaceNil() bool }
GenesisNodesSetupHandler defines a component able to provide the genesis nodes info
type IntraShardValidatorDistributor ¶
type IntraShardValidatorDistributor struct{}
IntraShardValidatorDistributor - distributes validators from source to destination inside the same shard
func (*IntraShardValidatorDistributor) DistributeValidators ¶
func (vd *IntraShardValidatorDistributor) DistributeValidators( destination map[uint32][]Validator, source map[uint32][]Validator, _ []byte, _ bool, ) error
DistributeValidators will handle the moving of the nodes to the map for intra shard validator distributor
func (*IntraShardValidatorDistributor) IsInterfaceNil ¶
func (vd *IntraShardValidatorDistributor) IsInterfaceNil() bool
IsInterfaceNil - verifies if the interface is nil
type NodeTypeProviderHandler ¶
type NodeTypeProviderHandler interface { SetType(nodeType core.NodeType) GetType() core.NodeType IsInterfaceNil() bool }
NodeTypeProviderHandler defines the actions needed for a component that can handle the node type
type NodesCoordinator ¶
type NodesCoordinator interface { NodesCoordinatorHelper PublicKeysSelector ComputeConsensusGroup(randomness []byte, round uint64, shardId uint32, epoch uint32) (validatorsGroup []Validator, err error) GetValidatorWithPublicKey(publicKey []byte) (validator Validator, shardId uint32, err error) LoadState(key []byte) error GetSavedStateKey() []byte ShardIdForEpoch(epoch uint32) (uint32, error) ShuffleOutForEpoch(_ uint32) GetConsensusWhitelistedNodes(epoch uint32) (map[string]struct{}, error) ConsensusGroupSize(uint32) int GetNumTotalEligible() uint64 GetWaitingEpochsLeftForPublicKey(publicKey []byte) (uint32, error) IsInterfaceNil() bool }
NodesCoordinator defines the behaviour of a struct able to do validator group selection
type NodesCoordinatorHelper ¶
type NodesCoordinatorHelper interface { ValidatorsWeights(validators []Validator) ([]uint32, error) ComputeAdditionalLeaving(allValidators []*state.ShardValidatorInfo) (map[uint32][]Validator, error) GetChance(uint32) uint32 }
NodesCoordinatorHelper provides polymorphism functionality for nodesCoordinator
type NodesCoordinatorRegistry ¶
type NodesCoordinatorRegistry struct { EpochsConfig map[string]*EpochValidators `json:"epochConfigs"` CurrentEpoch uint32 `json:"currentEpoch"` }
NodesCoordinatorRegistry holds the data that can be used to initialize a nodes coordinator
func (*NodesCoordinatorRegistry) GetCurrentEpoch ¶ added in v1.7.0
func (ncr *NodesCoordinatorRegistry) GetCurrentEpoch() uint32
GetCurrentEpoch returns the current epoch
func (*NodesCoordinatorRegistry) GetEpochsConfig ¶ added in v1.7.0
func (ncr *NodesCoordinatorRegistry) GetEpochsConfig() map[string]EpochValidatorsHandler
GetEpochsConfig returns epoch-validators configuration
func (*NodesCoordinatorRegistry) SetCurrentEpoch ¶ added in v1.7.0
func (ncr *NodesCoordinatorRegistry) SetCurrentEpoch(epoch uint32)
SetCurrentEpoch sets internally the current epoch
type NodesCoordinatorRegistryFactory ¶ added in v1.7.0
type NodesCoordinatorRegistryFactory interface { CreateNodesCoordinatorRegistry(buff []byte) (NodesCoordinatorRegistryHandler, error) GetRegistryData(registry NodesCoordinatorRegistryHandler, epoch uint32) ([]byte, error) IsInterfaceNil() bool }
NodesCoordinatorRegistryFactory handles NodesCoordinatorRegistryHandler marshall/unmarshall
type NodesCoordinatorRegistryHandler ¶ added in v1.7.0
type NodesCoordinatorRegistryHandler interface { GetEpochsConfig() map[string]EpochValidatorsHandler GetCurrentEpoch() uint32 SetCurrentEpoch(epoch uint32) }
NodesCoordinatorRegistryHandler defines what is used to initialize nodes coordinator
type NodesCoordinatorRegistryWithAuction ¶ added in v1.7.0
type NodesCoordinatorRegistryWithAuction struct { CurrentEpoch uint32 `protobuf:"varint,1,opt,name=CurrentEpoch,proto3" json:"CurrentEpoch,omitempty"` EpochsConfigWithAuction map[string]*EpochValidatorsWithAuction `` /* 187-byte string literal not displayed */ }
func (*NodesCoordinatorRegistryWithAuction) Descriptor ¶ added in v1.7.0
func (*NodesCoordinatorRegistryWithAuction) Descriptor() ([]byte, []int)
func (*NodesCoordinatorRegistryWithAuction) Equal ¶ added in v1.7.0
func (this *NodesCoordinatorRegistryWithAuction) Equal(that interface{}) bool
func (*NodesCoordinatorRegistryWithAuction) GetCurrentEpoch ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) GetCurrentEpoch() uint32
func (*NodesCoordinatorRegistryWithAuction) GetEpochsConfig ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) GetEpochsConfig() map[string]EpochValidatorsHandler
GetEpochsConfig returns epoch-validators configuration
func (*NodesCoordinatorRegistryWithAuction) GetEpochsConfigWithAuction ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) GetEpochsConfigWithAuction() map[string]*EpochValidatorsWithAuction
func (*NodesCoordinatorRegistryWithAuction) GoString ¶ added in v1.7.0
func (this *NodesCoordinatorRegistryWithAuction) GoString() string
func (*NodesCoordinatorRegistryWithAuction) Marshal ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) Marshal() (dAtA []byte, err error)
func (*NodesCoordinatorRegistryWithAuction) MarshalTo ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) MarshalTo(dAtA []byte) (int, error)
func (*NodesCoordinatorRegistryWithAuction) MarshalToSizedBuffer ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*NodesCoordinatorRegistryWithAuction) ProtoMessage ¶ added in v1.7.0
func (*NodesCoordinatorRegistryWithAuction) ProtoMessage()
func (*NodesCoordinatorRegistryWithAuction) Reset ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) Reset()
func (*NodesCoordinatorRegistryWithAuction) SetCurrentEpoch ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) SetCurrentEpoch(epoch uint32)
SetCurrentEpoch sets internally the current epoch
func (*NodesCoordinatorRegistryWithAuction) Size ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) Size() (n int)
func (*NodesCoordinatorRegistryWithAuction) String ¶ added in v1.7.0
func (this *NodesCoordinatorRegistryWithAuction) String() string
func (*NodesCoordinatorRegistryWithAuction) Unmarshal ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) Unmarshal(dAtA []byte) error
func (*NodesCoordinatorRegistryWithAuction) XXX_DiscardUnknown ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) XXX_DiscardUnknown()
func (*NodesCoordinatorRegistryWithAuction) XXX_Marshal ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*NodesCoordinatorRegistryWithAuction) XXX_Merge ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) XXX_Merge(src proto.Message)
func (*NodesCoordinatorRegistryWithAuction) XXX_Size ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) XXX_Size() int
func (*NodesCoordinatorRegistryWithAuction) XXX_Unmarshal ¶ added in v1.7.0
func (m *NodesCoordinatorRegistryWithAuction) XXX_Unmarshal(b []byte) error
type NodesShuffler ¶
type NodesShuffler interface { UpdateParams(numNodesShard uint32, numNodesMeta uint32, hysteresis float32, adaptivity bool) UpdateNodeLists(args ArgsUpdateNodes) (*ResUpdateNodes, error) IsInterfaceNil() bool }
NodesShuffler provides shuffling functionality for nodes
type NodesShufflerArgs ¶
type NodesShufflerArgs struct { NodesShard uint32 NodesMeta uint32 Hysteresis float32 Adaptivity bool ShuffleBetweenShards bool MaxNodesEnableConfig []config.MaxNodesChangeConfig EnableEpochsHandler common.EnableEpochsHandler EnableEpochs config.EnableEpochs }
NodesShufflerArgs defines the arguments required to create a nodes shuffler
type PublicKeysSelector ¶
type PublicKeysSelector interface { GetValidatorsIndexes(publicKeys []string, epoch uint32) ([]uint64, error) GetAllEligibleValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetAllWaitingValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetAllLeavingValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetAllShuffledOutValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetShuffledOutToAuctionValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetConsensusValidatorsPublicKeys(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error) GetOwnPublicKey() []byte }
PublicKeysSelector allows retrieval of eligible validators public keys
type RandomSelector ¶
type RandomSelector interface { Select(randSeed []byte, sampleSize uint32) ([]uint32, error) IsInterfaceNil() bool }
RandomSelector selects randomly a subset of elements from a set of data
type ResUpdateNodes ¶
type ResUpdateNodes struct { Eligible map[uint32][]Validator Waiting map[uint32][]Validator ShuffledOut map[uint32][]Validator Leaving []Validator StillRemaining []Validator LowWaitingList bool }
ResUpdateNodes holds the result of the UpdateNodes method
type SelectionBasedProvider ¶
type SelectionBasedProvider struct {
// contains filtered or unexported fields
}
SelectionBasedProvider will handle the returning of the consensus group by simulating a reslicing of the expanded eligible list. A comparison between a real reslicing and this can be found in common_test.go
func NewSelectionBasedProvider ¶
func NewSelectionBasedProvider(hasher hashing.Hasher, maxSize uint32) *SelectionBasedProvider
NewSelectionBasedProvider will return a new instance of SelectionBasedProvider
func (*SelectionBasedProvider) Get ¶
func (sbp *SelectionBasedProvider) Get(randomness []byte, numValidators int64, expandedEligibleList []uint32) ([]uint32, error)
Get will return the consensus group based on the randomness. After an item is chosen, it is added to the slice, so it won't be selected again so next time a new item is needed, the index is recalculated until the validator doesn't exist in that slice
type SerializableValidator ¶
type SerializableValidator struct { PubKey []byte `protobuf:"bytes,1,opt,name=PubKey,proto3" json:"pubKey"` Chances uint32 `protobuf:"varint,2,opt,name=Chances,proto3" json:"chances"` Index uint32 `protobuf:"varint,3,opt,name=Index,proto3" json:"index"` }
func ValidatorArrayToSerializableValidatorArray ¶
func ValidatorArrayToSerializableValidatorArray(validators []Validator) []*SerializableValidator
ValidatorArrayToSerializableValidatorArray -
func (*SerializableValidator) Descriptor ¶ added in v1.7.0
func (*SerializableValidator) Descriptor() ([]byte, []int)
func (*SerializableValidator) Equal ¶ added in v1.7.0
func (this *SerializableValidator) Equal(that interface{}) bool
func (*SerializableValidator) GetChances ¶ added in v1.7.0
func (m *SerializableValidator) GetChances() uint32
func (*SerializableValidator) GetIndex ¶ added in v1.7.0
func (m *SerializableValidator) GetIndex() uint32
func (*SerializableValidator) GetPubKey ¶ added in v1.7.0
func (m *SerializableValidator) GetPubKey() []byte
func (*SerializableValidator) GoString ¶ added in v1.7.0
func (this *SerializableValidator) GoString() string
func (*SerializableValidator) Marshal ¶ added in v1.7.0
func (m *SerializableValidator) Marshal() (dAtA []byte, err error)
func (*SerializableValidator) MarshalTo ¶ added in v1.7.0
func (m *SerializableValidator) MarshalTo(dAtA []byte) (int, error)
func (*SerializableValidator) MarshalToSizedBuffer ¶ added in v1.7.0
func (m *SerializableValidator) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*SerializableValidator) ProtoMessage ¶ added in v1.7.0
func (*SerializableValidator) ProtoMessage()
func (*SerializableValidator) Reset ¶ added in v1.7.0
func (m *SerializableValidator) Reset()
func (*SerializableValidator) Size ¶ added in v1.7.0
func (m *SerializableValidator) Size() (n int)
func (*SerializableValidator) String ¶ added in v1.7.0
func (this *SerializableValidator) String() string
func (*SerializableValidator) Unmarshal ¶ added in v1.7.0
func (m *SerializableValidator) Unmarshal(dAtA []byte) error
func (*SerializableValidator) XXX_DiscardUnknown ¶ added in v1.7.0
func (m *SerializableValidator) XXX_DiscardUnknown()
func (*SerializableValidator) XXX_Marshal ¶ added in v1.7.0
func (m *SerializableValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*SerializableValidator) XXX_Merge ¶ added in v1.7.0
func (m *SerializableValidator) XXX_Merge(src proto.Message)
func (*SerializableValidator) XXX_Size ¶ added in v1.7.0
func (m *SerializableValidator) XXX_Size() int
func (*SerializableValidator) XXX_Unmarshal ¶ added in v1.7.0
func (m *SerializableValidator) XXX_Unmarshal(b []byte) error
type ShuffledOutHandler ¶
type ShuffledOutHandler interface { Process(newShardID uint32) error RegisterHandler(handler func(newShardID uint32)) CurrentShardID() uint32 IsInterfaceNil() bool }
ShuffledOutHandler defines the methods needed for the computation of a shuffled out event
type Validator ¶
Validator defines a node that can be allocated to a shard for participation in a consensus group as validator or block proposer
func SerializableShardValidatorListToValidatorList ¶
func SerializableShardValidatorListToValidatorList(shardValidators []*SerializableValidator) ([]Validator, error)
SerializableShardValidatorListToValidatorList creates the validator list from serializable validator list
type Validators ¶ added in v1.7.0
type Validators struct {
Data []*SerializableValidator `protobuf:"bytes,1,rep,name=Data,proto3" json:"Data,omitempty"`
}
func (*Validators) Descriptor ¶ added in v1.7.0
func (*Validators) Descriptor() ([]byte, []int)
func (*Validators) Equal ¶ added in v1.7.0
func (this *Validators) Equal(that interface{}) bool
func (*Validators) GetData ¶ added in v1.7.0
func (m *Validators) GetData() []*SerializableValidator
func (*Validators) GoString ¶ added in v1.7.0
func (this *Validators) GoString() string
func (*Validators) Marshal ¶ added in v1.7.0
func (m *Validators) Marshal() (dAtA []byte, err error)
func (*Validators) MarshalTo ¶ added in v1.7.0
func (m *Validators) MarshalTo(dAtA []byte) (int, error)
func (*Validators) MarshalToSizedBuffer ¶ added in v1.7.0
func (m *Validators) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*Validators) ProtoMessage ¶ added in v1.7.0
func (*Validators) ProtoMessage()
func (*Validators) Reset ¶ added in v1.7.0
func (m *Validators) Reset()
func (*Validators) Size ¶ added in v1.7.0
func (m *Validators) Size() (n int)
func (*Validators) String ¶ added in v1.7.0
func (this *Validators) String() string
func (*Validators) Unmarshal ¶ added in v1.7.0
func (m *Validators) Unmarshal(dAtA []byte) error
func (*Validators) XXX_DiscardUnknown ¶ added in v1.7.0
func (m *Validators) XXX_DiscardUnknown()
func (*Validators) XXX_Marshal ¶ added in v1.7.0
func (m *Validators) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Validators) XXX_Merge ¶ added in v1.7.0
func (m *Validators) XXX_Merge(src proto.Message)
func (*Validators) XXX_Size ¶ added in v1.7.0
func (m *Validators) XXX_Size() int
func (*Validators) XXX_Unmarshal ¶ added in v1.7.0
func (m *Validators) XXX_Unmarshal(b []byte) error
Source Files ¶
- common.go
- dtos.go
- errors.go
- expandedListSampling.go
- hashValidatorShuffler.go
- indexHashedNodesCoordinator.go
- indexHashedNodesCoordinatorLite.go
- indexHashedNodesCoordinatorRegistry.go
- indexHashedNodesCoordinatorRegistryWithAuction.go
- indexHashedNodesCoordinatorWithRater.go
- interface.go
- nodesCoordinatorRegistry.go
- nodesCoordinatorRegistryFactory.go
- nodesCoordinatorRegistryWithAuction.go
- nodesCoordinatorRegistryWithAuction.pb.go
- selectionBasedProvider.go
- shardingArgs.go
- validator.go
- validatorDistributor.go
- weightedRandomSampling.go