@@ -13,11 +13,11 @@ const DefaultHeightThreshold uint64 = 80000 // ~ 14 days of 15 second headers
13
13
// Verify verifies untrusted Header against trusted following general Header checks and
14
14
// custom user-specific checks defined in Header.Verify
15
15
//
16
- // If heightThreshold is zero, uses DefaultHeightThreshold.
16
+ // Given headers must be non-zero
17
17
// Always returns VerifyError.
18
- func Verify [H Header [H ]](trstd , untrstd H , heightThreshold uint64 ) error {
18
+ func Verify [H Header [H ]](trstd , untrstd H ) error {
19
19
// general mandatory verification
20
- err := verify [H ](trstd , untrstd , heightThreshold )
20
+ err := verify [H ](trstd , untrstd )
21
21
if err != nil {
22
22
return & VerifyError {Reason : err }
23
23
}
@@ -45,11 +45,10 @@ func Verify[H Header[H]](trstd, untrstd H, heightThreshold uint64) error {
45
45
46
46
// verify is a little bro of Verify yet performs mandatory Header checks
47
47
// for any Header implementation.
48
- func verify [H Header [H ]](trstd , untrstd H , heightThreshold uint64 ) error {
49
- if heightThreshold == 0 {
50
- heightThreshold = DefaultHeightThreshold
48
+ func verify [H Header [H ]](trstd , untrstd H ) error {
49
+ if trstd . IsZero () {
50
+ return ErrZeroHeader
51
51
}
52
-
53
52
if untrstd .IsZero () {
54
53
return ErrZeroHeader
55
54
}
@@ -71,24 +70,16 @@ func verify[H Header[H]](trstd, untrstd H, heightThreshold uint64) error {
71
70
if known {
72
71
return fmt .Errorf ("%w: '%d' <= current '%d'" , ErrKnownHeader , untrstd .Height (), trstd .Height ())
73
72
}
74
- // reject headers with height too far from the future
75
- // this is essential for headers failed non-adjacent verification
76
- // yet taken as sync target
77
- adequateHeight := untrstd .Height ()- trstd .Height () < heightThreshold
78
- if ! adequateHeight {
79
- return fmt .Errorf ("%w: '%d' - current '%d' >= threshold '%d'" , ErrHeightFromFuture , untrstd .Height (), trstd .Height (), heightThreshold )
80
- }
81
73
82
74
return nil
83
75
}
84
76
85
77
var (
86
- ErrZeroHeader = errors .New ("zero header" )
87
- ErrWrongChainID = errors .New ("wrong chain id" )
88
- ErrUnorderedTime = errors .New ("unordered headers" )
89
- ErrFromFuture = errors .New ("header is from the future" )
90
- ErrKnownHeader = errors .New ("known header" )
91
- ErrHeightFromFuture = errors .New ("header height is far from future" )
78
+ ErrZeroHeader = errors .New ("zero header" )
79
+ ErrWrongChainID = errors .New ("wrong chain id" )
80
+ ErrUnorderedTime = errors .New ("unordered headers" )
81
+ ErrFromFuture = errors .New ("header is from the future" )
82
+ ErrKnownHeader = errors .New ("known header" )
92
83
)
93
84
94
85
// VerifyError is thrown if a Header failed verification.
0 commit comments