mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 14:34:17 +00:00
cleanup evidence pkg. state.VerifyEvidence
This commit is contained in:
+8
-20
@@ -27,17 +27,17 @@ func (err *ErrEvidenceInvalid) Error() string {
|
||||
//-------------------------------------------
|
||||
|
||||
type HistoricalValidators interface {
|
||||
LoadValidators(height int) *ValidatorSet
|
||||
LoadValidators(height int) (*ValidatorSet, error)
|
||||
}
|
||||
|
||||
// Evidence represents any provable malicious activity by a validator
|
||||
type Evidence interface {
|
||||
Height() int // height of the equivocation
|
||||
Address() []byte // address of the equivocating validator
|
||||
Index() int // index of the validator in the validator set
|
||||
Hash() []byte // hash of the evidence
|
||||
Verify(chainID string, vals HistoricalValidators) error // verify the evidence
|
||||
Equal(Evidence) bool // check equality of evidence
|
||||
Height() int // height of the equivocation
|
||||
Address() []byte // address of the equivocating validator
|
||||
Index() int // index of the validator in the validator set
|
||||
Hash() []byte // hash of the evidence
|
||||
Verify(chainID string) error // verify the evidence
|
||||
Equal(Evidence) bool // check equality of evidence
|
||||
|
||||
String() string
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func (dve *DuplicateVoteEvidence) Hash() []byte {
|
||||
|
||||
// Verify returns an error if the two votes aren't conflicting.
|
||||
// To be conflicting, they must be from the same validator, for the same H/R/S, but for different blocks.
|
||||
func (dve *DuplicateVoteEvidence) Verify(chainID string, vals HistoricalValidators) error {
|
||||
func (dve *DuplicateVoteEvidence) Verify(chainID string) error {
|
||||
|
||||
// TODO: verify (cs.Height - dve.Height) < MaxHeightDiff
|
||||
|
||||
@@ -211,18 +211,6 @@ func (dve *DuplicateVoteEvidence) Verify(chainID string, vals HistoricalValidato
|
||||
return ErrVoteInvalidSignature
|
||||
}
|
||||
|
||||
// The address must have been an active validator at the height
|
||||
height := dve.Height()
|
||||
addr := dve.Address()
|
||||
idx := dve.Index()
|
||||
valset := vals.LoadValidators(height)
|
||||
valIdx, val := valset.GetByAddress(addr)
|
||||
if val == nil {
|
||||
return fmt.Errorf("Address %X was not a validator at height %d", addr, height)
|
||||
} else if idx != valIdx {
|
||||
return fmt.Errorf("Address %X was validator %d at height %d, not %d", addr, valIdx, height, idx)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+27
-2
@@ -14,7 +14,7 @@ import (
|
||||
//------------------------------------------------------
|
||||
// mempool
|
||||
|
||||
// Mempool defines the mempool interface.
|
||||
// Mempool defines the mempool interface as used by the ConsensusState.
|
||||
// Updates to the mempool need to be synchronized with committing a block
|
||||
// so apps can reset their transient state on Commit
|
||||
// UNSTABLE
|
||||
@@ -63,9 +63,34 @@ type BlockStoreRPC interface {
|
||||
LoadSeenCommit(height int64) *Commit
|
||||
}
|
||||
|
||||
// BlockStore defines the BlockStore interface.
|
||||
// BlockStore defines the BlockStore interface used by the ConsensusState.
|
||||
// UNSTABLE
|
||||
type BlockStore interface {
|
||||
BlockStoreRPC
|
||||
SaveBlock(block *Block, blockParts *PartSet, seenCommit *Commit)
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// state
|
||||
|
||||
type State interface {
|
||||
VerifyEvidence(Evidence) (priority int, err error)
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// evidence pool
|
||||
|
||||
// EvidencePool defines the EvidencePool interface used by the ConsensusState.
|
||||
// UNSTABLE
|
||||
type EvidencePool interface {
|
||||
PendingEvidence() []Evidence
|
||||
AddEvidence(Evidence)
|
||||
}
|
||||
|
||||
// MockMempool is an empty implementation of a Mempool, useful for testing.
|
||||
// UNSTABLE
|
||||
type MockEvidencePool struct {
|
||||
}
|
||||
|
||||
func (m MockEvidencePool) PendingEvidence() []Evidence { return nil }
|
||||
func (m MockEvidencePool) AddEvidence(Evidence) {}
|
||||
|
||||
Reference in New Issue
Block a user