validator

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

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 Klaytn

Klaytn implements `Validator` and `ValidatorSet` interface for Klaytn consensus. Klaytn 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.klaytn.com/klaytn/token_economy#klaytn-governance-council-reward. 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractValidators

func ExtractValidators(extraData []byte) []common.Address

func GetWeightedCouncilData

func GetWeightedCouncilData(valSet istanbul.ValidatorSet) (validators []common.Address, rewardAddrs []common.Address, votingPowers []uint64, weights []uint64, proposers []common.Address, proposersBlockNum uint64)

func New

func New(addr common.Address) istanbul.Validator

func NewSet

func NewSubSet

func NewSubSet(addrs []common.Address, policy istanbul.ProposerPolicy, subSize uint64) istanbul.ValidatorSet

func NewValidatorSet

func NewValidatorSet(addrs []common.Address, proposerPolicy istanbul.ProposerPolicy, subGroupSize uint64, chain consensus.ChainReader) istanbul.ValidatorSet

func NewWeightedCouncil

func NewWeightedCouncil(addrs []common.Address, rewards []common.Address, votingPowers []uint64, weights []uint64, policy istanbul.ProposerPolicy, committeeSize uint64, blockNum uint64, proposersBlockNum uint64, chain consensus.ChainReader) *weightedCouncil

func RecoverWeightedCouncilProposer

func RecoverWeightedCouncilProposer(valSet istanbul.ValidatorSet, proposerAddrs []common.Address)

Types

This section is empty.

Jump to

Keyboard shortcuts

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