consensus

package
v1.2.0-fork8-fix1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: LGPL-3.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
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)
)
View Source
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
)
View Source
const (
	PMModeNormal  PMMode = 1
	PMModeCatchUp        = 2
	PMModeObserve        = 3
)
View Source
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
)
View Source
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)
)
View Source
const (
	CHAN_DEFAULT_BUF_SIZE = 100
)
View Source
const (
	MSG_KEEP_HEIGHT = 80
)
View Source
const PROPOSAL_MAP_MAX_SIZE = 40

Variables

View Source
var (
	ErrUnrecognizedPayload = errors.New("unrecognized payload")
	ErrMagicMismatch       = errors.New("magic mismatch")
	ErrMalformattedMsg     = errors.New("malformatted msg")
)

Functions

func CalcRelayPeers

func CalcRelayPeers(myIndex, size int) (peers []int)

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

func IsCritical(err error) bool

IsCritical returns if the error is consensus related.

func IsFutureBlock

func IsFutureBlock(err error) bool

IsFutureBlock returns if the error indicates that the block should be processed later.

func IsKnownBlock

func IsKnownBlock(err error) bool

IsKnownBlock returns if the error means the block was already in the chain.

func IsParentMissing

func IsParentMissing(err error) bool

IsParentMissing ...

func MajorityTwoThird

func MajorityTwoThird(voterNum, committeeSize uint32) bool

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 PrintDelegates(delegates []*types.Delegate)

------------------------------------ UTILITY ------------------------------------

func RegisterConsensusMessages

func RegisterConsensusMessages(cdc *amino.Codec)

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 (*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 BlockProbe struct {
	Height uint32
	Round  uint32
	Type   uint32
	Raw    []byte
}

type BlockType

type BlockType uint32
const (
	KBlockType        BlockType = 1
	MBlockType        BlockType = 2
	StopCommitteeType BlockType = 255 //special message to stop pacemake, not a block
)

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 NewBlsCommonFromParams(pubKey bls.PublicKey, privKey bls.PrivateKey, system bls.System, params bls.Params, pairing bls.Pairing) *BlsCommon

func (*BlsCommon) GetPrivKey

func (cc *BlsCommon) GetPrivKey() bls.PrivateKey

func (*BlsCommon) GetPubKey

func (cc *BlsCommon) GetPubKey() *bls.PublicKey

func (*BlsCommon) GetSystem

func (cc *BlsCommon) GetSystem() *bls.System

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 (*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 GetConsensusGlobInst

func GetConsensusGlobInst() *ConsensusReactor

Glob Instance

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 (c *ConsensusReactor) ProcessProposedBlock(parentHeader *block.Header, blk *block.Block, nowTimestamp uint64) (*state.Stage, tx.Receipts, error)

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 MsgCache

type MsgCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMsgCache

func NewMsgCache(size int) *MsgCache

NewMsgCache creates the msg cache instance

func (*MsgCache) Add

func (c *MsgCache) Add(id []byte) bool

func (*MsgCache) CleanAll

func (c *MsgCache) CleanAll()

func (*MsgCache) Contains

func (c *MsgCache) Contains(id []byte) bool

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 (*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 (*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 PMCmd

type PMCmd uint32

enum PMCmd

func (PMCmd) String

func (cmd PMCmd) String() string

type PMCmdInfo

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

struct

type PMMode

type PMMode uint32

func (PMMode) String

func (m PMMode) String() string

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 (*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 (*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 (*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 PMTimeoutCertManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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 (*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

func (p *Pacemaker) AddressBlock(height uint32) *pmBlock

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 (p *Pacemaker) CreateLeaf(parent *pmBlock, qc *pmQuorumCert, height, round uint32) *pmBlock

func (*Pacemaker) Execute

func (p *Pacemaker) Execute(b *pmBlock)

TBD: how to emboy b.cmd

func (*Pacemaker) GetRelayPeers

func (p *Pacemaker) GetRelayPeers(round uint32) []*ConsensusPeer

func (*Pacemaker) IsExtendedFromBLocked

func (p *Pacemaker) IsExtendedFromBLocked(b *pmBlock) bool

check a pmBlock is the extension of b_locked, max 10 hops

func (*Pacemaker) IsStopped

func (p *Pacemaker) IsStopped() bool

func (*Pacemaker) OnBeat

func (p *Pacemaker) OnBeat(height, round uint32, reason beatReason) error

func (*Pacemaker) OnCommit

func (p *Pacemaker) OnCommit(commitReady []*pmBlock)

func (*Pacemaker) OnNextSyncView

func (p *Pacemaker) OnNextSyncView(nextHeight, nextRound uint32, reason NewViewReason, ti *PMRoundTimeoutInfo)

func (*Pacemaker) OnPreCommitBlock

func (p *Pacemaker) OnPreCommitBlock(b *pmBlock) error

func (*Pacemaker) OnPropose

func (p *Pacemaker) OnPropose(b *pmBlock, qc *pmQuorumCert, height, round uint32) (*pmBlock, error)

func (*Pacemaker) OnReceiveMsg

func (p *Pacemaker) OnReceiveMsg(w http.ResponseWriter, r *http.Request)

func (*Pacemaker) OnReceiveNewView

func (p *Pacemaker) OnReceiveNewView(mi *consensusMsgInfo) error

func (*Pacemaker) OnReceiveProposal

func (p *Pacemaker) OnReceiveProposal(mi *consensusMsgInfo) error

func (*Pacemaker) OnReceiveQueryProposal

func (p *Pacemaker) OnReceiveQueryProposal(mi *consensusMsgInfo) error

func (*Pacemaker) OnReceiveVote

func (p *Pacemaker) OnReceiveVote(mi *consensusMsgInfo) error

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 (p *Pacemaker) ScheduleOnBeat(height, round uint32, reason beatReason, d time.Duration) bool

func (*Pacemaker) SendCatchUpQuery

func (p *Pacemaker) SendCatchUpQuery()

func (*Pacemaker) SendKblockInfo

func (p *Pacemaker) SendKblockInfo(b *pmBlock)

func (*Pacemaker) Start

func (p *Pacemaker) Start(mode PMMode, calcStatsTx bool)

Committee Leader triggers

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) Update

func (p *Pacemaker) Update(bnew *pmBlock) error

b_exec b_lock b <- b' <- b" b*

func (*Pacemaker) UpdateQCHigh

func (p *Pacemaker) UpdateQCHigh(qc *pmQuorumCert) bool

func (*Pacemaker) ValidateProposal

func (p *Pacemaker) ValidateProposal(b *pmBlock) error

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) CleanAll

func (p *PendingList) CleanAll()

clean all the pending messages

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 ReactorConfig struct {
	InitCfgdDelegates bool
	EpochMBlockCount  uint32
	MinCommitteeSize  int
	MaxCommitteeSize  int
	MaxDelegateSize   int
	InitDelegates     []*types.Delegate
}

type RecvKBlockInfo

type RecvKBlockInfo struct {
	Height           uint32
	LastKBlockHeight uint32
	Nonce            uint64
	Epoch            uint64
}

type SignatureAggregator

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

func (*SignatureAggregator) Add

func (sa *SignatureAggregator) Add(index int, msgHash [32]byte, signature []byte, pubkey bls.PublicKey) bool

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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