Skip to content

Commit

Permalink
add small buffer for header from future accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Aug 24, 2023
1 parent 8db8d54 commit 84b76c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sync/sync_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func (s *Syncer[H]) verify(ctx context.Context, newHead H) (bool, error) {

var heightThreshold int64
if s.Params.TrustingPeriod != 0 && s.Params.blockTime != 0 {
heightThreshold = int64(s.Params.TrustingPeriod / s.Params.blockTime)
buffer := time.Hour * 6 / s.Params.blockTime // small buffer to account for network delays
heightThreshold = int64(s.Params.TrustingPeriod / s.Params.blockTime + buffer)
}

err = header.Verify(sbjHead, newHead, heightThreshold)
Expand Down
2 changes: 1 addition & 1 deletion verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// DefaultHeightThreshold defines default height threshold beyond which headers are rejected
// NOTE: Compared against subjective head which is guaranteed to be non-expired
const DefaultHeightThreshold int64 = 40000 // ~ 7 days of 15 second headers
const DefaultHeightThreshold int64 = 80000 // ~ 14 days of 15 second headers

// Verify verifies untrusted Header against trusted following general Header checks and
// custom user-specific checks defined in Header.Verify
Expand Down

0 comments on commit 84b76c3

Please sign in to comment.