memberchecker

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Membercheckers are responsible for tracking who can participate in consensus by having a list of their public keys. Membership can change on each iteration of consenus depding on the implementation of the application and memberchecker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitBinRotateMemberChecker

func InitBinRotateMemberChecker(myPriv sig.Priv, gc *generalconfig.GeneralConfig) consinterface.MemberChecker

func InitCurrentTrueMemberChecker

func InitCurrentTrueMemberChecker(localRand *rand.Rand, rotateCord bool, rndMemberCount int,
	rndMemberType types.RndMemberType, localRandChangeFrequency types.ConsensusInt, priv sig.Priv,
	gc *generalconfig.GeneralConfig) consinterface.MemberChecker

func InitLaterMemberChecker

func InitLaterMemberChecker(localRand *rand.Rand, rotateCord bool, rndMemberCount int,
	rndMemberType types.RndMemberType, localRandChangeFrequency types.ConsensusInt, priv sig.Priv,
	gc *generalconfig.GeneralConfig) consinterface.MemberChecker

func InitTrueMemberChecker

func InitTrueMemberChecker(rotateCord bool, myPriv sig.Priv, gc *generalconfig.GeneralConfig) consinterface.MemberChecker

Types

type AbsRandLocalKnownMemberChecker

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

AbsRandLocalKnownMemberChecker uses a set of locally chosen member for the consensus.

func (*AbsRandLocalKnownMemberChecker) GetRnd

func (arm *AbsRandLocalKnownMemberChecker) GetRnd() (ret [32]byte)

func (*AbsRandLocalKnownMemberChecker) GotVrf

func (arm *AbsRandLocalKnownMemberChecker) GotVrf(pub sig.Pub, isProposal bool, msgID messages.MsgID, vrf sig.VRFProof) error

type BinRotateMemberChecker

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

BinRotateMemberChecker rotates consensus members based on the decided value. If absMemberChecker.AddPubKeys was called with len(keys) > membercount, then this member checker has the list of cons members for the next consensus instance rotate by one position (of the list of all participants) each time 0 is decided by consensus. Any other decided value keeps the members the same.

func (*BinRotateMemberChecker) AbsGotDecision

func (mc *BinRotateMemberChecker) AbsGotDecision(newFixedCoord sig.Pub, newMemberPubs, newOtherPubs sig.PubList,
	prevDec []byte, randBytes [32]byte, prevMember *absMemberChecker) (retMemberPubs, retAllPubs []sig.Pub,
	changedMembers bool)

AbsGotDecision should be called at the end of UpdateState from the MemberChecker. The newAllPubs is a list of all new pubs in the system (note this list does not need to be sorted as it will be sorted here). If it is nil then the set of pubs must have not changed since the last consensus instance. These pubs will be sorted and returned to insure that their new ids are computed correctly. newMemberPubs pubs are the public keys that will now participate in consensus. newMemberPubs must be a equal to or a subset of newAllPubs. newMemberPubs should also be nil if they have not changed since the previous consensus index. myPubIndex is the index of the local nodes public key in the list, if it is negative then this nodes public key should not be in the list (i.e. is not a member). ChangedMembers must be true if either of the other return values are non-nil. Even if they are nil, but the membership could have changed in a different way (i.e. by random membership) it must return true

func (*BinRotateMemberChecker) AddPubKeys

func (mc *BinRotateMemberChecker) AddPubKeys(fixedCoord sig.Pub, memberPubKeys, otherPubs sig.PubList, initRandBytes [32]byte,
	shared *consinterface.Shared)

AddPubKeys is used for adding the public keys to the very inital member checker, and should not be called on later member checkers, as they should change pub keys through the call to UpdateState. allPubs are the list of all pubs in the system. memberPubs pubs are the public keys that will now participate in consensus. memberPubs must be equal to or a subset of newAllPubs. If shared is non-nil then the local nodes on the machine will share the same initial member objects (to save memory for experiments that run many nodes on the same machine).

func (*BinRotateMemberChecker) AllowsChange

func (mc *BinRotateMemberChecker) AllowsChange() bool

func (*BinRotateMemberChecker) CheckEstimatedRoundCoordNextIndex

func (mc *BinRotateMemberChecker) CheckEstimatedRoundCoordNextIndex(checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckEstimatedRoundCoordNextIndex returns the estimated public key of the coordinator for round round for the following consensus index. It might not return the correct coordinator for the next index because the decision might change the membership for the next index. This function should not be used if it needs to know the next coordinator for certain. It returns an error if there is a fixed cordinator or random membership is enabled as it is unsupported in these cases.

func (*BinRotateMemberChecker) CheckFixedCoord

func (mc *BinRotateMemberChecker) CheckFixedCoord(pub sig.Pub) (coordPub sig.Pub, err error)

CheckFixedCoord checks if checkPub the/a coordinator for round. If it is, err is returned as nil, otherwise an error is returned. If checkPub is nil, then it will return the fixed coordinator in coordPub. If there is no fixedCoordinator, then an error types.ErrNoFixedCoord is returned. Note this should only be called after the pub is verified to be a member with CheckMemberBytes

func (*BinRotateMemberChecker) CheckIndex

func (mc *BinRotateMemberChecker) CheckIndex(idx types.ConsensusIndex) bool

CheckIndex should return true if the index is the same as the one used in New, it is for testing.

func (*BinRotateMemberChecker) CheckMemberBytes

func (mc *BinRotateMemberChecker) CheckMemberBytes(idx types.ConsensusIndex, pubBytes sig.PubKeyID) sig.Pub

CheckMemberBytes checks the the pub key is a member and returns corresponding pub key object

func (*BinRotateMemberChecker) CheckRandMember

func (mc *BinRotateMemberChecker) CheckRandMember(pub sig.Pub, hdr messages.InternalSignedMsgHeader, msgID messages.MsgID,
	isLocal bool) error

CheckRandMember can be called after CheckMemberBytes is successful when ChooseRandomMember is enabled. If ChooseRandomMember is false it return nil, otherwise it uses the random bytes and the VRF to decide if this pud is a random member.

func (*BinRotateMemberChecker) CheckRandRoundCoord

func (mc *BinRotateMemberChecker) CheckRandRoundCoord(msgID messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (randValue uint64, coordPub sig.Pub, err error)

CheckRandRoundCoord is unsupported.

func (*BinRotateMemberChecker) CheckRoundCoord

func (mc *BinRotateMemberChecker) CheckRoundCoord(msgID messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

GetRoundCoord returns the public key of the coordinator for round round. It is just the mod of the round in the sorted list of public keys.

func (*BinRotateMemberChecker) DoneNextUpdateState

func (mc *BinRotateMemberChecker) DoneNextUpdateState() error

func (*BinRotateMemberChecker) FinishUpdateState

func (mc *BinRotateMemberChecker) FinishUpdateState()

FinishUpdateState sets the member checker to ready.

func (*BinRotateMemberChecker) GetAllPubs

func (mc *BinRotateMemberChecker) GetAllPubs() sig.PubList

GetAllPub returns all pubs in the system

func (*BinRotateMemberChecker) GetFaultCount

func (mc *BinRotateMemberChecker) GetFaultCount() int

GetFaultCount returns the number of possilbe faultly nodes that the consensus can handle.

func (*BinRotateMemberChecker) GetIndex

func (mc *BinRotateMemberChecker) GetIndex() types.ConsensusIndex

func (*BinRotateMemberChecker) GetMemberCount

func (mc *BinRotateMemberChecker) GetMemberCount() int

GetMemberCount returns the number of consensus members.

func (*BinRotateMemberChecker) GetMyPriv

func (mc *BinRotateMemberChecker) GetMyPriv() sig.Priv

GetMyPriv returns the local node's private key.

func (*BinRotateMemberChecker) GetMyVRF

func (mc *BinRotateMemberChecker) GetMyVRF(isProposal bool, id messages.MsgID) sig.VRFProof

func (*BinRotateMemberChecker) GetNewPub

func (mc *BinRotateMemberChecker) GetNewPub() sig.Pub

GetNewPub returns an empty public key object.

func (*BinRotateMemberChecker) GetParticipantCount

func (mc *BinRotateMemberChecker) GetParticipantCount() int

GetParticipantCount returns the total number of nodes in the system

func (*BinRotateMemberChecker) GetParticipants

func (mc *BinRotateMemberChecker) GetParticipants() sig.PubList

GetParticipant return the pub key of the participants.

func (*BinRotateMemberChecker) GetRnd

func (mc *BinRotateMemberChecker) GetRnd() (ret [32]byte)

func (*BinRotateMemberChecker) GetStats

func (mc *BinRotateMemberChecker) GetStats() stats.StatsInterface

func (*BinRotateMemberChecker) Invalidated

func (mc *BinRotateMemberChecker) Invalidated() error

Invalidated is called if the member checker has been made invalid. This happens if a different set of members was chosen then was initial proposed.

func (*BinRotateMemberChecker) IsReady

func (mc *BinRotateMemberChecker) IsReady() bool

IsReady returns false until FinishUpdateState is called.

func (*BinRotateMemberChecker) New

New generates a new member checker for the index, this is called on the inital member checker each time.

func (*BinRotateMemberChecker) RandMemberType

func (mc *BinRotateMemberChecker) RandMemberType() types.RndMemberType

SelectRandMembers returns true if the member checker is selecting random members.

func (*BinRotateMemberChecker) SetMainChannel

func (mc *BinRotateMemberChecker) SetMainChannel(mainChannel channelinterface.MainChannel)

SetMainChannel is called on the initial member checker to inform it of the network channel object

func (*BinRotateMemberChecker) UpdateState

func (mc *BinRotateMemberChecker) UpdateState(fixedCoord sig.Pub, prevDec []byte, randBytes [32]byte,
	prevMember consinterface.MemberChecker, prevSM consinterface.GeneralStateMachineInterface,
	futureFixed types.ConsensusID) (newMemberPubs,
	newAllPubs []sig.Pub, changedMembers bool)

Update state computes the new members, in case 0 was decided, then they rotate by one from the list of all public keys (see BinRotateMemberChecker struct description). func (mc *BinRotateMemberChecker) UpdateState(prevDec []byte, prevSM consinterface.StateMachineInterface, prevMember MemberChecker) []sig.Pub {

func (*BinRotateMemberChecker) Validated

func (mc *BinRotateMemberChecker) Validated(signType types.SignType)

ValidatedItem is called for stats to let it know a signature was validated. TODO cleanup.

type CurrentTrueMemberChecker

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

CurrentTrueMemberChecker is the same as TrueMemberChecker, except IsReady returns true only once FinishUpdateState has been called. It is just for testing

func (*CurrentTrueMemberChecker) AbsGotDecision

func (mc *CurrentTrueMemberChecker) AbsGotDecision(newFixedCoord sig.Pub, newMemberPubs, newOtherPubs sig.PubList,
	prevDec []byte, randBytes [32]byte, prevMember *absMemberChecker) (retMemberPubs, retAllPubs []sig.Pub,
	changedMembers bool)

AbsGotDecision should be called at the end of UpdateState from the MemberChecker. The newAllPubs is a list of all new pubs in the system (note this list does not need to be sorted as it will be sorted here). If it is nil then the set of pubs must have not changed since the last consensus instance. These pubs will be sorted and returned to insure that their new ids are computed correctly. newMemberPubs pubs are the public keys that will now participate in consensus. newMemberPubs must be a equal to or a subset of newAllPubs. newMemberPubs should also be nil if they have not changed since the previous consensus index. myPubIndex is the index of the local nodes public key in the list, if it is negative then this nodes public key should not be in the list (i.e. is not a member). ChangedMembers must be true if either of the other return values are non-nil. Even if they are nil, but the membership could have changed in a different way (i.e. by random membership) it must return true

func (*CurrentTrueMemberChecker) AddPubKeys

func (mc *CurrentTrueMemberChecker) AddPubKeys(fixedCoord sig.Pub, memberPubKeys, otherPubs sig.PubList, initRandBytes [32]byte,
	shared *consinterface.Shared)

AddPubKeys is used for adding the public keys to the very inital member checker, and should not be called on later member checkers, as they should change pub keys through the call to UpdateState. allPubs are the list of all pubs in the system. memberPubs pubs are the public keys that will now participate in consensus. memberPubs must be equal to or a subset of newAllPubs. If shared is non-nil then the local nodes on the machine will share the same initial member objects (to save memory for experiments that run many nodes on the same machine).

func (*CurrentTrueMemberChecker) AllowsChange

func (mc *CurrentTrueMemberChecker) AllowsChange() bool

AllowsChange returns true if the member checker allows changing members, used as a sanity check.

func (*CurrentTrueMemberChecker) CheckEstimatedRoundCoordNextIndex

func (mc *CurrentTrueMemberChecker) CheckEstimatedRoundCoordNextIndex(checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckEstimatedRoundCoordNextIndex returns the estimated public key of the coordinator for round round for the following consensus index. It might not return the correct coordinator for the next index because the decision might change the membership for the next index. This function should not be used if it needs to know the next coordinator for certain. It returns an error if there is a fixed cordinator or random membership is enabled as it is unsupported in these cases.

func (*CurrentTrueMemberChecker) CheckFixedCoord

func (mc *CurrentTrueMemberChecker) CheckFixedCoord(pub sig.Pub) (coordPub sig.Pub, err error)

CheckFixedCoord checks if checkPub the/a coordinator for round. If it is, err is returned as nil, otherwise an error is returned. If checkPub is nil, then it will return the fixed coordinator in coordPub. If there is no fixedCoordinator, then an error types.ErrNoFixedCoord is returned. Note this should only be called after the pub is verified to be a member with CheckMemberBytes

func (*CurrentTrueMemberChecker) CheckIndex

func (mc *CurrentTrueMemberChecker) CheckIndex(idx types.ConsensusIndex) bool

CheckIndex should return true if the index is the same as the one used in New, it is for testing.

func (*CurrentTrueMemberChecker) CheckMemberBytes

func (mc *CurrentTrueMemberChecker) CheckMemberBytes(idx types.ConsensusIndex, pubBytes sig.PubKeyID) sig.Pub

CheckMemberBytes checks the the pub key is a member and returns corresponding pub key object

func (*CurrentTrueMemberChecker) CheckRandMember

func (mc *CurrentTrueMemberChecker) CheckRandMember(pub sig.Pub, hdr messages.InternalSignedMsgHeader, msgID messages.MsgID,
	isLocal bool) error

CheckRandMember can be called after CheckMemberBytes is successful when ChooseRandomMember is enabled. If ChooseRandomMember is false it return nil, otherwise it uses the random bytes and the VRF to decide if this pud is a random member.

func (*CurrentTrueMemberChecker) CheckRandRoundCoord

func (mc *CurrentTrueMemberChecker) CheckRandRoundCoord(msgID messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (randValue uint64, coordPub sig.Pub, err error)

CheckRandRoundCoord should be called instead of CheckRoundCoord if random membership selection is enabled. If using VRFs then checkPub must not be nil. If checkPub is nil, then it will return the known coordinator in coordPub. If VRF is enabled randValue is the VRF random value for the inputs. Note this should be called after CheckRandMember for the same pub.

func (*CurrentTrueMemberChecker) CheckRoundCoord

func (mc *CurrentTrueMemberChecker) CheckRoundCoord(_ messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckRoundCoord returns the public key of the coordinator for round round. It is just the mod of the round in the sorted list of public keys.

func (*CurrentTrueMemberChecker) DoneNextUpdateState

func (mc *CurrentTrueMemberChecker) DoneNextUpdateState() error

func (*CurrentTrueMemberChecker) FinishUpdateState

func (mc *CurrentTrueMemberChecker) FinishUpdateState()

FinishUpdateState sets the member checker to ready.

func (*CurrentTrueMemberChecker) GetAllPubs

func (mc *CurrentTrueMemberChecker) GetAllPubs() sig.PubList

GetAllPub returns all pubs in the system

func (*CurrentTrueMemberChecker) GetFaultCount

func (mc *CurrentTrueMemberChecker) GetFaultCount() int

GetFaultCount returns the number of possilbe faultly nodes that the consensus can handle.

func (*CurrentTrueMemberChecker) GetIndex

func (mc *CurrentTrueMemberChecker) GetIndex() types.ConsensusIndex

func (*CurrentTrueMemberChecker) GetMemberCount

func (mc *CurrentTrueMemberChecker) GetMemberCount() int

GetMemberCount returns the number of consensus members.

func (*CurrentTrueMemberChecker) GetMyPriv

func (mc *CurrentTrueMemberChecker) GetMyPriv() sig.Priv

GetMyPriv returns the local node's private key.

func (*CurrentTrueMemberChecker) GetMyVRF

func (mc *CurrentTrueMemberChecker) GetMyVRF(isProposal bool, id messages.MsgID) sig.VRFProof

func (*CurrentTrueMemberChecker) GetNewPub

func (mc *CurrentTrueMemberChecker) GetNewPub() sig.Pub

GetNewPub returns an empty public key object.

func (*CurrentTrueMemberChecker) GetParticipantCount

func (mc *CurrentTrueMemberChecker) GetParticipantCount() int

GetParticipantCount returns the total number of nodes in the system

func (*CurrentTrueMemberChecker) GetParticipants

func (mc *CurrentTrueMemberChecker) GetParticipants() sig.PubList

GetParticipant return the pub key of the participants.

func (*CurrentTrueMemberChecker) GetRnd

func (mc *CurrentTrueMemberChecker) GetRnd() (ret [32]byte)

func (*CurrentTrueMemberChecker) GetStats

func (mc *CurrentTrueMemberChecker) GetStats() stats.StatsInterface

func (*CurrentTrueMemberChecker) Invalidated

func (mc *CurrentTrueMemberChecker) Invalidated() error

Invalidated is called if the member checker has been made invalid. This happens if a different set of members was chosen then was initial proposed.

func (*CurrentTrueMemberChecker) IsReady

func (mc *CurrentTrueMemberChecker) IsReady() bool

IsReady returns false until FinishUpdateState is called.

func (*CurrentTrueMemberChecker) New

New generates a new member checker for the index, this is called on the inital member checker each time.

func (*CurrentTrueMemberChecker) RandMemberType

func (mc *CurrentTrueMemberChecker) RandMemberType() types.RndMemberType

SelectRandMembers returns true if the member checker is selecting random members.

func (*CurrentTrueMemberChecker) SetMainChannel

func (mc *CurrentTrueMemberChecker) SetMainChannel(mainChannel channelinterface.MainChannel)

SetMainChannel is called on the initial member checker to inform it of the network channel object

func (*CurrentTrueMemberChecker) UpdateState

func (mc *CurrentTrueMemberChecker) UpdateState(fixedCoord sig.Pub, prevDec []byte, randBytes [32]byte,
	prevMember consinterface.MemberChecker, prevSM consinterface.GeneralStateMachineInterface,
	futureFixed types.ConsensusID) (newMemberPubs,
	newAllPubs []sig.Pub, changedMembers bool)

UpdateState does nothing since the members do not change. func (mc *CurrentTrueMemberChecker) UpdateState(prevDec []byte, prevSM consinterface.StateMachineInterface, prevMember MemberChecker) []sig.Pub {

func (*CurrentTrueMemberChecker) Validated

func (mc *CurrentTrueMemberChecker) Validated(signType types.SignType)

ValidatedItem is called for stats to let it know a signature was validated. TODO cleanup.

type CustomMemberChecker

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

CustomMemberChecker is intended to extended to be used as a custom member checker associated with a state machine.

func InitCustomMemberChecker

func InitCustomMemberChecker(localRand *rand.Rand, rotateCord bool, rndMemberCount int,
	rndMemberType types.RndMemberType, localRandChangeFrequency types.ConsensusInt, priv sig.Priv,
	gc *generalconfig.GeneralConfig) *CustomMemberChecker

InitCustomMemberChecker initiates a CustomMemberChecker object.

func (*CustomMemberChecker) AbsGotDecision

func (mc *CustomMemberChecker) AbsGotDecision(newFixedCoord sig.Pub, newMemberPubs, newOtherPubs sig.PubList,
	prevDec []byte, randBytes [32]byte, prevMember *absMemberChecker) (retMemberPubs, retAllPubs []sig.Pub,
	changedMembers bool)

AbsGotDecision should be called at the end of UpdateState from the MemberChecker. The newAllPubs is a list of all new pubs in the system (note this list does not need to be sorted as it will be sorted here). If it is nil then the set of pubs must have not changed since the last consensus instance. These pubs will be sorted and returned to insure that their new ids are computed correctly. newMemberPubs pubs are the public keys that will now participate in consensus. newMemberPubs must be a equal to or a subset of newAllPubs. newMemberPubs should also be nil if they have not changed since the previous consensus index. myPubIndex is the index of the local nodes public key in the list, if it is negative then this nodes public key should not be in the list (i.e. is not a member). ChangedMembers must be true if either of the other return values are non-nil. Even if they are nil, but the membership could have changed in a different way (i.e. by random membership) it must return true

func (*CustomMemberChecker) AddPubKeys

func (mc *CustomMemberChecker) AddPubKeys(fixedCoord sig.Pub, memberPubKeys, otherPubs sig.PubList, initRandBytes [32]byte,
	shared *consinterface.Shared)

AddPubKeys is used for adding the public keys to the very inital member checker, and should not be called on later member checkers, as they should change pub keys through the call to UpdateState. allPubs are the list of all pubs in the system. memberPubs pubs are the public keys that will now participate in consensus. memberPubs must be equal to or a subset of newAllPubs. If shared is non-nil then the local nodes on the machine will share the same initial member objects (to save memory for experiments that run many nodes on the same machine).

func (*CustomMemberChecker) CheckEstimatedRoundCoordNextIndex

func (mc *CustomMemberChecker) CheckEstimatedRoundCoordNextIndex(checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckEstimatedRoundCoordNextIndex returns the estimated public key of the coordinator for round round for the following consensus index. It might not return the correct coordinator for the next index because the decision might change the membership for the next index. This function should not be used if it needs to know the next coordinator for certain. It returns an error if there is a fixed cordinator or random membership is enabled as it is unsupported in these cases.

func (*CustomMemberChecker) CheckFixedCoord

func (mc *CustomMemberChecker) CheckFixedCoord(pub sig.Pub) (coordPub sig.Pub, err error)

CheckFixedCoord checks if checkPub the/a coordinator for round. If it is, err is returned as nil, otherwise an error is returned. If checkPub is nil, then it will return the fixed coordinator in coordPub. If there is no fixedCoordinator, then an error types.ErrNoFixedCoord is returned. Note this should only be called after the pub is verified to be a member with CheckMemberBytes

func (*CustomMemberChecker) CheckIndex

func (mc *CustomMemberChecker) CheckIndex(idx types.ConsensusIndex) bool

CheckIndex should return true if the index is the same as the one used in New, it is for testing.

func (*CustomMemberChecker) CheckMemberBytes

func (mc *CustomMemberChecker) CheckMemberBytes(idx types.ConsensusIndex, pubBytes sig.PubKeyID) sig.Pub

CheckMemberBytes checks the the pub key is a member and returns corresponding pub key object

func (*CustomMemberChecker) CheckRandMember

func (mc *CustomMemberChecker) CheckRandMember(pub sig.Pub, hdr messages.InternalSignedMsgHeader, msgID messages.MsgID,
	isLocal bool) error

CheckRandMember can be called after CheckMemberBytes is successful when ChooseRandomMember is enabled. If ChooseRandomMember is false it return nil, otherwise it uses the random bytes and the VRF to decide if this pud is a random member.

func (*CustomMemberChecker) CheckRandRoundCoord

func (mc *CustomMemberChecker) CheckRandRoundCoord(msgID messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (randValue uint64, coordPub sig.Pub, err error)

CheckRandRoundCoord should be called instead of CheckRoundCoord if random membership selection is enabled. If using VRFs then checkPub must not be nil. If checkPub is nil, then it will return the known coordinator in coordPub. If VRF is enabled randValue is the VRF random value for the inputs. Note this should be called after CheckRandMember for the same pub.

func (*CustomMemberChecker) CheckRoundCoord

func (mc *CustomMemberChecker) CheckRoundCoord(_ messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckRoundCoord returns the public key of the coordinator for round round. It is just the mod of the round in the sorted list of public keys.

func (*CustomMemberChecker) DoneNextUpdateState

func (mc *CustomMemberChecker) DoneNextUpdateState() error

func (*CustomMemberChecker) FinishUpdateState

func (mc *CustomMemberChecker) FinishUpdateState()

FinishUpdateState sets the member checker to ready.

func (*CustomMemberChecker) GetAllPubs

func (mc *CustomMemberChecker) GetAllPubs() sig.PubList

GetAllPub returns all pubs in the system

func (*CustomMemberChecker) GetFaultCount

func (mc *CustomMemberChecker) GetFaultCount() int

GetFaultCount returns the number of possilbe faultly nodes that the consensus can handle.

func (*CustomMemberChecker) GetIndex

func (mc *CustomMemberChecker) GetIndex() types.ConsensusIndex

func (*CustomMemberChecker) GetMemberCount

func (mc *CustomMemberChecker) GetMemberCount() int

GetMemberCount returns the number of consensus members.

func (*CustomMemberChecker) GetMyPriv

func (mc *CustomMemberChecker) GetMyPriv() sig.Priv

GetMyPriv returns the local node's private key.

func (*CustomMemberChecker) GetMyVRF

func (mc *CustomMemberChecker) GetMyVRF(isProposal bool, id messages.MsgID) sig.VRFProof

func (*CustomMemberChecker) GetNewPub

func (mc *CustomMemberChecker) GetNewPub() sig.Pub

GetNewPub returns an empty public key object.

func (*CustomMemberChecker) GetParticipantCount

func (mc *CustomMemberChecker) GetParticipantCount() int

GetParticipantCount returns the total number of nodes in the system

func (*CustomMemberChecker) GetParticipants

func (mc *CustomMemberChecker) GetParticipants() sig.PubList

GetParticipant return the pub key of the participants.

func (*CustomMemberChecker) GetRnd

func (mc *CustomMemberChecker) GetRnd() (ret [32]byte)

func (*CustomMemberChecker) GetStats

func (mc *CustomMemberChecker) GetStats() stats.StatsInterface

func (*CustomMemberChecker) Invalidated

func (mc *CustomMemberChecker) Invalidated() error

Invalidated is called if the member checker has been made invalid. This happens if a different set of members was chosen then was initial proposed.

func (*CustomMemberChecker) IsReady

func (mc *CustomMemberChecker) IsReady() bool

IsReady returns false until FinishUpdateState is called.

func (*CustomMemberChecker) New

New generates a new member checker for the index, this is called on the inital member checker each time.

func (*CustomMemberChecker) RandMemberType

func (mc *CustomMemberChecker) RandMemberType() types.RndMemberType

SelectRandMembers returns true if the member checker is selecting random members.

func (*CustomMemberChecker) SetMainChannel

func (mc *CustomMemberChecker) SetMainChannel(mainChannel channelinterface.MainChannel)

SetMainChannel is called on the initial member checker to inform it of the network channel object

func (*CustomMemberChecker) UpdateState

func (mc *CustomMemberChecker) UpdateState(fixedCoord sig.Pub, prevDec []byte, randBytes [32]byte,
	prevMember *CustomMemberChecker, newMemberPubs, newAllPubs []sig.Pub) (sig.PubList, sig.PubList, bool)

UpdateState does nothing since the members do not change. func (mc *CustomMemberChecker) UpdateState(prevDec []byte, prevSM consinterface.StateMachineInterface, prevMember MemberChecker) []sig.Pub {

func (*CustomMemberChecker) Validated

func (mc *CustomMemberChecker) Validated(signType types.SignType)

ValidatedItem is called for stats to let it know a signature was validated. TODO cleanup.

type LaterMemberChecker

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

LaterMemberChecker is used for consensus algorithms that piggyback consensus messages on later consensus instances, so that when a decision happens the members are changed not on the index that was decided, but on a future one. As returned by GetDecision() from the consinterface.ConsItem interface. The consensus instance starts with IsReady=true. When UpdateState is called, the previous consensus index member checker that received a non nil decision is input.

func (*LaterMemberChecker) AbsGotDecision

func (mc *LaterMemberChecker) AbsGotDecision(newFixedCoord sig.Pub, newMemberPubs, newOtherPubs sig.PubList,
	prevDec []byte, randBytes [32]byte, prevMember *absMemberChecker) (retMemberPubs, retAllPubs []sig.Pub,
	changedMembers bool)

AbsGotDecision should be called at the end of UpdateState from the MemberChecker. The newAllPubs is a list of all new pubs in the system (note this list does not need to be sorted as it will be sorted here). If it is nil then the set of pubs must have not changed since the last consensus instance. These pubs will be sorted and returned to insure that their new ids are computed correctly. newMemberPubs pubs are the public keys that will now participate in consensus. newMemberPubs must be a equal to or a subset of newAllPubs. newMemberPubs should also be nil if they have not changed since the previous consensus index. myPubIndex is the index of the local nodes public key in the list, if it is negative then this nodes public key should not be in the list (i.e. is not a member). ChangedMembers must be true if either of the other return values are non-nil. Even if they are nil, but the membership could have changed in a different way (i.e. by random membership) it must return true

func (*LaterMemberChecker) AddPubKeys

func (mc *LaterMemberChecker) AddPubKeys(fixedCoord sig.Pub, memberPubKeys, otherPubs sig.PubList, initRandBytes [32]byte,
	shared *consinterface.Shared)

AddPubKeys is used for adding the public keys to the very inital member checker, and should not be called on later member checkers, as they should change pub keys through the call to UpdateState. allPubs are the list of all pubs in the system. memberPubs pubs are the public keys that will now participate in consensus. memberPubs must be equal to or a subset of newAllPubs. If shared is non-nil then the local nodes on the machine will share the same initial member objects (to save memory for experiments that run many nodes on the same machine).

func (*LaterMemberChecker) AllowsChange

func (mc *LaterMemberChecker) AllowsChange() bool

AllowsChange returns true if the member checker allows changing members, used as a sanity check.

func (*LaterMemberChecker) CheckEstimatedRoundCoordNextIndex

func (mc *LaterMemberChecker) CheckEstimatedRoundCoordNextIndex(checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckEstimatedRoundCoordNextIndex returns the estimated public key of the coordinator for round round for the following consensus index. It might not return the correct coordinator for the next index because the decision might change the membership for the next index. This function should not be used if it needs to know the next coordinator for certain. It returns an error if there is a fixed cordinator or random membership is enabled as it is unsupported in these cases.

func (*LaterMemberChecker) CheckFixedCoord

func (mc *LaterMemberChecker) CheckFixedCoord(pub sig.Pub) (coordPub sig.Pub, err error)

CheckFixedCoord checks if checkPub the/a coordinator for round. If it is, err is returned as nil, otherwise an error is returned. If checkPub is nil, then it will return the fixed coordinator in coordPub. If there is no fixedCoordinator, then an error types.ErrNoFixedCoord is returned. Note this should only be called after the pub is verified to be a member with CheckMemberBytes

func (*LaterMemberChecker) CheckIndex

func (mc *LaterMemberChecker) CheckIndex(idx types.ConsensusIndex) bool

CheckIndex should return true if the index is the same as the one used in New, it is for testing.

func (*LaterMemberChecker) CheckMemberBytes

func (mc *LaterMemberChecker) CheckMemberBytes(idx types.ConsensusIndex, pubBytes sig.PubKeyID) sig.Pub

CheckMemberBytes checks the the pub key is a member and returns corresponding pub key object

func (*LaterMemberChecker) CheckRandMember

func (mc *LaterMemberChecker) CheckRandMember(pub sig.Pub, hdr messages.InternalSignedMsgHeader, msgID messages.MsgID,
	isLocal bool) error

CheckRandMember can be called after CheckMemberBytes is successful when ChooseRandomMember is enabled. If ChooseRandomMember is false it return nil, otherwise it uses the random bytes and the VRF to decide if this pud is a random member.

func (*LaterMemberChecker) CheckRandRoundCoord

func (mc *LaterMemberChecker) CheckRandRoundCoord(msgID messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (randValue uint64, coordPub sig.Pub, err error)

CheckRandRoundCoord should be called instead of CheckRoundCoord if random membership selection is enabled. If using VRFs then checkPub must not be nil. If checkPub is nil, then it will return the known coordinator in coordPub. If VRF is enabled randValue is the VRF random value for the inputs. Note this should be called after CheckRandMember for the same pub.

func (*LaterMemberChecker) CheckRoundCoord

func (mc *LaterMemberChecker) CheckRoundCoord(_ messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckRoundCoord returns the public key of the coordinator for round round. It is just the mod of the round in the sorted list of public keys.

func (*LaterMemberChecker) DoneNextUpdateState

func (mc *LaterMemberChecker) DoneNextUpdateState() error

func (*LaterMemberChecker) FinishUpdateState

func (mc *LaterMemberChecker) FinishUpdateState()

FinishUpdateState does nothing.

func (*LaterMemberChecker) GetAllPubs

func (mc *LaterMemberChecker) GetAllPubs() sig.PubList

GetAllPub returns all pubs in the system

func (*LaterMemberChecker) GetFaultCount

func (mc *LaterMemberChecker) GetFaultCount() int

GetFaultCount returns the number of possilbe faultly nodes that the consensus can handle.

func (*LaterMemberChecker) GetIndex

func (mc *LaterMemberChecker) GetIndex() types.ConsensusIndex

func (*LaterMemberChecker) GetMemberCount

func (mc *LaterMemberChecker) GetMemberCount() int

GetMemberCount returns the number of consensus members.

func (*LaterMemberChecker) GetMyPriv

func (mc *LaterMemberChecker) GetMyPriv() sig.Priv

GetMyPriv returns the local node's private key.

func (*LaterMemberChecker) GetMyVRF

func (mc *LaterMemberChecker) GetMyVRF(isProposal bool, id messages.MsgID) sig.VRFProof

func (*LaterMemberChecker) GetNewPub

func (mc *LaterMemberChecker) GetNewPub() sig.Pub

GetNewPub returns an empty public key object.

func (*LaterMemberChecker) GetParticipantCount

func (mc *LaterMemberChecker) GetParticipantCount() int

GetParticipantCount returns the total number of nodes in the system

func (*LaterMemberChecker) GetParticipants

func (mc *LaterMemberChecker) GetParticipants() sig.PubList

GetParticipant return the pub key of the participants.

func (*LaterMemberChecker) GetRnd

func (mc *LaterMemberChecker) GetRnd() (ret [32]byte)

func (*LaterMemberChecker) GetStats

func (mc *LaterMemberChecker) GetStats() stats.StatsInterface

func (*LaterMemberChecker) Invalidated

func (mc *LaterMemberChecker) Invalidated() error

Invalidated is called if the member checker has been made invalid. This happens if a different set of members was chosen then was initial proposed.

func (*LaterMemberChecker) IsReady

func (mc *LaterMemberChecker) IsReady() bool

IsReady returns true

func (*LaterMemberChecker) New

New generates a new member checker for the index, this is called on the inital member checker each time.

func (*LaterMemberChecker) RandMemberType

func (mc *LaterMemberChecker) RandMemberType() types.RndMemberType

SelectRandMembers returns true if the member checker is selecting random members.

func (*LaterMemberChecker) SetMainChannel

func (mc *LaterMemberChecker) SetMainChannel(mainChannel channelinterface.MainChannel)

SetMainChannel is called on the initial member checker to inform it of the network channel object

func (*LaterMemberChecker) UpdateState

func (mc *LaterMemberChecker) UpdateState(fixedCoord sig.Pub, prevDec []byte, randBytes [32]byte,
	prevMember consinterface.MemberChecker, prevSM consinterface.GeneralStateMachineInterface,
	futureFixed types.ConsensusID) (newMemberPubs,
	newAllPubs []sig.Pub, changedMembers bool)

UpdateState updates the random member checker state.

func (*LaterMemberChecker) Validated

func (mc *LaterMemberChecker) Validated(signType types.SignType)

ValidatedItem is called for stats to let it know a signature was validated. TODO cleanup.

type MultiSigMemChecker

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

NoSpecialMembers implements SpecialPubMemberChecker, it allows for multi-signature public keys using BLS signatures. Keys will be generated using the BitID of the merged public key being requested in CheckMemberLocalMsg by merging the normal public key, using their indecies.

func NewMultiSigMemChecker

func NewMultiSigMemChecker(pubs sig.PubList, allowsChange bool) *MultiSigMemChecker

NewMultSigMemChecker generates a new MultiSigMemChecker object.

func (*MultiSigMemChecker) CheckMember

CheckMemberLocalMsg checks if pub is a special member and returns new pub that has all the values filled. If pub has a valid BitID then CheckMemberLocalMsg will always return a merged public key by merging the indices from teh BitID using the normal public keys.

func (*MultiSigMemChecker) New

New generates a new member checker for the index, this is called on the inital special member checker each time.

func (*MultiSigMemChecker) UpdateState

func (msm *MultiSigMemChecker) UpdateState(newKeys sig.PubList, randBytes [32]byte,
	prevMember consinterface.SpecialPubMemberChecker)

UpdateState is called after MemberCheck.Update state. If there are new keys, they will be used to generate the multi-signature public keys.

type NoSpecialMembers

type NoSpecialMembers struct {
}

NoSpecialMembers implements SpecialPubMemberChecker, but contains no special public keys.

func NewNoSpecialMembers

func NewNoSpecialMembers() *NoSpecialMembers

NewNoSpecialMembers generates an empty NoSpecialMembers object.

func (*NoSpecialMembers) CheckMember

CheckMemberLocalMsg checks if pub is a special member, here is always returns an error since there are no speical pubs.

func (*NoSpecialMembers) New

New generates a new member checker for the index, this is called on the inital special member checker each time.

func (*NoSpecialMembers) UpdateState

func (tsm *NoSpecialMembers) UpdateState(newKeys sig.PubList, randBytes [32]byte,
	prevMember consinterface.SpecialPubMemberChecker)

UpdateState is called after MemberCheck.Update state. Here it does nothing.

type ThrshSigMemChecker

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

ThrshSigMemChecker implements SpecialPubMemberChecker, it allows for using a threshold public key. It does not allow the public keys to change over consensus instances as that would require computing a new threshold key, something that is not currently supported.

func NewThrshSigMemChecker

func NewThrshSigMemChecker(pubs []sig.Pub) *ThrshSigMemChecker

NewThrshSigMemberChecker generates a new ThrshSigMemChecker object

func (*ThrshSigMemChecker) CheckMember

CheckMemberLocalMsg checks if pub is the threshold key and returns new pub that has all the values filled.

func (*ThrshSigMemChecker) New

New generates a new member checker for the index, this is called on the inital special member checker each time.

func (*ThrshSigMemChecker) UpdateState

func (tsm *ThrshSigMemChecker) UpdateState(newKeys sig.PubList, randBytes [32]byte,
	prevMember consinterface.SpecialPubMemberChecker)

UpdateState is called after MemberCheck.Update state. It panics if newKeys != nil, as changing keys is not supported.

type TrueMemberChecker

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

TrueMemberChecker has a fixed list of member from the beginning.

func (*TrueMemberChecker) AbsGotDecision

func (mc *TrueMemberChecker) AbsGotDecision(newFixedCoord sig.Pub, newMemberPubs, newOtherPubs sig.PubList,
	prevDec []byte, randBytes [32]byte, prevMember *absMemberChecker) (retMemberPubs, retAllPubs []sig.Pub,
	changedMembers bool)

AbsGotDecision should be called at the end of UpdateState from the MemberChecker. The newAllPubs is a list of all new pubs in the system (note this list does not need to be sorted as it will be sorted here). If it is nil then the set of pubs must have not changed since the last consensus instance. These pubs will be sorted and returned to insure that their new ids are computed correctly. newMemberPubs pubs are the public keys that will now participate in consensus. newMemberPubs must be a equal to or a subset of newAllPubs. newMemberPubs should also be nil if they have not changed since the previous consensus index. myPubIndex is the index of the local nodes public key in the list, if it is negative then this nodes public key should not be in the list (i.e. is not a member). ChangedMembers must be true if either of the other return values are non-nil. Even if they are nil, but the membership could have changed in a different way (i.e. by random membership) it must return true

func (*TrueMemberChecker) AddPubKeys

func (mc *TrueMemberChecker) AddPubKeys(fixedCoord sig.Pub, memberPubKeys, otherPubs sig.PubList, initRandBytes [32]byte,
	shared *consinterface.Shared)

AddPubKeys is used for adding the public keys to the very inital member checker, and should not be called on later member checkers, as they should change pub keys through the call to UpdateState. allPubs are the list of all pubs in the system. memberPubs pubs are the public keys that will now participate in consensus. memberPubs must be equal to or a subset of newAllPubs. If shared is non-nil then the local nodes on the machine will share the same initial member objects (to save memory for experiments that run many nodes on the same machine).

func (*TrueMemberChecker) AllowsChange

func (mc *TrueMemberChecker) AllowsChange() bool

AllowsChange returns true if the member checker allows changing members, used as a sanity check.

func (*TrueMemberChecker) CheckEstimatedRoundCoordNextIndex

func (mc *TrueMemberChecker) CheckEstimatedRoundCoordNextIndex(checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckEstimatedRoundCoordNextIndex returns the estimated public key of the coordinator for round round for the following consensus index. It might not return the correct coordinator for the next index because the decision might change the membership for the next index. This function should not be used if it needs to know the next coordinator for certain. It returns an error if there is a fixed cordinator or random membership is enabled as it is unsupported in these cases.

func (*TrueMemberChecker) CheckFixedCoord

func (mc *TrueMemberChecker) CheckFixedCoord(pub sig.Pub) (coordPub sig.Pub, err error)

CheckFixedCoord checks if checkPub the/a coordinator for round. If it is, err is returned as nil, otherwise an error is returned. If checkPub is nil, then it will return the fixed coordinator in coordPub. If there is no fixedCoordinator, then an error types.ErrNoFixedCoord is returned. Note this should only be called after the pub is verified to be a member with CheckMemberBytes

func (*TrueMemberChecker) CheckIndex

func (mc *TrueMemberChecker) CheckIndex(idx types.ConsensusIndex) bool

CheckIndex should return true if the index is the same as the one used in New, it is for testing.

func (*TrueMemberChecker) CheckMemberBytes

func (mc *TrueMemberChecker) CheckMemberBytes(idx types.ConsensusIndex, pubBytes sig.PubKeyID) sig.Pub

CheckMemberBytes checks the the pub key is a member and returns corresponding pub key object

func (*TrueMemberChecker) CheckRandMember

func (mc *TrueMemberChecker) CheckRandMember(pub sig.Pub, hdr messages.InternalSignedMsgHeader, msgID messages.MsgID,
	isLocal bool) error

CheckRandMember can be called after CheckMemberBytes is successful when ChooseRandomMember is enabled. If ChooseRandomMember is false it return nil, otherwise it uses the random bytes and the VRF to decide if this pud is a random member.

func (*TrueMemberChecker) CheckRandRoundCoord

func (mc *TrueMemberChecker) CheckRandRoundCoord(msgID messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (randValue uint64, coordPub sig.Pub, err error)

CheckRandRoundCoord is unsupported.

func (*TrueMemberChecker) CheckRoundCoord

func (mc *TrueMemberChecker) CheckRoundCoord(_ messages.MsgID, checkPub sig.Pub,
	round types.ConsensusRound) (coordPub sig.Pub, err error)

CheckRoundCoord returns the public key of the coordinator for round round. It is just the mod of the round in the sorted list of public keys.

func (*TrueMemberChecker) DoneNextUpdateState

func (mc *TrueMemberChecker) DoneNextUpdateState() error

func (*TrueMemberChecker) FinishUpdateState

func (mc *TrueMemberChecker) FinishUpdateState()

FinishUpdateState does nothing since the members do not change.

func (*TrueMemberChecker) GetAllPubs

func (mc *TrueMemberChecker) GetAllPubs() sig.PubList

GetAllPub returns all pubs in the system

func (*TrueMemberChecker) GetFaultCount

func (mc *TrueMemberChecker) GetFaultCount() int

GetFaultCount returns the number of possilbe faultly nodes that the consensus can handle.

func (*TrueMemberChecker) GetIndex

func (mc *TrueMemberChecker) GetIndex() types.ConsensusIndex

func (*TrueMemberChecker) GetMemberCount

func (mc *TrueMemberChecker) GetMemberCount() int

GetMemberCount returns the number of consensus members.

func (*TrueMemberChecker) GetMyPriv

func (mc *TrueMemberChecker) GetMyPriv() sig.Priv

GetMyPriv returns the local node's private key.

func (*TrueMemberChecker) GetMyVRF

func (mc *TrueMemberChecker) GetMyVRF(isProposal bool, id messages.MsgID) sig.VRFProof

func (*TrueMemberChecker) GetNewPub

func (mc *TrueMemberChecker) GetNewPub() sig.Pub

GetNewPub returns an empty public key object.

func (*TrueMemberChecker) GetParticipantCount

func (mc *TrueMemberChecker) GetParticipantCount() int

GetParticipantCount returns the total number of nodes in the system

func (*TrueMemberChecker) GetParticipants

func (mc *TrueMemberChecker) GetParticipants() sig.PubList

GetParticipant return the pub key of the participants.

func (*TrueMemberChecker) GetRnd

func (mc *TrueMemberChecker) GetRnd() (ret [32]byte)

func (*TrueMemberChecker) GetStats

func (mc *TrueMemberChecker) GetStats() stats.StatsInterface

func (*TrueMemberChecker) Invalidated

func (mc *TrueMemberChecker) Invalidated() error

Invalidated is called if the member checker has been made invalid. This happens if a different set of members was chosen then was initial proposed.

func (*TrueMemberChecker) IsReady

func (mc *TrueMemberChecker) IsReady() bool

IsReady always returns true.

func (*TrueMemberChecker) New

New generates a new member checker for the index, this is called on the inital member checker each time.

func (*TrueMemberChecker) RandMemberType

func (mc *TrueMemberChecker) RandMemberType() types.RndMemberType

SelectRandMembers returns true if the member checker is selecting random members.

func (*TrueMemberChecker) SetMainChannel

func (mc *TrueMemberChecker) SetMainChannel(mainChannel channelinterface.MainChannel)

SetMainChannel is called on the initial member checker to inform it of the network channel object

func (*TrueMemberChecker) UpdateState

func (mc *TrueMemberChecker) UpdateState(fixedCoord sig.Pub, prevDec []byte, randBytes [32]byte,
	prevMember consinterface.MemberChecker, prevSM consinterface.GeneralStateMachineInterface,
	futureFixed types.ConsensusID) (newMemberPubs,
	newAllPubs []sig.Pub, changedMembers bool)

UpdateState does nothing since the members do not change. func (mc *TrueMemberChecker) UpdateState(prevDec []byte, prevSM consinterface.StateMachineInterface, prevMember MemberChecker) []sig.Pub {

func (*TrueMemberChecker) Validated

func (mc *TrueMemberChecker) Validated(signType types.SignType)

ValidatedItem is called for stats to let it know a signature was validated. TODO cleanup.

Jump to

Keyboard shortcuts

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