verifier

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MinQuorumForQc = 3

MinQuorumForQc defines the minimum votes count for a quorum certification

Variables

View Source
var (

	// ErrProposalHasBeenProceed export proposal has been proceed
	ErrProposalHasBeenProceed = fmt.Errorf("proposal has been proceed")
)

Functions

func CountNumFromVotes

func CountNumFromVotes(
	qc *maxbftpb.QuorumCert, minNodes uint) (votedBlockNum, votedRejectedNum uint, rejectedTxIds []string, err error)

CountNumFromVotes count votes for a qc

func VerifyVotes

func VerifyVotes(
	ac protocol.AccessControlProvider,
	validThreshold uint,
	votes []*maxbftpb.VoteData,
	members []string) (reachThreshold bool, err error)

VerifyVotes validate the votes concurrently

Types

type Validator

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

Validator is an implementation of Verifier interface

func (*Validator) BaseCheck

func (v *Validator) BaseCheck(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) error

BaseCheck implements basic check for proposals

func (*Validator) CheckRejectQcLeader added in v3.0.1

func (v *Validator) CheckRejectQcLeader(proposal *maxbftpb.ProposalData) error

CheckRejectQcLeader checks a rejectQc is from the right leader or not

func (*Validator) GetLeader

func (v *Validator) GetLeader(view uint64) string

GetLeader return the leader for the specified view

func (*Validator) IsLegalForNilBlock

func (v *Validator) IsLegalForNilBlock(block *common.Block) bool

IsLegalForNilBlock the logic is to verify the nil block whether can be generated. If the nearest ancestor blocks are empty or none exist, then no new empty block are allowed to be generated.

func (*Validator) SwitchEpoch

func (v *Validator) SwitchEpoch(contract *maxbftpb.GovernanceContract)

SwitchEpoch Sets the state of the new epoch

func (*Validator) ValidateJustifyQc

func (v *Validator) ValidateJustifyQc(proposal *maxbft.ProposalData) error

ValidateJustifyQc 验证提案中携带的QC

func (*Validator) ValidateProposal

func (v *Validator) ValidateProposal(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert,
	mode protocol.VerifyMode) (*consensus.VerifyResult, error)

ValidateProposal validate specified proposal

func (*Validator) ValidateQc

func (v *Validator) ValidateQc(qc *maxbftpb.QuorumCert, selfCreate bool) error

ValidateQc validate specified quorum certification selfCreate if qc is created by self which is true.

func (*Validator) ValidateVote

func (v *Validator) ValidateVote(vote *maxbftpb.VoteData, proposal *maxbftpb.ProposalData) error

ValidateVote validate specified vote with specified proposal

type Verifier

type Verifier interface {
	// BaseCheck implements basic check for proposals
	BaseCheck(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert) error
	ValidateProposal(proposal *maxbftpb.ProposalData, qc *maxbftpb.QuorumCert,
		mode protocol.VerifyMode) (*consensus.VerifyResult, error)
	// ValidateQc Verify the QC aggregated from the local vote, and the
	// proposal corresponding to the QC has been verified. This behavior
	// occurs on the leader, which collects votes for proposals to aggregate QC.
	// selfCreate if qc is created by self which is true.
	ValidateQc(qc *maxbftpb.QuorumCert, selfCreate bool) error
	// ValidateJustifyQc Verify the QC carried in the proposal
	ValidateJustifyQc(proposal *maxbftpb.ProposalData) error
	// IsLegalForNilBlock  the logic is to verify the nil block whether can be generated.
	IsLegalForNilBlock(block *common.Block) bool
	// ValidateVote validate specified vote with specified proposal
	ValidateVote(vote *maxbftpb.VoteData, proposal *maxbftpb.ProposalData) error
	// GetLeader return the leader for the specified view
	GetLeader(view uint64) string
	SwitchEpoch(contract *maxbftpb.GovernanceContract)
	// CheckRejectQcLeader checks a rejectQc is from the right leader or not
	CheckRejectQcLeader(proposal *maxbftpb.ProposalData) error
}

Verifier defines a verifier used to validate quorum certifications, proposals and blocks

func NewValidator

func NewValidator(validators []string, verifier protocol.BlockVerifier,
	ac protocol.AccessControlProvider, net protocol.NetService, nodeId string,
	forks forest.Forester, cache protocol.LedgerCache, epochState *maxbft.GovernanceContract,
	epochId uint64, logger protocol.Logger, manager epoch.Manager) Verifier

NewValidator initial and return a Validator object

Jump to

Keyboard shortcuts

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