mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-18 22:14:35 +00:00
evidence: introduce time.Duration to evidence params (#4254)
* evidence: introduce time.Duration to evidence params - add time.duration to evidence - this pr is taking pr #2606 and updating it to use both time and height - closes #2565 Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * fix testing and genesis cfg in signer harness * remove debugging fmt * change maxageheight to maxagenumblocks, rename other things to block instead of height * further check of duration * check duration to not send peers outdated evidence * change some lines, onward and upward * refactor evidence package * add a changelog pending entry * make mockbadevidence have time and use it * add what could possibly be called a test case * remove mockbadevidence and mockgoodevidence in favor of mockevidence * add a comment for err that is returned * add a changelog for removal of good & bad evidence * add a test for adding evidence * fix test * add ev to types in testcase * Update evidence/pool_test.go Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * Update evidence/pool_test.go Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * fix tests * fix linting Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
This commit is contained in:
+13
-5
@@ -158,13 +158,21 @@ func validateBlock(evidencePool EvidencePool, stateDB dbm.DB, state State, block
|
||||
// - it is internally consistent
|
||||
// - it was properly signed by the alleged equivocator
|
||||
func VerifyEvidence(stateDB dbm.DB, state State, evidence types.Evidence) error {
|
||||
height := state.LastBlockHeight
|
||||
var (
|
||||
height = state.LastBlockHeight
|
||||
evidenceParams = state.ConsensusParams.Evidence
|
||||
)
|
||||
|
||||
evidenceAge := height - evidence.Height()
|
||||
maxAge := state.ConsensusParams.Evidence.MaxAge
|
||||
if evidenceAge > maxAge {
|
||||
ageNumBlocks := height - evidence.Height()
|
||||
if ageNumBlocks > evidenceParams.MaxAgeNumBlocks {
|
||||
return fmt.Errorf("evidence from height %d is too old. Min height is %d",
|
||||
evidence.Height(), height-maxAge)
|
||||
evidence.Height(), height-evidenceParams.MaxAgeNumBlocks)
|
||||
}
|
||||
|
||||
ageDuration := state.LastBlockTime.Sub(evidence.Time())
|
||||
if ageDuration > evidenceParams.MaxAgeDuration {
|
||||
return fmt.Errorf("evidence created at %v has expired. Evidence can not be older than: %v",
|
||||
evidence.Time(), state.LastBlockTime.Add(evidenceParams.MaxAgeDuration))
|
||||
}
|
||||
|
||||
valset, err := LoadValidators(stateDB, evidence.Height())
|
||||
|
||||
Reference in New Issue
Block a user