sharding

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: GPL-3.0 Imports: 11 Imported by: 6 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotParseAddress = errors.New("could not parse node's address")

ErrCouldNotParseAddress signals that a given address could not be parsed

View Source
var ErrCouldNotParsePubKey = errors.New("could not parse node's public key")

ErrCouldNotParsePubKey signals that a given public key could not be parsed

View Source
var ErrInvalidMaximumNumberOfShards = errors.New("trying to set an invalid maximum number of shards")

ErrInvalidMaximumNumberOfShards signals that an invalid maximum number of shards has been provided

View Source
var ErrMinNodesPerShardSmallerThanConsensusSize = errors.New("minimum nodes per shard is smaller than consensus group size")

ErrMinNodesPerShardSmallerThanConsensusSize signals that an invalid min nodes per shard has been provided

View Source
var ErrNegativeOrZeroConsensusGroupSize = errors.New("negative or zero consensus group size")

ErrNegativeOrZeroConsensusGroupSize signals that an invalid consensus group size has been provided

View Source
var ErrNilEndOfProcessingHandler = errors.New("nil end of processing handler")

ErrNilEndOfProcessingHandler signals that a nil end of processing handler has been provided

View Source
var ErrNilOwnPublicKey = errors.New("nil own public key")

ErrNilOwnPublicKey signals that a nil own public key has been provided

View Source
var ErrNilPubkeyConverter = errors.New("trying to set nil pubkey converter")

ErrNilPubkeyConverter signals that a nil public key converter has been provided

View Source
var ErrNoPubKeys = errors.New("no public keys defined")

ErrNoPubKeys signals an error when public keys are missing

View Source
var ErrNodesSizeSmallerThanMinNoOfNodes = errors.New("length of nodes defined is smaller than min nodes per shard required")

ErrNodesSizeSmallerThanMinNoOfNodes signals that there are not enough nodes defined in genesis file

View Source
var ErrPublicKeyNotFoundInGenesis = errors.New("public key is not valid, it is missing from genesis file")

ErrPublicKeyNotFoundInGenesis signals an error when the public key is not in genesis file

View Source
var ErrShardIdOutOfRange = errors.New("shard id out of range")

ErrShardIdOutOfRange signals an error when shard id is out of range

Functions

func NewMultiShardCoordinator

func NewMultiShardCoordinator(numberOfShards, selfId uint32) (*multiShardCoordinator, error)

NewMultiShardCoordinator returns a new multiShardCoordinator and initializes the masks

func NewShuffledOutTrigger

func NewShuffledOutTrigger(
	ownPubKey []byte,
	currentShardID uint32,
	endProcessHandler func(argument endProcess.ArgEndProcess) error,
) (*shuffledOutTrigger, error)

NewShuffledOutTrigger returns a new instance of shuffledOutTrigger

Types

type Coordinator

type Coordinator interface {
	NumberOfShards() uint32
	ComputeId(address []byte) uint32
	SelfId() uint32
	SameShard(firstAddress, secondAddress []byte) bool
	CommunicationIdentifier(destShardID uint32) string
	IsInterfaceNil() bool
}

Coordinator defines what a shard state coordinator should hold

type EpochHandler

type EpochHandler interface {
	MetaEpoch() uint32
	IsInterfaceNil() bool
}

EpochHandler defines what a component which handles current epoch should be able to do

type GenesisNodesSetupHandler

type GenesisNodesSetupHandler interface {
	AllInitialNodes() []nodesCoordinator.GenesisNodeInfoHandler
	InitialNodesPubKeys() map[uint32][]string
	GetShardIDForPubKey(pubkey []byte) (uint32, error)
	InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error)
	InitialNodesInfoForShard(shardId uint32) ([]nodesCoordinator.GenesisNodeInfoHandler, []nodesCoordinator.GenesisNodeInfoHandler, error)
	InitialNodesInfo() (map[uint32][]nodesCoordinator.GenesisNodeInfoHandler, map[uint32][]nodesCoordinator.GenesisNodeInfoHandler)
	GetStartTime() int64
	GetRoundDuration() uint64
	GetShardConsensusGroupSize() uint32
	GetMetaConsensusGroupSize() uint32
	NumberOfShards() uint32
	MinNumberOfNodes() uint32
	MinNumberOfShardNodes() uint32
	MinNumberOfMetaNodes() uint32
	GetHysteresis() float32
	GetAdaptivity() bool
	MinNumberOfNodesWithHysteresis() uint32
	IsInterfaceNil() bool
}

GenesisNodesSetupHandler returns the genesis nodes info

type InitialNode

type InitialNode struct {
	PubKey        string `json:"pubkey"`
	Address       string `json:"address"`
	InitialRating uint32 `json:"initialRating"`
	// contains filtered or unexported fields
}

InitialNode holds data from json

func (*InitialNode) AddressBytes

func (ni *InitialNode) AddressBytes() []byte

AddressBytes gets the node address as bytes

func (*InitialNode) AssignedShard

func (ni *InitialNode) AssignedShard() uint32

AssignedShard gets the node assigned shard

func (*InitialNode) GetInitialRating

func (ni *InitialNode) GetInitialRating() uint32

GetInitialRating gets the initial rating for a node

func (*InitialNode) IsInterfaceNil

func (ni *InitialNode) IsInterfaceNil() bool

IsInterfaceNil returns true if underlying object is nil

func (*InitialNode) PubKeyBytes

func (ni *InitialNode) PubKeyBytes() []byte

PubKeyBytes gets the node public key as bytes

type NodesSetup

type NodesSetup struct {
	StartTime          int64  `json:"startTime"`
	RoundDuration      uint64 `json:"roundDuration"`
	ConsensusGroupSize uint32 `json:"consensusGroupSize"`
	MinNodesPerShard   uint32 `json:"minNodesPerShard"`

	MetaChainConsensusGroupSize uint32  `json:"metaChainConsensusGroupSize"`
	MetaChainMinNodes           uint32  `json:"metaChainMinNodes"`
	Hysteresis                  float32 `json:"hysteresis"`
	Adaptivity                  bool    `json:"adaptivity"`

	InitialNodes []*InitialNode `json:"initialNodes"`
	// contains filtered or unexported fields
}

NodesSetup hold data for decoded data from json file

func NewNodesSetup

func NewNodesSetup(
	nodesFilePath string,
	addressPubkeyConverter core.PubkeyConverter,
	validatorPubkeyConverter core.PubkeyConverter,
	genesisMaxNumShards uint32,
) (*NodesSetup, error)

NewNodesSetup creates a new decoded nodes structure from json config file

func (*NodesSetup) AllInitialNodes

func (ns *NodesSetup) AllInitialNodes() []nodesCoordinator.GenesisNodeInfoHandler

AllInitialNodes returns all initial nodes loaded

func (*NodesSetup) GetAdaptivity

func (ns *NodesSetup) GetAdaptivity() bool

GetAdaptivity returns the value of the adaptivity boolean flag

func (*NodesSetup) GetHysteresis

func (ns *NodesSetup) GetHysteresis() float32

GetHysteresis returns the hysteresis value

func (*NodesSetup) GetMetaConsensusGroupSize

func (ns *NodesSetup) GetMetaConsensusGroupSize() uint32

GetMetaConsensusGroupSize returns the metachain consensus group size

func (*NodesSetup) GetRoundDuration

func (ns *NodesSetup) GetRoundDuration() uint64

GetRoundDuration returns the round duration

func (*NodesSetup) GetShardConsensusGroupSize

func (ns *NodesSetup) GetShardConsensusGroupSize() uint32

GetShardConsensusGroupSize returns the shard consensus group size

func (*NodesSetup) GetShardIDForPubKey

func (ns *NodesSetup) GetShardIDForPubKey(pubKey []byte) (uint32, error)

GetShardIDForPubKey returns the allocated shard ID from public key

func (*NodesSetup) GetStartTime

func (ns *NodesSetup) GetStartTime() int64

GetStartTime returns the start time

func (*NodesSetup) InitialEligibleNodesPubKeysForShard

func (ns *NodesSetup) InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error)

InitialEligibleNodesPubKeysForShard - gets initial nodes public keys for shard

func (*NodesSetup) InitialNodesInfo

InitialNodesInfo - gets initial nodes info

func (*NodesSetup) InitialNodesInfoForShard

InitialNodesInfoForShard - gets initial nodes info for shard

func (*NodesSetup) InitialNodesPubKeys

func (ns *NodesSetup) InitialNodesPubKeys() map[uint32][]string

InitialNodesPubKeys - gets initial nodes public keys

func (*NodesSetup) IsInterfaceNil

func (ns *NodesSetup) IsInterfaceNil() bool

IsInterfaceNil returns true if underlying object is nil

func (*NodesSetup) MinMetaHysteresisNodes

func (ns *NodesSetup) MinMetaHysteresisNodes() uint32

MinMetaHysteresisNodes returns the minimum number of hysteresis nodes in metachain

func (*NodesSetup) MinNumberOfMetaNodes

func (ns *NodesSetup) MinNumberOfMetaNodes() uint32

MinNumberOfMetaNodes returns the minimum number of nodes in metachain

func (*NodesSetup) MinNumberOfNodes

func (ns *NodesSetup) MinNumberOfNodes() uint32

MinNumberOfNodes returns the minimum number of nodes

func (*NodesSetup) MinNumberOfNodesWithHysteresis

func (ns *NodesSetup) MinNumberOfNodesWithHysteresis() uint32

MinNumberOfNodesWithHysteresis returns the minimum number of nodes with hysteresis

func (*NodesSetup) MinNumberOfShardNodes

func (ns *NodesSetup) MinNumberOfShardNodes() uint32

MinNumberOfShardNodes returns the minimum number of nodes per shard

func (*NodesSetup) MinShardHysteresisNodes

func (ns *NodesSetup) MinShardHysteresisNodes() uint32

MinShardHysteresisNodes returns the minimum number of hysteresis nodes per shard

func (*NodesSetup) NumberOfShards

func (ns *NodesSetup) NumberOfShards() uint32

NumberOfShards returns the calculated number of shards

type OneShardCoordinator

type OneShardCoordinator struct{}

OneShardCoordinator creates a shard coordinator object

func (*OneShardCoordinator) CommunicationIdentifier

func (osc *OneShardCoordinator) CommunicationIdentifier(destShardID uint32) string

CommunicationIdentifier returns the identifier between current shard ID and destination shard ID for this implementation, it will always return "_0" as there is a single shard

func (*OneShardCoordinator) ComputeId

func (osc *OneShardCoordinator) ComputeId(_ []byte) uint32

ComputeId gets shard for the given address

func (*OneShardCoordinator) IsInterfaceNil

func (osc *OneShardCoordinator) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*OneShardCoordinator) NumberOfShards

func (osc *OneShardCoordinator) NumberOfShards() uint32

NumberOfShards gets number of shards

func (*OneShardCoordinator) SameShard

func (osc *OneShardCoordinator) SameShard(_, _ []byte) bool

SameShard returns weather two addresses belong to the same shard

func (*OneShardCoordinator) SelfId

func (osc *OneShardCoordinator) SelfId() uint32

SelfId gets shard of the current node

type PeerAccountListAndRatingHandler

type PeerAccountListAndRatingHandler interface {
	// GetChance returns the chances for the rating
	GetChance(uint32) uint32
	// GetStartRating gets the start rating values
	GetStartRating() uint32
	// GetSignedBlocksThreshold gets the threshold for the minimum signed blocks
	GetSignedBlocksThreshold() float32
	// ComputeIncreaseProposer computes the new rating for the increaseLeader
	ComputeIncreaseProposer(shardId uint32, currentRating uint32) uint32
	// ComputeDecreaseProposer computes the new rating for the decreaseLeader
	ComputeDecreaseProposer(shardId uint32, currentRating uint32, consecutiveMisses uint32) uint32
	// RevertIncreaseValidator computes the new rating if a revert for increaseProposer should be done
	RevertIncreaseValidator(shardId uint32, currentRating uint32, nrReverts uint32) uint32
	// ComputeIncreaseValidator computes the new rating for the increaseValidator
	ComputeIncreaseValidator(shardId uint32, currentRating uint32) uint32
	// ComputeDecreaseValidator computes the new rating for the decreaseValidator
	ComputeDecreaseValidator(shardId uint32, currentRating uint32) uint32
	// IsInterfaceNil verifies if the interface is nil
	IsInterfaceNil() bool
}

PeerAccountListAndRatingHandler provides Rating Computation Capabilites for the Nodes Coordinator and ValidatorStatistics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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