evidence

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package evidence implements recording duplicate blocks and votes for cbft consensus.

Index

Constants

View Source
const (
	DuplicatePrepareBlockType consensus.EvidenceType = 1
	DuplicatePrepareVoteType  consensus.EvidenceType = 2
	DuplicateViewChangeType   consensus.EvidenceType = 3
)
View Source
const (
	// IdentityLength is the expected length of the identity
	IdentityLength = 20
)

Variables

This section is empty.

Functions

func NewBaseEvidencePool

func NewBaseEvidencePool(path string) (*baseEvidencePool, error)

func NewEvidence

func NewEvidence(dupType consensus.EvidenceType, data string) (consensus.Evidence, error)

NewEvidences retrieves the duplicate evidence by parsing string

func NewEvidences

func NewEvidences(data string) (consensus.Evidences, error)

NewEvidences retrieves the duplicate evidence by parsing string

Types

type DuplicatePrepareBlockEvidence

type DuplicatePrepareBlockEvidence struct {
	PrepareA *EvidencePrepare `json:"prepare_a"`
	PrepareB *EvidencePrepare `json:"prepare_b"`
}

DuplicatePrepareBlockEvidence recording duplicate blocks

func (DuplicatePrepareBlockEvidence) Address

func (DuplicatePrepareBlockEvidence) BlockNumber

func (d DuplicatePrepareBlockEvidence) BlockNumber() uint64

func (DuplicatePrepareBlockEvidence) Epoch

func (DuplicatePrepareBlockEvidence) Equal

func (DuplicatePrepareBlockEvidence) Error

func (DuplicatePrepareBlockEvidence) Hash

func (DuplicatePrepareBlockEvidence) Type

func (DuplicatePrepareBlockEvidence) Validate

func (d DuplicatePrepareBlockEvidence) Validate() error

Validate verify the validity of the DuplicatePrepareBlockEvidence the same epoch,viewNumber,blockNumber,node address 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:"vote_a"`
	VoteB *EvidenceVote `json:"vote_b"`
}

DuplicatePrepareVoteEvidence recording duplicate vote

func (DuplicatePrepareVoteEvidence) Address

func (DuplicatePrepareVoteEvidence) BlockNumber

func (d DuplicatePrepareVoteEvidence) BlockNumber() uint64

func (DuplicatePrepareVoteEvidence) Epoch

func (DuplicatePrepareVoteEvidence) Equal

func (DuplicatePrepareVoteEvidence) Error

func (DuplicatePrepareVoteEvidence) Hash

func (DuplicatePrepareVoteEvidence) Type

func (DuplicatePrepareVoteEvidence) Validate

func (d DuplicatePrepareVoteEvidence) Validate() error

Validate verify the validity of the duplicatePrepareVoteEvidence the same epoch,viewNumber,blockNumber,node address 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:"view_a"`
	ViewB *EvidenceView `json:"view_b"`
}

DuplicateViewChangeEvidence recording duplicate viewChange

func (DuplicateViewChangeEvidence) Address

func (DuplicateViewChangeEvidence) BlockNumber

func (d DuplicateViewChangeEvidence) BlockNumber() uint64

func (DuplicateViewChangeEvidence) Epoch

func (DuplicateViewChangeEvidence) Equal

func (DuplicateViewChangeEvidence) Error

func (DuplicateViewChangeEvidence) Hash

func (d DuplicateViewChangeEvidence) Hash() []byte

func (DuplicateViewChangeEvidence) Type

func (DuplicateViewChangeEvidence) Validate

func (d DuplicateViewChangeEvidence) Validate() error

Validate verify the validity of the duplicateViewChangeEvidence the same epoch,viewNumber,blockNumber,node address and different blockHash

func (DuplicateViewChangeEvidence) ValidateMsg

func (d DuplicateViewChangeEvidence) ValidateMsg() bool

func (DuplicateViewChangeEvidence) ViewNumber

func (d DuplicateViewChangeEvidence) ViewNumber() uint64

type EvidenceData

type EvidenceData struct {
	DP []*DuplicatePrepareBlockEvidence `json:"duplicate_prepare"`
	DV []*DuplicatePrepareVoteEvidence  `json:"duplicate_vote"`
	DC []*DuplicateViewChangeEvidence   `json:"duplicate_viewchange"`
}

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"`
	Address   common.Address  `json:"address"`
	NodeID    discover.NodeID `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(ctx *node.ServiceContext, 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:"view_number"`
	BlockHash    common.Hash      `json:"block_hash"`
	BlockNumber  uint64           `json:"block_number"`
	BlockIndex   uint32           `json:"block_index"` // The block number of the current ViewNumber proposal, 0....10
	ValidateNode *EvidenceNode    `json:"validate_node"`
	Signature    ctypes.Signature `json:"signature"`
}

Proposed block carrier.

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:"view_number"`
	BlockHash    common.Hash      `json:"block_hash"`
	BlockNumber  uint64           `json:"block_number"`
	ValidateNode *EvidenceNode    `json:"validate_node"`
	Signature    ctypes.Signature `json:"signature"`
	BlockEpoch   uint64           `json:"block_epoch"`
	BlockView    uint64           `json:"block_view"`
}

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:"view_number"`
	BlockHash    common.Hash      `json:"block_hash"`
	BlockNumber  uint64           `json:"block_number"`
	BlockIndex   uint32           `json:"block_index"` // The block number of the current ViewNumber proposal, 0....10
	ValidateNode *EvidenceNode    `json:"validate_node"`
	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 Identity

type Identity string

func (Identity) Bytes

func (id Identity) Bytes() []byte

Bytes gets the string representation of the underlying identity.

type NumberOrderPrepareBlock

type NumberOrderPrepareBlock []*EvidencePrepare

func (*NumberOrderPrepareBlock) Add

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

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

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

Jump to

Keyboard shortcuts

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