Skip to content

Commit

Permalink
Fix ATX syncer hangs (#6137)
Browse files Browse the repository at this point in the history
## Motivation

The ATX syncer was observed to be hanging when a peer serves an invalid ATX. It counts only specific errors as failed requests, instead of every failed request and never reaches the configured requests limit.
  • Loading branch information
poszu committed Jul 15, 2024
1 parent 978d03c commit d79d86f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions syncer/atxsync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func DefaultConfig() Config {
return Config{
EpochInfoInterval: 4 * time.Hour,
AtxsBatch: 1000,
RequestsLimit: 20,
RequestsLimit: 10,
EpochInfoPeers: 2,
ProgressFraction: 0.1,
ProgressInterval: 20 * time.Minute,
Expand Down Expand Up @@ -314,10 +314,10 @@ func (s *Syncer) downloadAtxs(
if _, exists := state[types.ATXID(hash)]; !exists {
continue
}
if errors.Is(err, fetch.ErrExceedMaxRetries) {
state[types.ATXID(hash)]++
} else if errors.Is(err, pubsub.ErrValidationReject) {
if errors.Is(err, pubsub.ErrValidationReject) {
state[types.ATXID(hash)] = s.cfg.RequestsLimit
} else {
state[types.ATXID(hash)]++
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion syncer/atxsync/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestSyncer(t *testing.T) {
}
for _, bad := range bad.AtxIDs {
if bad == id {
berr.Add(bad.Hash32(), fmt.Errorf("%w: test", fetch.ErrExceedMaxRetries))
berr.Add(bad.Hash32(), fmt.Errorf("%w: test", errors.New("oh no failed")))
}
}
}
Expand Down

0 comments on commit d79d86f

Please sign in to comment.