Skip to content

Commit

Permalink
add VotingPower to abci.Evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
torao committed Aug 26, 2021
1 parent 92e2b95 commit d07066e
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 212 deletions.
386 changes: 212 additions & 174 deletions abci/types/types.pb.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions evidence/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func TestEvidencePoolBasic(t *testing.T) {
var evidenceBytes int64
switch keyType := voterSet.Voters[0].PubKey.(type) {
case ed25519.PubKey:
evidenceBytes = 372
evidenceBytes = 375
case bls.PubKey:
evidenceBytes = 436
evidenceBytes = 439
case composite.PubKey:
evidenceBytes = 436
evidenceBytes = 439
default:
assert.Fail(t, fmt.Sprintf("unknown public key: %s", keyType))
}
Expand Down
3 changes: 3 additions & 0 deletions proto/ostracon/abci/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ message Evidence {
// not store historical validators.
// https://github.com/tendermint/tendermint/issues/4581
int64 total_voting_power = 5;

// *** Ostracon Extended Fields ***
int64 voting_power = 1000;
}

//----------------------------------------
Expand Down
109 changes: 74 additions & 35 deletions proto/ostracon/types/evidence.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions proto/ostracon/types/evidence.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ message DuplicateVoteEvidence {
int64 total_voting_power = 3;
int64 validator_power = 4;
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];

// *** Ostracon Extended Fields ***
int64 voting_power = 1000;
}

// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client.
Expand Down
2 changes: 2 additions & 0 deletions state/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
Time: defaultEvidenceTime,
Validator: types.TM2PB.Validator(state.Validators.Validators[0]),
TotalVotingPower: 10,
VotingPower: 10,
},
{
Type: abci.EvidenceType_LIGHT_CLIENT_ATTACK,
Height: 8,
Time: defaultEvidenceTime,
Validator: types.TM2PB.Validator(state.Validators.Validators[0]),
TotalVotingPower: 12,
VotingPower: 0,
},
}

Expand Down
6 changes: 6 additions & 0 deletions types/evidence.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type DuplicateVoteEvidence struct {

// abci specific information
TotalVotingPower int64
VotingPower int64
ValidatorPower int64
Timestamp time.Time
}
Expand Down Expand Up @@ -83,6 +84,7 @@ func NewDuplicateVoteEvidence(vote1, vote2 *Vote, blockTime time.Time, voterSet
VoteA: voteA,
VoteB: voteB,
TotalVotingPower: voterSet.TotalVotingPower(),
VotingPower: val.VotingPower,
ValidatorPower: val.StakingPower,
Timestamp: blockTime,
}
Expand All @@ -99,6 +101,7 @@ func (dve *DuplicateVoteEvidence) ABCI() []abci.Evidence {
Height: dve.VoteA.Height,
Time: dve.Timestamp,
TotalVotingPower: dve.TotalVotingPower,
VotingPower: dve.VotingPower,
}}
}

Expand Down Expand Up @@ -163,6 +166,7 @@ func (dve *DuplicateVoteEvidence) ToProto() *tmproto.DuplicateVoteEvidence {
VoteA: voteA,
VoteB: voteB,
TotalVotingPower: dve.TotalVotingPower,
VotingPower: dve.VotingPower,
ValidatorPower: dve.ValidatorPower,
Timestamp: dve.Timestamp,
}
Expand All @@ -189,6 +193,7 @@ func DuplicateVoteEvidenceFromProto(pb *tmproto.DuplicateVoteEvidence) (*Duplica
VoteA: vA,
VoteB: vB,
TotalVotingPower: pb.TotalVotingPower,
VotingPower: pb.VotingPower,
ValidatorPower: pb.ValidatorPower,
Timestamp: pb.Timestamp,
}
Expand Down Expand Up @@ -229,6 +234,7 @@ func (l *LightClientAttackEvidence) ABCI() []abci.Evidence {
Height: l.Height(),
Time: l.Timestamp,
TotalVotingPower: l.TotalVotingPower,
VotingPower: 0,
}
}
return abciEv
Expand Down

0 comments on commit d07066e

Please sign in to comment.