evidence: introduction of LightClientAttackEvidence and refactor of evidence lifecycle (#5361)

evidence: modify evidence types (#5342)

light: detect light client attacks (#5344)

evidence: refactor evidence pool (#5345)

abci: application evidence prepared by evidence pool (#5354)
This commit is contained in:
Callum Waters
2020-09-22 10:22:54 +02:00
committed by GitHub
parent 309e29c245
commit ed002cea7e
57 changed files with 3240 additions and 1241 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/tendermint/tendermint/crypto/ed25519"
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
"github.com/tendermint/tendermint/crypto/tmhash"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/privval"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/rpc/client"
@@ -40,7 +41,7 @@ func newEvidence(t *testing.T, val *privval.FilePV,
vote2.Signature, err = val.Key.PrivKey.Sign(types.VoteSignBytes(chainID, v2))
require.NoError(t, err)
return types.NewDuplicateVoteEvidence(vote, vote2, defaultTestTime)
return types.NewDuplicateVoteEvidence(vote, vote2)
}
func makeEvidences(
@@ -56,7 +57,7 @@ func makeEvidences(
Type: tmproto.PrevoteType,
Timestamp: defaultTestTime,
BlockID: types.BlockID{
Hash: tmhash.Sum([]byte("blockhash")),
Hash: tmhash.Sum(tmrand.Bytes(tmhash.Size)),
PartSetHeader: types.PartSetHeader{
Total: 1000,
Hash: tmhash.Sum([]byte("partset")),
@@ -114,13 +115,10 @@ func TestBroadcastEvidence_DuplicateVoteEvidence(t *testing.T) {
pv = privval.LoadOrGenFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
)
correct, fakes := makeEvidences(t, pv, chainID)
for i, c := range GetClients() {
correct, fakes := makeEvidences(t, pv, chainID)
t.Logf("client %d", i)
t.Log(correct.Time())
result, err := c.BroadcastEvidence(correct)
require.NoError(t, err, "BroadcastEvidence(%s) failed", correct)
assert.Equal(t, correct.Hash(), result.Hash, "expected result hash to match evidence hash")