Documentation ¶
Overview ¶
Package evidence implements recording duplicate blocks and votes for cbft consensus.
Index ¶
- Constants
- func NewBaseEvidencePool(path string) (*baseEvidencePool, error)
- func NewEvidence(dupType consensus.EvidenceType, data string) (consensus.Evidence, error)
- func NewEvidences(data string) (consensus.Evidences, error)
- type DuplicatePrepareBlockEvidence
- func (d DuplicatePrepareBlockEvidence) BlockNumber() uint64
- func (d DuplicatePrepareBlockEvidence) BlsPubKey() *bls.PublicKey
- func (d DuplicatePrepareBlockEvidence) Epoch() uint64
- func (d DuplicatePrepareBlockEvidence) Equal(ev consensus.Evidence) bool
- func (d DuplicatePrepareBlockEvidence) Error() string
- func (d DuplicatePrepareBlockEvidence) Hash() []byte
- func (d DuplicatePrepareBlockEvidence) NodeID() enode.IDv0
- func (d DuplicatePrepareBlockEvidence) Type() consensus.EvidenceType
- func (d DuplicatePrepareBlockEvidence) Validate() error
- func (d DuplicatePrepareBlockEvidence) ValidateMsg() bool
- func (d DuplicatePrepareBlockEvidence) ViewNumber() uint64
- type DuplicatePrepareVoteEvidence
- func (d DuplicatePrepareVoteEvidence) BlockNumber() uint64
- func (d DuplicatePrepareVoteEvidence) BlsPubKey() *bls.PublicKey
- func (d DuplicatePrepareVoteEvidence) Epoch() uint64
- func (d DuplicatePrepareVoteEvidence) Equal(ev consensus.Evidence) bool
- func (d DuplicatePrepareVoteEvidence) Error() string
- func (d DuplicatePrepareVoteEvidence) Hash() []byte
- func (d DuplicatePrepareVoteEvidence) NodeID() enode.IDv0
- func (d DuplicatePrepareVoteEvidence) Type() consensus.EvidenceType
- func (d DuplicatePrepareVoteEvidence) Validate() error
- func (d DuplicatePrepareVoteEvidence) ValidateMsg() bool
- func (d DuplicatePrepareVoteEvidence) ViewNumber() uint64
- type DuplicateViewChangeEvidence
- func (d DuplicateViewChangeEvidence) BlockNumber() uint64
- func (d DuplicateViewChangeEvidence) BlsPubKey() *bls.PublicKey
- func (d DuplicateViewChangeEvidence) Epoch() uint64
- func (d DuplicateViewChangeEvidence) Equal(ev consensus.Evidence) bool
- func (d DuplicateViewChangeEvidence) Error() string
- func (d DuplicateViewChangeEvidence) Hash() []byte
- func (d DuplicateViewChangeEvidence) NodeID() enode.IDv0
- func (d DuplicateViewChangeEvidence) Type() consensus.EvidenceType
- func (d DuplicateViewChangeEvidence) Validate() error
- func (d DuplicateViewChangeEvidence) ValidateMsg() bool
- func (d DuplicateViewChangeEvidence) ViewNumber() uint64
- type EvidenceData
- type EvidenceNode
- type EvidencePool
- type EvidencePrepare
- type EvidenceView
- type EvidenceVote
- type Identity
- type NumberOrderPrepareBlock
- type NumberOrderPrepareVote
- type NumberOrderViewChange
- type PrepareBlockEvidence
- type PrepareVoteEvidence
- type ViewChangeEvidence
Constants ¶
const ( DuplicatePrepareBlockType consensus.EvidenceType = 1 DuplicatePrepareVoteType consensus.EvidenceType = 2 DuplicateViewChangeType consensus.EvidenceType = 3 )
const (
// IdentityLength is the expected length of the identity
IdentityLength = 20
)
Variables ¶
This section is empty.
Functions ¶
func NewBaseEvidencePool ¶
func NewEvidence ¶
NewEvidences retrieves the duplicate evidence by parsing string
Types ¶
type DuplicatePrepareBlockEvidence ¶
type DuplicatePrepareBlockEvidence struct { PrepareA *EvidencePrepare `json:"prepareA"` PrepareB *EvidencePrepare `json:"prepareB"` }
DuplicatePrepareBlockEvidence recording duplicate blocks
func (DuplicatePrepareBlockEvidence) BlockNumber ¶
func (d DuplicatePrepareBlockEvidence) BlockNumber() uint64
func (DuplicatePrepareBlockEvidence) BlsPubKey ¶ added in v0.7.3
func (d DuplicatePrepareBlockEvidence) BlsPubKey() *bls.PublicKey
func (DuplicatePrepareBlockEvidence) Epoch ¶
func (d DuplicatePrepareBlockEvidence) Epoch() uint64
func (DuplicatePrepareBlockEvidence) Equal ¶
func (d DuplicatePrepareBlockEvidence) Equal(ev consensus.Evidence) bool
func (DuplicatePrepareBlockEvidence) Error ¶
func (d DuplicatePrepareBlockEvidence) Error() string
func (DuplicatePrepareBlockEvidence) Hash ¶
func (d DuplicatePrepareBlockEvidence) Hash() []byte
func (DuplicatePrepareBlockEvidence) NodeID ¶ added in v0.7.3
func (d DuplicatePrepareBlockEvidence) NodeID() enode.IDv0
func (DuplicatePrepareBlockEvidence) Type ¶
func (d DuplicatePrepareBlockEvidence) Type() consensus.EvidenceType
func (DuplicatePrepareBlockEvidence) Validate ¶
func (d DuplicatePrepareBlockEvidence) Validate() error
Validate verify the validity of the DuplicatePrepareBlockEvidence the same epoch,viewNumber,blockNumber,nodeId and different blockHash
func (DuplicatePrepareBlockEvidence) ValidateMsg ¶
func (d DuplicatePrepareBlockEvidence) ValidateMsg() bool
func (DuplicatePrepareBlockEvidence) ViewNumber ¶
func (d DuplicatePrepareBlockEvidence) ViewNumber() uint64
type DuplicatePrepareVoteEvidence ¶
type DuplicatePrepareVoteEvidence struct { VoteA *EvidenceVote `json:"voteA"` VoteB *EvidenceVote `json:"voteB"` }
DuplicatePrepareVoteEvidence recording duplicate vote
func (DuplicatePrepareVoteEvidence) BlockNumber ¶
func (d DuplicatePrepareVoteEvidence) BlockNumber() uint64
func (DuplicatePrepareVoteEvidence) BlsPubKey ¶ added in v0.7.3
func (d DuplicatePrepareVoteEvidence) BlsPubKey() *bls.PublicKey
func (DuplicatePrepareVoteEvidence) Epoch ¶
func (d DuplicatePrepareVoteEvidence) Epoch() uint64
func (DuplicatePrepareVoteEvidence) Equal ¶
func (d DuplicatePrepareVoteEvidence) Equal(ev consensus.Evidence) bool
func (DuplicatePrepareVoteEvidence) Error ¶
func (d DuplicatePrepareVoteEvidence) Error() string
func (DuplicatePrepareVoteEvidence) Hash ¶
func (d DuplicatePrepareVoteEvidence) Hash() []byte
func (DuplicatePrepareVoteEvidence) NodeID ¶ added in v0.7.3
func (d DuplicatePrepareVoteEvidence) NodeID() enode.IDv0
func (DuplicatePrepareVoteEvidence) Type ¶
func (d DuplicatePrepareVoteEvidence) Type() consensus.EvidenceType
func (DuplicatePrepareVoteEvidence) Validate ¶
func (d DuplicatePrepareVoteEvidence) Validate() error
Validate verify the validity of the duplicatePrepareVoteEvidence the same epoch,viewNumber,blockNumber,nodeId and different blockHash
func (DuplicatePrepareVoteEvidence) ValidateMsg ¶
func (d DuplicatePrepareVoteEvidence) ValidateMsg() bool
func (DuplicatePrepareVoteEvidence) ViewNumber ¶
func (d DuplicatePrepareVoteEvidence) ViewNumber() uint64
type DuplicateViewChangeEvidence ¶
type DuplicateViewChangeEvidence struct { ViewA *EvidenceView `json:"viewA"` ViewB *EvidenceView `json:"viewB"` }
DuplicateViewChangeEvidence recording duplicate viewChange
func (DuplicateViewChangeEvidence) BlockNumber ¶
func (d DuplicateViewChangeEvidence) BlockNumber() uint64
func (DuplicateViewChangeEvidence) BlsPubKey ¶ added in v0.7.3
func (d DuplicateViewChangeEvidence) BlsPubKey() *bls.PublicKey
func (DuplicateViewChangeEvidence) Epoch ¶
func (d DuplicateViewChangeEvidence) Epoch() uint64
func (DuplicateViewChangeEvidence) Equal ¶
func (d DuplicateViewChangeEvidence) Equal(ev consensus.Evidence) bool
func (DuplicateViewChangeEvidence) Error ¶
func (d DuplicateViewChangeEvidence) Error() string
func (DuplicateViewChangeEvidence) Hash ¶
func (d DuplicateViewChangeEvidence) Hash() []byte
func (DuplicateViewChangeEvidence) NodeID ¶ added in v0.7.3
func (d DuplicateViewChangeEvidence) NodeID() enode.IDv0
func (DuplicateViewChangeEvidence) Type ¶
func (d DuplicateViewChangeEvidence) Type() consensus.EvidenceType
func (DuplicateViewChangeEvidence) Validate ¶
func (d DuplicateViewChangeEvidence) Validate() error
Validate verify the validity of the duplicateViewChangeEvidence the same epoch,viewNumber,nodeId and different block
func (DuplicateViewChangeEvidence) ValidateMsg ¶
func (d DuplicateViewChangeEvidence) ValidateMsg() bool
func (DuplicateViewChangeEvidence) ViewNumber ¶
func (d DuplicateViewChangeEvidence) ViewNumber() uint64
type EvidenceData ¶
type EvidenceData struct { DP []*DuplicatePrepareBlockEvidence `json:"duplicatePrepare"` DV []*DuplicatePrepareVoteEvidence `json:"duplicateVote"` DC []*DuplicateViewChangeEvidence `json:"duplicateViewchange"` }
EvidenceData encapsulate externally visible duplicate data
func ClassifyEvidence ¶
func ClassifyEvidence(evds consensus.Evidences) *EvidenceData
ClassifyEvidence tries to convert evidence list to evidenceData
func NewEvidenceData ¶
func NewEvidenceData() *EvidenceData
type EvidenceNode ¶
type EvidenceNode struct { Index uint32 `json:"index"` NodeID enode.IDv0 `json:"nodeId"` BlsPubKey *bls.PublicKey `json:"blsPubKey"` }
EvidenceNode mainly used to save node BlsPubKey
func NewEvidenceNode ¶
func NewEvidenceNode(node *cbfttypes.ValidateNode) *EvidenceNode
func (*EvidenceNode) Verify ¶
func (vn *EvidenceNode) Verify(data, sign []byte) error
bls verifies signature
type EvidencePool ¶
type EvidencePool interface { consensus.EvidencePool AddPrepareBlock(pb *protocols.PrepareBlock, node *cbfttypes.ValidateNode) error AddPrepareVote(pv *protocols.PrepareVote, node *cbfttypes.ValidateNode) error AddViewChange(vc *protocols.ViewChange, node *cbfttypes.ValidateNode) error }
EvidencePool encapsulates functions required to record duplicate blocks and votes.
func NewEvidencePool ¶
func NewEvidencePool(resolvePath func(string) string, evidenceDir string) (EvidencePool, error)
NewEvidencePool creates a new baseEvidencePool to record duplicate blocks and votes.
type EvidencePrepare ¶
type EvidencePrepare 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 BlockData common.Hash `json:"blockData"` ValidateNode *EvidenceNode `json:"validateNode"` Signature ctypes.Signature `json:"signature"` }
Proposed block carrier.
func NewEvidencePrepare ¶
func NewEvidencePrepare(pb *protocols.PrepareBlock, node *cbfttypes.ValidateNode) (*EvidencePrepare, error)
func (*EvidencePrepare) CannibalizeBytes ¶
func (ep *EvidencePrepare) CannibalizeBytes() ([]byte, error)
func (*EvidencePrepare) Verify ¶
func (ep *EvidencePrepare) Verify() error
type EvidenceView ¶
type EvidenceView struct { Epoch uint64 `json:"epoch"` ViewNumber uint64 `json:"viewNumber"` BlockHash common.Hash `json:"blockHash"` BlockNumber uint64 `json:"blockNumber"` ValidateNode *EvidenceNode `json:"validateNode"` Signature ctypes.Signature `json:"signature"` BlockEpoch uint64 `json:"blockEpoch"` BlockView uint64 `json:"blockView"` }
func NewEvidenceView ¶
func NewEvidenceView(vc *protocols.ViewChange, node *cbfttypes.ValidateNode) (*EvidenceView, error)
func (*EvidenceView) CannibalizeBytes ¶
func (ev *EvidenceView) CannibalizeBytes() ([]byte, error)
func (*EvidenceView) Verify ¶
func (ev *EvidenceView) Verify() error
type EvidenceVote ¶
type EvidenceVote 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 ValidateNode *EvidenceNode `json:"validateNode"` Signature ctypes.Signature `json:"signature"` }
func NewEvidenceVote ¶
func NewEvidenceVote(pv *protocols.PrepareVote, node *cbfttypes.ValidateNode) (*EvidenceVote, error)
func (*EvidenceVote) CannibalizeBytes ¶
func (ev *EvidenceVote) CannibalizeBytes() ([]byte, error)
func (*EvidenceVote) Verify ¶
func (ev *EvidenceVote) Verify() error
type NumberOrderPrepareBlock ¶
type NumberOrderPrepareBlock []*EvidencePrepare
func (*NumberOrderPrepareBlock) Add ¶
func (opb *NumberOrderPrepareBlock) Add(pb *EvidencePrepare) error
func (NumberOrderPrepareBlock) Len ¶
func (opb NumberOrderPrepareBlock) Len() int
func (NumberOrderPrepareBlock) Less ¶
func (opb NumberOrderPrepareBlock) Less(i, j int) bool
func (NumberOrderPrepareBlock) Swap ¶
func (opb NumberOrderPrepareBlock) Swap(i, j int)
type NumberOrderPrepareVote ¶
type NumberOrderPrepareVote []*EvidenceVote
func (*NumberOrderPrepareVote) Add ¶
func (opv *NumberOrderPrepareVote) Add(pv *EvidenceVote) error
func (NumberOrderPrepareVote) Len ¶
func (opv NumberOrderPrepareVote) Len() int
func (NumberOrderPrepareVote) Less ¶
func (opv NumberOrderPrepareVote) Less(i, j int) bool
func (NumberOrderPrepareVote) Swap ¶
func (opv NumberOrderPrepareVote) Swap(i, j int)
type NumberOrderViewChange ¶
type NumberOrderViewChange []*EvidenceView
func (*NumberOrderViewChange) Add ¶
func (ovc *NumberOrderViewChange) Add(vc *EvidenceView) error
func (NumberOrderViewChange) Len ¶
func (ovc NumberOrderViewChange) Len() int
func (NumberOrderViewChange) Less ¶
func (ovc NumberOrderViewChange) Less(i, j int) bool
func (NumberOrderViewChange) Swap ¶
func (ovc NumberOrderViewChange) Swap(i, j int)
type PrepareBlockEvidence ¶
type PrepareBlockEvidence map[Identity]NumberOrderPrepareBlock
func (PrepareBlockEvidence) Add ¶
func (pbe PrepareBlockEvidence) Add(pb *EvidencePrepare, id Identity) error
Add tries to add prepare block to PrepareBlockEvidence. if the return error is DuplicatePrepareBlockEvidence instructions the prepare is duplicated
func (PrepareBlockEvidence) Clear ¶
func (pbe PrepareBlockEvidence) Clear(epoch uint64, viewNumber uint64)
Clear tries to clear stale intermediate prepare
func (PrepareBlockEvidence) Size ¶
func (pbe PrepareBlockEvidence) Size() int
type PrepareVoteEvidence ¶
type PrepareVoteEvidence map[Identity]NumberOrderPrepareVote
func (PrepareVoteEvidence) Add ¶
func (pve PrepareVoteEvidence) Add(pv *EvidenceVote, id Identity) error
Add tries to add prepare vote to PrepareVoteEvidence. if the return error is DuplicatePrepareVoteEvidence instructions the vote is duplicated
func (PrepareVoteEvidence) Clear ¶
func (pve PrepareVoteEvidence) Clear(epoch uint64, viewNumber uint64)
Clear tries to clear stale intermediate vote
func (PrepareVoteEvidence) Size ¶
func (pve PrepareVoteEvidence) Size() int
type ViewChangeEvidence ¶
type ViewChangeEvidence map[Identity]NumberOrderViewChange
func (ViewChangeEvidence) Add ¶
func (vce ViewChangeEvidence) Add(vc *EvidenceView, id Identity) error
Add tries to add view to ViewChangeEvidence. if the return error is DuplicateViewChangeEvidence instructions the view is duplicated
func (ViewChangeEvidence) Clear ¶
func (vce ViewChangeEvidence) Clear(epoch uint64, viewNumber uint64)
Clear tries to clear stale intermediate view
func (ViewChangeEvidence) Size ¶
func (vce ViewChangeEvidence) Size() int