Browse Source

evidence: remove lunatic (#5318)

## Description

remove lunaticEvidence
pull/5318/merge
Marko 4 years ago
committed by GitHub
parent
commit
82011ee7ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 954 deletions
  1. +1
    -0
      CHANGELOG_PENDING.md
  2. +0
    -10
      evidence/pool.go
  3. +0
    -26
      evidence/reactor_test.go
  4. +0
    -7
      evidence/verify.go
  5. +0
    -110
      evidence/verify_test.go
  6. +44
    -476
      proto/tendermint/types/evidence.pb.go
  7. +2
    -12
      proto/tendermint/types/evidence.proto
  8. +0
    -232
      types/evidence.go
  9. +0
    -78
      types/evidence_test.go
  10. +0
    -3
      types/protobuf.go

+ 1
- 0
CHANGELOG_PENDING.md View File

@ -16,6 +16,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- Go API
- [evidence] \#5317 Remove ConflictingHeaders evidence type & CompositeEvidence Interface. (@marbar3778)
- [evidence] \#5318 Remove LunaticValidator evidence type. (@marbar3778)
- [crypto/secp256k1] \#5280 `secp256k1` has been removed from the Tendermint repo. (@marbar3778)
- Blockchain Protocol


+ 0
- 10
evidence/pool.go View File

@ -369,16 +369,6 @@ func (evpool *Pool) SetLogger(l log.Logger) {
evpool.logger = l
}
// Header gets the header from the block store at a specified height.
// Is used for validation of LunaticValidatorEvidence
func (evpool *Pool) Header(height int64) *types.Header {
blockMeta := evpool.blockStore.LoadBlockMeta(height)
if blockMeta == nil {
return nil
}
return &blockMeta.Header
}
// State returns the current state of the evpool.
func (evpool *Pool) State() sm.State {
evpool.mtx.Lock()


+ 0
- 26
evidence/reactor_test.go View File

@ -22,7 +22,6 @@ import (
"github.com/tendermint/tendermint/p2p"
ep "github.com/tendermint/tendermint/proto/tendermint/evidence"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/proto/tendermint/version"
"github.com/tendermint/tendermint/types"
)
@ -238,34 +237,10 @@ func exampleVote(t byte) *types.Vote {
}
}
func exampleHeader() *types.Header {
blockID := types.BlockID{Hash: []byte{0}, PartSetHeader: types.PartSetHeader{Total: 123, Hash: []byte{0}}}
h := &types.Header{
Version: version.Consensus{Block: 1, App: 2},
ChainID: "chainId",
Height: 3,
Time: time.Date(2019, 10, 13, 16, 14, 44, 0, time.UTC),
LastBlockID: blockID,
LastCommitHash: tmhash.Sum([]byte("last_commit_hash")),
DataHash: tmhash.Sum([]byte("data_hash")),
ValidatorsHash: tmhash.Sum([]byte("validators_hash")),
NextValidatorsHash: tmhash.Sum([]byte("next_validators_hash")),
ConsensusHash: tmhash.Sum([]byte("consensus_hash")),
AppHash: tmhash.Sum([]byte("app_hash")),
LastResultsHash: tmhash.Sum([]byte("last_results_hash")),
EvidenceHash: tmhash.Sum([]byte("evidence_hash")),
ProposerAddress: crypto.AddressHash([]byte("proposer_address")),
}
return h
}
// nolint:lll //ignore line length for tests
func TestEvidenceVectors(t *testing.T) {
dupl := types.NewDuplicateVoteEvidence(exampleVote(1), exampleVote(2), time.Date(2019, 10, 13, 16, 14, 44, 0, time.UTC))
lve := types.NewLunaticValidatorEvidence(exampleHeader(), exampleVote(1), "Datahash", time.Date(2019, 10, 13, 16, 14, 44, 0, time.UTC))
testCases := []struct {
testName string
@ -273,7 +248,6 @@ func TestEvidenceVectors(t *testing.T) {
expBytes string
}{
{"DuplicateVoteEvidence", []types.Evidence{dupl}, "0a81020afe010a79080210031802224a0a208b01023386c371778ecb6368573e539afc3cc860ec3a2f614e54fe5652f4fc80122608c0843d122072db3d959635dff1bb567bedaa70573392c5159666a3f8caf11e413aac52207a2a0b08b1d381d20510809dca6f32146af1f4111082efb388211bc72c55bcd61e9ac3d538d5bb031279080110031802224a0a208b01023386c371778ecb6368573e539afc3cc860ec3a2f614e54fe5652f4fc80122608c0843d122072db3d959635dff1bb567bedaa70573392c5159666a3f8caf11e413aac52207a2a0b08b1d381d20510809dca6f32146af1f4111082efb388211bc72c55bcd61e9ac3d538d5bb031a0608f49a8ded05"},
{"LunaticValidatorEvidence", []types.Evidence{lve}, "0ade031adb030acb020a04080110021207636861696e49641803220608f49a8ded052a0a0a01001205087b1201003220e7aad01a1af897b05bcf78c7563b5d1adc2939d543dac949a5c8712156d19bf83a206d6e28b8b98b5327042ea50a57dd46e6cc851c72e528bdeaa6efdeeefe66a0b84220db5d0767f57d844ba68132eaf74f6b8b83df6c03810a6a4378c2a6b2caf93e8d4a201eef9748a3c48ff996033757d73200886e7b2b4e9d9df07b19a34a44bae3e2c85220e5e566c41ed57e3ff8cc10f184178788b8faa602b07cf1f425217bd8179f1f245a2041cafae31cc70f5801fa1016a2dd54a9bcb8201b5b389919fe9976762532c5166220092e058630247ed6009863a12eee117d26cd9d08b5adcaab37f2ab35db475a376a2073865db08f49d58428905d389ab4ca4b96e45a3206c7a69d43a5dc7372e60714721427834082c131975497cdebfbdce6c8e5196a13541279080110031802224a0a208b01023386c371778ecb6368573e539afc3cc860ec3a2f614e54fe5652f4fc80122608c0843d122072db3d959635dff1bb567bedaa70573392c5159666a3f8caf11e413aac52207a2a0b08b1d381d20510809dca6f32146af1f4111082efb388211bc72c55bcd61e9ac3d538d5bb031a084461746168617368220608f49a8ded05"},
}
for _, tc := range testCases {


+ 0
- 7
evidence/verify.go View File

@ -56,13 +56,6 @@ func VerifyEvidence(evidence types.Evidence, state sm.State, stateDB StateStore,
)
}
// If in the case of lunatic validator evidence we need our committed header again to verify the evidence
if ev, ok := evidence.(*types.LunaticValidatorEvidence); ok {
if err := ev.VerifyHeader(header); err != nil {
return err
}
}
valset, err := stateDB.LoadValidators(evidence.Height())
if err != nil {
return err


+ 0
- 110
evidence/verify_test.go View File

@ -8,10 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/evidence/mocks"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/types"
)
@ -71,110 +68,3 @@ func TestVerifyEvidenceInvalidTime(t *testing.T) {
assert.Equal(t, errMsg, err.Error())
}
}
func TestVerifyEvidenceWithLunaticValidatorEvidence(t *testing.T) {
var height int64 = 4
val := types.NewMockPV()
stateStore := initializeValidatorState(val, height)
blockID := types.BlockID{
Hash: tmrand.Bytes(tmhash.Size),
PartSetHeader: types.PartSetHeader{
Total: 1,
Hash: tmrand.Bytes(tmhash.Size),
},
}
h := &types.Header{
ChainID: evidenceChainID,
Height: 3,
Time: defaultEvidenceTime,
LastBlockID: blockID,
LastCommitHash: tmhash.Sum([]byte("last_commit_hash")),
DataHash: tmhash.Sum([]byte("data_hash")),
ValidatorsHash: tmhash.Sum([]byte("validators_hash")),
NextValidatorsHash: tmhash.Sum([]byte("next_validators_hash")),
ConsensusHash: tmhash.Sum([]byte("consensus_hash")),
AppHash: tmhash.Sum([]byte("app_hash")),
LastResultsHash: tmhash.Sum([]byte("last_results_hash")),
EvidenceHash: tmhash.Sum([]byte("evidence_hash")),
ProposerAddress: crypto.AddressHash([]byte("proposer_address")),
}
blockStore := &mocks.BlockStore{}
blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return(
&types.BlockMeta{Header: *h},
)
validH1 := *h
validH1.ValidatorsHash = tmhash.Sum([]byte("different_validators_hash"))
validH2 := validH1
validH2.Time = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
badH1 := validH1
badH1.ChainID = "different_chain_id"
badH2 := *h
badH2.DataHash = tmhash.Sum([]byte("different_data_hash"))
testCases := []struct {
Header *types.Header
ExpErr bool
ErrMsg string
}{
{
h,
true,
"ValidatorsHash matches committed hash",
},
{
&validH1,
false,
"",
},
{
&validH2,
false,
"",
},
{
&badH1,
true,
"chainID do not match: test_chain vs different_chain_id",
},
{
&badH2,
true,
"ValidatorsHash matches committed hash", // it doesn't recognise that the data hashes are different
},
}
for idx, tc := range testCases {
ev := types.NewLunaticValidatorEvidence(tc.Header,
makeValidVoteForHeader(tc.Header, val), "ValidatorsHash", defaultEvidenceTime)
err := VerifyEvidence(ev, stateStore.LoadState(), stateStore, blockStore)
if tc.ExpErr {
if assert.Error(t, err, fmt.Sprintf("expected an error for case: %d", idx)) {
assert.Equal(t, tc.ErrMsg, err.Error(), fmt.Sprintf("case: %d", idx))
}
} else {
assert.NoError(t, err, fmt.Sprintf("did not expect an error for case: %d", idx))
}
}
}
func makeValidVoteForHeader(header *types.Header, val types.MockPV) *types.Vote {
vote := makeVote(header.Height, 1, 0, val.PrivKey.PubKey().Address(), types.BlockID{
Hash: header.Hash(),
PartSetHeader: types.PartSetHeader{
Total: 100,
Hash: crypto.CRandBytes(tmhash.Size),
},
}, defaultEvidenceTime)
v := vote.ToProto()
err := val.SignVote(evidenceChainID, v)
if err != nil {
panic("verify_test: failed to sign vote for header")
}
vote.Signature = v.Signature
return vote
}

+ 44
- 476
proto/tendermint/types/evidence.pb.go View File

@ -210,78 +210,9 @@ func (m *AmnesiaEvidence) GetPolc() *ProofOfLockChange {
return nil
}
type LunaticValidatorEvidence struct {
Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"`
Vote *Vote `protobuf:"bytes,2,opt,name=vote,proto3" json:"vote,omitempty"`
InvalidHeaderField string `protobuf:"bytes,3,opt,name=invalid_header_field,json=invalidHeaderField,proto3" json:"invalid_header_field,omitempty"`
Timestamp time.Time `protobuf:"bytes,4,opt,name=timestamp,proto3,stdtime" json:"timestamp"`
}
func (m *LunaticValidatorEvidence) Reset() { *m = LunaticValidatorEvidence{} }
func (m *LunaticValidatorEvidence) String() string { return proto.CompactTextString(m) }
func (*LunaticValidatorEvidence) ProtoMessage() {}
func (*LunaticValidatorEvidence) Descriptor() ([]byte, []int) {
return fileDescriptor_6825fabc78e0a168, []int{3}
}
func (m *LunaticValidatorEvidence) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *LunaticValidatorEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_LunaticValidatorEvidence.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *LunaticValidatorEvidence) XXX_Merge(src proto.Message) {
xxx_messageInfo_LunaticValidatorEvidence.Merge(m, src)
}
func (m *LunaticValidatorEvidence) XXX_Size() int {
return m.Size()
}
func (m *LunaticValidatorEvidence) XXX_DiscardUnknown() {
xxx_messageInfo_LunaticValidatorEvidence.DiscardUnknown(m)
}
var xxx_messageInfo_LunaticValidatorEvidence proto.InternalMessageInfo
func (m *LunaticValidatorEvidence) GetHeader() *Header {
if m != nil {
return m.Header
}
return nil
}
func (m *LunaticValidatorEvidence) GetVote() *Vote {
if m != nil {
return m.Vote
}
return nil
}
func (m *LunaticValidatorEvidence) GetInvalidHeaderField() string {
if m != nil {
return m.InvalidHeaderField
}
return ""
}
func (m *LunaticValidatorEvidence) GetTimestamp() time.Time {
if m != nil {
return m.Timestamp
}
return time.Time{}
}
type Evidence struct {
// Types that are valid to be assigned to Sum:
// *Evidence_DuplicateVoteEvidence
// *Evidence_LunaticValidatorEvidence
// *Evidence_PotentialAmnesiaEvidence
// *Evidence_AmnesiaEvidence
Sum isEvidence_Sum `protobuf_oneof:"sum"`
@ -291,7 +222,7 @@ func (m *Evidence) Reset() { *m = Evidence{} }
func (m *Evidence) String() string { return proto.CompactTextString(m) }
func (*Evidence) ProtoMessage() {}
func (*Evidence) Descriptor() ([]byte, []int) {
return fileDescriptor_6825fabc78e0a168, []int{4}
return fileDescriptor_6825fabc78e0a168, []int{3}
}
func (m *Evidence) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -329,18 +260,14 @@ type isEvidence_Sum interface {
type Evidence_DuplicateVoteEvidence struct {
DuplicateVoteEvidence *DuplicateVoteEvidence `protobuf:"bytes,1,opt,name=duplicate_vote_evidence,json=duplicateVoteEvidence,proto3,oneof" json:"duplicate_vote_evidence,omitempty"`
}
type Evidence_LunaticValidatorEvidence struct {
LunaticValidatorEvidence *LunaticValidatorEvidence `protobuf:"bytes,3,opt,name=lunatic_validator_evidence,json=lunaticValidatorEvidence,proto3,oneof" json:"lunatic_validator_evidence,omitempty"`
}
type Evidence_PotentialAmnesiaEvidence struct {
PotentialAmnesiaEvidence *PotentialAmnesiaEvidence `protobuf:"bytes,4,opt,name=potential_amnesia_evidence,json=potentialAmnesiaEvidence,proto3,oneof" json:"potential_amnesia_evidence,omitempty"`
PotentialAmnesiaEvidence *PotentialAmnesiaEvidence `protobuf:"bytes,2,opt,name=potential_amnesia_evidence,json=potentialAmnesiaEvidence,proto3,oneof" json:"potential_amnesia_evidence,omitempty"`
}
type Evidence_AmnesiaEvidence struct {
AmnesiaEvidence *AmnesiaEvidence `protobuf:"bytes,5,opt,name=amnesia_evidence,json=amnesiaEvidence,proto3,oneof" json:"amnesia_evidence,omitempty"`
AmnesiaEvidence *AmnesiaEvidence `protobuf:"bytes,3,opt,name=amnesia_evidence,json=amnesiaEvidence,proto3,oneof" json:"amnesia_evidence,omitempty"`
}
func (*Evidence_DuplicateVoteEvidence) isEvidence_Sum() {}
func (*Evidence_LunaticValidatorEvidence) isEvidence_Sum() {}
func (*Evidence_PotentialAmnesiaEvidence) isEvidence_Sum() {}
func (*Evidence_AmnesiaEvidence) isEvidence_Sum() {}
@ -358,13 +285,6 @@ func (m *Evidence) GetDuplicateVoteEvidence() *DuplicateVoteEvidence {
return nil
}
func (m *Evidence) GetLunaticValidatorEvidence() *LunaticValidatorEvidence {
if x, ok := m.GetSum().(*Evidence_LunaticValidatorEvidence); ok {
return x.LunaticValidatorEvidence
}
return nil
}
func (m *Evidence) GetPotentialAmnesiaEvidence() *PotentialAmnesiaEvidence {
if x, ok := m.GetSum().(*Evidence_PotentialAmnesiaEvidence); ok {
return x.PotentialAmnesiaEvidence
@ -383,7 +303,6 @@ func (m *Evidence) GetAmnesiaEvidence() *AmnesiaEvidence {
func (*Evidence) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*Evidence_DuplicateVoteEvidence)(nil),
(*Evidence_LunaticValidatorEvidence)(nil),
(*Evidence_PotentialAmnesiaEvidence)(nil),
(*Evidence_AmnesiaEvidence)(nil),
}
@ -399,7 +318,7 @@ func (m *EvidenceData) Reset() { *m = EvidenceData{} }
func (m *EvidenceData) String() string { return proto.CompactTextString(m) }
func (*EvidenceData) ProtoMessage() {}
func (*EvidenceData) Descriptor() ([]byte, []int) {
return fileDescriptor_6825fabc78e0a168, []int{5}
return fileDescriptor_6825fabc78e0a168, []int{4}
}
func (m *EvidenceData) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -451,7 +370,7 @@ func (m *ProofOfLockChange) Reset() { *m = ProofOfLockChange{} }
func (m *ProofOfLockChange) String() string { return proto.CompactTextString(m) }
func (*ProofOfLockChange) ProtoMessage() {}
func (*ProofOfLockChange) Descriptor() ([]byte, []int) {
return fileDescriptor_6825fabc78e0a168, []int{6}
return fileDescriptor_6825fabc78e0a168, []int{5}
}
func (m *ProofOfLockChange) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -498,7 +417,6 @@ func init() {
proto.RegisterType((*DuplicateVoteEvidence)(nil), "tendermint.types.DuplicateVoteEvidence")
proto.RegisterType((*PotentialAmnesiaEvidence)(nil), "tendermint.types.PotentialAmnesiaEvidence")
proto.RegisterType((*AmnesiaEvidence)(nil), "tendermint.types.AmnesiaEvidence")
proto.RegisterType((*LunaticValidatorEvidence)(nil), "tendermint.types.LunaticValidatorEvidence")
proto.RegisterType((*Evidence)(nil), "tendermint.types.Evidence")
proto.RegisterType((*EvidenceData)(nil), "tendermint.types.EvidenceData")
proto.RegisterType((*ProofOfLockChange)(nil), "tendermint.types.ProofOfLockChange")
@ -507,48 +425,41 @@ func init() {
func init() { proto.RegisterFile("tendermint/types/evidence.proto", fileDescriptor_6825fabc78e0a168) }
var fileDescriptor_6825fabc78e0a168 = []byte{
// 641 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00,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 0x8b, 0xbe,
0x7a, 0x19, 0x9f, 0xdd, 0xdc, 0xea, 0x7e, 0x6c, 0xb8, 0xd4, 0xdc, 0x25, 0x09, 0x6a, 0x07, 0xb1,
0xb1, 0x4b, 0x92, 0xc1, 0xbb, 0x93, 0xf3, 0xae, 0x74, 0x7a, 0xde, 0x95, 0x7e, 0x9e, 0x77, 0xa5,
0xe3, 0x8b, 0x6e, 0xe3, 0xf4, 0xa2, 0xdb, 0xf8, 0x7e, 0xd1, 0x6d, 0x7c, 0xdc, 0xb4, 0x29, 0x77,
0x62, 0x43, 0x35, 0x99, 0xa7, 0x5d, 0x7e, 0x21, 0xc6, 0x9f, 0xd9, 0x53, 0x33, 0xf9, 0x7a, 0x18,
0x6d, 0x61, 0x7f, 0xf6, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x2a, 0xcf, 0x0c, 0xc2, 0x06, 0x00,
0x00,
// 539 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xcb, 0x6e, 0xd3, 0x40,
0x14, 0xb5, 0x93, 0x34, 0x84, 0x69, 0xa4, 0x16, 0x8b, 0x82, 0x15, 0x55, 0x0e, 0x35, 0x0b, 0x10,
0x02, 0x5b, 0x02, 0xa1, 0x6e, 0xd8, 0xd4, 0x14, 0xa9, 0x52, 0x11, 0x14, 0x83, 0x58, 0xb0, 0x31,
0x63, 0xe7, 0xc6, 0x36, 0xb1, 0x3d, 0xa3, 0x78, 0x5c, 0xe1, 0xbf, 0xe8, 0xa7, 0xb0, 0x60, 0xc3,
0x1f, 0x74, 0xd9, 0x25, 0x2b, 0x8a, 0x92, 0x1f, 0x41, 0x1e, 0x3f, 0x92, 0xc6, 0x49, 0x10, 0x2c,
0xba, 0x89, 0x26, 0xf7, 0x9e, 0xfb, 0x38, 0xc7, 0x47, 0x17, 0xf5, 0x19, 0x44, 0x03, 0x18, 0x87,
0x7e, 0x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 0x76, 0xe0, 0x3b, 0xc7, 0x90, 0x9a, 0x6d, 0x9a, 0xd8, 0xc7, 0x90, 0x1a,
0xef, 0xce, 0x27, 0x8a, 0x78, 0x31, 0x51, 0xc4, 0xdf, 0x13, 0x45, 0x3c, 0x9b, 0x2a, 0xc2, 0xc5,
0x54, 0x11, 0x7e, 0x4e, 0x15, 0xe1, 0xd3, 0xbe, 0xeb, 0x33, 0x2f, 0xb1, 0x35, 0x87, 0x84, 0xfa,
0xfc, 0x11, 0x9b, 0x3d, 0xf3, 0x6b, 0xb8, 0x78, 0xe0, 0xec, 0x36, 0x8f, 0x3f, 0xfb, 0x13, 0x00,
0x00, 0xff, 0xff, 0x20, 0x49, 0xd9, 0x02, 0x65, 0x05, 0x00, 0x00,
}
func (m *DuplicateVoteEvidence) Marshal() (dAtA []byte, err error) {
@ -713,68 +624,6 @@ func (m *AmnesiaEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *LunaticValidatorEvidence) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *LunaticValidatorEvidence) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *LunaticValidatorEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
if err9 != nil {
return 0, err9
}
i -= n9
i = encodeVarintEvidence(dAtA, i, uint64(n9))
i--
dAtA[i] = 0x22
if len(m.InvalidHeaderField) > 0 {
i -= len(m.InvalidHeaderField)
copy(dAtA[i:], m.InvalidHeaderField)
i = encodeVarintEvidence(dAtA, i, uint64(len(m.InvalidHeaderField)))
i--
dAtA[i] = 0x1a
}
if m.Vote != nil {
{
size, err := m.Vote.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintEvidence(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
if m.Header != nil {
{
size, err := m.Header.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintEvidence(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *Evidence) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -828,27 +677,6 @@ func (m *Evidence_DuplicateVoteEvidence) MarshalToSizedBuffer(dAtA []byte) (int,
}
return len(dAtA) - i, nil
}
func (m *Evidence_LunaticValidatorEvidence) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Evidence_LunaticValidatorEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
if m.LunaticValidatorEvidence != nil {
{
size, err := m.LunaticValidatorEvidence.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintEvidence(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x1a
}
return len(dAtA) - i, nil
}
func (m *Evidence_PotentialAmnesiaEvidence) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
@ -866,7 +694,7 @@ func (m *Evidence_PotentialAmnesiaEvidence) MarshalToSizedBuffer(dAtA []byte) (i
i = encodeVarintEvidence(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
dAtA[i] = 0x12
}
return len(dAtA) - i, nil
}
@ -887,7 +715,7 @@ func (m *Evidence_AmnesiaEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error
i = encodeVarintEvidence(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x2a
dAtA[i] = 0x1a
}
return len(dAtA) - i, nil
}
@ -1053,29 +881,6 @@ func (m *AmnesiaEvidence) Size() (n int) {
return n
}
func (m *LunaticValidatorEvidence) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Header != nil {
l = m.Header.Size()
n += 1 + l + sovEvidence(uint64(l))
}
if m.Vote != nil {
l = m.Vote.Size()
n += 1 + l + sovEvidence(uint64(l))
}
l = len(m.InvalidHeaderField)
if l > 0 {
n += 1 + l + sovEvidence(uint64(l))
}
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp)
n += 1 + l + sovEvidence(uint64(l))
return n
}
func (m *Evidence) Size() (n int) {
if m == nil {
return 0
@ -1100,18 +905,6 @@ func (m *Evidence_DuplicateVoteEvidence) Size() (n int) {
}
return n
}
func (m *Evidence_LunaticValidatorEvidence) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.LunaticValidatorEvidence != nil {
l = m.LunaticValidatorEvidence.Size()
n += 1 + l + sovEvidence(uint64(l))
}
return n
}
func (m *Evidence_PotentialAmnesiaEvidence) Size() (n int) {
if m == nil {
return 0
@ -1640,196 +1433,6 @@ func (m *AmnesiaEvidence) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *LunaticValidatorEvidence) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: LunaticValidatorEvidence: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: LunaticValidatorEvidence: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvidence
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvidence
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Header == nil {
m.Header = &Header{}
}
if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Vote", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvidence
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvidence
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Vote == nil {
m.Vote = &Vote{}
}
if err := m.Vote.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field InvalidHeaderField", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthEvidence
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthEvidence
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.InvalidHeaderField = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvidence
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvidence
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Timestamp, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipEvidence(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthEvidence
}
if (iNdEx + skippy) < 0 {
return ErrInvalidLengthEvidence
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *Evidence) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -1894,42 +1497,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error {
}
m.Sum = &Evidence_DuplicateVoteEvidence{v}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LunaticValidatorEvidence", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthEvidence
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthEvidence
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
v := &LunaticValidatorEvidence{}
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Sum = &Evidence_LunaticValidatorEvidence{v}
iNdEx = postIndex
case 4:
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PotentialAmnesiaEvidence", wireType)
}
@ -1964,7 +1532,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error {
}
m.Sum = &Evidence_PotentialAmnesiaEvidence{v}
iNdEx = postIndex
case 5:
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AmnesiaEvidence", wireType)
}


+ 2
- 12
proto/tendermint/types/evidence.proto View File

@ -32,21 +32,11 @@ message AmnesiaEvidence {
ProofOfLockChange polc = 2;
}
message LunaticValidatorEvidence {
Header header = 1;
Vote vote = 2;
string invalid_header_field = 3;
google.protobuf.Timestamp timestamp = 4
[(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
}
message Evidence {
oneof sum {
DuplicateVoteEvidence duplicate_vote_evidence = 1;
LunaticValidatorEvidence lunatic_validator_evidence = 2;
PotentialAmnesiaEvidence potential_amnesia_evidence = 3;
AmnesiaEvidence amnesia_evidence = 4;
PotentialAmnesiaEvidence potential_amnesia_evidence = 2;
AmnesiaEvidence amnesia_evidence = 3;
}
}


+ 0
- 232
types/evidence.go View File

@ -33,14 +33,6 @@ type Evidence interface {
const (
// MaxEvidenceBytes is a maximum size of any evidence (including amino overhead).
MaxEvidenceBytes int64 = 444
// An invalid field in the header from LunaticValidatorEvidence.
// Must be a function of the ABCI application state.
ValidatorsHashField = "ValidatorsHash"
NextValidatorsHashField = "NextValidatorsHash"
ConsensusHashField = "ConsensusHash"
AppHashField = "AppHash"
LastResultsHashField = "LastResultsHash"
)
// ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.
@ -92,17 +84,6 @@ func EvidenceToProto(evidence Evidence) (*tmproto.Evidence, error) {
}
return tp, nil
case *LunaticValidatorEvidence:
pbevi := evi.ToProto()
tp := &tmproto.Evidence{
Sum: &tmproto.Evidence_LunaticValidatorEvidence{
LunaticValidatorEvidence: pbevi,
},
}
return tp, nil
case *PotentialAmnesiaEvidence:
pbevi := evi.ToProto()
@ -137,8 +118,6 @@ func EvidenceFromProto(evidence *tmproto.Evidence) (Evidence, error) {
switch evi := evidence.Sum.(type) {
case *tmproto.Evidence_DuplicateVoteEvidence:
return DuplicateVoteEvidenceFromProto(evi.DuplicateVoteEvidence)
case *tmproto.Evidence_LunaticValidatorEvidence:
return LunaticValidatorEvidenceFromProto(evi.LunaticValidatorEvidence)
case *tmproto.Evidence_PotentialAmnesiaEvidence:
return PotentialAmnesiaEvidenceFromProto(evi.PotentialAmnesiaEvidence)
case *tmproto.Evidence_AmnesiaEvidence:
@ -150,7 +129,6 @@ func EvidenceFromProto(evidence *tmproto.Evidence) (Evidence, error) {
func init() {
tmjson.RegisterType(&DuplicateVoteEvidence{}, "tendermint/DuplicateVoteEvidence")
tmjson.RegisterType(&LunaticValidatorEvidence{}, "tendermint/LunaticValidatorEvidence")
tmjson.RegisterType(&PotentialAmnesiaEvidence{}, "tendermint/PotentialAmnesiaEvidence")
tmjson.RegisterType(&AmnesiaEvidence{}, "tendermint/AmnesiaEvidence")
}
@ -362,216 +340,6 @@ func DuplicateVoteEvidenceFromProto(pb *tmproto.DuplicateVoteEvidence) (*Duplica
//-------------------------------------------
type LunaticValidatorEvidence struct {
Header *Header `json:"header"`
Vote *Vote `json:"vote"`
InvalidHeaderField string `json:"invalid_header_field"`
Timestamp time.Time `json:"timestamp"`
}
var _ Evidence = &LunaticValidatorEvidence{}
// NewLunaticValidatorEvidence creates a new instance of the respective evidence
func NewLunaticValidatorEvidence(header *Header,
vote *Vote, invalidHeaderField string, time time.Time) *LunaticValidatorEvidence {
return &LunaticValidatorEvidence{
Header: header,
Vote: vote,
InvalidHeaderField: invalidHeaderField,
Timestamp: time,
}
}
func (e *LunaticValidatorEvidence) Height() int64 {
return e.Header.Height
}
// Time returns the maximum between the header's time and vote's time.
func (e *LunaticValidatorEvidence) Time() time.Time {
return e.Timestamp
}
func (e *LunaticValidatorEvidence) Address() []byte {
return e.Vote.ValidatorAddress
}
func (e *LunaticValidatorEvidence) Hash() []byte {
bz := make([]byte, tmhash.Size+crypto.AddressSize)
copy(bz[:tmhash.Size-1], e.Header.Hash().Bytes())
copy(bz[tmhash.Size:], e.Vote.ValidatorAddress.Bytes())
return tmhash.Sum(bz)
}
func (e *LunaticValidatorEvidence) Bytes() []byte {
pbe := e.ToProto()
bz, err := pbe.Marshal()
if err != nil {
panic(err)
}
return bz
}
func (e *LunaticValidatorEvidence) Verify(chainID string, pubKey crypto.PubKey) error {
// chainID must be the same
if chainID != e.Header.ChainID {
return fmt.Errorf("chainID do not match: %s vs %s",
chainID,
e.Header.ChainID,
)
}
v := e.Vote.ToProto()
if !pubKey.VerifySignature(VoteSignBytes(chainID, v), e.Vote.Signature) {
return errors.New("invalid signature")
}
return nil
}
func (e *LunaticValidatorEvidence) Equal(ev Evidence) bool {
if e2, ok := ev.(*LunaticValidatorEvidence); ok {
return bytes.Equal(e.Header.Hash(), e2.Header.Hash()) &&
bytes.Equal(e.Vote.ValidatorAddress, e2.Vote.ValidatorAddress)
}
return false
}
func (e *LunaticValidatorEvidence) ValidateBasic() error {
if e == nil {
return errors.New("empty lunatic validator evidence")
}
if e.Header == nil {
return errors.New("empty header")
}
if e.Vote == nil {
return errors.New("empty vote")
}
if err := e.Header.ValidateBasic(); err != nil {
return fmt.Errorf("invalid header: %v", err)
}
if err := e.Vote.ValidateBasic(); err != nil {
return fmt.Errorf("invalid signature: %v", err)
}
if !e.Vote.BlockID.IsComplete() {
return errors.New("expected vote for block")
}
if e.Header.Height != e.Vote.Height {
return fmt.Errorf("header and vote have different heights: %d vs %d",
e.Header.Height,
e.Vote.Height,
)
}
switch e.InvalidHeaderField {
case "ValidatorsHash", "NextValidatorsHash", "ConsensusHash", "AppHash", "LastResultsHash":
break
default:
return errors.New("unknown invalid header field")
}
if !bytes.Equal(e.Header.Hash(), e.Vote.BlockID.Hash) {
return fmt.Errorf("vote was not for header: %X != %X",
e.Vote.BlockID.Hash,
e.Header.Hash(),
)
}
return nil
}
func (e *LunaticValidatorEvidence) String() string {
return fmt.Sprintf("LunaticValidatorEvidence{%X voted for %d/%X, which contains invalid %s}",
e.Vote.ValidatorAddress, e.Header.Height, e.Header.Hash(), e.InvalidHeaderField)
}
func (e *LunaticValidatorEvidence) VerifyHeader(committedHeader *Header) error {
matchErr := func(field string) error {
return fmt.Errorf("%s matches committed hash", field)
}
if committedHeader == nil {
return errors.New("committed header is nil")
}
switch e.InvalidHeaderField {
case ValidatorsHashField:
if bytes.Equal(committedHeader.ValidatorsHash, e.Header.ValidatorsHash) {
return matchErr(ValidatorsHashField)
}
case NextValidatorsHashField:
if bytes.Equal(committedHeader.NextValidatorsHash, e.Header.NextValidatorsHash) {
return matchErr(NextValidatorsHashField)
}
case ConsensusHashField:
if bytes.Equal(committedHeader.ConsensusHash, e.Header.ConsensusHash) {
return matchErr(ConsensusHashField)
}
case AppHashField:
if bytes.Equal(committedHeader.AppHash, e.Header.AppHash) {
return matchErr(AppHashField)
}
case LastResultsHashField:
if bytes.Equal(committedHeader.LastResultsHash, e.Header.LastResultsHash) {
return matchErr(LastResultsHashField)
}
default:
return errors.New("unknown InvalidHeaderField")
}
return nil
}
func (e *LunaticValidatorEvidence) ToProto() *tmproto.LunaticValidatorEvidence {
h := e.Header.ToProto()
v := e.Vote.ToProto()
tp := &tmproto.LunaticValidatorEvidence{
Header: h,
Vote: v,
InvalidHeaderField: e.InvalidHeaderField,
Timestamp: e.Timestamp,
}
return tp
}
func LunaticValidatorEvidenceFromProto(pb *tmproto.LunaticValidatorEvidence) (*LunaticValidatorEvidence, error) {
if pb == nil {
return nil, errors.New("nil LunaticValidatorEvidence")
}
h, err := HeaderFromProto(pb.GetHeader())
if err != nil {
return nil, err
}
v, err := VoteFromProto(pb.GetVote())
if err != nil {
return nil, err
}
tp := LunaticValidatorEvidence{
Header: &h,
Vote: v,
InvalidHeaderField: pb.InvalidHeaderField,
Timestamp: pb.Timestamp,
}
return &tp, tp.ValidateBasic()
}
//-------------------------------------------
// PotentialAmnesiaEvidence is constructed when a validator votes on two different blocks at different rounds
// in the same height. PotentialAmnesiaEvidence can then evolve into AmnesiaEvidence if the indicted validator
// is incapable of providing the proof of lock change that validates voting twice in the allotted trial period.


+ 0
- 78
types/evidence_test.go View File

@ -105,19 +105,11 @@ func TestMaxEvidenceBytes(t *testing.T) {
//TODO: Add other types of evidence to test and set MaxEvidenceBytes accordingly
// evl := &LunaticValidatorEvidence{
// Header: makeHeaderRandom(),
// Vote: makeVote(t, val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID2),
// InvalidHeaderField: "",
// }
testCases := []struct {
testName string
evidence Evidence
}{
{"DuplicateVote", ev},
// {"LunaticValidatorEvidence", evl},
}
for _, tt := range testCases {
@ -186,69 +178,6 @@ func TestMockEvidenceValidateBasic(t *testing.T) {
assert.Nil(t, goodEvidence.ValidateBasic())
}
func TestLunaticValidatorEvidence(t *testing.T) {
var (
invalidBlockID = makeBlockIDRandom()
header = makeHeaderRandom()
altHeader = makeHeaderRandom()
bTime, _ = time.Parse(time.RFC3339, "2006-01-02T15:04:05Z")
val = NewMockPV()
)
header.Time = bTime
blockID := BlockID{
Hash: header.Hash(),
PartSetHeader: PartSetHeader{
Total: 100,
Hash: crypto.CRandBytes(tmhash.Size),
},
}
vote := makeVote(t, val, header.ChainID, 0, header.Height, 0, 2, blockID, defaultVoteTime)
ev := NewLunaticValidatorEvidence(header, vote, "AppHash", bTime)
//happy path
assert.Equal(t, header.Height, ev.Height())
assert.Equal(t, bTime, ev.Time())
assert.EqualValues(t, vote.ValidatorAddress, ev.Address())
assert.NotEmpty(t, ev.Hash())
assert.NotEmpty(t, ev.Bytes())
assert.True(t, ev.Equal(ev))
pubKey, err := val.GetPubKey()
require.NoError(t, err)
assert.NoError(t, ev.Verify(header.ChainID, pubKey))
assert.NoError(t, ev.ValidateBasic())
assert.NotEmpty(t, ev.String())
assert.NoError(t, ev.VerifyHeader(altHeader))
// invalid evidence
assert.Error(t, ev.Verify("other", pubKey))
privKey2 := ed25519.GenPrivKey()
pubKey2 := privKey2.PubKey()
assert.Error(t, ev.Verify(header.ChainID, pubKey2))
assert.Error(t, ev.VerifyHeader(header))
invalidVote := makeVote(t, val, header.ChainID, 0, header.Height, 0, 2, invalidBlockID, defaultVoteTime)
invalidHeightVote := makeVote(t, val, header.ChainID, 0, header.Height+1, 0, 2, blockID, defaultVoteTime)
emptyBlockVote := makeVote(t, val, header.ChainID, 0, header.Height, 0, 2, BlockID{}, defaultVoteTime)
invalidLunaticEvidence := []*LunaticValidatorEvidence{
NewLunaticValidatorEvidence(header, invalidVote, "AppHash", header.Time),
NewLunaticValidatorEvidence(header, invalidHeightVote, "AppHash", header.Time),
NewLunaticValidatorEvidence(nil, vote, "AppHash", vote.Timestamp),
NewLunaticValidatorEvidence(header, nil, "AppHash", header.Time),
NewLunaticValidatorEvidence(header, vote, "other", header.Time),
NewLunaticValidatorEvidence(header, emptyBlockVote, "AppHash", header.Time),
}
for idx, ev := range invalidLunaticEvidence {
assert.Error(t, ev.ValidateBasic(), "#%d", idx)
}
}
func TestPotentialAmnesiaEvidence(t *testing.T) {
const (
chainID = "TestPotentialAmnesiaEvidence"
@ -577,13 +506,6 @@ func TestEvidenceProto(t *testing.T) {
{"DuplicateVoteEvidence nil voteB", &DuplicateVoteEvidence{VoteA: v, VoteB: nil}, false, true},
{"DuplicateVoteEvidence nil voteA", &DuplicateVoteEvidence{VoteA: nil, VoteB: v}, false, true},
{"DuplicateVoteEvidence success", &DuplicateVoteEvidence{VoteA: v2, VoteB: v}, false, false},
{"LunaticValidatorEvidence success", &LunaticValidatorEvidence{Header: header1,
Vote: v, InvalidHeaderField: "ValidatorsHash"}, false, true},
{"&LunaticValidatorEvidence empty fail", &LunaticValidatorEvidence{}, false, true},
{"LunaticValidatorEvidence only header fail", &LunaticValidatorEvidence{Header: header1}, false, true},
{"LunaticValidatorEvidence only vote fail", &LunaticValidatorEvidence{Vote: v}, false, true},
{"LunaticValidatorEvidence header & vote fail", &LunaticValidatorEvidence{Header: header1, Vote: v}, false, true},
{"LunaticValidatorEvidence empty fail", &LunaticValidatorEvidence{}, false, true},
{"PotentialAmnesiaEvidence empty fail", &PotentialAmnesiaEvidence{}, false, true},
{"PotentialAmnesiaEvidence nil VoteB", &PotentialAmnesiaEvidence{VoteA: v, VoteB: nil}, false, true},
{"PotentialAmnesiaEvidence nil VoteA", &PotentialAmnesiaEvidence{VoteA: nil, VoteB: v2}, false, true},


+ 0
- 3
types/protobuf.go View File

@ -16,7 +16,6 @@ import (
const (
ABCIEvidenceTypeDuplicateVote = "duplicate/vote"
ABCIEvidenceTypeLunatic = "lunatic"
ABCIEvidenceTypeAmnesia = "amnesia"
)
@ -130,8 +129,6 @@ func (tm2pb) Evidence(ev Evidence, valSet *ValidatorSet) abci.Evidence {
switch ev.(type) {
case *DuplicateVoteEvidence:
evType = ABCIEvidenceTypeDuplicateVote
case *LunaticValidatorEvidence:
evType = ABCIEvidenceTypeLunatic
case *AmnesiaEvidence:
evType = ABCIEvidenceTypeAmnesia
default:


Loading…
Cancel
Save