Documentation
¶
Index ¶
- Variables
- func GetBAThreshold(config *types.Config) int
- func GetCRSWithPanic(accessor crsAccessor, round uint64, logger common.Logger) common.Hash
- func GetConfigWithPanic(accessor configAccessor, round uint64, logger common.Logger) *types.Config
- func GetDKGThreshold(config *types.Config) int
- func GetDKGValidThreshold(config *types.Config) int
- func GetNextRoundValidationHeight(begin, length uint64) uint64
- func GetRoundHeight(accessor interface{}, round uint64) uint64
- func HashBlock(block *types.Block) (common.Hash, error)
- func HashPosition(position types.Position) common.Hash
- func HashVote(vote *types.Vote) common.Hash
- func IsDKGValid(gov governanceAccessor, logger common.Logger, round, reset uint64) (valid bool, gpkInvalid bool)
- func LaunchDummyReceiver(ctx context.Context, recv <-chan types.Msg, handler func(types.Msg)) (context.CancelFunc, <-chan struct{})
- func NeedPenaltyDKGPrivateShare(complaint *typesDKG.Complaint, mpk *typesDKG.MasterPublicKey) (bool, error)
- func NeedPenaltyForkBlock(block1, block2 *types.Block) (bool, error)
- func NeedPenaltyForkVote(vote1, vote2 *types.Vote) (bool, error)
- func Rehash(hash common.Hash, count uint) common.Hash
- func RoundEventRetryHandlerGenerator(rEvt *RoundEvent, hEvt *common.Event) func(uint64)
- func SetDKGDelayRound(delay uint64)
- func VerifyBlockSignature(b *types.Block) (err error)
- func VerifyBlockSignatureWithoutPayload(b *types.Block) (err error)
- func VerifyCRSSignature(block *types.Block, crs common.Hash, npks *typesDKG.NodePublicKeys) bool
- func VerifyDKGComplaint(complaint *typesDKG.Complaint, mpk *typesDKG.MasterPublicKey) (bool, error)
- func VerifyDKGComplaintSignature(complaint *typesDKG.Complaint) (bool, error)
- func VerifyDKGFinalizeSignature(final *typesDKG.Finalize) (bool, error)
- func VerifyDKGMPKReadySignature(ready *typesDKG.MPKReady) (bool, error)
- func VerifyDKGMasterPublicKeySignature(mpk *typesDKG.MasterPublicKey) (bool, error)
- func VerifyDKGPartialSignatureSignature(psig *typesDKG.PartialSignature) (bool, error)
- func VerifyDKGPrivateShareSignature(prvShare *typesDKG.PrivateShare) (bool, error)
- func VerifyDKGSuccessSignature(success *typesDKG.Success) (bool, error)
- func VerifyVoteSignature(vote *types.Vote) (bool, error)
- type ErrUnmatchedBlockHeightWithConfig
- type NodeSetCache
- func (cache *NodeSetCache) Exists(round uint64, nodeID types.NodeID) (exists bool, err error)
- func (cache *NodeSetCache) GetNodeSet(round uint64) (*types.NodeSet, error)
- func (cache *NodeSetCache) GetNotarySet(round uint64) (map[types.NodeID]struct{}, error)
- func (cache *NodeSetCache) GetPublicKey(nodeID types.NodeID) (key crypto.PublicKey, exists bool)
- func (cache *NodeSetCache) Purge(rID uint64)
- func (cache *NodeSetCache) Touch(round uint64) (err error)
- type NodeSetCacheInterface
- type RoundBasedConfig
- func (c *RoundBasedConfig) AppendTo(other RoundBasedConfig)
- func (c *RoundBasedConfig) Contains(h uint64) bool
- func (c *RoundBasedConfig) ExtendLength()
- func (c *RoundBasedConfig) IsLastBlock(b *types.Block) bool
- func (c *RoundBasedConfig) LastPeriodBeginHeight() uint64
- func (c *RoundBasedConfig) RoundEndHeight() uint64
- func (c *RoundBasedConfig) RoundID() uint64
- func (c *RoundBasedConfig) SetRoundBeginHeight(begin uint64)
- func (c *RoundBasedConfig) SetupRoundBasedFields(roundID uint64, cfg *types.Config)
- type RoundEvent
- type RoundEventParam
- func (e RoundEventParam) NextCRSProposingHeight() uint64
- func (e RoundEventParam) NextDKGPreparationHeight() uint64
- func (e RoundEventParam) NextDKGRegisterHeight() uint64
- func (e RoundEventParam) NextDKGResetHeight() uint64
- func (e RoundEventParam) NextRoundHeight() uint64
- func (e RoundEventParam) NextRoundValidationHeight() uint64
- func (e RoundEventParam) NextTouchNodeSetCacheHeight() uint64
- func (e RoundEventParam) RoundEndHeight() uint64
- func (e RoundEventParam) String() string
- type Signer
- func (s *Signer) SetBLSSigner(signer blsSigner)
- func (s *Signer) SignBlock(b *types.Block) (err error)
- func (s *Signer) SignCRS(b *types.Block, crs common.Hash) (err error)
- func (s *Signer) SignDKGComplaint(complaint *typesDKG.Complaint) (err error)
- func (s *Signer) SignDKGFinalize(final *typesDKG.Finalize) (err error)
- func (s *Signer) SignDKGMPKReady(ready *typesDKG.MPKReady) (err error)
- func (s *Signer) SignDKGMasterPublicKey(mpk *typesDKG.MasterPublicKey) (err error)
- func (s *Signer) SignDKGPartialSignature(pSig *typesDKG.PartialSignature) (err error)
- func (s *Signer) SignDKGPrivateShare(prvShare *typesDKG.PrivateShare) (err error)
- func (s *Signer) SignDKGSuccess(success *typesDKG.Success) (err error)
- func (s *Signer) SignVote(v *types.Vote) (err error)
- type VoteFilter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNodeSetNotReady means we got nil empty node set. ErrNodeSetNotReady = errors.New("node set is not ready") // ErrCRSNotReady means we got empty CRS. ErrCRSNotReady = errors.New("crs is not ready") // ErrConfigurationNotReady means we go nil configuration. ErrConfigurationNotReady = errors.New("configuration is not ready") )
var ( // ErrInvalidDKGMasterPublicKey means the DKG MasterPublicKey is invalid. ErrInvalidDKGMasterPublicKey = errors.New("invalid DKG master public key") // ErrPayloadNotEmpty means the payload of block is not empty. ErrPayloadNotEmpty = errors.New("payload not empty") )
var ( ErrInvalidProposerID = errors.New("invalid proposer id") ErrIncorrectHash = errors.New("hash of block is incorrect") ErrIncorrectSignature = errors.New("signature of block is incorrect") ErrNoBLSSigner = errors.New("bls signer not set") )
Errors for signer.
Functions ¶
func GetBAThreshold ¶
GetBAThreshold return threshold for BA votes.
func GetCRSWithPanic ¶
GetCRSWithPanic is a helper to access CRS, and panic when CRS for that round is not ready yet.
func GetConfigWithPanic ¶
GetConfigWithPanic is a helper to access configs, and panic when config for that round is not ready yet.
func GetDKGThreshold ¶
GetDKGThreshold return expected threshold for given DKG set size.
func GetDKGValidThreshold ¶
GetDKGValidThreshold return threshold for DKG set to considered valid.
func GetNextRoundValidationHeight ¶
GetNextRoundValidationHeight returns the block height to check if the next round is ready.
func GetRoundHeight ¶
GetRoundHeight wraps the workaround for the round height logic in fullnode.
func HashPosition ¶
HashPosition generates hash of a types.Position.
func IsDKGValid ¶
func IsDKGValid( gov governanceAccessor, logger common.Logger, round, reset uint64) ( valid bool, gpkInvalid bool)
IsDKGValid check if DKG is correctly prepared.
func LaunchDummyReceiver ¶
func LaunchDummyReceiver( ctx context.Context, recv <-chan types.Msg, handler func(types.Msg)) ( context.CancelFunc, <-chan struct{})
LaunchDummyReceiver launches a go routine to receive from the receive channel of a network module. An context is required to stop the go routine automatically. An optinal message handler could be provided.
func NeedPenaltyDKGPrivateShare ¶
func NeedPenaltyDKGPrivateShare( complaint *typesDKG.Complaint, mpk *typesDKG.MasterPublicKey) (bool, error)
NeedPenaltyDKGPrivateShare checks if the proposer of dkg private share should be penalized.
func NeedPenaltyForkBlock ¶
NeedPenaltyForkBlock checks if two blocks are fork block.
func NeedPenaltyForkVote ¶
NeedPenaltyForkVote checks if two votes are fork vote.
func RoundEventRetryHandlerGenerator ¶
func RoundEventRetryHandlerGenerator( rEvt *RoundEvent, hEvt *common.Event) func(uint64)
RoundEventRetryHandlerGenerator generates a handler to common.Event, which would register itself to retry next round validation if round event is not triggered.
func VerifyBlockSignature ¶
VerifyBlockSignature verifies the signature of types.Block.
func VerifyBlockSignatureWithoutPayload ¶
VerifyBlockSignatureWithoutPayload verifies the signature of types.Block but does not check if PayloadHash is correct.
func VerifyCRSSignature ¶
VerifyCRSSignature verifies the CRS signature of types.Block.
func VerifyDKGComplaint ¶
func VerifyDKGComplaint( complaint *typesDKG.Complaint, mpk *typesDKG.MasterPublicKey) (bool, error)
VerifyDKGComplaint verifies if its a valid DKGCompliant.
func VerifyDKGComplaintSignature ¶
VerifyDKGComplaintSignature verifies DKGCompliant signature.
func VerifyDKGFinalizeSignature ¶
VerifyDKGFinalizeSignature verifies DKGFinalize signature.
func VerifyDKGMPKReadySignature ¶
VerifyDKGMPKReadySignature verifies DKGMPKReady signature.
func VerifyDKGMasterPublicKeySignature ¶
func VerifyDKGMasterPublicKeySignature( mpk *typesDKG.MasterPublicKey) (bool, error)
VerifyDKGMasterPublicKeySignature verifies DKGMasterPublicKey signature.
func VerifyDKGPartialSignatureSignature ¶
func VerifyDKGPartialSignatureSignature( psig *typesDKG.PartialSignature) (bool, error)
VerifyDKGPartialSignatureSignature verifies the signature of typesDKG.PartialSignature.
func VerifyDKGPrivateShareSignature ¶
func VerifyDKGPrivateShareSignature( prvShare *typesDKG.PrivateShare) (bool, error)
VerifyDKGPrivateShareSignature verifies the signature of typesDKG.PrivateShare.
func VerifyDKGSuccessSignature ¶
VerifyDKGSuccessSignature verifies DKGSuccess signature.
Types ¶
type ErrUnmatchedBlockHeightWithConfig ¶
type ErrUnmatchedBlockHeightWithConfig struct {
// contains filtered or unexported fields
}
ErrUnmatchedBlockHeightWithConfig is for invalid parameters for NewRoundEvent.
func (ErrUnmatchedBlockHeightWithConfig) Error ¶
func (e ErrUnmatchedBlockHeightWithConfig) Error() string
type NodeSetCache ¶
type NodeSetCache struct {
// contains filtered or unexported fields
}
NodeSetCache caches node set information.
NOTE: this module doesn't handle DKG resetting and can only be used along
with utils.RoundEvent.
func NewNodeSetCache ¶
func NewNodeSetCache(nsIntf NodeSetCacheInterface) *NodeSetCache
NewNodeSetCache constructs an NodeSetCache instance.
func (*NodeSetCache) GetNodeSet ¶
func (cache *NodeSetCache) GetNodeSet(round uint64) (*types.NodeSet, error)
GetNodeSet returns IDs of nodes set of this round as map.
func (*NodeSetCache) GetNotarySet ¶
func (cache *NodeSetCache) GetNotarySet( round uint64) (map[types.NodeID]struct{}, error)
GetNotarySet returns of notary set of this round.
func (*NodeSetCache) GetPublicKey ¶
GetPublicKey return public key for that node:
func (*NodeSetCache) Touch ¶
func (cache *NodeSetCache) Touch(round uint64) (err error)
Touch updates the internal cache of round.
type NodeSetCacheInterface ¶
type NodeSetCacheInterface interface { // Configuration returns the configuration at a given round. // Return the genesis configuration if round == 0. Configuration(round uint64) *types.Config // CRS returns the CRS for a given round. // Return the genesis CRS if round == 0. CRS(round uint64) common.Hash // NodeSet returns the node set at a given round. // Return the genesis node set if round == 0. NodeSet(round uint64) []crypto.PublicKey }
NodeSetCacheInterface interface specifies interface used by NodeSetCache.
type RoundBasedConfig ¶
type RoundBasedConfig struct {
// contains filtered or unexported fields
}
RoundBasedConfig is based config for rounds and provide boundary checking for rounds.
func (*RoundBasedConfig) AppendTo ¶
func (c *RoundBasedConfig) AppendTo(other RoundBasedConfig)
AppendTo a config from previous round.
func (*RoundBasedConfig) Contains ¶
func (c *RoundBasedConfig) Contains(h uint64) bool
Contains checks if a block height is in this round.
func (*RoundBasedConfig) ExtendLength ¶
func (c *RoundBasedConfig) ExtendLength()
ExtendLength extends round ending height by the length of current round.
func (*RoundBasedConfig) IsLastBlock ¶
func (c *RoundBasedConfig) IsLastBlock(b *types.Block) bool
IsLastBlock checks if a block is the last block of this round.
func (*RoundBasedConfig) LastPeriodBeginHeight ¶
func (c *RoundBasedConfig) LastPeriodBeginHeight() uint64
LastPeriodBeginHeight returns the begin height of last period. For example, if a round is extended twice, then the return from this method is:
begin + 2 * roundLength - roundLength
func (*RoundBasedConfig) RoundEndHeight ¶
func (c *RoundBasedConfig) RoundEndHeight() uint64
RoundEndHeight returns next checkpoint to varify if this round is ended.
func (*RoundBasedConfig) RoundID ¶
func (c *RoundBasedConfig) RoundID() uint64
RoundID returns the round ID of this config.
func (*RoundBasedConfig) SetRoundBeginHeight ¶
func (c *RoundBasedConfig) SetRoundBeginHeight(begin uint64)
SetRoundBeginHeight gives the beginning height for the initial round provided when constructed.
func (*RoundBasedConfig) SetupRoundBasedFields ¶
func (c *RoundBasedConfig) SetupRoundBasedFields( roundID uint64, cfg *types.Config)
SetupRoundBasedFields setup round based fields, including round ID, the length of rounds.
type RoundEvent ¶
type RoundEvent struct {
// contains filtered or unexported fields
}
RoundEvent would be triggered when either:
- the next DKG set setup is ready.
- the next DKG set setup is failed, and previous DKG set already reset the CRS.
func NewRoundEvent ¶
func NewRoundEvent(parentCtx context.Context, gov governanceAccessor, logger common.Logger, initPos types.Position, roundShift uint64) ( *RoundEvent, error)
NewRoundEvent creates an RoundEvent instance.
func (*RoundEvent) LastPeriod ¶
func (e *RoundEvent) LastPeriod() (begin uint64, length uint64)
LastPeriod returns block height related info of the last period, including begin height and round length.
func (*RoundEvent) Register ¶
func (e *RoundEvent) Register(h roundEventFn)
Register a handler to be called when new round is confirmed or new DKG reset is detected.
The earlier registered handler has higher priority.
func (*RoundEvent) Stop ¶
func (e *RoundEvent) Stop()
Stop the event source and block until last trigger returns.
func (*RoundEvent) TriggerInitEvent ¶
func (e *RoundEvent) TriggerInitEvent()
TriggerInitEvent triggers event from the initial setting.
func (*RoundEvent) ValidateNextRound ¶
func (e *RoundEvent) ValidateNextRound(blockHeight uint64) (count uint)
ValidateNextRound validate if the DKG set for next round is ready to go or failed to setup, all registered handlers would be called once some decision is made on chain.
The count of triggered events would be returned.
type RoundEventParam ¶
type RoundEventParam struct { // 'Round' of next checkpoint, might be identical to previous checkpoint. Round uint64 // the count of reset DKG for 'Round+1'. Reset uint64 // the begin block height of this event, the end block height of this event // would be BeginHeight + config.RoundLength. BeginHeight uint64 // The configuration for 'Round'. Config *types.Config // The CRS for 'Round'. CRS common.Hash }
RoundEventParam defines the parameters passed to event handlers of RoundEvent.
func (RoundEventParam) NextCRSProposingHeight ¶
func (e RoundEventParam) NextCRSProposingHeight() uint64
NextCRSProposingHeight returns the height to propose CRS for next round.
func (RoundEventParam) NextDKGPreparationHeight ¶
func (e RoundEventParam) NextDKGPreparationHeight() uint64
NextDKGPreparationHeight returns the height to prepare DKG set for next round.
func (RoundEventParam) NextDKGRegisterHeight ¶
func (e RoundEventParam) NextDKGRegisterHeight() uint64
NextDKGRegisterHeight returns the height to register DKG.
func (RoundEventParam) NextDKGResetHeight ¶
func (e RoundEventParam) NextDKGResetHeight() uint64
NextDKGResetHeight returns the height to reset DKG for next period.
func (RoundEventParam) NextRoundHeight ¶
func (e RoundEventParam) NextRoundHeight() uint64
NextRoundHeight returns the height of the beginning of next round.
func (RoundEventParam) NextRoundValidationHeight ¶
func (e RoundEventParam) NextRoundValidationHeight() uint64
NextRoundValidationHeight returns the height to check if the next round is ready.
func (RoundEventParam) NextTouchNodeSetCacheHeight ¶
func (e RoundEventParam) NextTouchNodeSetCacheHeight() uint64
NextTouchNodeSetCacheHeight returns the height to touch the node set cache.
func (RoundEventParam) RoundEndHeight ¶
func (e RoundEventParam) RoundEndHeight() uint64
RoundEndHeight returns the round ending height of this round event.
func (RoundEventParam) String ¶
func (e RoundEventParam) String() string
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer signs a segment of data.
func NewSigner ¶
func NewSigner(prvKey crypto.PrivateKey) (s *Signer)
NewSigner constructs an Signer instance.
func (*Signer) SetBLSSigner ¶
func (s *Signer) SetBLSSigner(signer blsSigner)
SetBLSSigner for signing CRSSignature
func (*Signer) SignDKGComplaint ¶
SignDKGComplaint signs a DKG complaint.
func (*Signer) SignDKGFinalize ¶
SignDKGFinalize signs a DKG finalize message.
func (*Signer) SignDKGMPKReady ¶
SignDKGMPKReady signs a DKG ready message.
func (*Signer) SignDKGMasterPublicKey ¶
func (s *Signer) SignDKGMasterPublicKey( mpk *typesDKG.MasterPublicKey) (err error)
SignDKGMasterPublicKey signs a DKG master public key.
func (*Signer) SignDKGPartialSignature ¶
func (s *Signer) SignDKGPartialSignature( pSig *typesDKG.PartialSignature) (err error)
SignDKGPartialSignature signs a DKG partial signature.
func (*Signer) SignDKGPrivateShare ¶
func (s *Signer) SignDKGPrivateShare( prvShare *typesDKG.PrivateShare) (err error)
SignDKGPrivateShare signs a DKG private share.
func (*Signer) SignDKGSuccess ¶
SignDKGSuccess signs a DKG success message.
type VoteFilter ¶
type VoteFilter struct { Voted map[types.VoteHeader]struct{} Position types.Position LockIter uint64 Period uint64 Confirm bool }
VoteFilter filters votes that are useless for now. To maximize performance, this structure is not thread-safe and will never be.
func NewVoteFilter ¶
func NewVoteFilter() *VoteFilter
NewVoteFilter creates a new vote filter instance.
func (*VoteFilter) AddVote ¶
func (vf *VoteFilter) AddVote(vote *types.Vote)
AddVote to the filter so the same vote will be filtered.