consensuscontext

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 19 Imported by: 0

README

Consensus Context

This file explains non-trivial implementation details in the Consensus Context.

Committees

A committee is a subset of validator nodes, with size between some minimum (currently set at 4) and all of validator nodes. The committee nodes' purpose is to participate in a consensus round, that is to reach consensus for a specific block height.

After consensus is reached, a new committee is chosen.

Committee Selection

See RequestValidationCommittee in committee.go

Algorithm

A weighted random sort over the nodes is used for deciding which nodes become committee members. The random part is achieved by hashing the concatenation of the random seed and the node's public key. The weighted part is achieved by multiplying the node's resulting hash by its reputation, thus increasing its chance of inclusion in a committee. Note that at present, reputation is set to 1, so in effect it is not used by the calculation.

The actual committee is the committeeSize nodes with the highest weighted_grade. The descending weighted_grade ordering is important - the first node is the initial leader of this consensus round.

for each node
   hash = sha256(concat(random_seed, node.public_key))
   low_4_bytes_hash := hash[:4]
   weighted_grade := to_uint32(low_4_bytes_hash) * reputation

sort_nodes := sort(nodes, by descending weighted_grade)
committee = first [committeeSize] sort_nodes

Documentation

Index

Constants

View Source
const CALL_ELECTIONS_CONTRACT_INTERVAL = 200 * time.Millisecond

Variables

View Source
var ErrFailedTransactionOrdering = errors.New("ErrFailedTransactionOrdering")
View Source
var ErrGetStateHash = errors.New("ErrGetStateHash failed in GetStateHash() so cannot retrieve pre-execution state diff merkleRoot from previous block")
View Source
var ErrInvalidBlockTimestamp = errors.New("ErrInvalidBlockTimestamp")
View Source
var ErrMismatchedBlockHeight = errors.New("ErrMismatchedBlockHeight")
View Source
var ErrMismatchedPreExecutionStateMerkleRoot = errors.New("ErrMismatchedPreExecutionStateMerkleRoot pre-execution state diff merkleRoot is different between results block header and extracted from state storage for previous block")
View Source
var ErrMismatchedPrevBlockHash = errors.New("ErrMismatchedPrevBlockHash")
View Source
var ErrMismatchedProtocolVersion = errors.New("ErrMismatchedProtocolVersion")
View Source
var ErrMismatchedTxHashPtrToActualTxBlock = errors.New("ErrMismatchedTxHashPtrToActualTxBlock mismatched tx block hash ptr to actual tx block hash")
View Source
var ErrMismatchedTxRxBlockHeight = errors.New("ErrMismatchedTxRxBlockHeight mismatched block height between transactions and results")
View Source
var ErrMismatchedTxRxTimestamps = errors.New("ErrMismatchedTxRxTimestamps mismatched timestamp between transactions and results")
View Source
var ErrMismatchedVirtualChainID = errors.New("ErrMismatchedVirtualChainID")
View Source
var ErrProcessTransactionSet = errors.New("ErrProcessTransactionSet failed in ProcessTransactionSet()")
View Source
var LogTag = log.Service("consensus-context")

Functions

func NewConsensusContext

func NewConsensusContext(
	transactionPool services.TransactionPool,
	virtualMachine services.VirtualMachine,
	stateStorage services.StateStorage,
	config config.ConsensusContextConfig,
	logger log.BasicLogger,
	metricFactory metric.Factory,
) services.ConsensusContext

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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