consensus_v2

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 22 Imported by: 4

Documentation

Index

Constants

View Source
const (
	UnExpectedError = iota
	ConsensusTypeNotExistError
	ProducerSignatureError
	CommitteeSignatureError
	CombineSignatureError
	SignDataError
	LoadKeyError
	ConsensusAlreadyStartedError
	ConsensusAlreadyStoppedError
	DecodeValidationDataError
	EncodeValidationDataError
	BlockCreationError
)

Variables

View Source
var ErrCodeMessage = map[int]struct {
	Code    int
	message string
}{
	UnExpectedError:              {-1000, "Unexpected error"},
	ConsensusTypeNotExistError:   {-1001, "Consensus type isn't exist"},
	ProducerSignatureError:       {-1002, "Producer signature error"},
	CommitteeSignatureError:      {-1003, "Committee signature error"},
	CombineSignatureError:        {-1004, "Combine signature error"},
	SignDataError:                {-1005, "Sign data error"},
	LoadKeyError:                 {-1006, "Load key error"},
	ConsensusAlreadyStartedError: {-1007, "consensus already started error"},
	ConsensusAlreadyStoppedError: {-1008, "consensus already stopped error"},
	DecodeValidationDataError:    {-1009, "Decode Validation Data error"},
	EncodeValidationDataError:    {-1010, "Encode Validation Data Error"},
	BlockCreationError:           {-1011, "Block Creation Error"},
}
View Source
var Logger = consensusLogger{}

Global instant to use

Functions

func GenMiningKeyFromPrivateKey

func GenMiningKeyFromPrivateKey(privateKey string) (string, error)

func GetMiningKeyFromPrivateSeed

func GetMiningKeyFromPrivateSeed(privateSeed string) (*signatureschemes2.MiningKey, error)

func LoadUserKeyFromIncPrivateKey

func LoadUserKeyFromIncPrivateKey(privateKey string) (string, error)

func NewConsensusError

func NewConsensusError(key int, err error) error

Types

type ConsensusError

type ConsensusError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

func (ConsensusError) Error

func (e ConsensusError) Error() string

type Engine

type Engine struct {
	IsEnabled int //0 > stop, 1: running
	// contains filtered or unexported fields
}

func NewConsensusEngine

func NewConsensusEngine() *Engine

func (*Engine) BFTProcess

func (engine *Engine) BFTProcess() map[int]blsbft.Actor

BFTProcess for testing only

func (*Engine) ExtractBridgeValidationData

func (engine *Engine) ExtractBridgeValidationData(block types.BlockInterface) ([][]byte, []int, error)

func (*Engine) ExtractPortalV4ValidationData

func (engine *Engine) ExtractPortalV4ValidationData(block types.BlockInterface) ([]*portalprocessv4.PortalSig, error)

func (*Engine) GetAllMiningPublicKeys

func (engine *Engine) GetAllMiningPublicKeys() []string

legacy code -> get all key type of 1 mining key

func (*Engine) GetAllValidatorKeyState

func (engine *Engine) GetAllValidatorKeyState() map[string]consensus.MiningState

func (*Engine) GetCurrentMiningPublicKey

func (engine *Engine) GetCurrentMiningPublicKey() (publickey string, keyType string)

func (*Engine) GetCurrentValidators

func (s *Engine) GetCurrentValidators() []*consensus.Validator

func (*Engine) GetMiningPublicKeyByConsensus

func (engine *Engine) GetMiningPublicKeyByConsensus(consensusName string) (publickey string, err error)

func (*Engine) GetMiningPublicKeys

func (s *Engine) GetMiningPublicKeys() *incognitokey.CommitteePublicKey

func (*Engine) GetNodeMiningPublicKeys

func (s *Engine) GetNodeMiningPublicKeys() (userPks []*incognitokey.CommitteePublicKey)

func (*Engine) GetOneValidator

func (engine *Engine) GetOneValidator() *consensus.Validator

func (*Engine) GetOneValidatorForEachConsensusProcess

func (engine *Engine) GetOneValidatorForEachConsensusProcess() map[int]*consensus.Validator

func (*Engine) GetUserRole

func (s *Engine) GetUserRole() (string, string, int)

just get role of first validator this function support NODE monitor (getmininginfo) which assumed running only 1 validator

func (*Engine) GetValidators

func (s *Engine) GetValidators() []*consensus.Validator

func (*Engine) Init

func (engine *Engine) Init(config *EngineConfig)

func (*Engine) IsCommitteeInShard

func (engine *Engine) IsCommitteeInShard(shardID byte) bool

func (*Engine) NotifyNewRole

func (engine *Engine) NotifyNewRole(newCID int, newRole string)

func (*Engine) OnBFTMsg

func (engine *Engine) OnBFTMsg(msg *wire.MessageBFT)

func (*Engine) SignDataWithCurrentMiningKey

func (engine *Engine) SignDataWithCurrentMiningKey(
	data []byte,
) (
	publicKeyStr string,
	publicKeyType string,
	signature string,
	err error,
)

func (*Engine) Start

func (engine *Engine) Start() error

func (*Engine) Stop

func (engine *Engine) Stop() error

func (*Engine) ValidateBlockCommitteSig

func (engine *Engine) ValidateBlockCommitteSig(block types.BlockInterface, committees []incognitokey.CommitteePublicKey, numFixNode int) error

func (*Engine) ValidateProducerPosition

func (engine *Engine) ValidateProducerPosition(
	blk types.BlockInterface,
	lastProposerIdx int,
	committee []incognitokey.CommitteePublicKey,
	lenProposers int,
	produceTimeSlot int64,
	proposeTimeSlot int64,
) error

func (*Engine) ValidateProducerSig

func (engine *Engine) ValidateProducerSig(block types.BlockInterface, consensusType string) error

func (*Engine) VerifyData

func (engine *Engine) VerifyData(data []byte, sig string, publicKey string, consensusType string) error

func (*Engine) WatchCommitteeChange

func (engine *Engine) WatchCommitteeChange()

type EngineConfig

type EngineConfig struct {
	Node          NodeInterface
	Blockchain    *blockchain.BlockChain
	PubSubManager *pubsub.PubSubManager
}

type NodeInterface

type NodeInterface interface {
	PushBlockToAll(block types.BlockInterface, previousValidationData string, isBeacon bool) error
	PushMessageToChain(msg wire.Message, chain common.ChainInterface) error
	IsEnableMining() bool
	GetMiningKeys() string
	GetPrivateKey() string
	GetUserMiningState() (role string, chainID int)
	GetPubkeyMiningState(*incognitokey.CommitteePublicKey) (role string, chainID int)
	IsBeaconFullnode(*incognitokey.CommitteePublicKey) (bool, string)
	RequestMissingViewViaStream(peerID string, hashes [][]byte, fromCID int, chainName string) (err error)
	GetSelfPeerID() peer.ID
}

Used interfaces NodeInterface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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