protocols

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PBFTStatusMsg           = 0x00 // Protocol messages belonging to pbft
	PrepareBlockMsg         = 0x01
	PrepareVoteMsg          = 0x02
	ViewChangeMsg           = 0x03
	GetPrepareBlockMsg      = 0x04
	GetBlockQuorumCertMsg   = 0x05
	BlockQuorumCertMsg      = 0x06
	GetPrepareVoteMsg       = 0x07
	PrepareVotesMsg         = 0x08
	GetQCBlockListMsg       = 0x09
	QCBlockListMsg          = 0x0a
	GetLatestStatusMsg      = 0x0b
	LatestStatusMsg         = 0x0c
	PrepareBlockHashMsg     = 0x0d
	GetViewChangeMsg        = 0x0e
	PingMsg                 = 0x0f
	PongMsg                 = 0x10
	ViewChangeQuorumCertMsg = 0x11
	ViewChangesMsg          = 0x12

	PreCommitMsg                   = 0x13
	GetPreCommitMsg                = 0x14
	GetBlockPreCommitQuorumCertMsg = 0x15
	BlockPreCommitQuorumCertMsg    = 0x16
	PreCommitsMsg                  = 0x17
)
View Source
const (
	ConfirmedViewChangeMsg = 0x01
	SendViewChangeMsg      = 0x02
	SendPrepareBlockMsg    = 0x03
	SendPrepareVoteMsg     = 0x04
	SendPreCommitMsg       = 0x05
)
View Source
const (
	CommitState = 0x05
	LockState   = 0x06
	QCState     = 0x07
)
View Source
const DefaultAvgLatency = 100

Default average delay time (in milliseconds).

View Source
const PbftProtocolMaxMsgSize = 10 * 1024 * 1024

Maximum cap on the size of a pbft protocol message

Variables

View Source
var (
	WalMessages = []interface{}{
		ConfirmedViewChange{},
		SendViewChange{},
		SendPrepareBlock{},
		SendPrepareVote{},
		SendPreCommit{},
	}
)

Functions

func MessageType

func MessageType(msg interface{}) uint64

A is used to convert specific message types according to the message body. The program is forcibly terminated if there is an unmatched message type and all types must exist in the match list.

func WalMessageType

func WalMessageType(msg interface{}) uint64

Types

type BlockPreCommitQuorumCert

type BlockPreCommitQuorumCert struct {
	BlockQC *ctypes.QuorumCert `json:"qc"` // Block aggregation signature information.
	// contains filtered or unexported fields
}

Aggregate signature response message, representing aggregated signature information for a block.

func (*BlockPreCommitQuorumCert) BHash

func (*BlockPreCommitQuorumCert) MsgHash

func (s *BlockPreCommitQuorumCert) MsgHash() common.Hash

func (*BlockPreCommitQuorumCert) String

func (s *BlockPreCommitQuorumCert) String() string

type BlockQuorumCert

type BlockQuorumCert struct {
	BlockQC *ctypes.QuorumCert `json:"qc"` // Block aggregation signature information.
	// contains filtered or unexported fields
}

Aggregate signature response message, representing aggregated signature information for a block.

func (*BlockQuorumCert) BHash

func (s *BlockQuorumCert) BHash() common.Hash

func (*BlockQuorumCert) MsgHash

func (s *BlockQuorumCert) MsgHash() common.Hash

func (*BlockQuorumCert) String

func (s *BlockQuorumCert) String() string

type ChainState

type ChainState struct {
	Commit *State
	Lock   *State
	QC     []*State //PreCommitQC
}

ChainState indicates the latest consensus state.

func (*ChainState) String

func (cs *ChainState) String() string

func (*ChainState) ValidChainState

func (cs *ChainState) ValidChainState() bool

type ConfirmedViewChange

type ConfirmedViewChange struct {
	Epoch        uint64
	ViewNumber   uint64
	Block        *types.Block
	QC           *ctypes.QuorumCert   `rlp:"nil"`
	ViewChangeQC *ctypes.ViewChangeQC `rlp:"nil"`
}

ConfirmedViewChange indicates the latest confirmed view.

func (*ConfirmedViewChange) String

func (c *ConfirmedViewChange) String() string

type GetBlockPreCommitQuorumCert

type GetBlockPreCommitQuorumCert struct {
	BlockHash   common.Hash `json:"blockHash"`   // The hash of the block to be acquired.
	BlockNumber uint64      `json:"blockNumber"` // The number of the block to be acquired.
	// contains filtered or unexported fields
}

GetBlockPreCommitQuorumCert is the protocol message for obtaining an aggregated signature. todo: Need to determine the attribute field - ParentQC.

func (*GetBlockPreCommitQuorumCert) BHash

func (*GetBlockPreCommitQuorumCert) MsgHash

func (*GetBlockPreCommitQuorumCert) String

func (s *GetBlockPreCommitQuorumCert) String() string

type GetBlockQuorumCert

type GetBlockQuorumCert struct {
	BlockHash   common.Hash `json:"blockHash"`   // The hash of the block to be acquired.
	BlockNumber uint64      `json:"blockNumber"` // The number of the block to be acquired.
	// contains filtered or unexported fields
}

GetBlockQuorumCert is the protocol message for obtaining an aggregated signature. todo: Need to determine the attribute field - ParentQC.

func (*GetBlockQuorumCert) BHash

func (s *GetBlockQuorumCert) BHash() common.Hash

func (*GetBlockQuorumCert) MsgHash

func (s *GetBlockQuorumCert) MsgHash() common.Hash

func (*GetBlockQuorumCert) String

func (s *GetBlockQuorumCert) String() string

type GetLatestStatus

type GetLatestStatus struct {
	BlockNumber  uint64             `json:"blockNumber"`           // QC Block height
	BlockHash    common.Hash        `json:"blockHash"`             // QC block hash
	QuorumCert   *ctypes.QuorumCert `json:"quorumCert" rlp:"nil"`  // QC quorumCert
	LBlockNumber uint64             `json:"lBlockNumber"`          // Locked block height
	LBlockHash   common.Hash        `json:"lBlockHash"`            // Locked block hash
	LQuorumCert  *ctypes.QuorumCert `json:"lQuorumCert" rlp:"nil"` // Locked quorumCert
	LogicType    uint64             `json:"logicType"`             // LogicType: 1 QCBn, 2 LockedBn, 3 CommitBn
	// contains filtered or unexported fields
}

State synchronization for nodes.

func (*GetLatestStatus) BHash

func (s *GetLatestStatus) BHash() common.Hash

func (*GetLatestStatus) MsgHash

func (s *GetLatestStatus) MsgHash() common.Hash

func (*GetLatestStatus) String

func (s *GetLatestStatus) String() string

type GetPreCommit

type GetPreCommit struct {
	Epoch       uint64
	ViewNumber  uint64
	BlockNumber uint64
	BlockIndex  uint32
	UnKnownSet  *utils.BitArray
	// contains filtered or unexported fields
}

Message used to get PreCommit.

func (*GetPreCommit) BHash

func (s *GetPreCommit) BHash() common.Hash

func (*GetPreCommit) MsgHash

func (s *GetPreCommit) MsgHash() common.Hash

func (*GetPreCommit) String

func (s *GetPreCommit) String() string

type GetPrepareBlock

type GetPrepareBlock struct {
	Epoch       uint64
	BlockNumber uint64
	ViewNumber  uint64
	BlockIndex  uint32
	// contains filtered or unexported fields
}

GetPrepareBlock is used to get the proposed block information.

func (*GetPrepareBlock) BHash

func (s *GetPrepareBlock) BHash() common.Hash

func (*GetPrepareBlock) MsgHash

func (s *GetPrepareBlock) MsgHash() common.Hash

func (*GetPrepareBlock) String

func (s *GetPrepareBlock) String() string

type GetPrepareVote

type GetPrepareVote struct {
	Epoch       uint64
	ViewNumber  uint64
	BlockNumber uint64
	BlockIndex  uint32
	UnKnownSet  *utils.BitArray
	// contains filtered or unexported fields
}

Message used to get block voting.

func (*GetPrepareVote) BHash

func (s *GetPrepareVote) BHash() common.Hash

func (*GetPrepareVote) MsgHash

func (s *GetPrepareVote) MsgHash() common.Hash

func (*GetPrepareVote) String

func (s *GetPrepareVote) String() string

type GetQCBlockList

type GetQCBlockList struct {
	Epoch       uint64      `json:"epoch"`
	BlockHash   common.Hash `json:"blockHash"`   // The hash to the block.
	BlockNumber uint64      `json:"blockNumber"` // The number corresponding to the block.
	// contains filtered or unexported fields
}

Used to get block information that has reached QC. Note: Get up to 3 blocks of data at a time.

func (*GetQCBlockList) BHash

func (s *GetQCBlockList) BHash() common.Hash

func (*GetQCBlockList) MsgHash

func (s *GetQCBlockList) MsgHash() common.Hash

func (*GetQCBlockList) String

func (s *GetQCBlockList) String() string

type GetViewChange

type GetViewChange struct {
	Epoch          uint64          `json:"epoch"`
	BlockNumber    uint64          `json:"blockNumber"`
	ViewNumber     uint64          `json:"viewNumber"`
	ViewChangeBits *utils.BitArray `json:"nodeIndexes"`
	// contains filtered or unexported fields
}

Used to actively request to get viewChange.

func (*GetViewChange) BHash

func (s *GetViewChange) BHash() common.Hash

func (*GetViewChange) MsgHash

func (s *GetViewChange) MsgHash() common.Hash

func (*GetViewChange) String

func (s *GetViewChange) String() string

type LatestStatus

type LatestStatus struct {
	BlockNumber  uint64             `json:"blockNumber"`           // PreCommitQC Block height
	BlockHash    common.Hash        `json:"blockHash"`             // PreCommitQC block hash
	QuorumCert   *ctypes.QuorumCert `json:"quorumCert" rlp:"nil"`  // PreCommitQC quorumCert
	LBlockNumber uint64             `json:"lBlockNumber"`          // Locked block height
	LBlockHash   common.Hash        `json:"lBlockHash"`            // Locked block hash
	LQuorumCert  *ctypes.QuorumCert `json:"lQuorumCert" rlp:"nil"` // Locked quorumCert
	LogicType    uint64             `json:"logicType"`             // LogicType: 1 QCBn, 2 LockedBn, 3 CommitBn, 4 PreCommitQCBn
	// contains filtered or unexported fields
}

Response message to GetLatestStatus request.

func (*LatestStatus) BHash

func (s *LatestStatus) BHash() common.Hash

func (*LatestStatus) MsgHash

func (s *LatestStatus) MsgHash() common.Hash

func (*LatestStatus) String

func (s *LatestStatus) String() string

type PbftStatusData

type PbftStatusData struct {
	ProtocolVersion uint32      `json:"protocolVersion"` // PBFT protocol version number.
	QCBn            *big.Int    `json:"qcBn"`            // The highest local block number for collecting block signatures.
	QCBlock         common.Hash `json:"qcBlock"`         // The highest local block hash for collecting block signatures.
	LockBn          *big.Int    `json:"lockBn"`          // Locally locked block number.
	LockBlock       common.Hash `json:"lockBlock"`       // Locally locked block hash.
	CmtBn           *big.Int    `json:"cmtBn"`           // Locally submitted block number.
	CmtBlock        common.Hash `json:"cmtBlock"`        // Locally submitted block hash.
	// contains filtered or unexported fields
}

PbftStatusData implement Message and including status information about peer.

func (*PbftStatusData) BHash

func (s *PbftStatusData) BHash() common.Hash

func (*PbftStatusData) MsgHash

func (s *PbftStatusData) MsgHash() common.Hash

func (*PbftStatusData) String

func (s *PbftStatusData) String() string

type Ping

type Ping [1]string

For time detection.

func (*Ping) BHash

func (s *Ping) BHash() common.Hash

func (*Ping) MsgHash

func (s *Ping) MsgHash() common.Hash

func (*Ping) String

func (s *Ping) String() string

type Pong

type Pong [1]string

Response to ping.

func (*Pong) BHash

func (s *Pong) BHash() common.Hash

func (*Pong) MsgHash

func (s *Pong) MsgHash() common.Hash

func (*Pong) String

func (s *Pong) String() string

type PreCommit

type PreCommit struct {
	Epoch          uint64             `json:"epoch"`
	ViewNumber     uint64             `json:"viewNumber"`
	BlockHash      common.Hash        `json:"blockHash"`
	BlockNumber    uint64             `json:"blockNumber"`
	BlockIndex     uint32             `json:"blockIndex"` // The block number of the current ViewNumber proposal, 0....10
	ValidatorIndex uint32             `json:"validatorIndex"`
	ParentQC       *ctypes.QuorumCert `json:"parentQC" rlp:"nil"`
	Signature      ctypes.Signature   `json:"signature"`
	// contains filtered or unexported fields
}

Message used to PreCommit.

func (*PreCommit) BHash

func (pv *PreCommit) BHash() common.Hash

func (*PreCommit) BlockNum

func (pv *PreCommit) BlockNum() uint64

func (*PreCommit) CannibalizeBytes

func (pv *PreCommit) CannibalizeBytes() ([]byte, error)

func (*PreCommit) EpochNum

func (pv *PreCommit) EpochNum() uint64

func (*PreCommit) EqualState

func (pv *PreCommit) EqualState(vote *PreCommit) bool

func (*PreCommit) MsgHash

func (pv *PreCommit) MsgHash() common.Hash

func (*PreCommit) NodeIndex

func (pv *PreCommit) NodeIndex() uint32

func (*PreCommit) SetSign

func (pv *PreCommit) SetSign(sign []byte)

func (*PreCommit) Sign

func (pv *PreCommit) Sign() []byte

func (*PreCommit) String

func (pv *PreCommit) String() string

func (*PreCommit) ViewNum

func (pv *PreCommit) ViewNum() uint64

type PreCommits

type PreCommits struct {
	Epoch      uint64
	ViewNumber uint64
	BlockIndex uint32
	Votes      []*PreCommit // Block voting set.
	// contains filtered or unexported fields
}

Message used to respond to the number of block votes.

func (*PreCommits) BHash

func (s *PreCommits) BHash() common.Hash

func (*PreCommits) MsgHash

func (s *PreCommits) MsgHash() common.Hash

func (*PreCommits) String

func (s *PreCommits) String() string

type PrepareBlock

type PrepareBlock struct {
	Epoch         uint64               `json:"epoch"`
	ViewNumber    uint64               `json:"viewNumber"`
	Block         *types.Block         `json:"blockHash"`
	BlockIndex    uint32               `json:"blockIndex"`             // The block number of the current ViewNumber proposal, 0....10
	ProposalIndex uint32               `json:"proposalIndex"`          // Proposer's index.
	PrepareQC     *ctypes.QuorumCert   `json:"prepareQC" rlp:"nil"`    // N-f aggregate signature
	ViewChangeQC  *ctypes.ViewChangeQC `json:"viewchangeQC" rlp:"nil"` // viewChange aggregate signature
	Signature     ctypes.Signature     `json:"signature"`              // PrepareBlock signature information
	// contains filtered or unexported fields
}

Proposed block carrier.

func (*PrepareBlock) BHash

func (pb *PrepareBlock) BHash() common.Hash

func (*PrepareBlock) BlockNum

func (pb *PrepareBlock) BlockNum() uint64

func (*PrepareBlock) CannibalizeBytes

func (pb *PrepareBlock) CannibalizeBytes() ([]byte, error)

func (*PrepareBlock) EpochNum

func (pb *PrepareBlock) EpochNum() uint64

func (*PrepareBlock) MsgHash

func (pb *PrepareBlock) MsgHash() common.Hash

func (*PrepareBlock) NodeIndex

func (pb *PrepareBlock) NodeIndex() uint32

func (*PrepareBlock) SetSign

func (pb *PrepareBlock) SetSign(sign []byte)

func (*PrepareBlock) Sign

func (pb *PrepareBlock) Sign() []byte

func (*PrepareBlock) String

func (pb *PrepareBlock) String() string

func (*PrepareBlock) ViewNum

func (pb *PrepareBlock) ViewNum() uint64

type PrepareBlockHash

type PrepareBlockHash struct {
	Epoch       uint64
	ViewNumber  uint64
	BlockIndex  uint32
	BlockHash   common.Hash
	BlockNumber uint64
	// contains filtered or unexported fields
}

Represents the hash of the proposed block for secondary propagation.

func (*PrepareBlockHash) BHash

func (s *PrepareBlockHash) BHash() common.Hash

func (*PrepareBlockHash) MsgHash

func (s *PrepareBlockHash) MsgHash() common.Hash

func (*PrepareBlockHash) String

func (s *PrepareBlockHash) String() string

type PrepareVote

type PrepareVote struct {
	Epoch          uint64             `json:"epoch"`
	ViewNumber     uint64             `json:"viewNumber"`
	BlockHash      common.Hash        `json:"blockHash"`
	BlockNumber    uint64             `json:"blockNumber"`
	BlockIndex     uint32             `json:"blockIndex"` // The block number of the current ViewNumber proposal, 0....10
	ValidatorIndex uint32             `json:"validatorIndex"`
	ParentQC       *ctypes.QuorumCert `json:"parentQC" rlp:"nil"`
	Signature      ctypes.Signature   `json:"signature"`
	// contains filtered or unexported fields
}

Removed the validator address, index. Mainly to ensure that the signature hash of the aggregate signature is consistent.

func (*PrepareVote) BHash

func (pv *PrepareVote) BHash() common.Hash

func (*PrepareVote) BlockNum

func (pv *PrepareVote) BlockNum() uint64

func (*PrepareVote) CannibalizeBytes

func (pv *PrepareVote) CannibalizeBytes() ([]byte, error)

func (*PrepareVote) EpochNum

func (pv *PrepareVote) EpochNum() uint64

func (*PrepareVote) EqualState

func (pv *PrepareVote) EqualState(vote *PrepareVote) bool

func (*PrepareVote) MsgHash

func (pv *PrepareVote) MsgHash() common.Hash

func (*PrepareVote) NodeIndex

func (pv *PrepareVote) NodeIndex() uint32

func (*PrepareVote) SetSign

func (pv *PrepareVote) SetSign(sign []byte)

func (*PrepareVote) Sign

func (pv *PrepareVote) Sign() []byte

func (*PrepareVote) String

func (pv *PrepareVote) String() string

func (*PrepareVote) ViewNum

func (pv *PrepareVote) ViewNum() uint64

type PrepareVotes

type PrepareVotes struct {
	Epoch      uint64
	ViewNumber uint64
	BlockIndex uint32
	Votes      []*PrepareVote // Block voting set.
	// contains filtered or unexported fields
}

Message used to respond to the number of block votes.

func (*PrepareVotes) BHash

func (s *PrepareVotes) BHash() common.Hash

func (*PrepareVotes) MsgHash

func (s *PrepareVotes) MsgHash() common.Hash

func (*PrepareVotes) String

func (s *PrepareVotes) String() string

type QCBlockList

type QCBlockList struct {
	QC           []*ctypes.QuorumCert
	Blocks       []*types.Block
	ForkedQC     []*ctypes.QuorumCert
	ForkedBlocks []*types.Block
	// contains filtered or unexported fields
}

PBFT synchronize blocks that have reached qc.

func (*QCBlockList) BHash

func (s *QCBlockList) BHash() common.Hash

func (*QCBlockList) MsgHash

func (s *QCBlockList) MsgHash() common.Hash

func (*QCBlockList) String

func (s *QCBlockList) String() string

type SendPreCommit

type SendPreCommit struct {
	Block *types.Block
	Vote  *PreCommit
}

SendPreCommit indicates the prepareVote sent by the local node.

func (SendPreCommit) BlockNumber

func (s SendPreCommit) BlockNumber() uint64

func (SendPreCommit) Epoch

func (s SendPreCommit) Epoch() uint64

func (*SendPreCommit) String

func (s *SendPreCommit) String() string

func (SendPreCommit) ViewNumber

func (s SendPreCommit) ViewNumber() uint64

type SendPrepareBlock

type SendPrepareBlock struct {
	Prepare *PrepareBlock
}

SendPrepareBlock indicates the prepareBlock sent by the local node.

func (SendPrepareBlock) BlockNumber

func (s SendPrepareBlock) BlockNumber() uint64

func (SendPrepareBlock) Epoch

func (s SendPrepareBlock) Epoch() uint64

func (*SendPrepareBlock) String

func (s *SendPrepareBlock) String() string

func (SendPrepareBlock) ViewNumber

func (s SendPrepareBlock) ViewNumber() uint64

type SendPrepareVote

type SendPrepareVote struct {
	Block *types.Block
	Vote  *PrepareVote
}

SendPrepareVote indicates the prepareVote sent by the local node.

func (SendPrepareVote) BlockNumber

func (s SendPrepareVote) BlockNumber() uint64

func (SendPrepareVote) Epoch

func (s SendPrepareVote) Epoch() uint64

func (*SendPrepareVote) String

func (s *SendPrepareVote) String() string

func (SendPrepareVote) ViewNumber

func (s SendPrepareVote) ViewNumber() uint64

type SendViewChange

type SendViewChange struct {
	ViewChange *ViewChange
}

SendViewChange indicates the viewChange sent by the local node.

func (SendViewChange) BlockNumber

func (s SendViewChange) BlockNumber() uint64

func (SendViewChange) Epoch

func (s SendViewChange) Epoch() uint64

func (*SendViewChange) String

func (s *SendViewChange) String() string

func (SendViewChange) ViewNumber

func (s SendViewChange) ViewNumber() uint64

type State

type State struct {
	Block      *types.Block
	QuorumCert *ctypes.QuorumCert
}

func (*State) EqualState

func (s *State) EqualState(c *State) bool

func (*State) String

func (s *State) String() string

func (*State) ValidState

func (s *State) ValidState() bool

type ViewChange

type ViewChange struct {
	Epoch          uint64             `json:"epoch"`
	ViewNumber     uint64             `json:"viewNumber"`
	BlockHash      common.Hash        `json:"blockHash"`
	BlockNumber    uint64             `json:"blockNumber"`
	ValidatorIndex uint32             `json:"validatorIndex"`
	PrepareQC      *ctypes.QuorumCert `json:"prepareQC" rlp:"nil"`
	Signature      ctypes.Signature   `json:"signature"`
	// contains filtered or unexported fields
}

ViewChange is message structure for view switching.

func (*ViewChange) BHash

func (vc *ViewChange) BHash() common.Hash

func (*ViewChange) BlockNum

func (vc *ViewChange) BlockNum() uint64

func (*ViewChange) CannibalizeBytes

func (vc *ViewChange) CannibalizeBytes() ([]byte, error)

func (*ViewChange) EpochNum

func (vc *ViewChange) EpochNum() uint64

func (*ViewChange) MsgHash

func (vc *ViewChange) MsgHash() common.Hash

func (*ViewChange) NodeIndex

func (vc *ViewChange) NodeIndex() uint32

func (*ViewChange) SetSign

func (vc *ViewChange) SetSign(sign []byte)

func (*ViewChange) Sign

func (vc *ViewChange) Sign() []byte

func (*ViewChange) String

func (vc *ViewChange) String() string

func (*ViewChange) ViewNum

func (vc *ViewChange) ViewNum() uint64

type ViewChangeQuorumCert

type ViewChangeQuorumCert struct {
	ViewChangeQC        *ctypes.ViewChangeQC `json:"viewchangeQC"`                  // viewChange aggregate signature
	HighestViewChangeQC *ctypes.ViewChangeQC `json:"highestViewChangeQC" rlp:"nil"` // the highest viewChangeQC of current epoch
	// contains filtered or unexported fields
}

func (*ViewChangeQuorumCert) BHash

func (v *ViewChangeQuorumCert) BHash() common.Hash

func (*ViewChangeQuorumCert) MsgHash

func (v *ViewChangeQuorumCert) MsgHash() common.Hash

func (*ViewChangeQuorumCert) String

func (v *ViewChangeQuorumCert) String() string

type ViewChanges

type ViewChanges struct {
	VCs []*ViewChange
	// contains filtered or unexported fields
}

func (ViewChanges) BHash

func (ViewChanges) BHash() common.Hash

func (ViewChanges) MsgHash

func (v ViewChanges) MsgHash() common.Hash

func (ViewChanges) String

func (v ViewChanges) String() string

type WalMsg

type WalMsg interface {
	Epoch() uint64
	ViewNumber() uint64
	BlockNumber() uint64
}

Jump to

Keyboard shortcuts

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