From 36a859ae545d178756e7ca25582e79ac4526f328 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 13 Jul 2021 19:47:36 +0200 Subject: [PATCH] e2e: ensure evidence validator set matches nodes validator set (#6712) --- test/e2e/networks/ci.toml | 4 ++-- test/e2e/pkg/testnet.go | 2 +- test/e2e/runner/evidence.go | 13 ++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/e2e/networks/ci.toml b/test/e2e/networks/ci.toml index 62a2dad3a..afce3a2db 100644 --- a/test/e2e/networks/ci.toml +++ b/test/e2e/networks/ci.toml @@ -56,7 +56,7 @@ abci_protocol = "grpc" persist_interval = 3 perturb = ["kill"] privval_protocol = "grpc" -retain_blocks = 5 +retain_blocks = 7 [node.validator04] abci_protocol = "builtin" @@ -80,7 +80,7 @@ start_at = 1010 fast_sync = "v0" persistent_peers = ["validator01", "validator02", "validator03", "validator04", "validator05"] perturb = ["restart"] -retain_blocks = 5 +retain_blocks = 7 [node.full02] mode = "full" diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 1cbe919c5..ac22631f5 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -48,7 +48,7 @@ const ( PerturbationPause Perturbation = "pause" PerturbationRestart Perturbation = "restart" - EvidenceAgeHeight int64 = 5 + EvidenceAgeHeight int64 = 7 EvidenceAgeTime time.Duration = 500 * time.Millisecond ) diff --git a/test/e2e/runner/evidence.go b/test/e2e/runner/evidence.go index a1a77b9f0..7868d9174 100644 --- a/test/e2e/runner/evidence.go +++ b/test/e2e/runner/evidence.go @@ -43,15 +43,15 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error { if err != nil { return err } - lightEvidenceCommonHeight := blockRes.Block.Height + evidenceHeight := blockRes.Block.Height waitHeight := blockRes.Block.Height + 3 - duplicateVoteHeight := waitHeight nValidators := 100 - valRes, err := client.Validators(context.Background(), &lightEvidenceCommonHeight, nil, &nValidators) + valRes, err := client.Validators(context.Background(), &evidenceHeight, nil, &nValidators) if err != nil { return err } + valSet, err := types.ValidatorSetFromExistingValidators(valRes.Validators) if err != nil { return err @@ -65,21 +65,20 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error { // wait for the node to reach the height above the forged height so that // it is able to validate the evidence - status, err := waitForNode(targetNode, waitHeight, 30*time.Second) + _, err = waitForNode(targetNode, waitHeight, 30*time.Second) if err != nil { return err } - duplicateVoteTime := status.SyncInfo.LatestBlockTime var ev types.Evidence for i := 1; i <= amount; i++ { if i%lightClientEvidenceRatio == 0 { ev, err = generateLightClientAttackEvidence( - privVals, lightEvidenceCommonHeight, valSet, testnet.Name, blockRes.Block.Time, + privVals, evidenceHeight, valSet, testnet.Name, blockRes.Block.Time, ) } else { ev, err = generateDuplicateVoteEvidence( - privVals, duplicateVoteHeight, valSet, testnet.Name, duplicateVoteTime, + privVals, evidenceHeight, valSet, testnet.Name, blockRes.Block.Time, ) } if err != nil {