|
@ -43,15 +43,15 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error { |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
lightEvidenceCommonHeight := blockRes.Block.Height |
|
|
|
|
|
|
|
|
evidenceHeight := blockRes.Block.Height |
|
|
waitHeight := blockRes.Block.Height + 3 |
|
|
waitHeight := blockRes.Block.Height + 3 |
|
|
duplicateVoteHeight := waitHeight |
|
|
|
|
|
|
|
|
|
|
|
nValidators := 100 |
|
|
nValidators := 100 |
|
|
valRes, err := client.Validators(context.Background(), &lightEvidenceCommonHeight, nil, &nValidators) |
|
|
|
|
|
|
|
|
valRes, err := client.Validators(context.Background(), &evidenceHeight, nil, &nValidators) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
valSet, err := types.ValidatorSetFromExistingValidators(valRes.Validators) |
|
|
valSet, err := types.ValidatorSetFromExistingValidators(valRes.Validators) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
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
|
|
|
// wait for the node to reach the height above the forged height so that
|
|
|
// it is able to validate the evidence
|
|
|
// 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 { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
duplicateVoteTime := status.SyncInfo.LatestBlockTime |
|
|
|
|
|
|
|
|
|
|
|
var ev types.Evidence |
|
|
var ev types.Evidence |
|
|
for i := 1; i <= amount; i++ { |
|
|
for i := 1; i <= amount; i++ { |
|
|
if i%lightClientEvidenceRatio == 0 { |
|
|
if i%lightClientEvidenceRatio == 0 { |
|
|
ev, err = generateLightClientAttackEvidence( |
|
|
ev, err = generateLightClientAttackEvidence( |
|
|
privVals, lightEvidenceCommonHeight, valSet, testnet.Name, blockRes.Block.Time, |
|
|
|
|
|
|
|
|
privVals, evidenceHeight, valSet, testnet.Name, blockRes.Block.Time, |
|
|
) |
|
|
) |
|
|
} else { |
|
|
} else { |
|
|
ev, err = generateDuplicateVoteEvidence( |
|
|
ev, err = generateDuplicateVoteEvidence( |
|
|
privVals, duplicateVoteHeight, valSet, testnet.Name, duplicateVoteTime, |
|
|
|
|
|
|
|
|
privVals, evidenceHeight, valSet, testnet.Name, blockRes.Block.Time, |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
if err != nil { |
|
|
if err != nil { |
|
|