Documentation ¶
Index ¶
- Constants
- Variables
- func AddrTypeKey(address common.Address, voteType VoteType, index uint8) []byte
- func CompareCommonHash(p1, p2 common.Hash) int
- func ComputeSeed(sk vrf.PrivateKey, round *big.Int, roundIndex uint32, preSeed common.Hash) (seed common.Hash, proof []byte)
- func Encode(val interface{}) ([]byte, error)
- func GenerateEmptyBlock(parent *types.Block, sk *ecdsa.PrivateKey) *types.Block
- func GetInfoFromHash(h RoundIndexHash) (uint64, uint32)
- func GetSignatureAddress(data []byte, sig []byte) (common.Address, error)
- func GetSignaturePublicKey(data []byte, sig []byte) (*ecdsa.PublicKey, error)
- func GetVoteFromBool(vote bool) uint32
- func MakeM(seed common.Hash, role uint32, index uint32) []byte
- func MessageCodeToString(code MsgType) string
- func MillionSecond(time time.Time) int64
- func OppositeValidatorType(kind params.ValidatorKind) params.ValidatorKind
- func OverThreshold(count uint32, threshold uint64, isPos bool) bool
- func PrepareConsensusData(header *types.Header, data *BlockConsensusData) ([]byte, error)
- func ProbabilityForLimitedSampleing(communitySize int64, threshold float64, k uint32) float64
- func ProbabilityForSampleing(threshold float64, k uint32) float64
- func ProbabilityForViolateCondition1(honest, threshold, portion float64) float64
- func Sign(key *ecdsa.PrivateKey, data []byte) ([]byte, error)
- func VerifySignature(vote *VoteItem, address common.Address) bool
- func VoteTypeToString(voteType VoteType) string
- func VrfComputePriority(hash common.Hash, j uint32) common.Hash
- func VrfSortition(sk vrf.PrivateKey, seed common.Hash, index uint32, role uint32, ...) (common.Hash, []byte, uint32)
- func VrfVerifyPriority(pk vrf.PublicKey, seed common.Hash, index uint32, role uint32, proof []byte, ...) (bool, error)
- func VrfVerifySortition(pk vrf.PublicKey, seed common.Hash, index uint32, role uint32, proof []byte, ...) (bool, error)
- type AddrVoteStatus
- type AddrVoteType
- type AddressMap
- type AddressMsgInfo
- type AddressMsgs
- type BlockConsensusData
- func (data *BlockConsensusData) GetPublicKey() (*ecdsa.PublicKey, error)
- func (data *BlockConsensusData) IsValidRound() (bool, error)
- func (data *BlockConsensusData) IsValidSeed() (bool, error)
- func (data *BlockConsensusData) IsValidTime() (bool, error)
- func (data *BlockConsensusData) SetSignature(key *ecdsa.PrivateKey) error
- type BlockHashWithMaxPriorityFn
- type BlockHashWithVotes
- type BlockProposalEvent
- type BlsVerifier
- func (v *BlsVerifier) AggregateSignatures(rawSigs [][]byte) (aggregatedSig []byte, err error)
- func (v *BlsVerifier) GetBlsPubKey(bspubKey []byte) (bls.PublicKey, error)
- func (v *BlsVerifier) GetBlsSig(sig []byte) (bls.Signature, error)
- func (v *BlsVerifier) GetVrfPubKey(bspubKey []byte) (*ecdsa.PublicKey, error)
- func (v *BlsVerifier) PackVotes(ev CommitEvent, backType params.LookBackType) (*UconValidators, error)
- func (v *BlsVerifier) RecoverSignerInfo(vs *state.Validators, vote *SingleVote) (signer *state.Validator, pk bls.PublicKey, vrfpk *ecdsa.PublicKey, err error)
- type CachedBlockMessage
- type CachedMessage
- type CachedMsgMgr
- func (c *CachedMsgMgr) Clear(round uint64, roundIndex uint32)
- func (c *CachedMsgMgr) GetMessages(round uint64, roundIndex uint32, code MsgType) CachedMsgs
- func (c *CachedMsgMgr) NewMessage(msg CachedMessage, code MsgType, addr common.Address, timestamp time.Time)
- func (c *CachedMsgMgr) RemoveMessages(round uint64, roundIndex uint32, code MsgType)
- type CachedMsgs
- type CachedPriorityMessage
- type CachedVotesMessage
- type CommitEvent
- type ConsensusCommon
- type ContextChangeEvent
- type DatabaseDeleter
- type DatabaseReader
- type DatabaseWriter
- type GetBlockInCacheFn
- type GetCurrentParamsFn
- type GetLookBackValidatorFn
- type InvalidMsgMaker
- func (m *InvalidMsgMaker) DecodeFailedMsg() []byte
- func (m *InvalidMsgMaker) DecodePayloadFailed() []byte
- func (m *InvalidMsgMaker) EmptyRound() []byte
- func (m *InvalidMsgMaker) InvalidAddress() []byte
- func (m *InvalidMsgMaker) InvalidSignature() []byte
- func (m *InvalidMsgMaker) InvalidSize() []byte
- func (m *InvalidMsgMaker) InvalidVoteMsg() []byte
- type IsValidatorFn
- type LookBackMgr
- type MarkedBlockInfo
- type Message
- type MessageEvent
- type MessageHandler
- type MsgReceivedStatus
- type MsgType
- type OverThresholdFn
- type PriorityForRound
- type PriorityManager
- type PriorityMsgEvent
- type ProcessPriorityMsg
- type ProcessProposedBlockMsg
- type ProcessReceivedMsgFn
- type ProcessStepFn
- type ProcessTimeoutFn
- type ProcessVoteMsg
- type Proposal
- type ProposedBlockMsgEvent
- type ReceivedMsgEvent
- type RoundIndexChangeEvent
- type RoundIndexHash
- type SendMessageEvent
- type Server
- func (s *Server) Author(header *types.Header) (common.Address, error)
- func (s *Server) CertificateParams(round *big.Int) (*params.CaravelParams, error)
- func (s *Server) CheckValidatorVotes(chain consensus.ChainReader, header *types.Header) (map[common.Address]bool, error)
- func (s *Server) CompareBlocks(blockA *types.Block, blockB *types.Block) int
- func (s *Server) CurrentCaravelParams() *params.CaravelParams
- func (s *Server) Finalize(chain consensus.ChainReader, header *types.Header, statedb *state.StateDB, ...)
- func (s *Server) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (s *Server) GetLookBackBlockHash(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) (common.Hash, error)
- func (s *Server) GetLookBackBlockNumber(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) *big.Int
- func (s *Server) GetLookBackValidator(round *big.Int, addr common.Address, lbType params.LookBackType) (*state.Validator, bool)
- func (s *Server) GetLookBackVldReader(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) (state.ValidatorReader, error)
- func (s *Server) GetValMainAddress() common.Address
- func (s *Server) GetValidatorAddrs(chain consensus.ChainReader, header *types.Header) (*params.YouParams, *UconValidators, []common.Address, []common.Address, error)
- func (s *Server) GetValidatorByAddress(blockHash common.Hash, addr common.Address) *state.Validator
- func (s *Server) HandleMsg(data []byte, receivedAt time.Time) error
- func (s *Server) NewChainHead(block *types.Block)
- func (s *Server) NextRound(ev RoundIndexChangeEvent) error
- func (s *Server) Pause() error
- func (s *Server) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (s *Server) Resume() error
- func (s *Server) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (s *Server) SetValKey(sk *ecdsa.PrivateKey, blsKeyBytes []byte) (err error)
- func (s *Server) StartMining(chain consensus.ChainReader, inserter consensus.MineInserter, ...) error
- func (s *Server) StartNewRound(newRound bool) error
- func (s *Server) Stop() error
- func (s *Server) TotalStakeOfKind(blockHash common.Hash, kind params.ValidatorKind) *big.Int
- func (s *Server) UpdateContextForNewBlock(block *types.Block) error
- func (s *Server) ValidatorsNumOfKind(blockHash common.Hash, kind params.ValidatorKind) uint64
- func (s *Server) VerifyAcHeader(chain consensus.ChainReader, acHeader *types.Header, ...) error
- func (s *Server) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (s *Server) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (s *Server) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (s *Server) VerifySideChainHeader(cp *params.CaravelParams, seedHeader *types.Header, ...) error
- type SingleVote
- type SortitionData
- type SortitionManager
- type StartVoteFn
- type StepView
- type StepViews
- type TimerManager
- type TransferMessageEvent
- type TypedCacheMsgs
- type UconValidators
- type UpdateExistedHeaderEvent
- type VerifyPriorityFn
- type VerifySortitionFn
- type VoteBLSMgr
- func (vb *VoteBLSMgr) RecoverSignerInfo(vs *state.Validators, vote *SingleVote) (signer *state.Validator, pk bls.PublicKey, vrfpk *ecdsa.PublicKey, err error)
- func (vb *VoteBLSMgr) SetLookBackMgr(lbmgr LookBackMgr)
- func (vb *VoteBLSMgr) SignVote(voteType VoteType, voteInfo *SingleVote, payload []byte) error
- type VoteDB
- type VoteItem
- type VoteMsgEvent
- type VoteSta
- type VoteStatus
- type VoteType
- type Voter
- func (v *Voter) PackVotes(ev CommitEvent, backType params.LookBackType) (*UconValidators, error)
- func (v *Voter) RecoverSignerInfo(vs *state.Validators, vote *SingleVote) (signer *state.Validator, pk bls.PublicKey, vrfpk *ecdsa.PublicKey, err error)
- func (v *Voter) SetLookBackMgr(lbmgr LookBackMgr)
- func (v *Voter) Start(lbmgr LookBackMgr)
- func (v *Voter) Stop()
- type VotesInfoForBlockHash
- type VotesManager
- type VotesWrapper
- type VotesWrapperList
Constants ¶
const ( ValidatorProportionThreshold = 0.685 CertValProportionThreshold = 0.585 DefaultMsgTimerProportion = 0.5 DefaultStartVoteProportion = 0.34 )
const ( MsgNamePriority = "msgPriorityProposal" MsgNameBlock = "msgBlockProposal" MsgNamePrevote = "msgPrevote" MsgNamePrecommit = "msgPrecommit" MsgNameNext = "msgNext" MsgNameCert = "msgCertificate" )
const ( VoteMsgSize = 384 //293 PriorityMsgSize = 384 //261 )
const ( UConStepStart uint32 = 0 UConStepProposal = 1 // 1 UConStepPrevote = 2 // 2 UConStepPrecommit = 4 // 4 UConStepCertificate = 5 )
const MaxCachedMsgsCount = 1024
const MaxMsgsSingleInterval int64 = 10 // s
const OutdateFaultTolerance int64 = 10
const (
// HashLength is the expected length of the hash
RoundIndexHashLength = 12
)
Lengths of RoundIndexHash in bytes.
const VrfHashSizeInBits int64 = 256
Variables ¶
var ( // ErrInvalidConsensusData is returned if the length of extra-data is less than 32 bytes ErrInvalidConsensusData = errors.New("invalid consensus data") )
var ErrInvalidConsensusMsg = errors.New("invalid consensus message")
Functions ¶
func CompareCommonHash ¶
func ComputeSeed ¶
func GenerateEmptyBlock ¶
func GetInfoFromHash ¶
func GetInfoFromHash(h RoundIndexHash) (uint64, uint32)
func GetSignatureAddress ¶
func GetSignaturePublicKey ¶
func GetVoteFromBool ¶
func MessageCodeToString ¶
func MillionSecond ¶
func OppositeValidatorType ¶
func OppositeValidatorType(kind params.ValidatorKind) params.ValidatorKind
func PrepareConsensusData ¶
func PrepareConsensusData(header *types.Header, data *BlockConsensusData) ([]byte, error)
func ProbabilityForLimitedSampleing ¶
For: the probability of K's nodes be choosed
func ProbabilityForSampleing ¶
For: the probability of K's nodes be k where community size is big enough
func VoteTypeToString ¶
func VrfSortition ¶
Types ¶
type AddrVoteStatus ¶
type AddrVoteType ¶
type AddrVoteType uint8
type AddressMap ¶
type AddressMap map[common.Address]*AddressMsgInfo //time.Time
type AddressMsgInfo ¶
type AddressMsgInfo struct {
// contains filtered or unexported fields
}
type AddressMsgs ¶
type AddressMsgs struct {
// contains filtered or unexported fields
}
func NewAddressMsgs ¶
func NewAddressMsgs() *AddressMsgs
func (*AddressMsgs) NewAddressMsg ¶
func (am *AddressMsgs) NewAddressMsg(ev ReceivedMsgEvent, validatorKind params.ValidatorKind, chamberNum, houseNum uint64) (oldOver, futureOver, isValid bool)
type BlockConsensusData ¶
type BlockConsensusData struct { Round *big.Int RoundIndex uint32 Seed common.Hash SortitionProof []byte Priority common.Hash SubUsers uint32 Signature []byte ProposerThreshold uint64 ValidatorThreshold uint64 CertValThreshold uint64 }
func ExtractConsensusData ¶
func ExtractConsensusData(header *types.Header) (*BlockConsensusData, error)
func GetConsensusDataFromHeader ¶
func GetConsensusDataFromHeader(header *types.Header) (*BlockConsensusData, error)
BlockConsensusData should be added to types.Block, so that node can get parameters from local blockchain
func (*BlockConsensusData) GetPublicKey ¶
func (data *BlockConsensusData) GetPublicKey() (*ecdsa.PublicKey, error)
extract public key from Signature
func (*BlockConsensusData) IsValidRound ¶
func (data *BlockConsensusData) IsValidRound() (bool, error)
func (*BlockConsensusData) IsValidSeed ¶
func (data *BlockConsensusData) IsValidSeed() (bool, error)
func (*BlockConsensusData) IsValidTime ¶
func (data *BlockConsensusData) IsValidTime() (bool, error)
func (*BlockConsensusData) SetSignature ¶
func (data *BlockConsensusData) SetSignature(key *ecdsa.PrivateKey) error
type BlockHashWithVotes ¶
type BlockProposalEvent ¶
type BlsVerifier ¶
type BlsVerifier struct {
// contains filtered or unexported fields
}
func NewBlsVerifier ¶
func NewBlsVerifier(mgr bls.BlsManager) *BlsVerifier
func (*BlsVerifier) AggregateSignatures ¶
func (v *BlsVerifier) AggregateSignatures(rawSigs [][]byte) (aggregatedSig []byte, err error)
func (*BlsVerifier) GetBlsPubKey ¶
func (v *BlsVerifier) GetBlsPubKey(bspubKey []byte) (bls.PublicKey, error)
func (*BlsVerifier) GetVrfPubKey ¶
func (v *BlsVerifier) GetVrfPubKey(bspubKey []byte) (*ecdsa.PublicKey, error)
func (*BlsVerifier) PackVotes ¶
func (v *BlsVerifier) PackVotes(ev CommitEvent, backType params.LookBackType) (*UconValidators, error)
func (*BlsVerifier) RecoverSignerInfo ¶
func (v *BlsVerifier) RecoverSignerInfo(vs *state.Validators, vote *SingleVote) (signer *state.Validator, pk bls.PublicKey, vrfpk *ecdsa.PublicKey, err error)
type CachedBlockMessage ¶
type CachedBlockMessage struct {
// contains filtered or unexported fields
}
func (*CachedBlockMessage) GetContext ¶
func (m *CachedBlockMessage) GetContext() (*big.Int, uint32)
func (*CachedBlockMessage) Hash ¶
func (m *CachedBlockMessage) Hash() common.Hash
type CachedMessage ¶
type CachedMsgMgr ¶
type CachedMsgMgr struct {
// contains filtered or unexported fields
}
future round's message cache
func InitCachedMessages ¶
func InitCachedMessages() *CachedMsgMgr
func (*CachedMsgMgr) Clear ¶
func (c *CachedMsgMgr) Clear(round uint64, roundIndex uint32)
func (*CachedMsgMgr) GetMessages ¶
func (c *CachedMsgMgr) GetMessages(round uint64, roundIndex uint32, code MsgType) CachedMsgs
func (*CachedMsgMgr) NewMessage ¶
func (c *CachedMsgMgr) NewMessage(msg CachedMessage, code MsgType, addr common.Address, timestamp time.Time)
func (*CachedMsgMgr) RemoveMessages ¶
func (c *CachedMsgMgr) RemoveMessages(round uint64, roundIndex uint32, code MsgType)
type CachedMsgs ¶
type CachedMsgs []CachedMessage
type CachedPriorityMessage ¶
type CachedPriorityMessage struct {
// contains filtered or unexported fields
}
func (*CachedPriorityMessage) GetContext ¶
func (m *CachedPriorityMessage) GetContext() (*big.Int, uint32)
func (*CachedPriorityMessage) Hash ¶
func (m *CachedPriorityMessage) Hash() common.Hash
type CachedVotesMessage ¶
type CachedVotesMessage struct { VotesData *BlockHashWithVotes // contains filtered or unexported fields }
func (*CachedVotesMessage) GetContext ¶
func (m *CachedVotesMessage) GetContext() (*big.Int, uint32)
func (*CachedVotesMessage) Hash ¶
func (m *CachedVotesMessage) Hash() common.Hash
type CommitEvent ¶
type CommitEvent struct { Round *big.Int RoundIndex uint32 Block *types.Block ChamberPrecommits VotesInfoForBlockHash HousePrecommits VotesInfoForBlockHash ChamberCerts VotesInfoForBlockHash }
type ConsensusCommon ¶
type ContextChangeEvent ¶
type DatabaseDeleter ¶
DatabaseDeleter wraps the Delete method of a backing data store.
type DatabaseReader ¶
DatabaseReader wraps the Has and Get method of a backing data store.
type DatabaseWriter ¶
DatabaseWriter wraps the Put method of a backing data store.
type GetBlockInCacheFn ¶
type GetCurrentParamsFn ¶
type GetCurrentParamsFn func() *params.CaravelParams
type GetLookBackValidatorFn ¶
type InvalidMsgMaker ¶
type InvalidMsgMaker struct {
// contains filtered or unexported fields
}
func (*InvalidMsgMaker) DecodeFailedMsg ¶
func (m *InvalidMsgMaker) DecodeFailedMsg() []byte
func (*InvalidMsgMaker) DecodePayloadFailed ¶
func (m *InvalidMsgMaker) DecodePayloadFailed() []byte
func (*InvalidMsgMaker) EmptyRound ¶
func (m *InvalidMsgMaker) EmptyRound() []byte
func (*InvalidMsgMaker) InvalidAddress ¶
func (m *InvalidMsgMaker) InvalidAddress() []byte
func (*InvalidMsgMaker) InvalidSignature ¶
func (m *InvalidMsgMaker) InvalidSignature() []byte
func (*InvalidMsgMaker) InvalidSize ¶
func (m *InvalidMsgMaker) InvalidSize() []byte
func (*InvalidMsgMaker) InvalidVoteMsg ¶
func (m *InvalidMsgMaker) InvalidVoteMsg() []byte
type IsValidatorFn ¶
type LookBackMgr ¶
type LookBackMgr interface { CurrentCaravelParams() *params.CaravelParams // GetLookBackVldReader gets canonical look back validator reader GetLookBackVldReader(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) (state.ValidatorReader, error) }
type MarkedBlockInfo ¶
type Message ¶
func (*Message) DecodePayload ¶
func (*Message) EncodeNoSig ¶
func (*Message) PayloadHash ¶
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
func NewMessageHandler ¶
func NewMessageHandler(rawSk *ecdsa.PrivateKey, eventMux *event.TypeMux, getValidatorFn GetLookBackValidatorFn, processMsgFn ProcessReceivedMsgFn, processPriotiryMsg ProcessPriorityMsg, processProposedBlockMsg ProcessProposedBlockMsg, processVoteMsg ProcessVoteMsg) *MessageHandler
func (*MessageHandler) HandleMsg ¶
func (mh *MessageHandler) HandleMsg(data []byte, receivedAt time.Time) error
func (*MessageHandler) Start ¶
func (mh *MessageHandler) Start()
func (*MessageHandler) Stop ¶
func (mh *MessageHandler) Stop()
type MsgReceivedStatus ¶
type MsgReceivedStatus uint8
type OverThresholdFn ¶
type PriorityManager ¶
type PriorityManager struct {
// contains filtered or unexported fields
}
func NewPriorityMgr ¶
func NewPriorityMgr() *PriorityManager
type PriorityMsgEvent ¶
type PriorityMsgEvent struct {
Msg *CachedPriorityMessage
}
type ProcessPriorityMsg ¶
type ProcessPriorityMsg func(msg *CachedPriorityMessage, status MsgReceivedStatus) (error, bool)
type ProcessProposedBlockMsg ¶
type ProcessProposedBlockMsg func(msg *CachedBlockMessage, status MsgReceivedStatus) (error, bool)
type ProcessReceivedMsgFn ¶
type ProcessReceivedMsgFn func(event ReceivedMsgEvent) (error, bool)
type ProcessStepFn ¶
type ProcessStepFn func(step uint32)
type ProcessTimeoutFn ¶
type ProcessVoteMsg ¶
type ProcessVoteMsg func(ev VoteMsgEvent, status MsgReceivedStatus) (error, bool)
type Proposal ¶
type Proposal struct {
// contains filtered or unexported fields
}
func NewProposal ¶
func NewProposal(eventMux *event.TypeMux, verifyFn VerifyPriorityFn, startVoteFn StartVoteFn) *Proposal
type ProposedBlockMsgEvent ¶
type ProposedBlockMsgEvent struct {
Msg *CachedBlockMessage
}
type ReceivedMsgEvent ¶
type RoundIndexChangeEvent ¶
type RoundIndexHash ¶
type RoundIndexHash [RoundIndexHashLength]byte
func GenerateRoundIndexHash ¶
func GenerateRoundIndexHash(round uint64, index uint32) RoundIndexHash
func (*RoundIndexHash) SetBytes ¶
func (h *RoundIndexHash) SetBytes(b []byte)
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) CertificateParams ¶
func (*Server) CheckValidatorVotes ¶
func (s *Server) CheckValidatorVotes(chain consensus.ChainReader, header *types.Header) (map[common.Address]bool, error)
CheckValidatorVotes Check voting
func (*Server) CompareBlocks ¶
fork-selection rules
-1 if blockA < blockB 0 if blockA == blockB +1 if blockA > blockB
func (*Server) CurrentCaravelParams ¶
func (s *Server) CurrentCaravelParams() *params.CaravelParams
CurrentCaravelParams returns current round caravel parameters
func (*Server) FinalizeAndAssemble ¶
func (*Server) GetLookBackBlockHash ¶
func (s *Server) GetLookBackBlockHash(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) (common.Hash, error)
func (*Server) GetLookBackBlockNumber ¶
func (s *Server) GetLookBackBlockNumber(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) *big.Int
GetLookBackBlockNumber return the stake-look-back block number for the specific block number. when round > config.StakeLookBack, it returns round - config.StakeLookBack else it always return 0 (the genesis block number)
func (*Server) GetLookBackValidator ¶
func (*Server) GetLookBackVldReader ¶
func (s *Server) GetLookBackVldReader(cp *params.CaravelParams, num *big.Int, lbType params.LookBackType) (state.ValidatorReader, error)
func (*Server) GetValMainAddress ¶
func (*Server) GetValidatorAddrs ¶
func (*Server) GetValidatorByAddress ¶
func (*Server) HandleMsg ¶
HandleMsg handles related consensus messages or fallback to default procotol manager's handler
func (*Server) NewChainHead ¶
NewChainHead implements consensus.Ucon.NewChainHead
func (*Server) NextRound ¶
func (s *Server) NextRound(ev RoundIndexChangeEvent) error
NextRound will broadcast ChainHeadEvent to trigger next seal()
func (*Server) Seal ¶
func (s *Server) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal generates a new block for the given input block with the local miner's seal place on top.
func (*Server) SetValKey ¶
func (s *Server) SetValKey(sk *ecdsa.PrivateKey, blsKeyBytes []byte) (err error)
SetValKey sets the validator key
func (*Server) StartMining ¶
func (s *Server) StartMining(chain consensus.ChainReader, inserter consensus.MineInserter, eventMux *event.TypeMux) error
StartMining starts the engine to mine
func (*Server) StartNewRound ¶
func (*Server) TotalStakeOfKind ¶
TotalStakeOfKind 获取指定块上某类节点的 total stake
func (*Server) UpdateContextForNewBlock ¶
func (*Server) ValidatorsNumOfKind ¶
TotalStakeOfKind 获取指定块上某类节点的数量
func (*Server) VerifyAcHeader ¶
func (s *Server) VerifyAcHeader(chain consensus.ChainReader, acHeader *types.Header, verifiedAcParents []*types.Header) error
VerifyAcHeader verifies the header using and only using cht certificates
func (*Server) VerifyHeader ¶
VerifyHeader checks whether a header confirms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.
func (*Server) VerifyHeaders ¶
func (s *Server) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).
func (*Server) VerifySeal ¶
VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.
func (*Server) VerifySideChainHeader ¶
func (s *Server) VerifySideChainHeader(cp *params.CaravelParams, seedHeader *types.Header, vldReader state.ValidatorReader, certHeader *types.Header, certVldReader state.ValidatorReader, block *types.Block, parents []*types.Block) error
VerifySideChainHeader checks whether a side chain block confirms to the consensus rules
type SingleVote ¶
type SingleVote struct { VoterIdx uint32 Votes uint32 Signature []byte Proof []byte // used to verify whether is a validator }
data structure for statistics
type SortitionData ¶
type SortitionManager ¶
type SortitionManager struct {
// contains filtered or unexported fields
}
one round, multiple roundIndex
func NewSortitionManager ¶
func NewSortitionManager(vrfSk vrf.PrivateKey, getStake getStakeFn, getLookBackSeed getLookBackSeedFn, addr common.Address) *SortitionManager
func (*SortitionManager) ClearStepView ¶
func (sm *SortitionManager) ClearStepView(round *big.Int)
func (*SortitionManager) GetStepView ¶
func (*SortitionManager) NewStepView ¶
type StepView ¶
type StepView struct { Priority common.Hash SortitionProof []byte //SortitionValue common.Hash SubUsers uint32 //SeedProof []byte SeedValue common.Hash ValidatorType params.ValidatorKind Threshold uint64 }
data structure for StepView info
type StepViews ¶
func NewStepViews ¶
func NewStepViews() StepViews
type TimerManager ¶
type TimerManager struct {
// contains filtered or unexported fields
}
func NewTimerManager ¶
func NewTimerManager(timeoutFn ProcessTimeoutFn, stepFn ProcessStepFn) *TimerManager
func (*TimerManager) NewAddressMsg ¶
func (tm *TimerManager) NewAddressMsg(ev ReceivedMsgEvent, validatorKind params.ValidatorKind, chamberNum, houseNum uint64) bool
func (*TimerManager) Pause ¶ added in v0.9.6
func (tm *TimerManager) Pause()
func (*TimerManager) Start ¶
func (tm *TimerManager) Start()
func (*TimerManager) Stop ¶
func (tm *TimerManager) Stop()
should be called when stop the consensus server
type TransferMessageEvent ¶
type TypedCacheMsgs ¶
type TypedCacheMsgs struct {
// contains filtered or unexported fields
}
func NewTypedCacheMsgs ¶
func NewTypedCacheMsgs() *TypedCacheMsgs
func (*TypedCacheMsgs) Clear ¶
func (m *TypedCacheMsgs) Clear(round uint64, roundIndex uint32)
func (*TypedCacheMsgs) GetMessages ¶
func (m *TypedCacheMsgs) GetMessages(round uint64, roundIndex uint32) CachedMsgs
func (*TypedCacheMsgs) NewMessage ¶
func (m *TypedCacheMsgs) NewMessage(msg CachedMessage)
func (*TypedCacheMsgs) RemoveMessages ¶
func (m *TypedCacheMsgs) RemoveMessages(round uint64, roundIndex uint32)
type UconValidators ¶
type UconValidators struct { RoundIndex uint32 ChamberCommitters []SingleVote HouseCommitters []SingleVote ChamberCerts []SingleVote SCAggrSig []byte // bls aggregated signature for ChamberCommitters MCAggrSig []byte // bls aggregated signature for HouseCommitters CCAggrSig []byte // bls aggregated signature for ChamberCerts }
func ExtractUconValidators ¶
func ExtractUconValidators(h *types.Header, backType params.LookBackType) (*UconValidators, error)
ExtractUconValidators extracts all values of the UconValidators from the header. It returns an error if the length of the given validator-data is less than 32 bytes or the validator-data can not be decoded.
func NewUconValidators ¶
func NewUconValidators(ev CommitEvent, backType params.LookBackType) *UconValidators
func (*UconValidators) ValidatorsToByte ¶
func (uc *UconValidators) ValidatorsToByte() ([]byte, error)
type UpdateExistedHeaderEvent ¶
type UpdateExistedHeaderEvent struct { Round *big.Int RoundIndex uint32 BlockHash common.Hash ChamberPrecommits VotesInfoForBlockHash HousePrecommits VotesInfoForBlockHash }
type VerifyPriorityFn ¶
type VerifyPriorityFn func(pubkey *ecdsa.PublicKey, data *ConsensusCommon) error
type VerifySortitionFn ¶
type VerifySortitionFn func(pubKey *ecdsa.PublicKey, data *SortitionData, lbType params.LookBackType) error
type VoteBLSMgr ¶
type VoteBLSMgr struct { Verifier *BlsVerifier // contains filtered or unexported fields }
func NewVoteBLSMgr ¶
func NewVoteBLSMgr(rawSk *ecdsa.PrivateKey, blsSk bls.SecretKey) *VoteBLSMgr
func (*VoteBLSMgr) RecoverSignerInfo ¶
func (vb *VoteBLSMgr) RecoverSignerInfo(vs *state.Validators, vote *SingleVote) (signer *state.Validator, pk bls.PublicKey, vrfpk *ecdsa.PublicKey, err error)
func (*VoteBLSMgr) SetLookBackMgr ¶
func (vb *VoteBLSMgr) SetLookBackMgr(lbmgr LookBackMgr)
func (*VoteBLSMgr) SignVote ¶
func (vb *VoteBLSMgr) SignVote(voteType VoteType, voteInfo *SingleVote, payload []byte) error
type VoteDB ¶
type VoteDB struct {
// contains filtered or unexported fields
}
func (*VoteDB) ExistVoteData ¶
type VoteItem ¶
type VoteMsgEvent ¶
type VoteMsgEvent struct { Msg *CachedVotesMessage VType VoteType }
type VoteStatus ¶
type VoteStatus struct {
// contains filtered or unexported fields
}
type Voter ¶
type Voter struct {
// contains filtered or unexported fields
}
func NewVoter ¶
func NewVoter(db youdb.Database, rawSk *ecdsa.PrivateKey, blsSk bls.SecretKey, eventMux *event.TypeMux, verifySortitionFn VerifySortitionFn, isValidatorFn IsValidatorFn, getHashFn BlockHashWithMaxPriorityFn, blockInCacheFn GetBlockInCacheFn, getStake getStakeFn, getValidatorsCount getValidatorsCountFn, pmgr paramsManager) *Voter
func (*Voter) PackVotes ¶
func (v *Voter) PackVotes(ev CommitEvent, backType params.LookBackType) (*UconValidators, error)
func (*Voter) RecoverSignerInfo ¶
func (*Voter) SetLookBackMgr ¶
func (v *Voter) SetLookBackMgr(lbmgr LookBackMgr)
func (*Voter) Start ¶
func (v *Voter) Start(lbmgr LookBackMgr)
type VotesInfoForBlockHash ¶
type VotesInfoForBlockHash map[common.Address]*SingleVote
func NewVotesInfoForBlockHash ¶
func NewVotesInfoForBlockHash() VotesInfoForBlockHash
type VotesManager ¶
type VotesManager struct {
// contains filtered or unexported fields
}
func NewVotesManager ¶
func NewVotesManager() *VotesManager
type VotesWrapper ¶
type VotesWrapper struct {
// contains filtered or unexported fields
}
func NewVotesWrapper ¶
func NewVotesWrapper() *VotesWrapper
type VotesWrapperList ¶
type VotesWrapperList struct {
// contains filtered or unexported fields
}
func NewVotesWrapperList ¶
func NewVotesWrapperList() *VotesWrapperList
func (*VotesWrapperList) GetWrapper ¶
func (v *VotesWrapperList) GetWrapper(round *big.Int, roundIndex uint32) *VotesWrapper
func (*VotesWrapperList) NewWrapper ¶
func (v *VotesWrapperList) NewWrapper(round *big.Int, roundIndex uint32) *VotesWrapper
Source Files ¶
- block_consensus_data.go
- config.go
- consensus.go
- events.go
- init.go
- interfaces.go
- lookback_mgr.go
- make_invalid_msg.go
- msg_cache.go
- msg_handler.go
- parameters.go
- priority_mgr.go
- proposal.go
- signature.go
- sortition.go
- sortition_mgr.go
- sortition_verifier.go
- staking.go
- timer_mgr.go
- types.go
- ucon.go
- ucon_validators.go
- utils.go
- vote_bls.go
- vote_cache.go
- voter.go
- votes_mgr.go