Documentation
¶
Index ¶
- Constants
- Variables
- func GetAuctionInitialRelease() float64
- func GetAuctionReservedPrice() *big.Int
- func GetRelayPeers(myIndex, size int) (peers []int)
- func HandleScheduleLeader(conR *ConsensusReactor, epochID uint64, height uint32, round uint32, ...) bool
- func HandleScheduleReplayLeader(conR *ConsensusReactor, epochID uint64, height uint32, round uint32, ...) bool
- func IsCritical(err error) bool
- func IsFutureBlock(err error) bool
- func IsKnownBlock(err error) bool
- func IsParentMissing(err error) bool
- func LeaderMajorityTwoThird(voterNum, committeeSize uint32) bool
- func MajorityTwoThird(voterNum, committeeSize uint32) bool
- func NewConsensusCommonFromBlsCommon(blsCommon *BlsCommon) *types.ConsensusCommon
- func PrintDelegates(delegates []*types.Delegate)
- func RegisterConsensusMessages(cdc *amino.Codec)
- func SetConsensusGlobInst(inst *ConsensusReactor)
- func UserHomeDir() string
- func VerifyMsgType(m ConsensusMessage) bool
- func VerifySignature(m ConsensusMessage) bool
- type AnnounceCommitteeMessage
- type ApiCommitteeMember
- type BlockProbe
- type BlockType
- type BlsCommon
- type CommitCommitteeMessage
- type ConsensusConfig
- type ConsensusLeader
- func (cl *ConsensusLeader) CreateAnnounceMsgPeers() []*ConsensusPeer
- func (cl *ConsensusLeader) CreateNotaryMsgPeers() []*ConsensusPeer
- func (cl *ConsensusLeader) GenerateAnnounceMsg(height uint32, round uint32) bool
- func (cl *ConsensusLeader) GenerateNotaryAnnounceMsg() bool
- func (cl *ConsensusLeader) MoveInitState(curState byte) bool
- func (cl *ConsensusLeader) ProcessCommitMsg(commitMsg *CommitCommitteeMessage, src *ConsensusPeer) bool
- func (cl *ConsensusLeader) SendMsg(msg ConsensusMessage) bool
- type ConsensusMessage
- type ConsensusMsgCommonHeader
- type ConsensusPeer
- type ConsensusReactor
- func (conR *ConsensusReactor) BuildAnnounceSignMsg(pubKey ecdsa.PublicKey, epochID uint64, height uint64, round uint32) string
- func (conR *ConsensusReactor) BuildCommitteeInfoFromMember(system *bls.System, cms []types.CommitteeMember) []block.CommitteeInfo
- func (conR *ConsensusReactor) BuildCommitteeMemberFromInfo(system *bls.System, cis []block.CommitteeInfo) []types.CommitteeMember
- func (conR *ConsensusReactor) BuildKBlock(parentBlock *block.Block, data *block.KBlockData, rewards []powpool.PowReward) *ProposedBlockInfo
- func (conR *ConsensusReactor) BuildMBlock(parentBlock *block.Block) *ProposedBlockInfo
- func (conR *ConsensusReactor) BuildNewCommitteeSignMsg(pubKey ecdsa.PublicKey, epochID uint64, height uint64) string
- func (conR *ConsensusReactor) BuildNotaryAnnounceSignMsg(pubKey ecdsa.PublicKey, epochID uint64, height uint64, round uint32) string
- func (conR *ConsensusReactor) BuildProposalBlockSignMsg(blockType uint32, height uint64, id, txsRoot, stateRoot *meter.Bytes32) string
- func (conR *ConsensusReactor) BuildStopCommitteeBlock(parentBlock *block.Block) *ProposedBlockInfo
- func (conR *ConsensusReactor) CalcCommitteeByNonce(nonce uint64) (*types.ValidatorSet, uint, int, bool)
- func (conR *ConsensusReactor) CheckEstablishedCommittee(kHeight uint32) bool
- func (conR *ConsensusReactor) CommitteeInfoCompare(cm1, cm2 []block.CommitteeInfo) bool
- func (conR *ConsensusReactor) ConsensusHandleReceivedNonce(kBlockHeight uint32, nonce, epoch uint64, replay bool)
- func (conR *ConsensusReactor) FinalizeCommitBlock(blkInfo *ProposedBlockInfo, bestQC *block.QuorumCert) error
- func (conR *ConsensusReactor) GetActualCommitteeMemberIndex(pubKey *ecdsa.PublicKey) int
- func (conR *ConsensusReactor) GetCommitteeMember(pubKey []byte) *types.CommitteeMember
- func (conR *ConsensusReactor) GetCommitteeMemberIndex(pubKey ecdsa.PublicKey) int
- func (conR *ConsensusReactor) GetConsensusDelegates() ([]*types.Delegate, int, int)
- func (conR *ConsensusReactor) GetDelegateNameByIP(ip net.IP) string
- func (conR *ConsensusReactor) GetDelegatesSource() string
- func (conR *ConsensusReactor) GetLastKBlockHeight() uint32
- func (conR *ConsensusReactor) GetLatestCommitteeList() ([]*ApiCommitteeMember, error)
- func (conR *ConsensusReactor) GetMyActualCommitteeIndex() int
- func (conR *ConsensusReactor) GetMyName() string
- func (conR *ConsensusReactor) GetMyNetAddr() types.NetAddress
- func (conR *ConsensusReactor) GetMyPeers() ([]*ConsensusPeer, error)
- func (conR *ConsensusReactor) GetRelayPeers(round int) ([]*ConsensusPeer, error)
- func (conR *ConsensusReactor) HandleKBlockData(kd block.KBlockData)
- func (conR *ConsensusReactor) HandleRecvKBlockInfo(ki RecvKBlockInfo)
- func (conR *ConsensusReactor) HandleSchedule(fn func()) bool
- func (conR *ConsensusReactor) IsCommitteeMember() bool
- func (conR *ConsensusReactor) IsPacemakerRunning() bool
- func (conR *ConsensusReactor) JoinEstablishedCommittee(kBlock *block.Block, replay bool)
- func (conR *ConsensusReactor) LoadBlockBytes(num uint32) []byte
- func (conR *ConsensusReactor) MakeBlockCommitteeInfo(system *bls.System, cms []types.CommitteeMember) []block.CommitteeInfo
- func (conR *ConsensusReactor) MarshalMsg(msg *ConsensusMessage) ([]byte, error)
- func (conR *ConsensusReactor) NewCommitteeCleanup()
- func (conR *ConsensusReactor) NewCommitteeInit(height uint32, nonce uint64, replay bool)
- func (conR *ConsensusReactor) NewCommitteeTimeout()
- func (conR *ConsensusReactor) NewCommitteeTimerStart()
- func (conR *ConsensusReactor) NewCommitteeTimerStop()
- func (conR *ConsensusReactor) NewCommitteeUpdateRound(round uint32)
- func (conR *ConsensusReactor) NewConsensusStart() int
- func (conR *ConsensusReactor) NewConsensusStop() int
- func (c *ConsensusReactor) NewRuntimeForReplay(header *block.Header) (*runtime.Runtime, error)
- func (conR *ConsensusReactor) NewValidatorSetByNonce(nonce uint64) (uint, bool)
- func (conR *ConsensusReactor) OnStart() error
- func (conR *ConsensusReactor) OnStop()
- func (conR *ConsensusReactor) PacemakerProbe() *PMProbeResult
- func (conR *ConsensusReactor) PreCommitBlock(blkInfo *ProposedBlockInfo) error
- func (conR *ConsensusReactor) PrepareEnvForPacemaker() error
- func (c *ConsensusReactor) Process(blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)
- func (conR *ConsensusReactor) ProcessNewCommitteeMessage(newCommitteeMsg *NewCommitteeMessage, src *ConsensusPeer) bool
- func (c *ConsensusReactor) ProcessProposedBlock(parentHeader *block.Header, blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)
- func (conR *ConsensusReactor) ReceiveCommitteeMsg(w http.ResponseWriter, r *http.Request)
- func (conR *ConsensusReactor) ReceivePacemakerMsg(w http.ResponseWriter, r *http.Request)
- func (conR *ConsensusReactor) RefreshCurHeight() error
- func (conR *ConsensusReactor) ScheduleLeader(epochID uint64, height uint32, round uint32, ev *NCEvidence, d time.Duration) bool
- func (conR *ConsensusReactor) ScheduleReplayLeader(epochID uint64, height uint32, round uint32, ev *NCEvidence, d time.Duration) bool
- func (conR *ConsensusReactor) SignConsensusMsg(msgHash []byte) (sig []byte, err error)
- func (conR *ConsensusReactor) String() string
- func (conR *ConsensusReactor) SwitchToConsensus()
- func (conR *ConsensusReactor) UnmarshalMsg(data []byte) (*consensusMsgInfo, error)
- func (conR *ConsensusReactor) UpdateActualCommittee(leaderIndex uint32) bool
- func (conR *ConsensusReactor) UpdateCurDelegates()
- func (conR *ConsensusReactor) UpdateHeight(height uint32) bool
- func (conR *ConsensusReactor) UpdateLastKBlockHeight(height uint32) bool
- type ConsensusValidator
- func (cv *ConsensusValidator) GenerateCommitMessage(sig bls.Signature, msgHash [32]byte, round uint32) *CommitCommitteeMessage
- func (cv *ConsensusValidator) ProcessAnnounceCommittee(announceMsg *AnnounceCommitteeMessage, src *ConsensusPeer) bool
- func (cv *ConsensusValidator) ProcessNotaryAnnounceMessage(notaryMsg *NotaryAnnounceMessage, src *ConsensusPeer) bool
- func (cv *ConsensusValidator) RemoveAllcsPeers() bool
- func (cv *ConsensusValidator) SendMsgToPeer(msg *ConsensusMessage, netAddr types.NetAddress) bool
- type MsgCache
- type NCEvidence
- type NewCommittee
- type NewCommitteeKey
- type NewCommitteeMessage
- type NewViewReason
- type NotaryAnnounceMessage
- type PMBeatInfo
- type PMCmd
- type PMCmdInfo
- type PMMode
- type PMNewViewMessage
- type PMProbeResult
- type PMProposalMessage
- func (m *PMProposalMessage) CompactString() string
- func (m *PMProposalMessage) EpochID() uint64
- func (m *PMProposalMessage) Header() *ConsensusMsgCommonHeader
- func (m *PMProposalMessage) MsgType() byte
- func (m *PMProposalMessage) SigningHash() (hash meter.Bytes32)
- func (m *PMProposalMessage) String() string
- type PMQueryProposalMessage
- type PMRoundState
- type PMRoundTimeoutInfo
- type PMTimeoutCert
- type PMTimeoutCertManager
- type PMVoteMessage
- type Pacemaker
- func (p *Pacemaker) AddressBlock(height uint32) *pmBlock
- func (p *Pacemaker) BlockMatchQC(b *pmBlock, qc *block.QuorumCert) (bool, error)
- func (p *Pacemaker) BuildNewViewMessage(nextHeight, nextRound uint32, qcHigh *pmQuorumCert, reason NewViewReason, ...) (*PMNewViewMessage, error)
- func (p *Pacemaker) BuildNewViewSignMsg(pubKey ecdsa.PublicKey, reason NewViewReason, height, round uint32, ...) string
- func (p *Pacemaker) BuildProposalMessage(height, round uint32, bnew *pmBlock, tc *PMTimeoutCert) (*PMProposalMessage, error)
- func (p *Pacemaker) BuildQueryProposalMessage(fromHeight, toHeight, round uint32, epochID uint64, retAddr types.NetAddress) (*PMQueryProposalMessage, error)
- func (p *Pacemaker) BuildVoteForProposalMessage(proposalMsg *PMProposalMessage, blockID, txsRoot, stateRoot meter.Bytes32) (*PMVoteMessage, error)
- func (p *Pacemaker) CreateLeaf(parent *pmBlock, qc *pmQuorumCert, height, round uint32) *pmBlock
- func (p *Pacemaker) Execute(b *pmBlock)
- func (p *Pacemaker) GetRelayPeers(round uint32) []*ConsensusPeer
- func (p *Pacemaker) IsExtendedFromBLocked(b *pmBlock) bool
- func (p *Pacemaker) IsStopped() bool
- func (p *Pacemaker) OnBeat(height, round uint32, reason beatReason) error
- func (p *Pacemaker) OnCommit(commitReady []*pmBlock)
- func (p *Pacemaker) OnNextSyncView(nextHeight, nextRound uint32, reason NewViewReason, ti *PMRoundTimeoutInfo)
- func (p *Pacemaker) OnPreCommitBlock(b *pmBlock) error
- func (p *Pacemaker) OnPropose(b *pmBlock, qc *pmQuorumCert, height, round uint32) (*pmBlock, error)
- func (p *Pacemaker) OnReceiveNewView(mi *consensusMsgInfo) error
- func (p *Pacemaker) OnReceiveProposal(mi *consensusMsgInfo) error
- func (p *Pacemaker) OnReceiveQueryProposal(mi *consensusMsgInfo) error
- func (p *Pacemaker) OnReceiveVote(mi *consensusMsgInfo) error
- func (p *Pacemaker) OnRoundTimeout(ti PMRoundTimeoutInfo)
- func (p *Pacemaker) OnTimeoutBeat(height, round uint32, reason beatReason) error
- func (p *Pacemaker) Probe() *PMProbeResult
- func (p *Pacemaker) Restart(mode PMMode)
- func (p *Pacemaker) ScheduleOnBeat(height, round uint32, reason beatReason, d time.Duration) bool
- func (p *Pacemaker) SendCatchUpQuery()
- func (p *Pacemaker) SendConsensusMessage(round uint32, msg ConsensusMessage, copyMyself bool) bool
- func (p *Pacemaker) SendKblockInfo(b *pmBlock)
- func (p *Pacemaker) Start(mode PMMode)
- func (p *Pacemaker) Stop()
- func (p *Pacemaker) Update(bnew *pmBlock) error
- func (p *Pacemaker) UpdateQCHigh(qc *pmQuorumCert) bool
- func (p *Pacemaker) ValidateProposal(b *pmBlock) error
- type PendingList
- type ProposalMap
- type ProposedBlockInfo
- type RecvKBlockInfo
- type SignatureAggregator
- type ValidatorReward
- type ValidatorRewardList
- func (v *ValidatorRewardList) Count() int
- func (v *ValidatorRewardList) Get(epoch uint32) *ValidatorReward
- func (v *ValidatorRewardList) GetList() []*ValidatorReward
- func (v *ValidatorRewardList) String() string
- func (v *ValidatorRewardList) ToList() []*ValidatorReward
- func (v *ValidatorRewardList) ToString() string
Constants ¶
const ( // FSM of Committee Leader COMMITTEE_LEADER_INIT = byte(0x01) COMMITTEE_LEADER_ANNOUNCED = byte(0x02) // COMMITTEE_LEADER_NOTARYSENT = byte(0x03) COMMITTEE_LEADER_COMMITED = byte(0x04) THRESHOLD_TIMER_TIMEOUT = 4 * time.Second //wait for reach 2/3 consensus timeout )
const ( // FSM of VALIDATOR COMMITTEE_VALIDATOR_INIT = byte(0x01) COMMITTEE_VALIDATOR_COMMITSENT = byte(0x02) )
for all committee mermbers
const ( //Consensus Message Type CONSENSUS_MSG_NEW_COMMITTEE = byte(0x01) CONSENSUS_MSG_ANNOUNCE_COMMITTEE = byte(0x02) CONSENSUS_MSG_COMMIT_COMMITTEE = byte(0x03) CONSENSUS_MSG_NOTARY_ANNOUNCE = byte(0x04) // CONSENSUS_MSG_PROPOSAL_BLOCK = byte(0x03) // CONSENSUS_MSG_NOTARY_BLOCK = byte(0x05) // CONSENSUS_MSG_VOTE_FOR_PROPOSAL = byte(0x06) // CONSENSUS_MSG_VOTE_FOR_NOTARY = byte(0x07) // CONSENSUS_MSG_MOVE_NEW_ROUND = byte(0x08) PACEMAKER_MSG_PROPOSAL = byte(0x10) PACEMAKER_MSG_VOTE = byte(0x11) PACEMAKER_MSG_NEW_VIEW = byte(0x12) PACEMAKER_MSG_QUERY_PROPOSAL = byte(0x13) )
const ( RoundInterval = 2 * time.Second RoundTimeoutInterval = 20 * time.Second // move the timeout from 30 to 20 secs. MIN_MBLOCKS_AN_EPOCH = uint32(4) CATCH_UP_THRESHOLD = 5 )
const ( PMModeNormal PMMode = 1 PMModeCatchUp = 2 PMModeObserve = 3 )
const ( UpdateOnBeat = roundUpdateReason(1) UpdateOnRegularProposal = roundUpdateReason(2) UpdateOnTimeout = roundUpdateReason(3) UpdateOnTimeoutCertProposal = roundUpdateReason(4) BeatOnInit = beatReason(0) BeatOnHigherQC = beatReason(1) BeatOnTimeout = beatReason(2) TimerInit = roundTimerUpdateReason(0) TimerInc = roundTimerUpdateReason(1) )
const ( MsgHashSize = 8 //normally when a block is committed, wait for a while to let whole network to sync and move to next round WHOLE_NETWORK_BLOCK_SYNC_TIME = 5 * time.Second CHAN_DEFAULT_BUF_SIZE = 100 DEFAULT_EPOCHS_PERDAY = 24 )
const ( CONSENSUS_MODE_OTHER = byte(0x01) CONSENSUS_MODE_OBSERVER = byte(0x02) CONSENSUS_MODE_DELEGATE = byte(0x03) CONSENSUS_MODE_COMMITTEE = byte(0x04) // Flags of Roles CONSENSUS_COMMIT_ROLE_NONE = uint(0x0) CONSENSUS_COMMIT_ROLE_LEADER = uint(0x01) CONSENSUS_COMMIT_ROLE_PROPOSER = uint(0x02) CONSENSUS_COMMIT_ROLE_VALIDATOR = uint(0x04) )
const (
MSG_KEEP_HEIGHT = 80
)
const (
NEW_COMMITTEE_INIT_INTV = 30 * time.Second // 30s
)
const PROPOSAL_MAP_MAX_SIZE = 40
const (
STAKING_MAX_VALIDATOR_REWARDS = 1200
)
Variables ¶
Functions ¶
func GetAuctionInitialRelease ¶ added in v1.2.0
func GetAuctionInitialRelease() float64
func GetAuctionReservedPrice ¶ added in v1.2.0
func GetRelayPeers ¶
Assumptions to use this: myIndex is always 0 for proposer (or leader in consensus) indexes starts from 0 1st layer: 0 (proposer) 2nd layer: [1, 2], [3, 4], [5, 6], [7, 8] 3rd layer (32 groups): [9..] ...
func HandleScheduleLeader ¶
func HandleScheduleLeader(conR *ConsensusReactor, epochID uint64, height uint32, round uint32, ev *NCEvidence) bool
func HandleScheduleReplayLeader ¶
func HandleScheduleReplayLeader(conR *ConsensusReactor, epochID uint64, height uint32, round uint32, ev *NCEvidence) bool
-------------------------------
func IsCritical ¶
IsCritical returns if the error is consensus related.
func IsFutureBlock ¶
IsFutureBlock returns if the error indicates that the block should be processed later.
func IsKnownBlock ¶
IsKnownBlock returns if the error means the block was already in the chain.
func LeaderMajorityTwoThird ¶
for committee The voteNum does not include leader himself
func MajorityTwoThird ¶
since votes of pacemaker include propser, but committee votes do not have leader itself, we seperate the majority func Easier adjust the logic of major 2/3, for pacemaker
func NewConsensusCommonFromBlsCommon ¶
func NewConsensusCommonFromBlsCommon(blsCommon *BlsCommon) *types.ConsensusCommon
func PrintDelegates ¶
func SetConsensusGlobInst ¶
func SetConsensusGlobInst(inst *ConsensusReactor)
func UserHomeDir ¶
func UserHomeDir() string
func VerifyMsgType ¶
func VerifyMsgType(m ConsensusMessage) bool
func VerifySignature ¶
func VerifySignature(m ConsensusMessage) bool
Types ¶
type AnnounceCommitteeMessage ¶
type AnnounceCommitteeMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
AnnouncerID []byte //ecdsa.PublicKey
AnnouncerBlsPK []byte //bls.PublicKey
CommitteeSize uint32
Nonce uint64 //nonce is 8 bytes
KBlockHeight uint32 // kblockdata
POWBlockHeight uint32
//collected NewCommittee signature
VotingBitArray *cmn.BitArray
VotingMsgHash [32]byte // all message hash from Newcommittee msgs
VotingAggSig []byte // aggregate signature of voterSig above
}
New Consensus Message Definitions --------------------------------------- AnnounceCommitteeMessage is sent when new committee is relayed. The leader of new committee send out to announce the new committee is setup, after collects the majority signature from new committee members.
func (*AnnounceCommitteeMessage) EpochID ¶
func (m *AnnounceCommitteeMessage) EpochID() uint64
func (*AnnounceCommitteeMessage) Header ¶
func (m *AnnounceCommitteeMessage) Header() *ConsensusMsgCommonHeader
func (*AnnounceCommitteeMessage) MsgType ¶
func (m *AnnounceCommitteeMessage) MsgType() byte
func (*AnnounceCommitteeMessage) SigningHash ¶
func (m *AnnounceCommitteeMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*AnnounceCommitteeMessage) String ¶
func (m *AnnounceCommitteeMessage) String() string
String returns a string representation.
type ApiCommitteeMember ¶
type BlockProbe ¶ added in v1.2.0
type BlsCommon ¶
type BlsCommon struct {
PrivKey bls.PrivateKey //my private key
PubKey bls.PublicKey //my public key
// contains filtered or unexported fields
}
func NewBlsCommon ¶
func NewBlsCommon() *BlsCommon
func NewBlsCommonFromParams ¶
func (*BlsCommon) GetPrivKey ¶
func (cc *BlsCommon) GetPrivKey() bls.PrivateKey
type CommitCommitteeMessage ¶
type CommitCommitteeMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
CommitterID []byte //ecdsa.PublicKey
CommitterBlsPK []byte //bls.PublicKey
CommitterIndex uint32
BlsSignature []byte //bls.Signature
SignedMsgHash [32]byte //bls signed message hash
}
CommitCommitteMessage is sent after announce committee is received. Told the Leader there is enough member to setup the committee.
func (*CommitCommitteeMessage) EpochID ¶
func (m *CommitCommitteeMessage) EpochID() uint64
func (*CommitCommitteeMessage) Header ¶
func (m *CommitCommitteeMessage) Header() *ConsensusMsgCommonHeader
func (*CommitCommitteeMessage) MsgType ¶
func (m *CommitCommitteeMessage) MsgType() byte
func (*CommitCommitteeMessage) SigningHash ¶
func (m *CommitCommitteeMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*CommitCommitteeMessage) String ¶
func (m *CommitCommitteeMessage) String() string
String returns a string representation.
type ConsensusConfig ¶
type ConsensusLeader ¶
type ConsensusLeader struct {
EpochID uint64
Nonce uint64
// contains filtered or unexported fields
}
func NewCommitteeLeader ¶
func NewCommitteeLeader(conR *ConsensusReactor) *ConsensusLeader
New CommitteeLeader
func (*ConsensusLeader) CreateAnnounceMsgPeers ¶
func (cl *ConsensusLeader) CreateAnnounceMsgPeers() []*ConsensusPeer
curCommittee others except myself
func (*ConsensusLeader) CreateNotaryMsgPeers ¶
func (cl *ConsensusLeader) CreateNotaryMsgPeers() []*ConsensusPeer
ActulCommittee except myself
func (*ConsensusLeader) GenerateAnnounceMsg ¶
func (cl *ConsensusLeader) GenerateAnnounceMsg(height uint32, round uint32) bool
Committee leader create AnnounceCommittee to all peers
func (*ConsensusLeader) GenerateNotaryAnnounceMsg ¶
func (cl *ConsensusLeader) GenerateNotaryAnnounceMsg() bool
After announce vote > 2/3, Leader generate Notary Committee leader create NotaryAnnounce to all members
func (*ConsensusLeader) MoveInitState ¶
func (cl *ConsensusLeader) MoveInitState(curState byte) bool
Move to the init State
func (*ConsensusLeader) ProcessCommitMsg ¶
func (cl *ConsensusLeader) ProcessCommitMsg(commitMsg *CommitCommitteeMessage, src *ConsensusPeer) bool
process commitCommittee in response of announce committee
func (*ConsensusLeader) SendMsg ¶
func (cl *ConsensusLeader) SendMsg(msg ConsensusMessage) bool
send consensus message to all connected peers
type ConsensusMessage ¶
type ConsensusMessage interface {
String() string
EpochID() uint64
MsgType() byte
Header() *ConsensusMsgCommonHeader
SigningHash() meter.Bytes32
}
ConsensusMessage is a message that can be sent and received on the ConsensusReactor
type ConsensusMsgCommonHeader ¶
type ConsensusMsgCommonHeader struct {
Height uint32
Round uint32
Sender []byte //ecdsa.PublicKey
Timestamp time.Time
MsgType byte
MsgSubType byte
EpochID uint64
Signature []byte // ecdsa signature of whole consensus message
}
ConsensusMsgCommonHeader
func (*ConsensusMsgCommonHeader) SetMsgSignature ¶
func (cmh *ConsensusMsgCommonHeader) SetMsgSignature(sig []byte)
type ConsensusPeer ¶
type ConsensusPeer struct {
// contains filtered or unexported fields
}
Consensus Topology Peer
func (*ConsensusPeer) FullString ¶
func (cp *ConsensusPeer) FullString() string
func (*ConsensusPeer) String ¶
func (cp *ConsensusPeer) String() string
type ConsensusReactor ¶
type ConsensusReactor struct {
SyncDone bool
// kBlock data
KBlockDataQueue chan block.KBlockData // from POW simulation
RcvKBlockInfoQueue chan RecvKBlockInfo // this channel for kblock notify from node module.
// contains filtered or unexported fields
}
----------------------------------------------------------------------------- ConsensusReactor defines a reactor for the consensus service.
var (
ConsensusGlobInst *ConsensusReactor
)
func NewConsensusReactor ¶
func NewConsensusReactor(ctx *cli.Context, chain *chain.Chain, state *state.Creator, privKey *ecdsa.PrivateKey, pubKey *ecdsa.PublicKey, magic [4]byte, blsCommon *BlsCommon, initDelegates []*types.Delegate) *ConsensusReactor
NewConsensusReactor returns a new ConsensusReactor with the given consensusState.
func (*ConsensusReactor) BuildAnnounceSignMsg ¶
func (conR *ConsensusReactor) BuildAnnounceSignMsg(pubKey ecdsa.PublicKey, epochID uint64, height uint64, round uint32) string
---------------------------------------------------------------------------- Sign Announce Committee "Announce Committee Message: Leader <pubkey 64(hexdump 32x2) bytes> EpochID <16 (8x2)bytes> Height <16 (8x2) bytes> Round <8(4x2)bytes>
func (*ConsensusReactor) BuildCommitteeInfoFromMember ¶
func (conR *ConsensusReactor) BuildCommitteeInfoFromMember(system *bls.System, cms []types.CommitteeMember) []block.CommitteeInfo
build block committee info part
func (*ConsensusReactor) BuildCommitteeMemberFromInfo ¶
func (conR *ConsensusReactor) BuildCommitteeMemberFromInfo(system *bls.System, cis []block.CommitteeInfo) []types.CommitteeMember
de-serialize the block committee info part
func (*ConsensusReactor) BuildKBlock ¶
func (conR *ConsensusReactor) BuildKBlock(parentBlock *block.Block, data *block.KBlockData, rewards []powpool.PowReward) *ProposedBlockInfo
func (*ConsensusReactor) BuildMBlock ¶
func (conR *ConsensusReactor) BuildMBlock(parentBlock *block.Block) *ProposedBlockInfo
Build MBlock
func (*ConsensusReactor) BuildNewCommitteeSignMsg ¶
func (conR *ConsensusReactor) BuildNewCommitteeSignMsg(pubKey ecdsa.PublicKey, epochID uint64, height uint64) string
---------------------------------------------------------------------------- Sign New Committee "New Committee Message: Leader <pubkey 64(hexdump 32x2) bytes> EpochID <16 (8x2)bytes> Height <16 (8x2) bytes>
func (*ConsensusReactor) BuildNotaryAnnounceSignMsg ¶
func (conR *ConsensusReactor) BuildNotaryAnnounceSignMsg(pubKey ecdsa.PublicKey, epochID uint64, height uint64, round uint32) string
Sign Notary Announce Message "Announce Notarization Message: Leader <pubkey 64(32x2)> EpochID <16 (8x2)bytes> Height <16 (8x2) bytes> Round <8 (4x2) bytes>
func (*ConsensusReactor) BuildProposalBlockSignMsg ¶
func (conR *ConsensusReactor) BuildProposalBlockSignMsg(blockType uint32, height uint64, id, txsRoot, stateRoot *meter.Bytes32) string
Sign Propopal Message "Proposal Block Message: BlockType <8 bytes> Height <16 (8x2) bytes> Round <8 (4x2) bytes>
func (*ConsensusReactor) BuildStopCommitteeBlock ¶
func (conR *ConsensusReactor) BuildStopCommitteeBlock(parentBlock *block.Block) *ProposedBlockInfo
func (*ConsensusReactor) CalcCommitteeByNonce ¶
func (conR *ConsensusReactor) CalcCommitteeByNonce(nonce uint64) (*types.ValidatorSet, uint, int, bool)
This is similar routine of NewValidatorSetByNonce. it is used for temp calculate committee set by a given nonce in the fly. also return the committee
func (*ConsensusReactor) CheckEstablishedCommittee ¶
func (conR *ConsensusReactor) CheckEstablishedCommittee(kHeight uint32) bool
if best block is moving ahead, and lastkblock is match, we consider there is an established committee and proposing
func (*ConsensusReactor) CommitteeInfoCompare ¶
func (conR *ConsensusReactor) CommitteeInfoCompare(cm1, cm2 []block.CommitteeInfo) bool
func (*ConsensusReactor) ConsensusHandleReceivedNonce ¶
func (conR *ConsensusReactor) ConsensusHandleReceivedNonce(kBlockHeight uint32, nonce, epoch uint64, replay bool)
Consensus module handle received nonce from kblock
func (*ConsensusReactor) FinalizeCommitBlock ¶
func (conR *ConsensusReactor) FinalizeCommitBlock(blkInfo *ProposedBlockInfo, bestQC *block.QuorumCert) error
finalize the block with its own QC
func (*ConsensusReactor) GetActualCommitteeMemberIndex ¶
func (conR *ConsensusReactor) GetActualCommitteeMemberIndex(pubKey *ecdsa.PublicKey) int
func (*ConsensusReactor) GetCommitteeMember ¶
func (conR *ConsensusReactor) GetCommitteeMember(pubKey []byte) *types.CommitteeMember
input is serialized ecdsa.PublicKey
func (*ConsensusReactor) GetCommitteeMemberIndex ¶
func (conR *ConsensusReactor) GetCommitteeMemberIndex(pubKey ecdsa.PublicKey) int
func (*ConsensusReactor) GetConsensusDelegates ¶
func (conR *ConsensusReactor) GetConsensusDelegates() ([]*types.Delegate, int, int)
entry point for each committee return with delegates list, delegateSize, committeeSize maxDelegateSize >= maxCommiteeSize >= minCommitteeSize
func (*ConsensusReactor) GetDelegateNameByIP ¶
func (conR *ConsensusReactor) GetDelegateNameByIP(ip net.IP) string
func (*ConsensusReactor) GetDelegatesSource ¶ added in v1.2.0
func (conR *ConsensusReactor) GetDelegatesSource() string
func (*ConsensusReactor) GetLastKBlockHeight ¶
func (conR *ConsensusReactor) GetLastKBlockHeight() uint32
func (*ConsensusReactor) GetLatestCommitteeList ¶
func (conR *ConsensusReactor) GetLatestCommitteeList() ([]*ApiCommitteeMember, error)
func (*ConsensusReactor) GetMyActualCommitteeIndex ¶
func (conR *ConsensusReactor) GetMyActualCommitteeIndex() int
func (*ConsensusReactor) GetMyName ¶
func (conR *ConsensusReactor) GetMyName() string
func (*ConsensusReactor) GetMyNetAddr ¶
func (conR *ConsensusReactor) GetMyNetAddr() types.NetAddress
func (*ConsensusReactor) GetMyPeers ¶
func (conR *ConsensusReactor) GetMyPeers() ([]*ConsensusPeer, error)
func (*ConsensusReactor) GetRelayPeers ¶
func (conR *ConsensusReactor) GetRelayPeers(round int) ([]*ConsensusPeer, error)
func (*ConsensusReactor) HandleKBlockData ¶
func (conR *ConsensusReactor) HandleKBlockData(kd block.KBlockData)
func (*ConsensusReactor) HandleRecvKBlockInfo ¶
func (conR *ConsensusReactor) HandleRecvKBlockInfo(ki RecvKBlockInfo)
func (*ConsensusReactor) HandleSchedule ¶
func (conR *ConsensusReactor) HandleSchedule(fn func()) bool
Handle Schedules from conR.scheduleQueue
func (*ConsensusReactor) IsCommitteeMember ¶
func (conR *ConsensusReactor) IsCommitteeMember() bool
func (*ConsensusReactor) IsPacemakerRunning ¶
func (conR *ConsensusReactor) IsPacemakerRunning() bool
used for probe API
func (*ConsensusReactor) JoinEstablishedCommittee ¶
func (conR *ConsensusReactor) JoinEstablishedCommittee(kBlock *block.Block, replay bool)
func (*ConsensusReactor) LoadBlockBytes ¶
func (conR *ConsensusReactor) LoadBlockBytes(num uint32) []byte
func (*ConsensusReactor) MakeBlockCommitteeInfo ¶
func (conR *ConsensusReactor) MakeBlockCommitteeInfo(system *bls.System, cms []types.CommitteeMember) []block.CommitteeInfo
build block committee info part
func (*ConsensusReactor) MarshalMsg ¶
func (conR *ConsensusReactor) MarshalMsg(msg *ConsensusMessage) ([]byte, error)
func (*ConsensusReactor) NewCommitteeCleanup ¶
func (conR *ConsensusReactor) NewCommitteeCleanup()
func (*ConsensusReactor) NewCommitteeInit ¶
func (conR *ConsensusReactor) NewCommitteeInit(height uint32, nonce uint64, replay bool)
func (*ConsensusReactor) NewCommitteeTimeout ¶
func (conR *ConsensusReactor) NewCommitteeTimeout()
func (*ConsensusReactor) NewCommitteeTimerStart ¶
func (conR *ConsensusReactor) NewCommitteeTimerStart()
func (*ConsensusReactor) NewCommitteeTimerStop ¶
func (conR *ConsensusReactor) NewCommitteeTimerStop()
func (*ConsensusReactor) NewCommitteeUpdateRound ¶
func (conR *ConsensusReactor) NewCommitteeUpdateRound(round uint32)
func (*ConsensusReactor) NewConsensusStart ¶
func (conR *ConsensusReactor) NewConsensusStart() int
Entry point of new consensus
func (*ConsensusReactor) NewConsensusStop ¶
func (conR *ConsensusReactor) NewConsensusStop() int
called by reactor stop
func (*ConsensusReactor) NewRuntimeForReplay ¶
func (*ConsensusReactor) NewValidatorSetByNonce ¶
func (conR *ConsensusReactor) NewValidatorSetByNonce(nonce uint64) (uint, bool)
create validatorSet by a given nonce. return by my self role
func (*ConsensusReactor) OnStart ¶
func (conR *ConsensusReactor) OnStart() error
OnStart implements BaseService by subscribing to events, which later will be broadcasted to other peers and starting state if we're not in fast sync.
func (*ConsensusReactor) OnStop ¶
func (conR *ConsensusReactor) OnStop()
OnStop implements BaseService by unsubscribing from events and stopping state.
func (*ConsensusReactor) PacemakerProbe ¶ added in v1.2.0
func (conR *ConsensusReactor) PacemakerProbe() *PMProbeResult
func (*ConsensusReactor) PreCommitBlock ¶
func (conR *ConsensusReactor) PreCommitBlock(blkInfo *ProposedBlockInfo) error
========================================================
func (*ConsensusReactor) PrepareEnvForPacemaker ¶ added in v1.2.0
func (conR *ConsensusReactor) PrepareEnvForPacemaker() error
func (*ConsensusReactor) Process ¶
func (c *ConsensusReactor) Process(blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)
Process process a block.
func (*ConsensusReactor) ProcessNewCommitteeMessage ¶
func (conR *ConsensusReactor) ProcessNewCommitteeMessage(newCommitteeMsg *NewCommitteeMessage, src *ConsensusPeer) bool
once reach 2/3 send aout annouce message
func (*ConsensusReactor) ProcessProposedBlock ¶
func (*ConsensusReactor) ReceiveCommitteeMsg ¶
func (conR *ConsensusReactor) ReceiveCommitteeMsg(w http.ResponseWriter, r *http.Request)
func (*ConsensusReactor) ReceivePacemakerMsg ¶
func (conR *ConsensusReactor) ReceivePacemakerMsg(w http.ResponseWriter, r *http.Request)
func (*ConsensusReactor) RefreshCurHeight ¶
func (conR *ConsensusReactor) RefreshCurHeight() error
Refresh the current Height from the best block normally call this routine after block chain changed
func (*ConsensusReactor) ScheduleLeader ¶
func (conR *ConsensusReactor) ScheduleLeader(epochID uint64, height uint32, round uint32, ev *NCEvidence, d time.Duration) bool
======end of New consensus ========================================= ----------------------------------------------------------------------------- New consensus timed schedule util type Scheduler func(conR *ConsensusReactor) bool
func (*ConsensusReactor) ScheduleReplayLeader ¶
func (conR *ConsensusReactor) ScheduleReplayLeader(epochID uint64, height uint32, round uint32, ev *NCEvidence, d time.Duration) bool
func (*ConsensusReactor) SignConsensusMsg ¶
func (conR *ConsensusReactor) SignConsensusMsg(msgHash []byte) (sig []byte, err error)
============================================
func (*ConsensusReactor) String ¶
func (conR *ConsensusReactor) String() string
String returns a string representation of the ConsensusReactor. NOTE: For now, it is just a hard-coded string to avoid accessing unprotected shared variables. TODO: improve!
func (*ConsensusReactor) SwitchToConsensus ¶
func (conR *ConsensusReactor) SwitchToConsensus()
SwitchToConsensus switches from fast_sync mode to consensus mode. It resets the state, turns off fast_sync, and starts the consensus state-machine
func (*ConsensusReactor) UnmarshalMsg ¶
func (conR *ConsensusReactor) UnmarshalMsg(data []byte) (*consensusMsgInfo, error)
func (*ConsensusReactor) UpdateActualCommittee ¶
func (conR *ConsensusReactor) UpdateActualCommittee(leaderIndex uint32) bool
after announce/commit, Leader got the actual committee, which is the subset of curCommittee if some committee member offline. indexs and pubKeys are not sorted slice, AcutalCommittee must be sorted. Only Leader can call this method. indexes do not include the leader itself.
func (*ConsensusReactor) UpdateCurDelegates ¶
func (conR *ConsensusReactor) UpdateCurDelegates()
//////////////////////////////////////////////////// update current delegates with new delegates from staking or config file keep this standalone method intentionly
func (*ConsensusReactor) UpdateHeight ¶
func (conR *ConsensusReactor) UpdateHeight(height uint32) bool
func (*ConsensusReactor) UpdateLastKBlockHeight ¶
func (conR *ConsensusReactor) UpdateLastKBlockHeight(height uint32) bool
update the LastKBlockHeight
type ConsensusValidator ¶
type ConsensusValidator struct {
EpochID uint64 // epoch ID of this committee
// contains filtered or unexported fields
}
func NewConsensusValidator ¶
func NewConsensusValidator(conR *ConsensusReactor) *ConsensusValidator
validator receives the initiated messages
func (*ConsensusValidator) GenerateCommitMessage ¶
func (cv *ConsensusValidator) GenerateCommitMessage(sig bls.Signature, msgHash [32]byte, round uint32) *CommitCommitteeMessage
Generate commitCommittee Message
func (*ConsensusValidator) ProcessAnnounceCommittee ¶
func (cv *ConsensusValidator) ProcessAnnounceCommittee(announceMsg *AnnounceCommitteeMessage, src *ConsensusPeer) bool
process Announcement from committee leader, join the committee
func (*ConsensusValidator) ProcessNotaryAnnounceMessage ¶
func (cv *ConsensusValidator) ProcessNotaryAnnounceMessage(notaryMsg *NotaryAnnounceMessage, src *ConsensusPeer) bool
process notary Block Message
func (*ConsensusValidator) RemoveAllcsPeers ¶
func (cv *ConsensusValidator) RemoveAllcsPeers() bool
validator need to build consensus peer topology
func (*ConsensusValidator) SendMsgToPeer ¶
func (cv *ConsensusValidator) SendMsgToPeer(msg *ConsensusMessage, netAddr types.NetAddress) bool
type NCEvidence ¶
type NCEvidence struct {
// contains filtered or unexported fields
}
func NewNCEvidence ¶
type NewCommittee ¶
type NewCommittee struct {
KblockHeight uint32
Round uint32
Nonce uint64
Replay bool
TimeoutTimer *time.Timer
//precalc committee for given nonce
Committee *types.ValidatorSet
Role uint //leader, validator, none
Index int //the index of delegates
InCommittee bool
// contains filtered or unexported fields
}
type NewCommitteeKey ¶
type NewCommitteeKey struct {
// contains filtered or unexported fields
}
type NewCommitteeMessage ¶
type NewCommitteeMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
NewLeaderID []byte //ecdsa.PublicKey
ValidatorID []byte //ecdsa.PublicKey
ValidatorBlsPK []byte //bls publickey
NextEpochID uint64
Nonce uint64 // 8 bytes Kblock info
KBlockHeight uint32
SignedMsgHash [32]byte // BLS signed message hash
BlsSignature []byte // BLS signed signature
}
------------------------------------
func (*NewCommitteeMessage) EpochID ¶
func (m *NewCommitteeMessage) EpochID() uint64
func (*NewCommitteeMessage) Header ¶
func (m *NewCommitteeMessage) Header() *ConsensusMsgCommonHeader
func (*NewCommitteeMessage) MsgType ¶
func (m *NewCommitteeMessage) MsgType() byte
func (*NewCommitteeMessage) SigningHash ¶
func (m *NewCommitteeMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*NewCommitteeMessage) String ¶
func (m *NewCommitteeMessage) String() string
String returns a string representation.
type NewViewReason ¶
type NewViewReason byte
NewViewReason is the reason for new view
const ( // HigherQCSeen HigherQCSeen NewViewReason = NewViewReason(1) RoundTimeout NewViewReason = NewViewReason(2) )
func (NewViewReason) String ¶
func (r NewViewReason) String() string
type NotaryAnnounceMessage ¶
type NotaryAnnounceMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
AnnouncerID []byte //ecdsa.PublicKey
AnnouncerBlsPK []byte //bls.PublicKey
//collected NewCommittee messages
VotingBitArray *cmn.BitArray
VotingMsgHash [32]byte // all message hash from Newcommittee msgs
VotingAggSig []byte // aggregate signature of voterSig above
// collected from commitcommittee messages
NotarizeBitArray *cmn.BitArray
NotarizeMsgHash [32]byte // all message hash from Newcommittee msgs
NotarizeAggSig []byte // aggregate signature of voterSig above
CommitteeSize uint32 // summarized committee info
CommitteeMembers []block.CommitteeInfo
}
-------------------------------------
func (*NotaryAnnounceMessage) EpochID ¶
func (m *NotaryAnnounceMessage) EpochID() uint64
func (*NotaryAnnounceMessage) Header ¶
func (m *NotaryAnnounceMessage) Header() *ConsensusMsgCommonHeader
func (*NotaryAnnounceMessage) MsgType ¶
func (m *NotaryAnnounceMessage) MsgType() byte
func (*NotaryAnnounceMessage) SigningHash ¶
func (m *NotaryAnnounceMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*NotaryAnnounceMessage) String ¶
func (m *NotaryAnnounceMessage) String() string
String returns a string representation.
type PMBeatInfo ¶
type PMBeatInfo struct {
// contains filtered or unexported fields
}
type PMNewViewMessage ¶
type PMNewViewMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
QCHeight uint32
QCRound uint32
QCHigh []byte
Reason NewViewReason
TimeoutHeight uint32
TimeoutRound uint32
TimeoutCounter uint64
PeerID []byte
PeerIndex uint32
SignedMessageHash [32]byte
PeerSignature []byte
}
PMNewViewMessage is sent to the next leader in these two senarios 1. leader relay 2. repica timeout
func (*PMNewViewMessage) EpochID ¶
func (m *PMNewViewMessage) EpochID() uint64
func (*PMNewViewMessage) Header ¶
func (m *PMNewViewMessage) Header() *ConsensusMsgCommonHeader
func (*PMNewViewMessage) MsgType ¶
func (m *PMNewViewMessage) MsgType() byte
func (*PMNewViewMessage) SigningHash ¶
func (m *PMNewViewMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*PMNewViewMessage) String ¶
func (m *PMNewViewMessage) String() string
String returns a string representation.
type PMProbeResult ¶ added in v1.2.0
type PMProbeResult struct {
Mode string
StartHeight uint32
StartRound uint32
CurRound uint32
MyCommitteeIndex int
LastVotingHeight uint32
QCHigh *block.QuorumCert
BlockLeaf *BlockProbe
BlockExecuted *BlockProbe
BlockLocked *BlockProbe
ProposalCount int
PendingCount int
PendingLowest uint32
}
type PMProposalMessage ¶
type PMProposalMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
ParentHeight uint32
ParentRound uint32
ProposerID []byte //ecdsa.PublicKey
ProposerBlsPK []byte //bls.PublicKey
KBlockHeight uint32
// SignOffset uint
// SignLength uint
ProposedSize uint32
ProposedBlock []byte
ProposedBlockType BlockType
TimeoutCert *PMTimeoutCert
}
PMProposalMessage is sent when a new block leaf is proposed
func (*PMProposalMessage) CompactString ¶ added in v1.2.0
func (m *PMProposalMessage) CompactString() string
func (*PMProposalMessage) EpochID ¶
func (m *PMProposalMessage) EpochID() uint64
func (*PMProposalMessage) Header ¶
func (m *PMProposalMessage) Header() *ConsensusMsgCommonHeader
func (*PMProposalMessage) MsgType ¶
func (m *PMProposalMessage) MsgType() byte
func (*PMProposalMessage) SigningHash ¶
func (m *PMProposalMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*PMProposalMessage) String ¶
func (m *PMProposalMessage) String() string
String returns a string representation.
type PMQueryProposalMessage ¶
type PMQueryProposalMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
FromHeight uint32
ToHeight uint32
Round uint32
ReturnAddr types.NetAddress
}
PMQueryProposalMessage is sent to current leader to get the parent proposal
func (*PMQueryProposalMessage) EpochID ¶
func (m *PMQueryProposalMessage) EpochID() uint64
func (*PMQueryProposalMessage) Header ¶
func (m *PMQueryProposalMessage) Header() *ConsensusMsgCommonHeader
func (*PMQueryProposalMessage) MsgType ¶
func (m *PMQueryProposalMessage) MsgType() byte
func (*PMQueryProposalMessage) SigningHash ¶
func (m *PMQueryProposalMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*PMQueryProposalMessage) String ¶
func (m *PMQueryProposalMessage) String() string
String returns a string representation.
type PMRoundState ¶
type PMRoundState byte
PMRoundState is the const state for pacemaker state machine
const ( PMRoundStateInit PMRoundState = 1 PMRoundStateProposalRcvd PMRoundState = 2 PMRoundStateProposalSent PMRoundState = 3 PMRoundStateProposalMajorReached PMRoundState = 4 PMRoundStateProposalCommitted PMRoundState = 4 PMRoundStateProposalDecided PMRoundState = 4 )
type PMRoundTimeoutInfo ¶
type PMRoundTimeoutInfo struct {
// contains filtered or unexported fields
}
type PMTimeoutCert ¶
type PMTimeoutCert struct {
TimeoutRound uint32
TimeoutHeight uint32
TimeoutCounter uint32
TimeoutBitArray *cmn.BitArray
TimeoutAggSig []byte
}
TimeoutCert
func (*PMTimeoutCert) DecodeRLP ¶
func (tc *PMTimeoutCert) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder.
func (*PMTimeoutCert) EncodeRLP ¶
func (tc *PMTimeoutCert) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder.
func (*PMTimeoutCert) SigningHash ¶
func (tc *PMTimeoutCert) SigningHash() (hash meter.Bytes32)
func (*PMTimeoutCert) String ¶
func (tc *PMTimeoutCert) String() string
type PMTimeoutCertManager ¶
type PMVoteMessage ¶
type PMVoteMessage struct {
CSMsgCommonHeader ConsensusMsgCommonHeader
VoterID []byte //ecdsa.PublicKey
VoterBlsPK []byte //bls.PublicKey
BlsSignature []byte //bls.Signature
VoterIndex uint32
SignedMessageHash [32]byte
}
PMVoteResponseMessage is sent when voting for a proposal (or lack thereof).
func (*PMVoteMessage) EpochID ¶
func (m *PMVoteMessage) EpochID() uint64
func (*PMVoteMessage) Header ¶
func (m *PMVoteMessage) Header() *ConsensusMsgCommonHeader
func (*PMVoteMessage) MsgType ¶
func (m *PMVoteMessage) MsgType() byte
func (*PMVoteMessage) SigningHash ¶
func (m *PMVoteMessage) SigningHash() (hash meter.Bytes32)
SigningHash computes hash of all header fields excluding signature.
func (*PMVoteMessage) String ¶
func (m *PMVoteMessage) String() string
String returns a string representation.
type Pacemaker ¶
type Pacemaker struct {
QCHigh *pmQuorumCert
// contains filtered or unexported fields
}
func NewPaceMaker ¶
func NewPaceMaker(conR *ConsensusReactor) *Pacemaker
func (*Pacemaker) AddressBlock ¶
find out b b' b"
func (*Pacemaker) BlockMatchQC ¶
func (p *Pacemaker) BlockMatchQC(b *pmBlock, qc *block.QuorumCert) (bool, error)
qc is for that block? blk is derived from pmBlock message. pass it in if already decoded
func (*Pacemaker) BuildNewViewMessage ¶
func (p *Pacemaker) BuildNewViewMessage(nextHeight, nextRound uint32, qcHigh *pmQuorumCert, reason NewViewReason, ti *PMRoundTimeoutInfo) (*PMNewViewMessage, error)
BuildVoteForProposalMsg build VFP message for proposal
func (*Pacemaker) BuildNewViewSignMsg ¶
func (p *Pacemaker) BuildNewViewSignMsg(pubKey ecdsa.PublicKey, reason NewViewReason, height, round uint32, qc *block.QuorumCert) string
func (*Pacemaker) BuildProposalMessage ¶
func (p *Pacemaker) BuildProposalMessage(height, round uint32, bnew *pmBlock, tc *PMTimeoutCert) (*PMProposalMessage, error)
func (*Pacemaker) BuildQueryProposalMessage ¶
func (p *Pacemaker) BuildQueryProposalMessage(fromHeight, toHeight, round uint32, epochID uint64, retAddr types.NetAddress) (*PMQueryProposalMessage, error)
func (*Pacemaker) BuildVoteForProposalMessage ¶
func (p *Pacemaker) BuildVoteForProposalMessage(proposalMsg *PMProposalMessage, blockID, txsRoot, stateRoot meter.Bytes32) (*PMVoteMessage, error)
BuildVoteForProposalMsg build VFP message for proposal txRoot, stateRoot is decoded from proposalMsg.ProposedBlock, carry in cos already decoded outside
func (*Pacemaker) CreateLeaf ¶
func (*Pacemaker) GetRelayPeers ¶
func (p *Pacemaker) GetRelayPeers(round uint32) []*ConsensusPeer
func (*Pacemaker) IsExtendedFromBLocked ¶
check a pmBlock is the extension of b_locked, max 10 hops
func (*Pacemaker) OnNextSyncView ¶
func (p *Pacemaker) OnNextSyncView(nextHeight, nextRound uint32, reason NewViewReason, ti *PMRoundTimeoutInfo)
func (*Pacemaker) OnPreCommitBlock ¶
func (*Pacemaker) OnReceiveNewView ¶
func (*Pacemaker) OnReceiveProposal ¶
func (*Pacemaker) OnReceiveQueryProposal ¶
func (*Pacemaker) OnReceiveVote ¶
func (*Pacemaker) OnRoundTimeout ¶
func (p *Pacemaker) OnRoundTimeout(ti PMRoundTimeoutInfo)
func (*Pacemaker) OnTimeoutBeat ¶
func (*Pacemaker) Probe ¶ added in v1.2.0
func (p *Pacemaker) Probe() *PMProbeResult
func (*Pacemaker) ScheduleOnBeat ¶
func (*Pacemaker) SendCatchUpQuery ¶
func (p *Pacemaker) SendCatchUpQuery()
func (*Pacemaker) SendConsensusMessage ¶
func (p *Pacemaker) SendConsensusMessage(round uint32, msg ConsensusMessage, copyMyself bool) bool
------------------------------------------------------ Message Delivery Utilities ------------------------------------------------------
func (*Pacemaker) SendKblockInfo ¶
func (p *Pacemaker) SendKblockInfo(b *pmBlock)
func (*Pacemaker) Stop ¶
func (p *Pacemaker) Stop()
actions of commites/receives kblock, stop pacemake to next committee all proposal txs need to be reclaimed before stop
func (*Pacemaker) UpdateQCHigh ¶
func (*Pacemaker) ValidateProposal ¶
type PendingList ¶
type PendingList struct {
// contains filtered or unexported fields
}
func NewPendingList ¶
func NewPendingList() *PendingList
func (*PendingList) Add ¶
func (p *PendingList) Add(mi *consensusMsgInfo)
func (*PendingList) CleanUpTo ¶
func (p *PendingList) CleanUpTo(height uint32)
func (*PendingList) GetLowestHeight ¶
func (p *PendingList) GetLowestHeight() uint32
func (*PendingList) Len ¶ added in v1.2.0
func (p *PendingList) Len() int
type ProposalMap ¶ added in v1.2.0
type ProposalMap struct {
// contains filtered or unexported fields
}
func NewProposalMap ¶ added in v1.2.0
func NewProposalMap() *ProposalMap
func (*ProposalMap) Add ¶ added in v1.2.0
func (p *ProposalMap) Add(blk *pmBlock)
func (*ProposalMap) Get ¶ added in v1.2.0
func (p *ProposalMap) Get(key uint32) *pmBlock
func (*ProposalMap) Len ¶ added in v1.2.0
func (p *ProposalMap) Len() int
func (*ProposalMap) Reset ¶ added in v1.2.0
func (p *ProposalMap) Reset()
func (*ProposalMap) RevertTo ¶ added in v1.2.0
func (p *ProposalMap) RevertTo(height uint32)
type ProposedBlockInfo ¶
type ProposedBlockInfo struct {
ProposedBlock *block.Block
Stage *state.Stage
Receipts *tx.Receipts
CheckPoint int
BlockType BlockType
// contains filtered or unexported fields
}
proposed block info
func (*ProposedBlockInfo) String ¶
func (pb *ProposedBlockInfo) String() string
type RecvKBlockInfo ¶
type SignatureAggregator ¶
type SignatureAggregator struct {
// contains filtered or unexported fields
}
func (*SignatureAggregator) Aggregate ¶
func (sa *SignatureAggregator) Aggregate() []byte
func (*SignatureAggregator) BitArrayString ¶
func (sa *SignatureAggregator) BitArrayString() string
func (*SignatureAggregator) Count ¶
func (sa *SignatureAggregator) Count() uint32
func (*SignatureAggregator) Seal ¶
func (sa *SignatureAggregator) Seal()
seal the signature, no future modification could be done anymore
type ValidatorReward ¶ added in v1.2.0
type ValidatorReward struct {
Epoch uint32
BaseReward *big.Int
ExpectDistribute *big.Int
ActualDistribute *big.Int
}
func (*ValidatorReward) ToString ¶ added in v1.2.0
func (v *ValidatorReward) ToString() string
type ValidatorRewardList ¶ added in v1.2.0
type ValidatorRewardList struct {
// contains filtered or unexported fields
}
func NewValidatorRewardList ¶ added in v1.2.0
func NewValidatorRewardList(rewards []*ValidatorReward) *ValidatorRewardList
func (*ValidatorRewardList) Count ¶ added in v1.2.0
func (v *ValidatorRewardList) Count() int
func (*ValidatorRewardList) Get ¶ added in v1.2.0
func (v *ValidatorRewardList) Get(epoch uint32) *ValidatorReward
func (*ValidatorRewardList) GetList ¶ added in v1.2.0
func (v *ValidatorRewardList) GetList() []*ValidatorReward
func (*ValidatorRewardList) String ¶ added in v1.2.0
func (v *ValidatorRewardList) String() string
func (*ValidatorRewardList) ToList ¶ added in v1.2.0
func (v *ValidatorRewardList) ToList() []*ValidatorReward
func (*ValidatorRewardList) ToString ¶ added in v1.2.0
func (v *ValidatorRewardList) ToString() string
Source Files
¶
- auction_reward.go
- bls_common.go
- committee_leader.go
- committee_new.go
- committee_validator.go
- common.go
- consensus_block.go
- consensus_peer.go
- errors.go
- message_relay.go
- messages.go
- msg_cache.go
- pacemaker.go
- pacemaker_message.go
- pacemaker_util.go
- pending_list.go
- pm_structs.go
- prometheus.go
- proposal_map.go
- reactor.go
- signature_aggregator.go
- timeout_cert_manager.go
- validator_reward_api.go
- wire.go