spos

package
v1.10.6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const LeaderPeerHonestyDecreaseFactor = -4

LeaderPeerHonestyDecreaseFactor specifies the factor with which the honesty of the leader should be decreased if it proposed a block or sent the final info, in an incorrect allocated slot/time-frame/round

View Source
const LeaderPeerHonestyIncreaseFactor = 2

LeaderPeerHonestyIncreaseFactor specifies the factor with which the honesty of the leader should be increased if it proposed a block or sent the final info, in its correct allocated slot/time-frame/round

View Source
const MaxThresholdPercent = 95

MaxThresholdPercent specifies the max allocated time percent for doing Job as a percentage of the total time of one round

View Source
const ValidatorPeerHonestyDecreaseFactor = -2

ValidatorPeerHonestyDecreaseFactor specifies the factor with which the honesty of the validator should be decreased if it sent the signature, in an incorrect allocated slot/time-frame/round

View Source
const ValidatorPeerHonestyIncreaseFactor = 1

ValidatorPeerHonestyIncreaseFactor specifies the factor with which the honesty of the validator should be increased if it sent the signature, in its correct allocated slot/time-frame/round

Variables

View Source
var ErrBlacklistedConsensusPeer = errors.New("blacklisted consensus peer")

ErrBlacklistedConsensusPeer signals that a consensus message has been received from a blacklisted peer

View Source
var ErrConsensusMessageNotExpected = errors.New("consensus message not expected")

ErrConsensusMessageNotExpected signals that a consensus message was not expected

View Source
var ErrEmptyConsensusGroup = errors.New("consensusGroup is empty")

ErrEmptyConsensusGroup is raised when an operation is attempted with an empty consensus group

View Source
var ErrEquivalentMessageAlreadyReceived = errors.New("equivalent message already received")

ErrEquivalentMessageAlreadyReceived signals that an equivalent message has been already received

View Source
var ErrHeaderProofNotExpected = errors.New("header proof not expected")

ErrHeaderProofNotExpected signals that a header proof was not expected

View Source
var ErrInvalidBodySize = errors.New("invalid body size")

ErrInvalidBodySize signals that an invalid body size has been received from consensus topic

View Source
var ErrInvalidCacheSize = errors.New("invalid cache size")

ErrInvalidCacheSize signals an invalid size provided for cache

View Source
var ErrInvalidChainID = errors.New("invalid chain ID in consensus")

ErrInvalidChainID signals that an invalid chain ID has been provided

View Source
var ErrInvalidHeader = errors.New("header is invalid")

ErrInvalidHeader is raised when header is invalid

View Source
var ErrInvalidHeaderHashSize = errors.New("invalid header hash size")

ErrInvalidHeaderHashSize signals that an invalid header hash size has been received from consensus topic

View Source
var ErrInvalidHeaderSize = errors.New("invalid header size")

ErrInvalidHeaderSize signals that an invalid header size has been received from consensus topic

View Source
var ErrInvalidKey = errors.New("map key is invalid")

ErrInvalidKey is raised when an invalid key is used with a map

View Source
var ErrInvalidMessage = errors.New("invalid message")

ErrInvalidMessage signals that an invalid message has been received from consensus topic

View Source
var ErrInvalidMessageType = errors.New("invalid message type")

ErrInvalidMessageType signals that an invalid message type has been received from consensus topic

View Source
var ErrInvalidMetaHeader = errors.New("meta header is invalid")

ErrInvalidMetaHeader is raised when an invalid meta header was provided

View Source
var ErrInvalidNumSigShares = errors.New("invalid number of sig shares")

ErrInvalidNumSigShares signals that an invalid number of signature shares has been provided

View Source
var ErrInvalidPublicKeyBitmapSize = errors.New("invalid public key bitmap size")

ErrInvalidPublicKeyBitmapSize signals that an invalid public key bitmap size has been received from consensus topic

View Source
var ErrInvalidPublicKeySize = errors.New("invalid public key size")

ErrInvalidPublicKeySize signals that an invalid public key size has been received from consensus topic

View Source
var ErrInvalidSignature = errors.New("signature is invalid")

ErrInvalidSignature is raised when signature is invalid

View Source
var ErrInvalidSignatureSize = errors.New("invalid signature size")

ErrInvalidSignatureSize signals that an invalid signature size has been received from consensus topic

View Source
var ErrInvalidSignersAlreadyReceived = errors.New("invalid signers already received")

ErrInvalidSignersAlreadyReceived signals that an invalid signers message has been already received

View Source
var ErrMessageForFutureRound = errors.New("message is for future round")

ErrMessageForFutureRound is raised when message is for future round

View Source
var ErrMessageForPastRound = errors.New("message is for past round")

ErrMessageForPastRound is raised when message is for past round

View Source
var ErrMessageFromItself = errors.New("message is from itself")

ErrMessageFromItself is raised when a message from itself is received

View Source
var ErrMessageTypeLimitReached = errors.New("consensus message type limit has been reached")

ErrMessageTypeLimitReached signals that a consensus message type limit has been reached for a public key

View Source
var ErrNilAlarmScheduler = errors.New("alarm scheduler is nil")

ErrNilAlarmScheduler is raised when a valid alarm scheduler is expected but nil is provided

View Source
var ErrNilAntifloodHandler = errors.New("nil antiflood handler")

ErrNilAntifloodHandler signals that a nil antiflood handler has been provided

View Source
var ErrNilAppStatusHandler = errors.New("nil AppStatusHandler")

ErrNilAppStatusHandler defines the error for setting a nil AppStatusHandler

View Source
var ErrNilBlockChain = errors.New("blockchain is nil")

ErrNilBlockChain is raised when a valid blockchain is expected but nil used

View Source
var ErrNilBlockProcessor = errors.New("block processor is nil")

ErrNilBlockProcessor is raised when a valid block processor is expected but nil used

View Source
var ErrNilBody = errors.New("body is nil")

ErrNilBody is raised when an expected body is nil

View Source
var ErrNilBootstrapper = errors.New("bootstrapper is nil")

ErrNilBootstrapper is raised when a valid block processor is expected but nil used

View Source
var ErrNilBroadcastMessenger = errors.New("broadcast messenger is nil")

ErrNilBroadcastMessenger is raised when a valid broadcast messenger is expected but nil used

View Source
var ErrNilChannel = errors.New("channel is nil")

ErrNilChannel is raised when a valid channel is expected but nil used

View Source
var ErrNilChronologyHandler = errors.New("chronology handler is nil")

ErrNilChronologyHandler is raised when a valid chronology handler is expected but nil used

View Source
var ErrNilConsensusCore = errors.New("consensus core is nil")

ErrNilConsensusCore is raised when a valid ConsensusCore is expected but nil used

View Source
var ErrNilConsensusGroup = errors.New("consensusGroup is null")

ErrNilConsensusGroup is raised when an operation is attempted with a nil consensus group

View Source
var ErrNilConsensusService = errors.New("consensus service is nil")

ErrNilConsensusService is raised when a valid ConsensusService is expected but nil used

View Source
var ErrNilConsensusState = errors.New("consensus state is nil")

ErrNilConsensusState is raised when a valid consensus is expected but nil used

View Source
var ErrNilDataToProcess = errors.New("nil data to process")

ErrNilDataToProcess signals that nil data was provided

View Source
var ErrNilEnableEpochsHandler = errors.New("nil enable epochs handler")

ErrNilEnableEpochsHandler signals that a nil enable epochs handler has been provided

View Source
var ErrNilEpochNotifier = errors.New("nil epoch notifier")

ErrNilEpochNotifier signals that a nil epoch notifier has been provided

View Source
var ErrNilEpochStartNotifier = errors.New("nil epoch start notifier")

ErrNilEpochStartNotifier signals that nil epoch start notifier has been provided

View Source
var ErrNilEquivalentProofPool = errors.New("nil equivalent proof pool")

ErrNilEquivalentProofPool signals that a nil proof pool has been provided

View Source
var ErrNilExecuteStoredMessages = errors.New("executeStoredMessages is nil")

ErrNilExecuteStoredMessages is raised when a valid executeStoredMessages function is expected but nil used

View Source
var ErrNilFallbackHeaderValidator = errors.New("nil fallback header validator")

ErrNilFallbackHeaderValidator signals that a nil fallback header validator has been provided

View Source
var ErrNilForkDetector = errors.New("fork detector is nil")

ErrNilForkDetector is raised when a valid fork detector is expected but nil used

View Source
var ErrNilFunctionHandler = errors.New("nil function handler")

ErrNilFunctionHandler signals that a nil function handler was provided

View Source
var ErrNilHasher = errors.New("hasher is nil")

ErrNilHasher is raised when a valid hasher is expected but nil used

View Source
var ErrNilHeader = errors.New("header is nil")

ErrNilHeader is raised when an expected header is nil

View Source
var ErrNilHeaderHash = errors.New("header hash is nil")

ErrNilHeaderHash is raised when a nil header hash is provided

View Source
var ErrNilHeaderIntegrityVerifier = errors.New("nil header integrity verifier")

ErrNilHeaderIntegrityVerifier signals that a nil header integrity verifier has been provided

View Source
var ErrNilHeaderProof = errors.New("nil header proof")

ErrNilHeaderProof signals that a nil header proof has been provided

View Source
var ErrNilHeaderSigVerifier = errors.New("nil header sig verifier")

ErrNilHeaderSigVerifier signals that a nil header sig verifier has been provided

View Source
var ErrNilHeadersSubscriber = errors.New("headers subscriber is nil")

ErrNilHeadersSubscriber is raised when a valid headers subscriber is expected but nil is provided

View Source
var ErrNilInterceptorsContainer = errors.New("interceptor container is nil")

ErrNilInterceptorsContainer is raised when a nil interceptor container is provided

View Source
var ErrNilInvalidSignersCache = errors.New("nil invalid signers cache")

ErrNilInvalidSignersCache signals that nil invalid signers has been provided

View Source
var ErrNilKeysHandler = errors.New("nil keys handler")

ErrNilKeysHandler signals that a nil keys handler was provided

View Source
var ErrNilMarshalizer = errors.New("marshalizer is nil")

ErrNilMarshalizer is raised when a valid marshalizer is expected but nil used

View Source
var ErrNilMessage = errors.New("nil message")

ErrNilMessage signals that a nil message has been received

View Source
var ErrNilMessageSigningHandler = errors.New("nil message signing handler")

ErrNilMessageSigningHandler signals that the provided message signing handler is nil

View Source
var ErrNilMessenger = errors.New("messenger is nil")

ErrNilMessenger is raised when a valid messenger is expected but nil used

View Source
var ErrNilMetaHeader = errors.New("meta header is nil")

ErrNilMetaHeader is raised when an expected meta header is nil

View Source
var ErrNilMultiSigner = errors.New("multiSigner is nil")

ErrNilMultiSigner is raised when a valid multiSigner is expected but nil used

View Source
var ErrNilMultiSignerContainer = errors.New("multiSigner container is nil")

ErrNilMultiSignerContainer is raised when a valid multiSigner container is expected, but nil used

View Source
var ErrNilNetworkShardingCollector = errors.New("nil network sharding collector")

ErrNilNetworkShardingCollector defines the error for setting a nil network sharding collector

View Source
var ErrNilNodeRedundancyHandler = errors.New("nil node redundancy handler")

ErrNilNodeRedundancyHandler signals that provided node redundancy handler is nil

View Source
var ErrNilNodesCoordinator = errors.New("validator group selector is nil")

ErrNilNodesCoordinator is raised when a valid validator group selector is expected but nil used

View Source
var ErrNilParameter = errors.New("parameter is nil")

ErrNilParameter is raised when a nil parameter is provided

View Source
var ErrNilPeerBlacklistCacher = errors.New("nil peer blacklist cacher")

ErrNilPeerBlacklistCacher signals that a nil peer blacklist cacher has been provided

View Source
var ErrNilPeerBlacklistHandler = errors.New("nil peer blacklist handler")

ErrNilPeerBlacklistHandler signals that the provided peer blacklist handler is nil

View Source
var ErrNilPeerHonestyHandler = errors.New("nil peer honesty handler")

ErrNilPeerHonestyHandler signals that a nil peer honesty handler has been provided

View Source
var ErrNilPeerSignatureHandler = errors.New("trying to set nil peerSignatureHandler")

ErrNilPeerSignatureHandler signals that a nil peerSignatureHandler object has been provided

View Source
var ErrNilPoolAdder = errors.New("nil pool adder")

ErrNilPoolAdder signals that a nil pool adder has been provided

View Source
var ErrNilRoundHandler = errors.New("roundHandler is nil")

ErrNilRoundHandler is raised when a valid roundHandler is expected but nil used

View Source
var ErrNilRoundState = errors.New("round state is nil")

ErrNilRoundState is raised when a valid round state is expected but nil used

View Source
var ErrNilScheduledProcessor = errors.New("nil scheduled processor")

ErrNilScheduledProcessor signals that the provided scheduled processor is nil

View Source
var ErrNilSentSignatureTracker = errors.New("nil sent signature tracker")

ErrNilSentSignatureTracker defines the error for setting a nil SentSignatureTracker

View Source
var ErrNilShardCoordinator = errors.New("shard coordinator is nil")

ErrNilShardCoordinator is raised when a valid shard coordinator is expected but nil used

View Source
var ErrNilSignature = errors.New("signature is nil")

ErrNilSignature is raised when a valid signature was expected but nil was used

View Source
var ErrNilSignatureOnP2PMessage = errors.New("nil signature on the p2p message")

ErrNilSignatureOnP2PMessage signals that a p2p message without signature was received

View Source
var ErrNilSigningHandler = errors.New("nil signing handler")

ErrNilSigningHandler signals that provided signing handler is nil

View Source
var ErrNilSubround = errors.New("subround is nil")

ErrNilSubround is raised when a valid subround is expected but nil used

View Source
var ErrNilSyncTimer = errors.New("sync timer is nil")

ErrNilSyncTimer is raised when a valid sync timer is expected but nil used

View Source
var ErrNilThrottler = errors.New("nil throttler")

ErrNilThrottler signals that a nil throttler has been provided

View Source
var ErrNilWorker = errors.New("worker is nil")

ErrNilWorker is raised when a valid Worker is expected but nil used

View Source
var ErrNilWorkerArgs = errors.New("worker args is nil")

ErrNilWorkerArgs signals that nil a workerArgs has been provided

View Source
var ErrNodeIsNotInEligibleList = errors.New("node is not in eligible list")

ErrNodeIsNotInEligibleList is raised when a node is not in eligible list

View Source
var ErrNotFoundInConsensus = errors.New("self not found in consensus group")

ErrNotFoundInConsensus is raised when self expected in consensus group but not found

View Source
var ErrOriginatorMismatch = errors.New("consensus message originator mismatch")

ErrOriginatorMismatch signals that an original consensus message has been re-broadcast manually by another peer

View Source
var ErrRoundCanceled = errors.New("round is canceled")

ErrRoundCanceled is raised when round is canceled

View Source
var ErrTimeIsOut = errors.New("time is out")

ErrTimeIsOut signals that time is out

View Source
var ErrWrongHashForHeader = errors.New("wrong hash for header")

ErrWrongHashForHeader signals that the hash of the header is not the expected one

Functions

func GetConsensusTopicID

func GetConsensusTopicID(shardCoordinator sharding.Coordinator) string

GetConsensusTopicID will construct and return the topic ID based on shard coordinator

func NewConsensusMessageValidator

func NewConsensusMessageValidator(args ArgsConsensusMessageValidator) (*consensusMessageValidator, error)

NewConsensusMessageValidator creates a new consensusMessageValidator object

func NewInvalidSignersCache added in v1.9.0

func NewInvalidSignersCache(args ArgInvalidSignersCache) (*invalidSignersCache, error)

NewInvalidSignersCache returns a new instance of invalidSignersCache

func NewRoundConsensus

func NewRoundConsensus(
	eligibleNodes map[string]struct{},
	consensusGroupSize int,
	selfId string,
	keysHandler consensus.KeysHandler,
) (*roundConsensus, error)

NewRoundConsensus creates a new roundConsensus object

func NewRoundState

func NewRoundState() *roundState

NewRoundState creates a new roundState object

func NewRoundStatus

func NewRoundStatus() *roundStatus

NewRoundStatus creates a new roundStatus object

func NewRoundThreshold

func NewRoundThreshold() *roundThreshold

NewRoundThreshold creates a new roundThreshold object

func NewScheduledProcessorWrapper

func NewScheduledProcessorWrapper(args ScheduledProcessorWrapperArgs) (*scheduledProcessorWrapper, error)

NewScheduledProcessorWrapper creates a new processor for scheduled transactions

func ValidateConsensusCore

func ValidateConsensusCore(container ConsensusCoreHandler) error

ValidateConsensusCore checks for nil all the container objects

Types

type ArgInvalidSignersCache added in v1.9.0

type ArgInvalidSignersCache struct {
	Hasher         hashing.Hasher
	SigningHandler p2p.P2PSigningHandler
	Marshaller     marshal.Marshalizer
}

ArgInvalidSignersCache defines the DTO used to create a new instance of invalidSignersCache

type ArgsConsensusMessageValidator

type ArgsConsensusMessageValidator struct {
	ConsensusState       *ConsensusState
	ConsensusService     ConsensusService
	PeerSignatureHandler crypto.PeerSignatureHandler
	EnableEpochsHandler  common.EnableEpochsHandler
	Marshaller           marshal.Marshalizer
	ShardCoordinator     sharding.Coordinator
	SignatureSize        int
	PublicKeySize        int
	HeaderHashSize       int
	ChainID              []byte
}

ArgsConsensusMessageValidator holds the consensus message validator arguments

type ConsensusCore

type ConsensusCore struct {
	// contains filtered or unexported fields
}

ConsensusCore implements ConsensusCoreHandler and provides access to common functionality for the rest of the consensus structures

func NewConsensusCore

func NewConsensusCore(
	args *ConsensusCoreArgs,
) (*ConsensusCore, error)

NewConsensusCore creates a new ConsensusCore instance

func (*ConsensusCore) BlockProcessor

func (cc *ConsensusCore) BlockProcessor() process.BlockProcessor

BlockProcessor gets the BlockProcessor stored in the ConsensusCore

func (*ConsensusCore) Blockchain

func (cc *ConsensusCore) Blockchain() data.ChainHandler

Blockchain gets the ChainHandler stored in the ConsensusCore

func (*ConsensusCore) BootStrapper

func (cc *ConsensusCore) BootStrapper() process.Bootstrapper

BootStrapper gets the Bootstrapper stored in the ConsensusCore

func (*ConsensusCore) BroadcastMessenger

func (cc *ConsensusCore) BroadcastMessenger() consensus.BroadcastMessenger

BroadcastMessenger gets the BroadcastMessenger stored in the ConsensusCore

func (*ConsensusCore) Chronology

func (cc *ConsensusCore) Chronology() consensus.ChronologyHandler

Chronology gets the ChronologyHandler stored in the ConsensusCore

func (*ConsensusCore) EnableEpochsHandler added in v1.9.0

func (cc *ConsensusCore) EnableEpochsHandler() common.EnableEpochsHandler

EnableEpochsHandler returns the enable epochs handler component

func (*ConsensusCore) EpochNotifier added in v1.9.0

func (cc *ConsensusCore) EpochNotifier() process.EpochNotifier

EpochNotifier returns the epoch notifier

func (*ConsensusCore) EpochStartRegistrationHandler

func (cc *ConsensusCore) EpochStartRegistrationHandler() epochStart.RegistrationHandler

EpochStartRegistrationHandler returns the epoch start registration handler

func (*ConsensusCore) EquivalentProofsPool added in v1.9.0

func (cc *ConsensusCore) EquivalentProofsPool() consensus.EquivalentProofsPool

EquivalentProofsPool returns the equivalent proofs component

func (*ConsensusCore) FallbackHeaderValidator

func (cc *ConsensusCore) FallbackHeaderValidator() consensus.FallbackHeaderValidator

FallbackHeaderValidator will return the fallback header validator which will be used in subrounds

func (*ConsensusCore) GetAntiFloodHandler

func (cc *ConsensusCore) GetAntiFloodHandler() consensus.P2PAntifloodHandler

GetAntiFloodHandler will return the antiflood handler which will be used in subrounds

func (*ConsensusCore) Hasher

func (cc *ConsensusCore) Hasher() hashing.Hasher

Hasher gets the Hasher stored in the ConsensusCore

func (*ConsensusCore) HeaderSigVerifier

func (cc *ConsensusCore) HeaderSigVerifier() consensus.HeaderSigVerifier

HeaderSigVerifier returns the sig verifier handler which will be used in subrounds

func (*ConsensusCore) InvalidSignersCache added in v1.9.0

func (cc *ConsensusCore) InvalidSignersCache() InvalidSignersCache

InvalidSignersCache returns the invalid signers cache component

func (*ConsensusCore) IsInterfaceNil

func (cc *ConsensusCore) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ConsensusCore) Marshalizer

func (cc *ConsensusCore) Marshalizer() marshal.Marshalizer

Marshalizer gets the Marshalizer stored in the ConsensusCore

func (*ConsensusCore) MessageSigningHandler added in v1.6.0

func (cc *ConsensusCore) MessageSigningHandler() consensus.P2PSigningHandler

MessageSigningHandler will return the message signing handler

func (*ConsensusCore) MultiSignerContainer

func (cc *ConsensusCore) MultiSignerContainer() cryptoCommon.MultiSignerContainer

MultiSignerContainer gets the MultiSignerContainer stored in the ConsensusCore

func (*ConsensusCore) NodeRedundancyHandler

func (cc *ConsensusCore) NodeRedundancyHandler() consensus.NodeRedundancyHandler

NodeRedundancyHandler will return the node redundancy handler which will be used in subrounds

func (*ConsensusCore) NodesCoordinator

func (cc *ConsensusCore) NodesCoordinator() nodesCoordinator.NodesCoordinator

NodesCoordinator gets the NodesCoordinator stored in the ConsensusCore

func (*ConsensusCore) PeerBlacklistHandler added in v1.6.0

func (cc *ConsensusCore) PeerBlacklistHandler() consensus.PeerBlacklistHandler

PeerBlacklistHandler will return the peer blacklist handler

func (*ConsensusCore) PeerHonestyHandler

func (cc *ConsensusCore) PeerHonestyHandler() consensus.PeerHonestyHandler

PeerHonestyHandler will return the peer honesty handler which will be used in subrounds

func (*ConsensusCore) RoundHandler

func (cc *ConsensusCore) RoundHandler() consensus.RoundHandler

RoundHandler gets the RoundHandler stored in the ConsensusCore

func (*ConsensusCore) ScheduledProcessor

func (cc *ConsensusCore) ScheduledProcessor() consensus.ScheduledProcessor

ScheduledProcessor will return the scheduled processor

func (*ConsensusCore) SetAntifloodHandler added in v1.9.0

func (cc *ConsensusCore) SetAntifloodHandler(antifloodHandler consensus.P2PAntifloodHandler)

SetAntifloodHandler sets antiflood handler

func (*ConsensusCore) SetBlockProcessor added in v1.9.0

func (cc *ConsensusCore) SetBlockProcessor(blockProcessor process.BlockProcessor)

SetBlockProcessor sets block processor

func (*ConsensusCore) SetBlockchain added in v1.9.0

func (cc *ConsensusCore) SetBlockchain(blockChain data.ChainHandler)

SetBlockchain sets blockchain handler

func (*ConsensusCore) SetBootStrapper added in v1.9.0

func (cc *ConsensusCore) SetBootStrapper(bootstrapper process.Bootstrapper)

SetBootStrapper sets process bootstrapper

func (*ConsensusCore) SetBroadcastMessenger added in v1.9.0

func (cc *ConsensusCore) SetBroadcastMessenger(broadcastMessenger consensus.BroadcastMessenger)

SetBroadcastMessenger sets broadcast messenger

func (*ConsensusCore) SetChronology added in v1.9.0

func (cc *ConsensusCore) SetChronology(chronologyHandler consensus.ChronologyHandler)

SetChronology sets chronology

func (*ConsensusCore) SetEnableEpochsHandler added in v1.9.0

func (cc *ConsensusCore) SetEnableEpochsHandler(enableEpochsHandler common.EnableEpochsHandler)

SetEnableEpochsHandler sets enable eopchs handler

func (*ConsensusCore) SetEpochNotifier added in v1.9.0

func (cc *ConsensusCore) SetEpochNotifier(epochNotifier process.EpochNotifier)

SetEpochNotifier sets epoch notifier

func (*ConsensusCore) SetEpochStartNotifier added in v1.9.0

func (cc *ConsensusCore) SetEpochStartNotifier(epochStartNotifier epochStart.RegistrationHandler)

SetEpochStartNotifier sets epoch start notifier

func (*ConsensusCore) SetEquivalentProofsPool added in v1.9.0

func (cc *ConsensusCore) SetEquivalentProofsPool(proofPool consensus.EquivalentProofsPool)

SetEquivalentProofsPool sets equivalent proofs pool

func (*ConsensusCore) SetFallbackHeaderValidator added in v1.9.0

func (cc *ConsensusCore) SetFallbackHeaderValidator(fallbackHeaderValidator consensus.FallbackHeaderValidator)

SetFallbackHeaderValidator sets fallback header validaor

func (*ConsensusCore) SetHasher added in v1.9.0

func (cc *ConsensusCore) SetHasher(hasher hashing.Hasher)

SetHasher sets hasher component

func (*ConsensusCore) SetHeaderSigVerifier added in v1.9.0

func (cc *ConsensusCore) SetHeaderSigVerifier(headerSigVerifier consensus.HeaderSigVerifier)

SetHeaderSigVerifier sets header sig verifier

func (*ConsensusCore) SetInvalidSignersCache added in v1.9.0

func (cc *ConsensusCore) SetInvalidSignersCache(cache InvalidSignersCache)

SetInvalidSignersCache sets the invalid signers cache

func (*ConsensusCore) SetMarshalizer added in v1.9.0

func (cc *ConsensusCore) SetMarshalizer(marshalizer marshal.Marshalizer)

SetMarshalizer sets marshaller component

func (*ConsensusCore) SetMessageSigningHandler added in v1.9.0

func (cc *ConsensusCore) SetMessageSigningHandler(messageSigningHandler consensus.P2PSigningHandler)

SetMessageSigningHandler sets message signing handler

func (*ConsensusCore) SetMultiSignerContainer added in v1.9.0

func (cc *ConsensusCore) SetMultiSignerContainer(multiSignerContainer cryptoCommon.MultiSignerContainer)

SetMultiSignerContainer sets multi signer container

func (*ConsensusCore) SetNodeRedundancyHandler added in v1.9.0

func (cc *ConsensusCore) SetNodeRedundancyHandler(nodeRedundancyHandler consensus.NodeRedundancyHandler)

SetNodeRedundancyHandler set nodes redundancy handler

func (*ConsensusCore) SetNodesCoordinator added in v1.9.0

func (cc *ConsensusCore) SetNodesCoordinator(nodesCoordinator nodesCoordinator.NodesCoordinator)

SetNodesCoordinator sets nodes coordinaotr

func (*ConsensusCore) SetPeerBlacklistHandler added in v1.9.0

func (cc *ConsensusCore) SetPeerBlacklistHandler(peerBlacklistHandler consensus.PeerBlacklistHandler)

SetPeerBlacklistHandler sets peer blacklist handlerc

func (*ConsensusCore) SetPeerHonestyHandler added in v1.9.0

func (cc *ConsensusCore) SetPeerHonestyHandler(peerHonestyHandler consensus.PeerHonestyHandler)

SetPeerHonestyHandler sets peer honesty handler

func (*ConsensusCore) SetRoundHandler added in v1.9.0

func (cc *ConsensusCore) SetRoundHandler(roundHandler consensus.RoundHandler)

SetRoundHandler sets round handler

func (*ConsensusCore) SetScheduledProcessor added in v1.9.0

func (cc *ConsensusCore) SetScheduledProcessor(scheduledProcessor consensus.ScheduledProcessor)

SetScheduledProcessor set scheduled processor

func (*ConsensusCore) SetShardCoordinator added in v1.9.0

func (cc *ConsensusCore) SetShardCoordinator(shardCoordinator sharding.Coordinator)

SetShardCoordinator set shard coordinator

func (*ConsensusCore) SetSigningHandler added in v1.9.0

func (cc *ConsensusCore) SetSigningHandler(signingHandler consensus.SigningHandler)

SetSigningHandler sets signing handler

func (*ConsensusCore) SetSyncTimer added in v1.9.0

func (cc *ConsensusCore) SetSyncTimer(syncTimer ntp.SyncTimer)

SetSyncTimer sets sync timer

func (*ConsensusCore) ShardCoordinator

func (cc *ConsensusCore) ShardCoordinator() sharding.Coordinator

ShardCoordinator gets the ShardCoordinator stored in the ConsensusCore

func (*ConsensusCore) SigningHandler added in v1.6.0

func (cc *ConsensusCore) SigningHandler() consensus.SigningHandler

SigningHandler will return the signing handler component

func (*ConsensusCore) SyncTimer

func (cc *ConsensusCore) SyncTimer() ntp.SyncTimer

SyncTimer gets the SyncTimer stored in the ConsensusCore

type ConsensusCoreArgs

type ConsensusCoreArgs struct {
	BlockChain                    data.ChainHandler
	BlockProcessor                process.BlockProcessor
	Bootstrapper                  process.Bootstrapper
	BroadcastMessenger            consensus.BroadcastMessenger
	ChronologyHandler             consensus.ChronologyHandler
	Hasher                        hashing.Hasher
	Marshalizer                   marshal.Marshalizer
	MultiSignerContainer          cryptoCommon.MultiSignerContainer
	RoundHandler                  consensus.RoundHandler
	ShardCoordinator              sharding.Coordinator
	NodesCoordinator              nodesCoordinator.NodesCoordinator
	SyncTimer                     ntp.SyncTimer
	EpochStartRegistrationHandler epochStart.RegistrationHandler
	AntifloodHandler              consensus.P2PAntifloodHandler
	PeerHonestyHandler            consensus.PeerHonestyHandler
	HeaderSigVerifier             consensus.HeaderSigVerifier
	FallbackHeaderValidator       consensus.FallbackHeaderValidator
	NodeRedundancyHandler         consensus.NodeRedundancyHandler
	ScheduledProcessor            consensus.ScheduledProcessor
	MessageSigningHandler         consensus.P2PSigningHandler
	PeerBlacklistHandler          consensus.PeerBlacklistHandler
	SigningHandler                consensus.SigningHandler
	EnableEpochsHandler           common.EnableEpochsHandler
	EquivalentProofsPool          consensus.EquivalentProofsPool
	EpochNotifier                 process.EpochNotifier
	InvalidSignersCache           InvalidSignersCache
}

ConsensusCoreArgs store all arguments that are needed to create a ConsensusCore object

type ConsensusCoreHandler

type ConsensusCoreHandler interface {
	Blockchain() data.ChainHandler
	BlockProcessor() process.BlockProcessor
	BootStrapper() process.Bootstrapper
	BroadcastMessenger() consensus.BroadcastMessenger
	Chronology() consensus.ChronologyHandler
	GetAntiFloodHandler() consensus.P2PAntifloodHandler
	Hasher() hashing.Hasher
	Marshalizer() marshal.Marshalizer
	MultiSignerContainer() cryptoCommon.MultiSignerContainer
	RoundHandler() consensus.RoundHandler
	ShardCoordinator() sharding.Coordinator
	SyncTimer() ntp.SyncTimer
	NodesCoordinator() nodesCoordinator.NodesCoordinator
	EpochStartRegistrationHandler() epochStart.RegistrationHandler
	PeerHonestyHandler() consensus.PeerHonestyHandler
	HeaderSigVerifier() consensus.HeaderSigVerifier
	FallbackHeaderValidator() consensus.FallbackHeaderValidator
	NodeRedundancyHandler() consensus.NodeRedundancyHandler
	ScheduledProcessor() consensus.ScheduledProcessor
	MessageSigningHandler() consensus.P2PSigningHandler
	PeerBlacklistHandler() consensus.PeerBlacklistHandler
	SigningHandler() consensus.SigningHandler
	EnableEpochsHandler() common.EnableEpochsHandler
	EquivalentProofsPool() consensus.EquivalentProofsPool
	EpochNotifier() process.EpochNotifier
	InvalidSignersCache() InvalidSignersCache
	IsInterfaceNil() bool
}

ConsensusCoreHandler encapsulates all needed data for the Consensus

type ConsensusDataIndexer

type ConsensusDataIndexer interface {
	SaveRoundsInfo(roundsInfos []*outport.RoundInfo)
	IsInterfaceNil() bool
}

ConsensusDataIndexer defines the actions that a consensus data indexer has to do

type ConsensusService

type ConsensusService interface {
	// InitReceivedMessages initializes the MessagesType map for all messages for the current ConsensusService
	InitReceivedMessages() map[consensus.MessageType][]*consensus.Message
	// GetStringValue gets the name of the messageType
	GetStringValue(consensus.MessageType) string
	// GetSubroundName gets the subround name for the subround id provided
	GetSubroundName(int) string
	// GetMessageRange provides the MessageType range used in checks by the consensus
	GetMessageRange() []consensus.MessageType
	// CanProceed returns if the current messageType can proceed further if previous subrounds finished
	CanProceed(*ConsensusState, consensus.MessageType) bool
	// IsMessageWithBlockBodyAndHeader returns if the current messageType is about block body and header
	IsMessageWithBlockBodyAndHeader(consensus.MessageType) bool
	// IsMessageWithBlockBody returns if the current messageType is about block body
	IsMessageWithBlockBody(consensus.MessageType) bool
	// IsMessageWithBlockHeader returns if the current messageType is about block header
	IsMessageWithBlockHeader(consensus.MessageType) bool
	// IsMessageWithSignature returns if the current messageType is about signature
	IsMessageWithSignature(consensus.MessageType) bool
	// IsMessageWithFinalInfo returns if the current messageType is about header final info
	IsMessageWithFinalInfo(consensus.MessageType) bool
	// IsMessageTypeValid returns if the current messageType is valid
	IsMessageTypeValid(consensus.MessageType) bool
	// IsMessageWithInvalidSigners returns if the current messageType is with invalid signers
	IsMessageWithInvalidSigners(consensus.MessageType) bool
	// IsSubroundSignature returns if the current subround is about signature
	IsSubroundSignature(int) bool
	// IsSubroundStartRound returns if the current subround is about start round
	IsSubroundStartRound(int) bool
	// GetMaxMessagesInARoundPerPeer returns the maximum number of messages a peer can send per round
	GetMaxMessagesInARoundPerPeer() uint32
	// GetMaxNumOfMessageTypeAccepted returns the maximum number of accepted consensus message types per round, per public key
	GetMaxNumOfMessageTypeAccepted(msgType consensus.MessageType) uint32
	// GetMessageTypeBlockHeader returns the message type for the block header
	GetMessageTypeBlockHeader() consensus.MessageType
	// IsInterfaceNil returns true if there is no value under the interface
	IsInterfaceNil() bool
}

ConsensusService encapsulates the methods specifically for a consensus type (bls, bn) and will be used in the sposWorker

type ConsensusState

type ConsensusState struct {
	// hold the data on which validators do the consensus (could be for example a hash of the block header
	// proposed by the leader)
	Data []byte

	RoundIndex                  int64
	RoundTimeStamp              time.Time
	RoundCanceled               bool
	ExtendedCalled              bool
	WaitingAllSignaturesTimeOut bool
	// contains filtered or unexported fields
}

ConsensusState defines the data needed by spos to do the consensus in each round

func NewConsensusState

func NewConsensusState(
	roundConsensus *roundConsensus,
	roundThreshold *roundThreshold,
	roundStatus *roundStatus,
) *ConsensusState

NewConsensusState creates a new ConsensusState object

func (*ConsensusState) AddMessageWithSignature added in v1.6.0

func (cns *ConsensusState) AddMessageWithSignature(key string, message p2p.MessageP2P)

AddMessageWithSignature will add the p2p message to received list of messages

func (*ConsensusState) AddReceivedHeader

func (cns *ConsensusState) AddReceivedHeader(headerHandler data.HeaderHandler)

AddReceivedHeader append the provided header to the inner received headers list

func (*ConsensusState) CanDoSubroundJob

func (cns *ConsensusState) CanDoSubroundJob(currentSubroundId int) bool

CanDoSubroundJob method returns true if the job of the subround can be done and false otherwise

func (*ConsensusState) CanProcessReceivedMessage

func (cns *ConsensusState) CanProcessReceivedMessage(cnsDta *consensus.Message, currentRoundIndex int64,
	currentSubroundId int) bool

CanProcessReceivedMessage method returns true if the message received can be processed and false otherwise

func (ConsensusState) ComputeSize

func (rcns ConsensusState) ComputeSize(subroundId int) int

ComputeSize method returns the number of messages received from the nodes belonging to the current jobDone group related to this subround

func (ConsensusState) ConsensusGroup

func (rcns ConsensusState) ConsensusGroup() []string

ConsensusGroup returns the consensus group ID's

func (ConsensusState) ConsensusGroupIndex

func (rcns ConsensusState) ConsensusGroupIndex(pubKey string) (int, error)

ConsensusGroupIndex returns the index of given public key in the current consensus group

func (ConsensusState) ConsensusGroupSize

func (rcns ConsensusState) ConsensusGroupSize() int

ConsensusGroupSize returns the consensus group size

func (ConsensusState) FallbackThreshold

func (rthr ConsensusState) FallbackThreshold(subroundId int) int

FallbackThreshold returns the fallback threshold of agreements needed in the given subround id

func (*ConsensusState) GenerateBitmap

func (cns *ConsensusState) GenerateBitmap(subroundId int) []byte

GenerateBitmap method generates a bitmap, for a given subround, in which each node will be marked with 1 if its job has been done

func (*ConsensusState) GetBody added in v1.9.0

func (cns *ConsensusState) GetBody() data.BodyHandler

GetBody returns the body of the current round

func (*ConsensusState) GetData

func (cns *ConsensusState) GetData() []byte

GetData gets the Data of the consensusState

func (*ConsensusState) GetExtendedCalled added in v1.9.0

func (cns *ConsensusState) GetExtendedCalled() bool

GetExtendedCalled returns the state of the extended called

func (*ConsensusState) GetHeader added in v1.9.0

func (cns *ConsensusState) GetHeader() data.HeaderHandler

GetHeader returns the header of the current round

func (ConsensusState) GetKeysHandler added in v1.9.0

func (rcns ConsensusState) GetKeysHandler() consensus.KeysHandler

GetKeysHandler returns the keysHandler instance

func (*ConsensusState) GetLeader

func (cns *ConsensusState) GetLeader() (string, error)

GetLeader method gets the leader of the current round

func (*ConsensusState) GetMessageWithSignature added in v1.6.0

func (cns *ConsensusState) GetMessageWithSignature(key string) (p2p.MessageP2P, bool)

GetMessageWithSignature will get the p2p message based on key

func (*ConsensusState) GetMultikeyRedundancyStepInReason added in v1.6.14

func (cns *ConsensusState) GetMultikeyRedundancyStepInReason() string

GetMultikeyRedundancyStepInReason returns the reason if the current node stepped in as a multikey redundancy node

func (*ConsensusState) GetNextConsensusGroup

func (cns *ConsensusState) GetNextConsensusGroup(
	randomSource []byte,
	round uint64,
	shardId uint32,
	nodesCoordinator nodesCoordinator.NodesCoordinator,
	epoch uint32,
) (string, []string, error)

GetNextConsensusGroup gets the new consensus group for the current round based on current eligible list and a random source for the new selection

func (*ConsensusState) GetReceivedHeaders

func (cns *ConsensusState) GetReceivedHeaders() []data.HeaderHandler

GetReceivedHeaders returns the received headers list

func (*ConsensusState) GetRoundCanceled added in v1.9.0

func (cns *ConsensusState) GetRoundCanceled() bool

GetRoundCanceled returns the state of the current round

func (*ConsensusState) GetRoundIndex added in v1.9.0

func (cns *ConsensusState) GetRoundIndex() int64

GetRoundIndex returns the index of the current round

func (*ConsensusState) GetRoundTimeStamp added in v1.9.0

func (cns *ConsensusState) GetRoundTimeStamp() time.Time

GetRoundTimeStamp returns the time stamp of the current round

func (*ConsensusState) GetWaitingAllSignaturesTimeOut added in v1.9.0

func (cns *ConsensusState) GetWaitingAllSignaturesTimeOut() bool

GetWaitingAllSignaturesTimeOut returns the state of the waiting all signatures time out

func (ConsensusState) IncrementRoundsWithoutReceivedMessages added in v1.6.0

func (rcns ConsensusState) IncrementRoundsWithoutReceivedMessages(pkBytes []byte)

IncrementRoundsWithoutReceivedMessages increments the number of rounds without received messages on a provided public key

func (*ConsensusState) IsBlockBodyAlreadyReceived

func (cns *ConsensusState) IsBlockBodyAlreadyReceived() bool

IsBlockBodyAlreadyReceived method returns true if block body is already received and false otherwise

func (*ConsensusState) IsConsensusDataEqual

func (cns *ConsensusState) IsConsensusDataEqual(data []byte) bool

IsConsensusDataEqual method returns true if the consensus data for the current round is the same with the given one and false otherwise

func (*ConsensusState) IsConsensusDataSet

func (cns *ConsensusState) IsConsensusDataSet() bool

IsConsensusDataSet method returns true if the consensus data for the current round is set and false otherwise

func (*ConsensusState) IsHeaderAlreadyReceived

func (cns *ConsensusState) IsHeaderAlreadyReceived() bool

IsHeaderAlreadyReceived method returns true if header is already received and false otherwise

func (*ConsensusState) IsInterfaceNil added in v1.9.0

func (cns *ConsensusState) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ConsensusState) IsJobDone

func (cns *ConsensusState) IsJobDone(node string, currentSubroundId int) bool

IsJobDone method returns true if the node job for the current subround is done and false otherwise

func (ConsensusState) IsKeyManagedBySelf added in v1.9.0

func (rcns ConsensusState) IsKeyManagedBySelf(pkBytes []byte) bool

IsKeyManagedBySelf returns true if the key is managed by the current node

func (*ConsensusState) IsLeaderJobDone added in v1.6.0

func (cns *ConsensusState) IsLeaderJobDone(currentSubroundId int) bool

IsLeaderJobDone method returns true if the leader job for the current subround is done and false otherwise

func (ConsensusState) IsMultiKeyInConsensusGroup added in v1.6.0

func (rcns ConsensusState) IsMultiKeyInConsensusGroup() bool

IsMultiKeyInConsensusGroup method checks if one of the nodes which are controlled by this instance is in consensus group in the current round

func (*ConsensusState) IsMultiKeyJobDone added in v1.6.0

func (cns *ConsensusState) IsMultiKeyJobDone(currentSubroundId int) bool

IsMultiKeyJobDone method returns true if all the nodes controlled by this instance finished the current job for the current subround and false otherwise

func (*ConsensusState) IsMultiKeyLeaderInCurrentRound added in v1.6.0

func (cns *ConsensusState) IsMultiKeyLeaderInCurrentRound() bool

IsMultiKeyLeaderInCurrentRound method checks if one of the nodes which are controlled by this instance is leader in the current round

func (ConsensusState) IsNodeInConsensusGroup

func (rcns ConsensusState) IsNodeInConsensusGroup(node string) bool

IsNodeInConsensusGroup method checks if the node is part of consensus group of the current round

func (ConsensusState) IsNodeInEligibleList

func (rcns ConsensusState) IsNodeInEligibleList(node string) bool

IsNodeInEligibleList method checks if the node is part of the eligible list

func (*ConsensusState) IsNodeLeaderInCurrentRound

func (cns *ConsensusState) IsNodeLeaderInCurrentRound(node string) bool

IsNodeLeaderInCurrentRound method checks if the given node is leader in the current round

func (*ConsensusState) IsNodeSelf

func (cns *ConsensusState) IsNodeSelf(node string) bool

IsNodeSelf method returns true if the message is received from itself and false otherwise

func (*ConsensusState) IsSelfJobDone

func (cns *ConsensusState) IsSelfJobDone(currentSubroundID int) bool

IsSelfJobDone method returns true if self job for the current subround is done and false otherwise

func (*ConsensusState) IsSubroundFinished

func (cns *ConsensusState) IsSubroundFinished(subroundID int) bool

IsSubroundFinished method returns true if the current subround is finished and false otherwise

func (ConsensusState) JobDone

func (rcns ConsensusState) JobDone(key string, subroundId int) (bool, error)

JobDone returns the state of the action done, by the node represented by the key parameter, in subround given by the subroundId parameter

func (ConsensusState) Leader added in v1.9.0

func (rcns ConsensusState) Leader() string

Leader returns the leader for the current consensus

func (*ConsensusState) ProcessingBlock

func (cns *ConsensusState) ProcessingBlock() bool

ProcessingBlock gets the state of block processing

func (*ConsensusState) ResetConsensusRoundState added in v1.9.0

func (cns *ConsensusState) ResetConsensusRoundState()

ResetConsensusRoundState method resets all the consensus round data (except messages received)

func (*ConsensusState) ResetConsensusState

func (cns *ConsensusState) ResetConsensusState()

ResetConsensusState method resets all the consensus data

func (ConsensusState) ResetRoundState

func (rcns ConsensusState) ResetRoundState()

ResetRoundState method resets the state of each node from the current jobDone group, regarding the consensus validatorRoundStates

func (ConsensusState) ResetRoundStatus

func (rstatus ConsensusState) ResetRoundStatus()

ResetRoundStatus method resets the state of each subround

func (*ConsensusState) ResetRoundsWithoutReceivedMessages added in v1.6.2

func (cns *ConsensusState) ResetRoundsWithoutReceivedMessages(pkBytes []byte, pid core.PeerID)

ResetRoundsWithoutReceivedMessages will reset the rounds received without a message for a specified public key by providing also the peer ID from the received message

func (ConsensusState) SelfConsensusGroupIndex

func (rcns ConsensusState) SelfConsensusGroupIndex() (int, error)

SelfConsensusGroupIndex returns the index of self public key in current consensus group

func (ConsensusState) SelfJobDone

func (rcns ConsensusState) SelfJobDone(subroundId int) (bool, error)

SelfJobDone returns the self state of the action done in subround given by the subroundId parameter

func (ConsensusState) SelfPubKey

func (rcns ConsensusState) SelfPubKey() string

SelfPubKey returns selfPubKey ID

func (*ConsensusState) SetBody added in v1.9.0

func (cns *ConsensusState) SetBody(body data.BodyHandler)

SetBody sets the body of the current round

func (ConsensusState) SetConsensusGroup

func (rcns ConsensusState) SetConsensusGroup(consensusGroup []string)

SetConsensusGroup sets the consensus group ID's

func (ConsensusState) SetConsensusGroupSize

func (rcns ConsensusState) SetConsensusGroupSize(consensusGroupSize int)

SetConsensusGroupSize sets the consensus group size

func (*ConsensusState) SetData added in v1.9.0

func (cns *ConsensusState) SetData(data []byte)

SetData sets the Data of the consensusState

func (ConsensusState) SetEligibleList

func (rcns ConsensusState) SetEligibleList(eligibleList map[string]struct{})

SetEligibleList sets the eligible list ID's

func (*ConsensusState) SetExtendedCalled added in v1.9.0

func (cns *ConsensusState) SetExtendedCalled(extendedCalled bool)

SetExtendedCalled sets the state of the extended called

func (ConsensusState) SetFallbackThreshold

func (rthr ConsensusState) SetFallbackThreshold(subroundId int, threshold int)

SetFallbackThreshold sets the fallback threshold of agreements needed in the given subround id

func (*ConsensusState) SetHeader added in v1.9.0

func (cns *ConsensusState) SetHeader(header data.HeaderHandler)

SetHeader sets the header of the current round

func (ConsensusState) SetJobDone

func (rcns ConsensusState) SetJobDone(key string, subroundId int, value bool) error

SetJobDone set the state of the action done, by the node represented by the key parameter, in subround given by the subroundId parameter

func (ConsensusState) SetLeader added in v1.9.0

func (rcns ConsensusState) SetLeader(leader string)

SetLeader sets the leader for the current consensus

func (*ConsensusState) SetProcessingBlock

func (cns *ConsensusState) SetProcessingBlock(processingBlock bool)

SetProcessingBlock sets the state of block processing

func (*ConsensusState) SetRoundCanceled added in v1.9.0

func (cns *ConsensusState) SetRoundCanceled(roundCanceled bool)

SetRoundCanceled sets the state of the current round

func (*ConsensusState) SetRoundIndex added in v1.9.0

func (cns *ConsensusState) SetRoundIndex(roundIndex int64)

SetRoundIndex sets the index of the current round

func (*ConsensusState) SetRoundTimeStamp added in v1.9.0

func (cns *ConsensusState) SetRoundTimeStamp(roundTimeStamp time.Time)

SetRoundTimeStamp sets the time stamp of the current round

func (ConsensusState) SetSelfPubKey

func (rcns ConsensusState) SetSelfPubKey(selfPubKey string)

SetSelfPubKey sets selfPubKey ID

func (ConsensusState) SetStatus

func (rstatus ConsensusState) SetStatus(subroundId int, subroundStatus SubroundStatus)

SetStatus sets the status of the given subround id

func (ConsensusState) SetThreshold

func (rthr ConsensusState) SetThreshold(subroundId int, threshold int)

SetThreshold sets the threshold of agreements needed in the given subround id

func (*ConsensusState) SetWaitingAllSignaturesTimeOut added in v1.9.0

func (cns *ConsensusState) SetWaitingAllSignaturesTimeOut(waitingAllSignaturesTimeOut bool)

SetWaitingAllSignaturesTimeOut sets the state of the waiting all signatures time out

func (ConsensusState) Status

func (rstatus ConsensusState) Status(subroundId int) SubroundStatus

Status returns the status of the given subround id

func (ConsensusState) Threshold

func (rthr ConsensusState) Threshold(subroundId int) int

Threshold returns the threshold of agreements needed in the given subround id

type ConsensusStateHandler added in v1.9.0

type ConsensusStateHandler interface {
	ResetConsensusState()
	ResetConsensusRoundState()
	AddReceivedHeader(headerHandler data.HeaderHandler)
	GetReceivedHeaders() []data.HeaderHandler
	AddMessageWithSignature(key string, message p2p.MessageP2P)
	GetMessageWithSignature(key string) (p2p.MessageP2P, bool)
	IsNodeLeaderInCurrentRound(node string) bool
	GetLeader() (string, error)
	GetNextConsensusGroup(
		randomSource []byte,
		round uint64,
		shardId uint32,
		nodesCoordinator nodesCoordinator.NodesCoordinator,
		epoch uint32,
	) (string, []string, error)
	IsConsensusDataSet() bool
	IsConsensusDataEqual(data []byte) bool
	IsJobDone(node string, currentSubroundId int) bool
	IsSubroundFinished(subroundID int) bool
	IsNodeSelf(node string) bool
	IsBlockBodyAlreadyReceived() bool
	IsHeaderAlreadyReceived() bool
	CanDoSubroundJob(currentSubroundId int) bool
	CanProcessReceivedMessage(cnsDta *consensus.Message, currentRoundIndex int64, currentSubroundId int) bool
	GenerateBitmap(subroundId int) []byte
	ProcessingBlock() bool
	SetProcessingBlock(processingBlock bool)
	GetData() []byte
	SetData(data []byte)
	IsMultiKeyLeaderInCurrentRound() bool
	IsLeaderJobDone(currentSubroundId int) bool
	IsMultiKeyJobDone(currentSubroundId int) bool
	IsSelfJobDone(currentSubroundID int) bool
	GetMultikeyRedundancyStepInReason() string
	ResetRoundsWithoutReceivedMessages(pkBytes []byte, pid core.PeerID)
	GetRoundCanceled() bool
	SetRoundCanceled(state bool)
	GetRoundIndex() int64
	SetRoundIndex(roundIndex int64)
	GetRoundTimeStamp() time.Time
	SetRoundTimeStamp(roundTimeStamp time.Time)
	GetExtendedCalled() bool
	GetBody() data.BodyHandler
	SetBody(body data.BodyHandler)
	GetHeader() data.HeaderHandler
	SetHeader(header data.HeaderHandler)
	GetWaitingAllSignaturesTimeOut() bool
	SetWaitingAllSignaturesTimeOut(bool)
	RoundConsensusHandler
	RoundStatusHandler
	RoundThresholdHandler
	IsInterfaceNil() bool
}

ConsensusStateHandler encapsulates all needed data for the Consensus

type HeaderSigVerifier

type HeaderSigVerifier interface {
	VerifyRandSeed(header data.HeaderHandler) error
	VerifyLeaderSignature(header data.HeaderHandler) error
	VerifySignature(header data.HeaderHandler) error
	VerifySignatureForHash(header data.HeaderHandler, hash []byte, pubkeysBitmap []byte, signature []byte) error
	VerifyHeaderProof(headerProof data.HeaderProofHandler) error
	IsInterfaceNil() bool
}

HeaderSigVerifier encapsulates methods that check if header signature is correct

type InvalidSignersCache added in v1.9.0

type InvalidSignersCache interface {
	AddInvalidSigners(headerHash []byte, invalidSigners []byte, invalidPublicKeys []string)
	CheckKnownInvalidSigners(headerHash []byte, invalidSigners []byte) bool
	Reset()
	IsInterfaceNil() bool
}

InvalidSignersCache encapsulates the methods needed for a invalid signers cache

type PeerBlackListCacher added in v1.6.0

type PeerBlackListCacher interface {
	Upsert(pid core.PeerID, span time.Duration) error
	Has(pid core.PeerID) bool
	Sweep()
	IsInterfaceNil() bool
}

PeerBlackListCacher can determine if a certain peer id is blacklisted or not

type PoolAdder

type PoolAdder interface {
	Put(key []byte, value interface{}, sizeInBytes int) (evicted bool)
	IsInterfaceNil() bool
}

PoolAdder adds data in a key-value pool

type RoundConsensusHandler added in v1.9.0

type RoundConsensusHandler interface {
	ConsensusGroupIndex(pubKey string) (int, error)
	SelfConsensusGroupIndex() (int, error)
	SetEligibleList(eligibleList map[string]struct{})
	ConsensusGroup() []string
	SetConsensusGroup(consensusGroup []string)
	SetLeader(leader string)
	ConsensusGroupSize() int
	SetConsensusGroupSize(consensusGroupSize int)
	SelfPubKey() string
	SetSelfPubKey(selfPubKey string)
	JobDone(key string, subroundId int) (bool, error)
	SetJobDone(key string, subroundId int, value bool) error
	SelfJobDone(subroundId int) (bool, error)
	IsNodeInConsensusGroup(node string) bool
	IsNodeInEligibleList(node string) bool
	ComputeSize(subroundId int) int
	ResetRoundState()
	IsMultiKeyInConsensusGroup() bool
	IsKeyManagedBySelf(pkBytes []byte) bool
	IncrementRoundsWithoutReceivedMessages(pkBytes []byte)
	GetKeysHandler() consensus.KeysHandler
	Leader() string
}

RoundConsensusHandler encapsulates the methods needed for a consensus round

type RoundStatusHandler added in v1.9.0

type RoundStatusHandler interface {
	Status(subroundId int) SubroundStatus
	SetStatus(subroundId int, subroundStatus SubroundStatus)
	ResetRoundStatus()
}

RoundStatusHandler encapsulates the methods needed for the status of a subround

type RoundThresholdHandler added in v1.9.0

type RoundThresholdHandler interface {
	Threshold(subroundId int) int
	SetThreshold(subroundId int, threshold int)
	FallbackThreshold(subroundId int) int
	SetFallbackThreshold(subroundId int, threshold int)
}

RoundThresholdHandler encapsulates the methods needed for the round consensus threshold

type ScheduledProcessorWrapperArgs

type ScheduledProcessorWrapperArgs struct {
	SyncTimer                ntp.SyncTimer
	Processor                process.ScheduledBlockProcessor
	RoundTimeDurationHandler process.RoundTimeDurationHandler
}

ScheduledProcessorWrapperArgs holds the arguments required to instantiate the pipelineExecution

type SentSignaturesTracker added in v1.6.2

type SentSignaturesTracker interface {
	StartRound()
	SignatureSent(pkBytes []byte)
	IsInterfaceNil() bool
}

SentSignaturesTracker defines a component able to handle sent signature from self

type Subround

type Subround struct {
	ConsensusCoreHandler
	ConsensusStateHandler

	Job    func(ctx context.Context) bool // method does the Subround Job and send the result to the peers
	Check  func() bool                    // method checks if the consensus of the Subround is done
	Extend func(subroundId int)           // method is called when round time is out
	// contains filtered or unexported fields
}

Subround struct contains the needed data for one Subround and the Subround properties. It defines a Subround with its properties (its ID, next Subround ID, its duration, its name) and also it has some handler functions which should be set. Job function will be the main function of this Subround, Extend function will handle the overtime situation of the Subround and Check function will decide if in this Subround the consensus is achieved

func NewSubround

func NewSubround(
	previous int,
	current int,
	next int,
	startTime int64,
	endTime int64,
	name string,
	consensusState ConsensusStateHandler,
	consensusStateChangedChannel chan bool,
	executeStoredMessages func(),
	container ConsensusCoreHandler,
	chainID []byte,
	currentPid core.PeerID,
	appStatusHandler core.AppStatusHandler,
) (*Subround, error)

NewSubround creates a new SubroundId object

func (*Subround) AppStatusHandler

func (sr *Subround) AppStatusHandler() core.AppStatusHandler

AppStatusHandler method returns the appStatusHandler instance

func (*Subround) ChainID

func (sr *Subround) ChainID() []byte

ChainID method returns the current chain ID

func (*Subround) ConsensusChannel

func (sr *Subround) ConsensusChannel() chan bool

ConsensusChannel method returns the consensus channel

func (*Subround) Current

func (sr *Subround) Current() int

Current method returns the ID of the current Subround

func (*Subround) CurrentPid

func (sr *Subround) CurrentPid() core.PeerID

CurrentPid returns the current p2p peer ID

func (*Subround) DoWork

func (sr *Subround) DoWork(ctx context.Context, roundHandler consensus.RoundHandler) bool

DoWork method actually does the work of this Subround. First it tries to do the Job of the Subround then it will Check the consensus. If the upper time limit of this Subround is reached, the Extend method will be called before returning. If this method returns true the chronology will advance to the next Subround.

func (*Subround) EndTime

func (sr *Subround) EndTime() int64

EndTime method returns the upper time limit of the Subround

func (*Subround) GetAssociatedPid added in v1.6.0

func (sr *Subround) GetAssociatedPid(pkBytes []byte) core.PeerID

GetAssociatedPid returns the associated PeerID to the provided public key bytes

func (*Subround) GetLeaderStartRoundMessage added in v1.9.0

func (sr *Subround) GetLeaderStartRoundMessage() string

GetLeaderStartRoundMessage returns the leader start round message based on single key or multi-key node type

func (*Subround) IsInterfaceNil

func (sr *Subround) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Subround) IsSelfInConsensusGroup added in v1.9.0

func (sr *Subround) IsSelfInConsensusGroup() bool

IsSelfInConsensusGroup returns true is the current node is in consensus group in single key or in multi-key mode

func (*Subround) IsSelfLeader added in v1.9.0

func (sr *Subround) IsSelfLeader() bool

IsSelfLeader returns true is the current node is leader is single key or in multi-key mode

func (*Subround) IsSelfLeaderInCurrentRound added in v1.9.0

func (sr *Subround) IsSelfLeaderInCurrentRound() bool

IsSelfLeaderInCurrentRound method checks if the current node is leader in the current round

func (*Subround) Name

func (sr *Subround) Name() string

Name method returns the name of the Subround

func (*Subround) Next

func (sr *Subround) Next() int

Next method returns the ID of the next Subround

func (*Subround) Previous

func (sr *Subround) Previous() int

Previous method returns the ID of the previous Subround

func (*Subround) ShouldConsiderSelfKeyInConsensus added in v1.6.2

func (sr *Subround) ShouldConsiderSelfKeyInConsensus() bool

ShouldConsiderSelfKeyInConsensus returns true if current machine is the main one, or it is a backup machine but the main machine failed

func (*Subround) StartTime

func (sr *Subround) StartTime() int64

StartTime method returns the start time of the Subround

type SubroundStatus

type SubroundStatus = int

SubroundStatus defines the type used to refer the state of the current subround

const (
	// SsNotFinished defines the un-finished state of the subround
	SsNotFinished SubroundStatus = iota
	// SsFinished defines the finished state of the subround
	SsFinished
)

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker defines the data needed by spos to communicate between nodes which are in the validators group

func NewWorker

func NewWorker(args *WorkerArgs) (*Worker, error)

NewWorker creates a new Worker object

func (*Worker) AddReceivedHeaderHandler

func (wrk *Worker) AddReceivedHeaderHandler(handler func(data.HeaderHandler))

AddReceivedHeaderHandler adds a new handler function for a received header

func (*Worker) AddReceivedMessageCall

func (wrk *Worker) AddReceivedMessageCall(messageType consensus.MessageType, receivedMessageCall func(ctx context.Context, cnsDta *consensus.Message) bool)

AddReceivedMessageCall adds a new handler function for a received message type

func (*Worker) AddReceivedProofHandler added in v1.9.0

func (wrk *Worker) AddReceivedProofHandler(handler func(proofHandler consensus.ProofHandler))

AddReceivedProofHandler adds a new handler function for a received proof

func (*Worker) Close

func (wrk *Worker) Close() error

Close will close the endless running go routine

func (*Worker) DisplayStatistics

func (wrk *Worker) DisplayStatistics()

DisplayStatistics logs the consensus messages split on proposed headers

func (*Worker) ExecuteStoredMessages

func (wrk *Worker) ExecuteStoredMessages()

ExecuteStoredMessages tries to execute all the messages received which are valid for execution

func (*Worker) Extend

func (wrk *Worker) Extend(subroundId int)

Extend does an extension for the subround with subroundId

func (*Worker) GetConsensusStateChangedChannel

func (wrk *Worker) GetConsensusStateChangedChannel() chan bool

GetConsensusStateChangedChannel gets the channel for the consensusStateChanged

func (*Worker) IsInterfaceNil

func (wrk *Worker) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Worker) ProcessReceivedMessage

func (wrk *Worker) ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID, _ p2p.MessageHandler) ([]byte, error)

ProcessReceivedMessage method redirects the received message to the channel which should handle it

func (*Worker) ReceivedHeader

func (wrk *Worker) ReceivedHeader(headerHandler data.HeaderHandler, _ []byte)

ReceivedHeader process the received header, calling each received header handler registered in worker instance

func (*Worker) ReceivedProof added in v1.9.0

func (wrk *Worker) ReceivedProof(proofHandler consensus.ProofHandler)

ReceivedProof process the received proof, calling each received proof handler registered in worker instance

func (*Worker) RemoveAllReceivedHeaderHandlers added in v1.9.0

func (wrk *Worker) RemoveAllReceivedHeaderHandlers()

RemoveAllReceivedHeaderHandlers removes all the functions handlers

func (*Worker) RemoveAllReceivedMessagesCalls

func (wrk *Worker) RemoveAllReceivedMessagesCalls()

RemoveAllReceivedMessagesCalls removes all the functions handlers

func (*Worker) ResetConsensusMessages

func (wrk *Worker) ResetConsensusMessages()

ResetConsensusMessages resets at the start of each round all the previous consensus messages received and equivalent messages, keeping the provided proofs

func (*Worker) ResetConsensusRoundState added in v1.9.0

func (wrk *Worker) ResetConsensusRoundState()

ResetConsensusRoundState resets the consensus round state

func (*Worker) ResetInvalidSignersCache added in v1.9.0

func (wrk *Worker) ResetInvalidSignersCache()

ResetInvalidSignersCache resets the invalid signers cache

func (*Worker) StartWorking

func (wrk *Worker) StartWorking()

StartWorking actually starts the consensus working mechanism

type WorkerArgs

type WorkerArgs struct {
	ConsensusService         ConsensusService
	BlockChain               data.ChainHandler
	BlockProcessor           process.BlockProcessor
	ScheduledProcessor       consensus.ScheduledProcessor
	Bootstrapper             process.Bootstrapper
	BroadcastMessenger       consensus.BroadcastMessenger
	ConsensusState           *ConsensusState
	ForkDetector             process.ForkDetector
	Marshalizer              marshal.Marshalizer
	Hasher                   hashing.Hasher
	RoundHandler             consensus.RoundHandler
	ShardCoordinator         sharding.Coordinator
	PeerSignatureHandler     crypto.PeerSignatureHandler
	SyncTimer                ntp.SyncTimer
	HeaderSigVerifier        HeaderSigVerifier
	HeaderIntegrityVerifier  process.HeaderIntegrityVerifier
	ChainID                  []byte
	NetworkShardingCollector consensus.NetworkShardingCollector
	AntifloodHandler         consensus.P2PAntifloodHandler
	PoolAdder                PoolAdder
	SignatureSize            int
	PublicKeySize            int
	AppStatusHandler         core.AppStatusHandler
	NodeRedundancyHandler    consensus.NodeRedundancyHandler
	PeerBlacklistHandler     consensus.PeerBlacklistHandler
	EnableEpochsHandler      common.EnableEpochsHandler
	InvalidSignersCache      InvalidSignersCache
}

WorkerArgs holds the consensus worker arguments

type WorkerHandler

type WorkerHandler interface {
	Close() error
	StartWorking()
	// AddReceivedMessageCall adds a new handler function for a received message type
	AddReceivedMessageCall(messageType consensus.MessageType, receivedMessageCall func(ctx context.Context, cnsDta *consensus.Message) bool)
	// AddReceivedHeaderHandler adds a new handler function for a received header
	AddReceivedHeaderHandler(handler func(data.HeaderHandler))
	// RemoveAllReceivedHeaderHandlers removes all the functions handlers
	RemoveAllReceivedHeaderHandlers()
	// AddReceivedProofHandler adds a new handler function for a received proof
	AddReceivedProofHandler(handler func(consensus.ProofHandler))
	// RemoveAllReceivedMessagesCalls removes all the functions handlers
	RemoveAllReceivedMessagesCalls()
	// ProcessReceivedMessage method redirects the received message to the channel which should handle it
	ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID, source p2p.MessageHandler) ([]byte, error)
	// Extend does an extension for the subround with subroundId
	Extend(subroundId int)
	// GetConsensusStateChangedChannel gets the channel for the consensusStateChanged
	GetConsensusStateChangedChannel() chan bool
	// ExecuteStoredMessages tries to execute all the messages received which are valid for execution
	ExecuteStoredMessages()
	// DisplayStatistics method displays statistics of worker at the end of the round
	DisplayStatistics()
	// ReceivedHeader method is a wired method through which worker will receive headers from network
	ReceivedHeader(headerHandler data.HeaderHandler, headerHash []byte)
	// ResetConsensusMessages resets at the start of each round all the previous consensus messages received and equivalent messages, keeping the provided proofs
	ResetConsensusMessages()
	// ResetConsensusRoundState resets the consensus round state when transitioning to a different consensus version
	ResetConsensusRoundState()
	// ResetInvalidSignersCache resets the invalid signers cache
	ResetInvalidSignersCache()
	// IsInterfaceNil returns true if there is no value under the interface
	IsInterfaceNil() bool
}

WorkerHandler represents the interface for the SposWorker

Directories

Path Synopsis
bls
v1
v2

Jump to

Keyboard shortcuts

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