Documentation
¶
Index ¶
- Constants
- Variables
- func CalcRelayPeers(myIndex, size int) (peers []int)
- func IsCritical(err error) bool
- func IsFutureBlock(err error) bool
- func IsKnownBlock(err error) bool
- func IsParentMissing(err error) 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 VerifyMsgType(m ConsensusMessage) bool
- func VerifySignature(m ConsensusMessage) bool
- type AnnounceCommitteeMessage
- type ApiCommitteeMember
- type BlockProbe
- type BlockType
- type BlsCommon
- type CommitCommitteeMessage
- type ConsensusMessage
- type ConsensusMsgCommonHeader
- type ConsensusPeer
- type ConsensusReactor
- func (conR *ConsensusReactor) BuildProposalBlockSignMsg(blockType uint32, height uint64, id, txsRoot, stateRoot *meter.Bytes32) string
- func (conR *ConsensusReactor) GetCombinePubKey() string
- 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) IsCommitteeMember() bool
- func (conR *ConsensusReactor) IsPacemakerRunning() bool
- func (conR *ConsensusReactor) LoadBlockBytes(num uint32) []byte
- func (conR *ConsensusReactor) MakeBlockCommitteeInfo() []block.CommitteeInfo
- func (conR *ConsensusReactor) MarshalMsg(msg *ConsensusMessage) ([]byte, error)
- func (conR *ConsensusReactor) OnReceivePacemakerMsg(w http.ResponseWriter, r *http.Request)
- func (conR *ConsensusReactor) OnStart() error
- func (conR *ConsensusReactor) PacemakerProbe() *PMProbeResult
- func (conR *ConsensusReactor) PrepareEnvForPacemaker() error
- func (c *ConsensusReactor) ProcessProposedBlock(parentHeader *block.Header, blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)
- func (c *ConsensusReactor) ProcessSyncedBlock(blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)
- func (conR *ConsensusReactor) RefreshCurHeight() error
- func (conR *ConsensusReactor) SignConsensusMsg(msgHash []byte) (sig []byte, err error)
- func (conR *ConsensusReactor) SwitchToConsensus()
- func (conR *ConsensusReactor) UnmarshalMsg(data []byte) (*consensusMsgInfo, error)
- func (conR *ConsensusReactor) UpdateActualCommittee() bool
- func (conR *ConsensusReactor) UpdateCurCommitteeByNonce(nonce uint64) bool
- func (conR *ConsensusReactor) UpdateCurDelegates()
- func (conR *ConsensusReactor) UpdateHeight(height uint32) bool
- func (conR *ConsensusReactor) VerifyBothPubKey()
- type MsgCache
- 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 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) OnReceiveMsg(w http.ResponseWriter, r *http.Request)
- 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) Probe() *PMProbeResult
- func (p *Pacemaker) ScheduleOnBeat(height, round uint32, reason beatReason, d time.Duration) bool
- func (p *Pacemaker) SendCatchUpQuery()
- func (p *Pacemaker) SendKblockInfo(b *pmBlock)
- func (p *Pacemaker) Start(mode PMMode, calcStatsTx bool)
- 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 ReactorConfig
- type RecvKBlockInfo
- type SignatureAggregator
Constants ¶
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 = 1500 * time.Millisecond RoundTimeoutInterval = 12 * time.Second // update timeout from 16 to 12 secs. RoundTimeoutLongInterval = 21 * time.Second // update timeout from 40 to 21 secs MIN_MBLOCKS_AN_EPOCH = uint32(4) CATCH_UP_THRESHOLD = 5 // TIMEOUT_THRESHOLD_FOR_REBOOT = 5 // defines how many continuous timeouts will trigger a pacemaker reboot )
const ( PMModeNormal PMMode = 1 PMModeCatchUp = 2 PMModeObserve = 3 )
const ( PMCmdStop PMCmd = 1 PMCmdRestart = 2 // restart pacemaker perserving previous settings PMCmdReboot = 3 // reboot pacemaker with all fresh start, should be used only when KBlock is received )
const ( UpdateOnBeat = roundUpdateReason(1) UpdateOnRegularProposal = roundUpdateReason(2) UpdateOnTimeout = roundUpdateReason(3) UpdateOnTimeoutCertProposal = roundUpdateReason(4) UpdateOnKBlockProposal = roundUpdateReason(5) BeatOnInit = beatReason(0) BeatOnHigherQC = beatReason(1) BeatOnTimeout = beatReason(2) TimerInit = roundTimerUpdateReason(0) TimerInc = roundTimerUpdateReason(1) TimerInitLong = roundTimerUpdateReason(2) // new view reasons HigherQCSeen NewViewReason = NewViewReason(1) RoundTimeout NewViewReason = NewViewReason(2) )
const (
CHAN_DEFAULT_BUF_SIZE = 100
)
const (
MSG_KEEP_HEIGHT = 80
)
const PROPOSAL_MAP_MAX_SIZE = 40
Variables ¶
Functions ¶
func CalcRelayPeers ¶
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 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 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 ¶
------------------------------------ UTILITY ------------------------------------
func SetConsensusGlobInst ¶
func SetConsensusGlobInst(inst *ConsensusReactor)
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 ApiCommitteeMember struct {
Name string
Address meter.Address
PubKey string
VotingPower int64
NetAddr string
CsPubKey string
CsIndex int
InCommittee bool
}
------------------------------------ USED FOR API ONLY ------------------------------------
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 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) Fields ¶
func (ch ConsensusMsgCommonHeader) Fields() []interface{}
func (*ConsensusMsgCommonHeader) SetMsgSignature ¶
func (cmh *ConsensusMsgCommonHeader) SetMsgSignature(sig []byte)
func (*ConsensusMsgCommonHeader) ToString ¶
func (cmh *ConsensusMsgCommonHeader) ToString() string
type ConsensusPeer ¶
type ConsensusPeer struct {
// contains filtered or unexported fields
}
Consensus Topology Peer
func (*ConsensusPeer) NameString ¶
func (cp *ConsensusPeer) NameString() string
func (*ConsensusPeer) String ¶
func (cp *ConsensusPeer) String() string
type ConsensusReactor ¶
type ConsensusReactor struct {
SyncDone bool
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 config
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) GetCombinePubKey ¶
func (conR *ConsensusReactor) GetCombinePubKey() string
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) IsCommitteeMember ¶
func (conR *ConsensusReactor) IsCommitteeMember() bool
func (*ConsensusReactor) IsPacemakerRunning ¶
func (conR *ConsensusReactor) IsPacemakerRunning() bool
------------------------------------ USED FOR PROBE ONLY ------------------------------------
func (*ConsensusReactor) LoadBlockBytes ¶
func (conR *ConsensusReactor) LoadBlockBytes(num uint32) []byte
func (*ConsensusReactor) MakeBlockCommitteeInfo ¶
func (conR *ConsensusReactor) MakeBlockCommitteeInfo() []block.CommitteeInfo
build block committee info part
func (*ConsensusReactor) MarshalMsg ¶
func (conR *ConsensusReactor) MarshalMsg(msg *ConsensusMessage) ([]byte, error)
func (*ConsensusReactor) OnReceivePacemakerMsg ¶
func (conR *ConsensusReactor) OnReceivePacemakerMsg(w http.ResponseWriter, r *http.Request)
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) PacemakerProbe ¶ added in v1.2.0
func (conR *ConsensusReactor) PacemakerProbe() *PMProbeResult
func (*ConsensusReactor) PrepareEnvForPacemaker ¶ added in v1.2.0
func (conR *ConsensusReactor) PrepareEnvForPacemaker() error
func (*ConsensusReactor) ProcessProposedBlock ¶
func (*ConsensusReactor) ProcessSyncedBlock ¶
func (c *ConsensusReactor) ProcessSyncedBlock(blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)
Process process a block.
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) SignConsensusMsg ¶
func (conR *ConsensusReactor) SignConsensusMsg(msgHash []byte) (sig []byte, err error)
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() bool
actual committee is exactly the same as committee with one more field: CSIndex, the index order in committee
func (*ConsensusReactor) UpdateCurCommitteeByNonce ¶
func (conR *ConsensusReactor) UpdateCurCommitteeByNonce(nonce uint64) bool
create validatorSet by a given nonce. return by my self role
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) VerifyBothPubKey ¶
func (conR *ConsensusReactor) VerifyBothPubKey()
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
enum NewViewReason is the reason for new view
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
LastOnBeatRound 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 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
}
definition for PMTimeoutCert
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) OnReceiveMsg ¶
func (p *Pacemaker) OnReceiveMsg(w http.ResponseWriter, r *http.Request)
func (*Pacemaker) OnReceiveNewView ¶
func (*Pacemaker) OnReceiveProposal ¶
func (*Pacemaker) OnReceiveQueryProposal ¶
func (*Pacemaker) OnReceiveVote ¶
func (*Pacemaker) OnRoundTimeout ¶
func (p *Pacemaker) OnRoundTimeout(ti PMRoundTimeoutInfo)
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) 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 ReactorConfig ¶
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
Source Files
¶
- bls_common.go
- consensus_peer.go
- errors.go
- messages.go
- msg_cache.go
- pacemaker.go
- pacemaker_assist.go
- pacemaker_commit.go
- pacemaker_probe.go
- pacemaker_propose.go
- pacemaker_receive.go
- pacemaker_send.go
- pending_list.go
- prometheus.go
- proposal_map.go
- reactor.go
- reactor_api.go
- reactor_assist.go
- reactor_message.go
- reactor_validate.go
- signature_aggregator.go
- timeout_cert_manager.go
- types.go
- wire.go