Skip to content

Commit

Permalink
abci: update evidence (#5324)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Sep 2, 2020
1 parent c2ce5e6 commit c752e2e
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 206 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi

- Apps

- [abci] [\#5324](https://github.com/tendermint/tendermint/pull/5324) abci evidence type is an enum with two types of possible evidence (@cmwaters)

- P2P Protocol

- Go API
Expand Down
4 changes: 2 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ field allows ABCI applications to dictate which events should be indexed.
The blockchain can now start from an arbitrary initial height, provided to the
application via `RequestInitChain.InitialHeight`.

A new form of evidence: amnesia evidence, has been added. Potential amnesia and
mock evidence have been removed. Applications should be able to handle these
ABCI evidence type is now an enum with two recognised types of evidence:
`DUPLICATE_VOTE` and `LIGHT_CLIENT_ATTACK`. Applications should be able to handle these
evidence types.

### P2P Protocol
Expand Down
3 changes: 1 addition & 2 deletions abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/libs/log"
pc "github.com/tendermint/tendermint/proto/tendermint/crypto"
tmtypes "github.com/tendermint/tendermint/types"
)

const (
Expand Down Expand Up @@ -127,7 +126,7 @@ func (app *PersistentKVStoreApplication) BeginBlock(req types.RequestBeginBlock)

// Punish validators who committed equivocation.
for _, ev := range req.ByzantineValidators {
if ev.Type == tmtypes.ABCIEvidenceTypeDuplicateVote {
if ev.Type == types.EvidenceType_DUPLICATE_VOTE {
addr := string(ev.Validator.Address)
if pubKey, ok := app.valAddrToPubKeyMap[addr]; ok {
app.updateValidator(types.ValidatorUpdate{
Expand Down
405 changes: 211 additions & 194 deletions abci/types/types.pb.go

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion proto/tendermint/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,14 @@ message VoteInfo {
bool signed_last_block = 2;
}

enum EvidenceType {
UNKNOWN = 0;
DUPLICATE_VOTE = 1;
LIGHT_CLIENT_ATTACK = 2;
}

message Evidence {
string type = 1;
EvidenceType type = 1;
// The offending validator
Validator validator = 2 [(gogoproto.nullable) = false];
// The height when the offense occurred
Expand Down
8 changes: 2 additions & 6 deletions types/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
//-------------------------------------------------------
// Use strings to distinguish types in ABCI messages

const (
ABCIEvidenceTypeDuplicateVote = "duplicate/vote"
)

const (
ABCIPubKeyTypeEd25519 = "ed25519"
)
Expand Down Expand Up @@ -124,10 +120,10 @@ func (tm2pb) Evidence(ev Evidence, valSet *ValidatorSet) abci.Evidence {
}

// set type
var evType string
var evType abci.EvidenceType
switch ev.(type) {
case *DuplicateVoteEvidence:
evType = ABCIEvidenceTypeDuplicateVote
evType = abci.EvidenceType_DUPLICATE_VOTE
default:
panic(fmt.Sprintf("unknown evidence type: %v %v", ev, reflect.TypeOf(ev)))
}
Expand Down
2 changes: 1 addition & 1 deletion types/protobuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestABCIEvidence(t *testing.T) {
NewValidatorSet([]*Validator{NewValidator(pubKey, 10)}),
)

assert.Equal(t, ABCIEvidenceTypeDuplicateVote, abciEv.Type)
assert.Equal(t, abci.EvidenceType_DUPLICATE_VOTE, abciEv.Type)
assert.Equal(t, ev.Time(), abciEv.GetTime())
assert.Equal(t, ev.Address(), abciEv.Validator.GetAddress())
assert.Equal(t, ev.Height(), abciEv.GetHeight())
Expand Down

0 comments on commit c752e2e

Please sign in to comment.