evidence: fix bug with hashes (#6375)

This commit is contained in:
Callum Waters
2021-04-21 18:50:39 +02:00
committed by GitHub
parent d36a5905a6
commit 5bafedff17
15 changed files with 430 additions and 370 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
# functionality with a single network.
disable_legacy_p2p = false
evidence = 0
evidence = 5
initial_height = 1000
initial_state = {initial01 = "a", initial02 = "b", initial03 = "c"}
queue_type = "priority"
@@ -57,7 +57,7 @@ seeds = ["seed01"]
persist_interval = 3
perturb = ["kill"]
privval_protocol = "grpc"
retain_blocks = 3
retain_blocks = 5
[node.validator04]
abci_protocol = "builtin"
@@ -82,7 +82,7 @@ start_at = 1010
fast_sync = "v0"
persistent_peers = ["validator01", "validator02", "validator03", "validator04", "validator05"]
perturb = ["restart"]
retain_blocks = 3
retain_blocks = 5
[node.full02]
mode = "full"
+1 -1
View File
@@ -48,7 +48,7 @@ const (
PerturbationPause Perturbation = "pause"
PerturbationRestart Perturbation = "restart"
EvidenceAgeHeight int64 = 3
EvidenceAgeHeight int64 = 5
EvidenceAgeTime time.Duration = 10 * time.Second
)
+3 -6
View File
@@ -19,11 +19,8 @@ import (
"github.com/tendermint/tendermint/version"
)
// 1 in 11 evidence is light client evidence, the rest is duplicate vote
// FIXME: Setting to 11 disables light client attack evidence since nodes
// don't follow a minimum retention height invariant. When we fix this we
// should use a ratio of 4.
const lightClientEvidenceRatio = 11
// 1 in 4 evidence is light client evidence, the rest is duplicate vote evidence
const lightClientEvidenceRatio = 4
// InjectEvidence takes a running testnet and generates an amount of valid
// evidence and broadcasts it to a random node through the rpc endpoint `/broadcast_evidence`.
@@ -74,7 +71,7 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error {
duplicateVoteTime := status.SyncInfo.LatestBlockTime
var ev types.Evidence
for i := 0; i < amount; i++ {
for i := 1; i <= amount; i++ {
if i%lightClientEvidenceRatio == 0 {
ev, err = generateLightClientAttackEvidence(
privVals, lightEvidenceCommonHeight, valSet, testnet.Name, blockRes.Block.Time,
+5 -1
View File
@@ -37,8 +37,12 @@ func TestBlock_Header(t *testing.T) {
}
resp, err := client.Block(ctx, &block.Header.Height)
require.NoError(t, err)
require.Equal(t, block, resp.Block,
"block mismatch for height %v", block.Header.Height)
"block mismatch for height %d", block.Header.Height)
require.NoError(t, resp.Block.ValidateBasic(),
"block at height %d is invalid", block.Header.Height)
}
})
}