Documentation ¶
Overview ¶
Package validator implements the types related to the validators participating in consensus.
`Validator` and `ValidatorSet` interfaces are used to validate blocks and make a consensus. Implementations of these interfaces are different, depending on proposer-choosing policy.
Validator ¶
`Validator` is a node which has 2 features to make a consensus: proposing and validating.
Propose: A node can propose a block if it is a proposer. Only validators can be a proposer.
Validate: A validator node can validate blocks from proposers. A block is valid only if more than 2/3 of validators approve the given block.
ValidatorSet ¶
`ValidatorSet` is a group of validators. It is also called as a council. ValidatorSet calculates the block proposer of an upcoming block. A validator selected as a block proposer will have a chance to make a block.
Implementation in Kaia ¶
Kaia implements `Validator` and `ValidatorSet` interface for Kaia consensus. Kaia reflects the ratio of staking amounts to the probability of selecting a proposer. This is called weightedRandom policy. Detailed information can be found in https://docs.kaia.io/docs/learn/token-economy/#kaia-governance-council-reward-mechanism-. Implementation structures are weightedValidator and weightedCouncil in weighted.go file.
Files ¶
- default.go : Validator and ValidatorSet for roundRobin policy is implemented.
- weighted.go : Validator and ValidatorSet for weightedRandom policy is implemented.
- validator.go : common functions for Validator and ValidatorSet are implemented.
Index ¶
- func ConvertHashToSeed(hash common.Hash) (int64, error)
- func ExtractValidators(extraData []byte) []common.Address
- func GetWeightedCouncilData(valSet istanbul.ValidatorSet) (validators []common.Address, demotedValidators []common.Address, ...)
- func New(addr common.Address) istanbul.Validator
- func NewSet(addrs []common.Address, policy istanbul.ProposerPolicy) istanbul.ValidatorSet
- func NewSubSet(addrs []common.Address, policy istanbul.ProposerPolicy, subSize uint64) istanbul.ValidatorSet
- func NewValidatorSet(addrs, demotedAddrs []common.Address, proposerPolicy istanbul.ProposerPolicy, ...) istanbul.ValidatorSet
- func NewWeightedCouncil(addrs []common.Address, demotedAddrs []common.Address, ...) *weightedCouncil
- func RecoverWeightedCouncilProposer(valSet istanbul.ValidatorSet, proposerAddrs []common.Address)
- func SelectRandaoCommittee(validators []istanbul.Validator, committeeSize uint64, mixHash []byte) []istanbul.Validator
- func SelectRandomCommittee(validators []istanbul.Validator, committeeSize uint64, seed int64, ...) []istanbul.Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertHashToSeed ¶
ConvertHashToSeed returns a random seed used to calculate proposer. It converts first 7.5 bytes of the given hash to int64.
func ExtractValidators ¶
func GetWeightedCouncilData ¶
func NewSet ¶
func NewSet(addrs []common.Address, policy istanbul.ProposerPolicy) istanbul.ValidatorSet
func NewSubSet ¶
func NewSubSet(addrs []common.Address, policy istanbul.ProposerPolicy, subSize uint64) istanbul.ValidatorSet
func NewValidatorSet ¶
func NewValidatorSet(addrs, demotedAddrs []common.Address, proposerPolicy istanbul.ProposerPolicy, subGroupSize uint64, chain consensus.ChainReader) istanbul.ValidatorSet
func NewWeightedCouncil ¶
func RecoverWeightedCouncilProposer ¶
func RecoverWeightedCouncilProposer(valSet istanbul.ValidatorSet, proposerAddrs []common.Address)
func SelectRandaoCommittee ¶
func SelectRandaoCommittee(validators []istanbul.Validator, committeeSize uint64, mixHash []byte) []istanbul.Validator
SelectRandaoCommittee composes a committee selecting validators randomly based on the mixHash. It returns nil if the given committeeSize is bigger than validatorSize.
func SelectRandomCommittee ¶
func SelectRandomCommittee(validators []istanbul.Validator, committeeSize uint64, seed int64, proposerIdx int, nextProposerIdx int) []istanbul.Validator
SelectRandomCommittee composes a committee selecting validators randomly based on the seed value. It returns nil if the given committeeSize is bigger than validatorSize or proposer indexes are invalid.
Types ¶
This section is empty.