Documentation ¶
Index ¶
- Constants
- Variables
- func AddVoteByBlockHashToDB(blockHash string, bftVote BFTVote) error
- func CheckValidationDataWithCommittee(valData *consensustypes.ValidationData, ...) bool
- func CombineVotes(votes map[string]*BFTVote, committees []string) (aggSig []byte, brigSigs [][]byte, validatorIdx []int, ...)
- func ExtractBridgeValidationData(block types.BlockInterface) ([][]byte, []int, error)
- func ExtractPortalV4ValidationData(block types.BlockInterface) ([]*portalprocessv4.PortalSig, []int, error)
- func GetLatestReduceFixNodeVersion() int
- func GetProposer(ts int64, committees []incognitokey.CommitteePublicKey, lenProposers int) (incognitokey.CommitteePublicKey, int)
- func GetProposerByTimeSlot(ts int64, committeeLen int) int
- func GetProposerByTimeSlotFromCommitteeList(ts int64, committees []incognitokey.CommitteePublicKey, ...) (incognitokey.CommitteePublicKey, int)
- func GetProposerIndexByRound(lastId, round, committeeSize int) int
- func GetVotesByBlockHashFromDB(proposeHash string) (map[string]*BFTVote, map[string]*BFTVote, error)
- func InitProposeHistory(chainID int) (map[int64]struct{}, error)
- func InitReceiveBlockByHash(chainID int) (map[string]*ProposeBlockInfo, error)
- func InitVoteHistory(chainID int) (map[uint64]types.BlockInterface, error)
- func NewActorV1WithValue(chain Chain, chainKey string, chainID int, node NodeInterface, ...) *actorV1
- func NewActorV2() *actorV2
- func NewActorV2WithValue(chain Chain, committeeChain CommitteeChainHandler, chainKey string, ...) *actorV2
- func NewActorV3() *actorV3
- func NewActorV3WithValue(chain Chain, committeeChain CommitteeChainHandler, chainKey string, ...) *actorV3
- func NewBlackListValidator(reason error) *rawdb_consensus.BlackListValidator
- func NewConsensusError(key int, err error) error
- func SetBuilderContext(lemma2Height uint64)
- func ValidateCommitteeSig(block types.BlockInterface, committee []incognitokey.CommitteePublicKey, ...) error
- func ValidateProducerSigV1(block types.BlockInterface) error
- func ValidateProducerSigV2(block types.BlockInterface) error
- type Actor
- type ActorV2RuleBuilder
- func (r *ActorV2RuleBuilder) CreateRule() ICreateNewBlockRule
- func (r *ActorV2RuleBuilder) HandleVoteMessageRule() IHandleVoteMessageRule
- func (r *ActorV2RuleBuilder) InsertBlockRule() IInsertBlockRule
- func (r *ActorV2RuleBuilder) ProposeMessageRule() IProposeMessageRule
- func (r *ActorV2RuleBuilder) SetCreateRule(rule ICreateNewBlockRule)
- func (r *ActorV2RuleBuilder) SetHandleVoteMessageRule(rule IHandleVoteMessageRule)
- func (r *ActorV2RuleBuilder) SetInsertBlockRule(rule IInsertBlockRule)
- func (r *ActorV2RuleBuilder) SetProposeMessageRule(rule IProposeMessageRule)
- func (r *ActorV2RuleBuilder) SetValidatorRule(validator IConsensusValidator)
- func (r *ActorV2RuleBuilder) SetVoteRule(rule IVoteRule)
- func (r *ActorV2RuleBuilder) ValidatorRule() IConsensusValidator
- func (r *ActorV2RuleBuilder) VoteRule() IVoteRule
- type ActorV2RuleDirector
- type BFTPropose
- type BFTRequestBlock
- type BFTVote
- type BlockValidation
- type ByzantineDetector
- func (b ByzantineDetector) GetByzantineDetectorInfo() map[string]interface{}
- func (b *ByzantineDetector) Loop()
- func (b *ByzantineDetector) RemoveBlackListValidator(validator string) error
- func (b *ByzantineDetector) SetFixedNodes(fixedNodes []incognitokey.CommitteePublicKey)
- func (b *ByzantineDetector) UpdateState(finalHeight uint64, finalTimeSlot int64)
- func (b *ByzantineDetector) Validate(bestViewHeight uint64, vote *BFTVote) error
- type Chain
- type CommitteeChainHandler
- type ConsensusError
- type ConsensusValidatorLemma1
- func (c ConsensusValidatorLemma1) FilterValidProposeBlockInfo(bestViewHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, ...) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string)
- func (c ConsensusValidatorLemma1) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, ...) (bool, error)
- func (c ConsensusValidatorLemma1) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, ...) bool
- type ConsensusValidatorLemma2
- func (c ConsensusValidatorLemma2) FilterValidProposeBlockInfo(bestViewProposeHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, ...) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string)
- func (c ConsensusValidatorLemma2) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, ...) (bool, error)
- func (c ConsensusValidatorLemma2) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, ...) bool
- type ConsensusValidatorNoValidate
- func (c ConsensusValidatorNoValidate) FilterValidProposeBlockInfo(bestViewHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, ...) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string)
- func (c ConsensusValidatorNoValidate) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, ...) (bool, error)
- func (c ConsensusValidatorNoValidate) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, ...) bool
- type FinalityProof
- type HandleVoteMessage
- type IActorV2RuleBuilder
- type IConsensusValidator
- type ICreateNewBlockRule
- type IHandleVoteMessageRule
- type IInsertBlockRule
- type IProposeMessageRule
- type IVoteRule
- type InsertAndBroadcastRule
- type InsertOnlyRule
- type NoHandleProposeMessageRule
- func (n NoHandleProposeMessageRule) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error)
- func (n NoHandleProposeMessageRule) FinalityProof() map[string]map[int64]string
- func (n NoHandleProposeMessageRule) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string)
- func (n NoHandleProposeMessageRule) HandleBFTProposeMessage(env *ProposeMessageEnvironment, propose *BFTPropose) (*ProposeBlockInfo, error)
- func (n NoHandleProposeMessageRule) HandleCleanMem(finalView uint64)
- type NoHandleVoteMessage
- type NoVoteRule
- type NodeInterface
- type NormalCreateBlockRule
- type OnlyCreateBlockRule
- type POLC
- type ProposeBlockInfo
- type ProposeMessageEnvironment
- type ProposeRuleLemma1
- func (p ProposeRuleLemma1) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error)
- func (p ProposeRuleLemma1) FinalityProof() map[string]map[int64]string
- func (p ProposeRuleLemma1) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string)
- func (p ProposeRuleLemma1) HandleBFTProposeMessage(env *ProposeMessageEnvironment, propose *BFTPropose) (*ProposeBlockInfo, error)
- func (p ProposeRuleLemma1) HandleCleanMem(finalView uint64)
- type ProposeRuleLemma2
- func (p ProposeRuleLemma2) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error)
- func (p ProposeRuleLemma2) FinalityProof() map[string]map[int64]string
- func (p ProposeRuleLemma2) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string)
- func (p ProposeRuleLemma2) HandleBFTProposeMessage(env *ProposeMessageEnvironment, proposeMsg *BFTPropose) (*ProposeBlockInfo, error)
- func (p ProposeRuleLemma2) HandleCleanMem(finalView uint64)
- type ReProposeBlockInfo
- type SendProposeBlockEnvironment
- type VoteMessageEnvironment
- type VoteMessageHandler
- type VoteRule
Constants ¶
View Source
const ( UnExpectedError = iota ConsensusTypeNotExistError ProducerSignatureError CommitteeSignatureError CombineSignatureError SignDataError LoadKeyError ConsensusAlreadyStartedError ConsensusAlreadyStoppedError DecodeValidationDataError EncodeValidationDataError BlockCreationError )
View Source
const ( MSG_PROPOSE = "propose" MSG_VOTE = "vote" MsgRequestBlk = "getblk" )
Variables ¶
View Source
var ( ErrDuplicateVoteInOneTimeSlot = errors.New("duplicate vote in one timeslot") ErrVoteForHigherTimeSlot = errors.New("vote for block with same height but higher timeslot") ErrVoteForSmallerBlockHeight = errors.New("vote for block smaller block height but voted for higher block height") )
View Source
var ( VOTE_RULE_VOTE = "vote" VOTE_RULE_NO_VOTE = "no-vote" HANDLE_VOTE_MESSAGE_COLLECT = "collect-vote" HANDLE_VOTE_MESSAGE_NO_COLLECT = "no-collect-vote" CREATE_RULE_CREATE_ONLY = "create-only" CREATE_RULE_NORMAL = "create-repropose" HANDLE_PROPOSE_MESSAGE_NORMAL = "handle-propose-message" HANDLE_PROPOSEMESSAGE_NO = "no-handle-propose-message" INSERT_ONLY = "insert-only" INSERT_AND_BROADCAST = "insert-and-broadcast" VALIDATOR_NO_VALIDATE = "validator-no-validate" VALIDATOR_LEMMA2 = "validator-lemma2" )
View Source
var ActorRuleBuilderContext = &builderContext{ PreVoteRule: VOTE_RULE_VOTE, VoteRule: VOTE_RULE_VOTE, CreateRule: CREATE_RULE_NORMAL, HandleVoteRule: HANDLE_VOTE_MESSAGE_COLLECT, HandleProposeRule: HANDLE_PROPOSE_MESSAGE_NORMAL, InsertRule: INSERT_AND_BROADCAST, ValidatorRule: VALIDATOR_LEMMA2, }
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 (
MAX_FINALITY_PROOF = int64(22)
)
Functions ¶
func AddVoteByBlockHashToDB ¶
func CheckValidationDataWithCommittee ¶
func CheckValidationDataWithCommittee(valData *consensustypes.ValidationData, committee []incognitokey.CommitteePublicKey) bool
func CombineVotes ¶
func ExtractBridgeValidationData ¶
func ExtractBridgeValidationData(block types.BlockInterface) ([][]byte, []int, error)
func ExtractPortalV4ValidationData ¶
func ExtractPortalV4ValidationData(block types.BlockInterface) ([]*portalprocessv4.PortalSig, []int, error)
func GetLatestReduceFixNodeVersion ¶
func GetLatestReduceFixNodeVersion() int
func GetProposer ¶
func GetProposer( ts int64, committees []incognitokey.CommitteePublicKey, lenProposers int) (incognitokey.CommitteePublicKey, int)
func GetProposerByTimeSlot ¶
func GetProposerByTimeSlotFromCommitteeList ¶
func GetProposerByTimeSlotFromCommitteeList(ts int64, committees []incognitokey.CommitteePublicKey, numberOfFixedShardBlockValidator int) (incognitokey.CommitteePublicKey, int)
ProposerByTimeSlot ...
func GetProposerIndexByRound ¶
func InitProposeHistory ¶
func InitReceiveBlockByHash ¶
func InitReceiveBlockByHash(chainID int) (map[string]*ProposeBlockInfo, error)
func InitVoteHistory ¶
func InitVoteHistory(chainID int) (map[uint64]types.BlockInterface, error)
func NewActorV1WithValue ¶
func NewActorV2 ¶
func NewActorV2() *actorV2
func NewActorV2WithValue ¶
func NewActorV2WithValue( chain Chain, committeeChain CommitteeChainHandler, chainKey string, blockVersion, chainID int, node NodeInterface, logger common.Logger, ) *actorV2
func NewActorV3 ¶
func NewActorV3() *actorV3
func NewActorV3WithValue ¶
func NewActorV3WithValue( chain Chain, committeeChain CommitteeChainHandler, chainKey string, blockVersion, chainID int, node NodeInterface, logger common.Logger, ) *actorV3
func NewBlackListValidator ¶
func NewBlackListValidator(reason error) *rawdb_consensus.BlackListValidator
func NewConsensusError ¶
func SetBuilderContext ¶
func SetBuilderContext(lemma2Height uint64)
func ValidateCommitteeSig ¶
func ValidateCommitteeSig(block types.BlockInterface, committee []incognitokey.CommitteePublicKey, numFixNode int) error
func ValidateProducerSigV1 ¶
func ValidateProducerSigV1(block types.BlockInterface) error
func ValidateProducerSigV2 ¶
func ValidateProducerSigV2(block types.BlockInterface) error
Types ¶
type Actor ¶
type Actor interface { // GetConsensusName - retrieve consensus name GetConsensusName() string GetChainKey() string GetChainID() int // GetUserPublicKey - get user public key of loaded mining key GetUserPublicKey() *incognitokey.CommitteePublicKey // Start - start consensus Start() error // Stop - stop consensus Stop() error Destroy() // IsOngoing - check whether consensus is currently voting on a block IsStarted() bool // ProcessBFTMsg - process incoming BFT message ProcessBFTMsg(msg *wire.MessageBFT) // LoadUserKey - load user mining key LoadUserKeys(miningKey []signatureschemes2.MiningKey) // ValidateData - validate data with this consensus signature scheme ValidateData(data []byte, sig string, publicKey string) error // SignData - sign data with this consensus signature scheme SignData(data []byte) (string, error) BlockVersion() int SetBlockVersion(version int) }
Actor
func NewActorWithValue ¶
func NewActorWithValue( chain Chain, committeeChain CommitteeChainHandler, version int, chainID, blockVersion int, chainName string, node NodeInterface, logger common.Logger, ) Actor
type ActorV2RuleBuilder ¶
type ActorV2RuleBuilder struct {
// contains filtered or unexported fields
}
func NewActorV2RuleBuilder ¶
func NewActorV2RuleBuilder() *ActorV2RuleBuilder
func (*ActorV2RuleBuilder) CreateRule ¶
func (r *ActorV2RuleBuilder) CreateRule() ICreateNewBlockRule
func (*ActorV2RuleBuilder) HandleVoteMessageRule ¶
func (r *ActorV2RuleBuilder) HandleVoteMessageRule() IHandleVoteMessageRule
func (*ActorV2RuleBuilder) InsertBlockRule ¶
func (r *ActorV2RuleBuilder) InsertBlockRule() IInsertBlockRule
func (*ActorV2RuleBuilder) ProposeMessageRule ¶
func (r *ActorV2RuleBuilder) ProposeMessageRule() IProposeMessageRule
func (*ActorV2RuleBuilder) SetCreateRule ¶
func (r *ActorV2RuleBuilder) SetCreateRule(rule ICreateNewBlockRule)
func (*ActorV2RuleBuilder) SetHandleVoteMessageRule ¶
func (r *ActorV2RuleBuilder) SetHandleVoteMessageRule(rule IHandleVoteMessageRule)
func (*ActorV2RuleBuilder) SetInsertBlockRule ¶
func (r *ActorV2RuleBuilder) SetInsertBlockRule(rule IInsertBlockRule)
func (*ActorV2RuleBuilder) SetProposeMessageRule ¶
func (r *ActorV2RuleBuilder) SetProposeMessageRule(rule IProposeMessageRule)
func (*ActorV2RuleBuilder) SetValidatorRule ¶
func (r *ActorV2RuleBuilder) SetValidatorRule(validator IConsensusValidator)
func (*ActorV2RuleBuilder) SetVoteRule ¶
func (r *ActorV2RuleBuilder) SetVoteRule(rule IVoteRule)
func (*ActorV2RuleBuilder) ValidatorRule ¶
func (r *ActorV2RuleBuilder) ValidatorRule() IConsensusValidator
func (*ActorV2RuleBuilder) VoteRule ¶
func (r *ActorV2RuleBuilder) VoteRule() IVoteRule
type ActorV2RuleDirector ¶
type ActorV2RuleDirector struct {
// contains filtered or unexported fields
}
func NewActorV2RuleDirector ¶
func NewActorV2RuleDirector() *ActorV2RuleDirector
type BFTPropose ¶
type BFTPropose struct { PeerID string Block json.RawMessage ReProposeHashSignature string FinalityProof FinalityProof BestBlockConsensusData map[int]types.BlockConsensusData POLC POLC }
func CreateProposeBFTMessage ¶
func CreateProposeBFTMessage(block types.BlockInterface, peerID string) (*BFTPropose, error)
type BFTRequestBlock ¶
type BFTVote ¶
type BFTVote struct { Phase string RoundKey string PrevBlockHash string BlockHeight uint64 BlockHash string //this is propose block hash Hash string //this is block hash Validator string BLS []byte BRI []byte Confirmation []byte IsValid int // 0 not process, 1 valid, -1 not valid ProduceTimeSlot int64 ProposeTimeSlot int64 CommitteeFromBlock common.Hash ChainID int // Portal v4 PortalSigs []*portalprocessv4.PortalSig }
func CreateVote ¶
func CreateVote( chain Chain, userKey *signatureschemes2.MiningKey, block types.BlockInterface, committees []incognitokey.CommitteePublicKey, portalParamsV4 portalv4.PortalParams, ) (*BFTVote, error)
type BlockValidation ¶
type BlockValidation interface { types.BlockInterface AddValidationField(validationData string) }
type ByzantineDetector ¶
type ByzantineDetector struct {
// contains filtered or unexported fields
}
var ByzantineDetectorObject *ByzantineDetector
func NewByzantineDetector ¶
func NewByzantineDetector(logger common.Logger) *ByzantineDetector
func (ByzantineDetector) GetByzantineDetectorInfo ¶
func (b ByzantineDetector) GetByzantineDetectorInfo() map[string]interface{}
func (*ByzantineDetector) Loop ¶
func (b *ByzantineDetector) Loop()
func (*ByzantineDetector) RemoveBlackListValidator ¶
func (b *ByzantineDetector) RemoveBlackListValidator(validator string) error
func (*ByzantineDetector) SetFixedNodes ¶
func (b *ByzantineDetector) SetFixedNodes(fixedNodes []incognitokey.CommitteePublicKey)
func (*ByzantineDetector) UpdateState ¶
func (b *ByzantineDetector) UpdateState(finalHeight uint64, finalTimeSlot int64)
type Chain ¶
type Chain interface { BestViewCommitteeFromBlock() common.Hash GetMultiView() multiview.MultiView GetFinalView() multiview.View GetBestView() multiview.View GetEpoch() uint64 GetChainName() string GetConsensusType() string GetBlockConsensusData() map[int]types.BlockConsensusData GetLastBlockTimeStamp() int64 GetMinBlkInterval() time.Duration GetMaxBlkCreateTime() time.Duration IsReady() bool SetReady(bool) GetActiveShardNumber() int CurrentHeight() uint64 GetCommitteeSize() int IsBeaconChain() bool GetCommittee() []incognitokey.CommitteePublicKey GetPendingCommittee() []incognitokey.CommitteePublicKey GetPubKeyCommitteeIndex(string) int GetLastProposerIndex() int UnmarshalBlock(blockString []byte) (types.BlockInterface, error) CreateNewBlock( version int, proposer string, round int, startTime int64, committees []incognitokey.CommitteePublicKey, hash common.Hash) (types.BlockInterface, error) CreateNewBlockFromOldBlock(oldBlock types.BlockInterface, proposer string, startTime int64, isValidRePropose bool) (types.BlockInterface, error) InsertBlock(block types.BlockInterface, shouldValidate bool) error InsertAndBroadcastBlock(block types.BlockInterface) error InsertWithPrevValidationData(types.BlockInterface, string) error InsertAndBroadcastBlockWithPrevValidationData(types.BlockInterface, string) error ValidatePreSignBlock(block types.BlockInterface, signingCommittees, committees []incognitokey.CommitteePublicKey) error GetShardID() int GetChainDatabase() incdb.Database //for new syncker GetBestViewHeight() uint64 GetFinalViewHeight() uint64 GetBestViewHash() string GetFinalViewHash() string GetViewByHash(hash common.Hash) multiview.View CommitteeEngineVersion() int GetProposerByTimeSlotFromCommitteeList(ts int64, committees []incognitokey.CommitteePublicKey) (incognitokey.CommitteePublicKey, int) ReplacePreviousValidationData(previousBlockHash common.Hash, previousProposeBlockHash common.Hash, previousCommittee []incognitokey.CommitteePublicKey, newValidationData string) error // GetSigningCommitteesFromBestView must be retrieve from a shard view, because it's based on the committee state version GetSigningCommittees( proposerIndex int, committees []incognitokey.CommitteePublicKey, blockVersion int, ) []incognitokey.CommitteePublicKey GetPortalParamsV4(beaconHeight uint64) portalv4.PortalParams GetBlockByHash(hash common.Hash) (types.BlockInterface, error) CollectTxs(view multiview.View) }
type CommitteeChainHandler ¶
type CommitteeChainHandler interface { CommitteesFromViewHashForShard(committeeHash common.Hash, shardID byte) ([]incognitokey.CommitteePublicKey, error) FinalView() multiview.View }
type ConsensusError ¶
func (ConsensusError) Error ¶
func (e ConsensusError) Error() string
type ConsensusValidatorLemma1 ¶
type ConsensusValidatorLemma1 struct {
// contains filtered or unexported fields
}
func NewConsensusValidatorLemma1 ¶
func NewConsensusValidatorLemma1(logger common.Logger, chain Chain) *ConsensusValidatorLemma1
func (ConsensusValidatorLemma1) FilterValidProposeBlockInfo ¶
func (c ConsensusValidatorLemma1) FilterValidProposeBlockInfo(bestViewHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, currentTimeSlot int64, proposeBlockInfos map[string]*ProposeBlockInfo) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string)
func (ConsensusValidatorLemma1) ValidateBlock ¶
func (c ConsensusValidatorLemma1) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) (bool, error)
func (ConsensusValidatorLemma1) ValidateConsensusRules ¶
func (c ConsensusValidatorLemma1) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) bool
type ConsensusValidatorLemma2 ¶
type ConsensusValidatorLemma2 struct {
// contains filtered or unexported fields
}
func NewConsensusValidatorLemma2 ¶
func NewConsensusValidatorLemma2(logger common.Logger, chain Chain) *ConsensusValidatorLemma2
func (ConsensusValidatorLemma2) FilterValidProposeBlockInfo ¶
func (c ConsensusValidatorLemma2) FilterValidProposeBlockInfo(bestViewProposeHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, currentTimeSlot int64, proposeBlockInfos map[string]*ProposeBlockInfo) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string)
FilterValidProposeBlockInfo validate received proposed block and return valid proposed block Special case: in case block is already inserted, try to send vote (avoid slashing) 1. by pass nil block 2. just validate recently 3. not in current time slot 4. not connect to best view
func (ConsensusValidatorLemma2) ValidateBlock ¶
func (c ConsensusValidatorLemma2) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) (bool, error)
func (ConsensusValidatorLemma2) ValidateConsensusRules ¶
func (c ConsensusValidatorLemma2) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) bool
type ConsensusValidatorNoValidate ¶
type ConsensusValidatorNoValidate struct { }
func NewConsensusValidatorNoValidate ¶
func NewConsensusValidatorNoValidate() *ConsensusValidatorNoValidate
func (ConsensusValidatorNoValidate) FilterValidProposeBlockInfo ¶
func (c ConsensusValidatorNoValidate) FilterValidProposeBlockInfo(bestViewHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, currentTimeSlot int64, proposeBlockInfos map[string]*ProposeBlockInfo) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string)
func (ConsensusValidatorNoValidate) ValidateBlock ¶
func (c ConsensusValidatorNoValidate) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) (bool, error)
func (ConsensusValidatorNoValidate) ValidateConsensusRules ¶
func (c ConsensusValidatorNoValidate) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) bool
type FinalityProof ¶
type FinalityProof struct {
ReProposeHashSignature []string
}
func NewFinalityProof ¶
func NewFinalityProof() *FinalityProof
func (*FinalityProof) AddProof ¶
func (f *FinalityProof) AddProof(reProposeHashSig string)
func (*FinalityProof) GetProofByIndex ¶
func (f *FinalityProof) GetProofByIndex(index int) (string, error)
type HandleVoteMessage ¶
type HandleVoteMessage struct { }
func NewHandleVoteMessage ¶
func NewHandleVoteMessage() *HandleVoteMessage
func (HandleVoteMessage) IsHandle ¶
func (h HandleVoteMessage) IsHandle() bool
type IActorV2RuleBuilder ¶
type IActorV2RuleBuilder interface { SetProposeMessageRule(IProposeMessageRule) SetVoteRule(IVoteRule) SetCreateRule(ICreateNewBlockRule) SetValidatorRule(IConsensusValidator) SetHandleVoteMessageRule(IHandleVoteMessageRule) SetInsertBlockRule(IInsertBlockRule) ProposeMessageRule() IProposeMessageRule VoteRule() IVoteRule CreateRule() ICreateNewBlockRule ValidatorRule() IConsensusValidator HandleVoteMessageRule() IHandleVoteMessageRule InsertBlockRule() IInsertBlockRule }
type IConsensusValidator ¶
type IConsensusValidator interface { FilterValidProposeBlockInfo(bestViewHash common.Hash, bestViewHeight uint64, finalViewHeight uint64, currentTimeSlot int64, proposeBlockInfos map[string]*ProposeBlockInfo) ([]*ProposeBlockInfo, []*ProposeBlockInfo, []string) ValidateBlock(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) (bool, error) ValidateConsensusRules(lastVotedBlock types.BlockInterface, isVoteNextHeight bool, proposeBlockInfo *ProposeBlockInfo) bool }
type ICreateNewBlockRule ¶
type ICreateNewBlockRule interface { CreateBlock( b58Str string, block types.BlockInterface, committees []incognitokey.CommitteePublicKey, committeeViewHash common.Hash, isValidRePropose bool, consensusName string, blockVersion int, currentTime int64, isRePropose bool, ) (types.BlockInterface, error) }
type IHandleVoteMessageRule ¶
type IHandleVoteMessageRule interface {
IsHandle() bool
}
type IInsertBlockRule ¶
type IInsertBlockRule interface { InsertBlock(block types.BlockInterface) error InsertWithPrevValidationData(types.BlockInterface, string) error }
type IProposeMessageRule ¶
type IProposeMessageRule interface { HandleBFTProposeMessage(env *ProposeMessageEnvironment, propose *BFTPropose) (*ProposeBlockInfo, error) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string) HandleCleanMem(finalView uint64) FinalityProof() map[string]map[int64]string }
type IVoteRule ¶
type IVoteRule interface { ValidateVote(*ProposeBlockInfo) *ProposeBlockInfo CreateVote(Chain, *VoteMessageEnvironment, types.BlockInterface) (*BFTVote, error) }
type InsertAndBroadcastRule ¶
type InsertAndBroadcastRule struct {
// contains filtered or unexported fields
}
func NewInsertAndBroadcastRule ¶
func NewInsertAndBroadcastRule(chain Chain, logger common.Logger) *InsertAndBroadcastRule
func (InsertAndBroadcastRule) InsertBlock ¶
func (i InsertAndBroadcastRule) InsertBlock(block types.BlockInterface) error
func (InsertAndBroadcastRule) InsertWithPrevValidationData ¶
func (i InsertAndBroadcastRule) InsertWithPrevValidationData(blockInterface types.BlockInterface, s string) error
type InsertOnlyRule ¶
type InsertOnlyRule struct {
// contains filtered or unexported fields
}
func NewInsertOnlyRule ¶
func NewInsertOnlyRule(chain Chain, logger common.Logger) *InsertOnlyRule
func (InsertOnlyRule) InsertBlock ¶
func (i InsertOnlyRule) InsertBlock(block types.BlockInterface) error
func (InsertOnlyRule) InsertWithPrevValidationData ¶
func (i InsertOnlyRule) InsertWithPrevValidationData(blockInterface types.BlockInterface, s string) error
type NoHandleProposeMessageRule ¶
type NoHandleProposeMessageRule struct {
// contains filtered or unexported fields
}
func NewNoHandleProposeMessageRule ¶
func NewNoHandleProposeMessageRule(logger common.Logger) *NoHandleProposeMessageRule
func (NoHandleProposeMessageRule) CreateProposeBFTMessage ¶
func (n NoHandleProposeMessageRule) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error)
func (NoHandleProposeMessageRule) FinalityProof ¶
func (n NoHandleProposeMessageRule) FinalityProof() map[string]map[int64]string
func (NoHandleProposeMessageRule) GetValidFinalityProof ¶
func (n NoHandleProposeMessageRule) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string)
func (NoHandleProposeMessageRule) HandleBFTProposeMessage ¶
func (n NoHandleProposeMessageRule) HandleBFTProposeMessage(env *ProposeMessageEnvironment, propose *BFTPropose) (*ProposeBlockInfo, error)
func (NoHandleProposeMessageRule) HandleCleanMem ¶
func (n NoHandleProposeMessageRule) HandleCleanMem(finalView uint64)
type NoHandleVoteMessage ¶
type NoHandleVoteMessage struct { }
func NewNoHandleVoteMessage ¶
func NewNoHandleVoteMessage() *NoHandleVoteMessage
func (NoHandleVoteMessage) IsHandle ¶
func (h NoHandleVoteMessage) IsHandle() bool
type NoVoteRule ¶
type NoVoteRule struct {
// contains filtered or unexported fields
}
func NewNoVoteRule ¶
func NewNoVoteRule(logger common.Logger) *NoVoteRule
func (NoVoteRule) CreateVote ¶
func (i NoVoteRule) CreateVote(chain Chain, environment *VoteMessageEnvironment, block types.BlockInterface) (*BFTVote, error)
func (NoVoteRule) ValidateVote ¶
func (v NoVoteRule) ValidateVote(proposeBlockInfo *ProposeBlockInfo) *ProposeBlockInfo
type NodeInterface ¶
type NodeInterface interface { PushMessageToChain(msg wire.Message, chain common.ChainInterface) error PushBlockToAll(block types.BlockInterface, previousValidationData string, isBeacon bool) error IsEnableMining() bool GetMiningKeys() string GetPrivateKey() string GetUserMiningState() (role string, chainID int) RequestMissingViewViaStream(peerID string, hashes [][]byte, fromCID int, chainName string) (err error) GetSelfPeerID() peer.ID }
NodeInterface
type NormalCreateBlockRule ¶
type NormalCreateBlockRule struct {
// contains filtered or unexported fields
}
func NewNormalCreateBlockRule ¶
func NewNormalCreateBlockRule(logger common.Logger, chain Chain) *NormalCreateBlockRule
func (NormalCreateBlockRule) CreateBlock ¶
func (n NormalCreateBlockRule) CreateBlock( b58Str string, block types.BlockInterface, committees []incognitokey.CommitteePublicKey, committeeViewHash common.Hash, isValidRePropose bool, consensusName string, blockVersion int, currentTime int64, isRePropose bool, ) (types.BlockInterface, error)
type OnlyCreateBlockRule ¶
type OnlyCreateBlockRule struct {
// contains filtered or unexported fields
}
func NewOnlyCreateBlockRule ¶
func NewOnlyCreateBlockRule(logger common.Logger, chain Chain) *OnlyCreateBlockRule
func (OnlyCreateBlockRule) CreateBlock ¶
func (n OnlyCreateBlockRule) CreateBlock( b58Str string, block types.BlockInterface, committees []incognitokey.CommitteePublicKey, committeeViewHash common.Hash, isValidRePropose bool, consensusName string, blockVersion int, currentTime int64, isRePropose bool, ) (types.BlockInterface, error)
type ProposeBlockInfo ¶
type ProposeBlockInfo struct { ReceiveTime time.Time Committees []incognitokey.CommitteePublicKey NumberOfFixNode int SigningCommittees []incognitokey.CommitteePublicKey UserKeySet []signatureschemes2.MiningKey Votes map[string]*BFTVote //pk->BFTVote PreVotes map[string]*BFTVote //pk->BFTVote IsValid bool HasNewPreVote bool HasNewVote bool IsVoted bool IsPreVoted bool IsCommitted bool ValidPreVotes int ErrPreVotes int ValidVotes int ErrVotes int ProposerSendPreVote bool ProposerSendVote bool ProposerMiningKeyBase58 string LastValidateTime time.Time ReProposeHashSignature string IsValidLemma2Proof bool FinalityProof FinalityProof ValidPOLC bool // contains filtered or unexported fields }
func NewProposeBlockInfo ¶
func NewProposeBlockInfo() *ProposeBlockInfo
func (*ProposeBlockInfo) MarshalJSON ¶
func (p *ProposeBlockInfo) MarshalJSON() ([]byte, error)
func (*ProposeBlockInfo) UnmarshalJSON ¶
func (p *ProposeBlockInfo) UnmarshalJSON(data []byte) error
func (*ProposeBlockInfo) ValidateFixNodeMajority ¶
func (p *ProposeBlockInfo) ValidateFixNodeMajority() bool
type ProposeMessageEnvironment ¶
type ProposeMessageEnvironment struct { NumberOfFixedShardBlockValidator int // contains filtered or unexported fields }
func NewProposeMessageEnvironment ¶
func NewProposeMessageEnvironment(block types.BlockInterface, previousBlock types.BlockInterface, committees []incognitokey.CommitteePublicKey, signingCommittees []incognitokey.CommitteePublicKey, userKeySet []signatureschemes2.MiningKey, numberOfFixedShardBlockValidator int, proposerPublicBLSMiningKey string) *ProposeMessageEnvironment
type ProposeRuleLemma1 ¶
type ProposeRuleLemma1 struct {
// contains filtered or unexported fields
}
func NewProposeRuleLemma1 ¶
func NewProposeRuleLemma1(logger common.Logger) *ProposeRuleLemma1
func (ProposeRuleLemma1) CreateProposeBFTMessage ¶
func (p ProposeRuleLemma1) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error)
func (ProposeRuleLemma1) FinalityProof ¶
func (p ProposeRuleLemma1) FinalityProof() map[string]map[int64]string
func (ProposeRuleLemma1) GetValidFinalityProof ¶
func (p ProposeRuleLemma1) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string)
func (ProposeRuleLemma1) HandleBFTProposeMessage ¶
func (p ProposeRuleLemma1) HandleBFTProposeMessage(env *ProposeMessageEnvironment, propose *BFTPropose) (*ProposeBlockInfo, error)
func (ProposeRuleLemma1) HandleCleanMem ¶
func (p ProposeRuleLemma1) HandleCleanMem(finalView uint64)
type ProposeRuleLemma2 ¶
type ProposeRuleLemma2 struct {
// contains filtered or unexported fields
}
func NewProposeRuleLemma2 ¶
func (ProposeRuleLemma2) CreateProposeBFTMessage ¶
func (p ProposeRuleLemma2) CreateProposeBFTMessage(env *SendProposeBlockEnvironment, block types.BlockInterface) (*BFTPropose, error)
func (ProposeRuleLemma2) FinalityProof ¶
func (p ProposeRuleLemma2) FinalityProof() map[string]map[int64]string
func (ProposeRuleLemma2) GetValidFinalityProof ¶
func (p ProposeRuleLemma2) GetValidFinalityProof(block types.BlockInterface, currentTimeSlot int64) (*FinalityProof, bool, string)
func (ProposeRuleLemma2) HandleBFTProposeMessage ¶
func (p ProposeRuleLemma2) HandleBFTProposeMessage(env *ProposeMessageEnvironment, proposeMsg *BFTPropose) (*ProposeBlockInfo, error)
func (ProposeRuleLemma2) HandleCleanMem ¶
func (p ProposeRuleLemma2) HandleCleanMem(finalView uint64)
type ReProposeBlockInfo ¶
type ReProposeBlockInfo struct { PreviousBlockHash common.Hash Producer string ProducerTimeSlot int64 Proposer string ProposerTimeSlot int64 RootHash common.Hash }
previousblockhash, producerTimeslot, Producer, proposerTimeslot, Proposer roothash
func (ReProposeBlockInfo) Hash ¶
func (r ReProposeBlockInfo) Hash() common.Hash
func (ReProposeBlockInfo) Sign ¶
func (r ReProposeBlockInfo) Sign(privateKey []byte) (string, error)
func (ReProposeBlockInfo) VerifySignature ¶
func (r ReProposeBlockInfo) VerifySignature(sigBase58 string, publicKey []byte) (bool, error)
type SendProposeBlockEnvironment ¶
type SendProposeBlockEnvironment struct {
// contains filtered or unexported fields
}
func NewSendProposeBlockEnvironment ¶
func NewSendProposeBlockEnvironment(finalityProof *FinalityProof, isValidRePropose bool, userProposeKey signatureschemes2.MiningKey, peerID string, consensusData map[int]types.BlockConsensusData) *SendProposeBlockEnvironment
type VoteMessageEnvironment ¶
type VoteMessageEnvironment struct {
// contains filtered or unexported fields
}
func NewVoteMessageEnvironment ¶
func NewVoteMessageEnvironment(userKey *signatureschemes2.MiningKey, signingCommittees []incognitokey.CommitteePublicKey, portalParamV4 portalv4.PortalParams) *VoteMessageEnvironment
type VoteMessageHandler ¶
type VoteRule ¶
type VoteRule struct {
// contains filtered or unexported fields
}
func NewVoteRule ¶
func (VoteRule) CreateVote ¶
func (v VoteRule) CreateVote(chain Chain, env *VoteMessageEnvironment, block types.BlockInterface) (*BFTVote, error)
func (VoteRule) ValidateVote ¶
func (v VoteRule) ValidateVote(proposeBlockInfo *ProposeBlockInfo) *ProposeBlockInfo
Source Files ¶
- actor_base.go
- actor_v1.go
- actor_v2.go
- actor_v2_byzantine_detector.go
- actor_v2_rule_builder.go
- actor_v2_rule_create.go
- actor_v2_rule_propose.go
- actor_v2_rule_validator.go
- actor_v2_rule_vote.go
- actor_v3.go
- actor_v3_commit.go
- actor_v3_prevote.go
- actor_v3_propose.go
- actor_v3_vote.go
- block_info.go
- constants.go
- error.go
- interface.go
- message.go
- validation.go
Click to show internal directories.
Click to hide internal directories.