Skip to content

Commit

Permalink
recreate peer selector in fetchRound
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Nov 3, 2023
1 parent 8f9addc commit f70f0aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 9 additions & 1 deletion catchup/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,15 @@ func (s *Service) fetchRound(cert agreement.Certificate, verifier *agreement.Asy
// None, there is no exit condition on too many retries as per the function contract.
if count, ok := peerErrors[peer]; ok {
if count > errNoBlockForRoundThreshold {
time.Sleep(100 * time.Millisecond)
time.Sleep(50 * time.Millisecond)

Check warning on line 741 in catchup/service.go

View check run for this annotation

Codecov / codecov/patch

catchup/service.go#L739-L741

Added lines #L739 - L741 were not covered by tests
}
if count > errNoBlockForRoundThreshold*10 {

Check warning on line 743 in catchup/service.go

View check run for this annotation

Codecov / codecov/patch

catchup/service.go#L743

Added line #L743 was not covered by tests
// for the low number of connected peers (like 2) the following scenatio is possible:
// - both peers do not have the block
// - peer selector punishes one of the peers more than the other
// - the punoshed peer gets the block, and the less punished peer stucks.
// It this case reset the peer selector to let it re-learn priorities.
peerSelector = createPeerSelector(s.net, s.cfg, false)

Check warning on line 749 in catchup/service.go

View check run for this annotation

Codecov / codecov/patch

catchup/service.go#L749

Added line #L749 was not covered by tests
}
}
peerErrors[peer]++

Check warning on line 752 in catchup/service.go

View check run for this annotation

Codecov / codecov/patch

catchup/service.go#L752

Added line #L752 was not covered by tests
Expand Down
3 changes: 0 additions & 3 deletions catchup/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ func TestServiceFetchBlocksMultiBlocks(t *testing.T) {
}
addBlocks(t, remote, blk, int(numberOfBlocks)-1)

logging.Base().SetLevel(logging.Debug)

// Create a network and block service
blockServiceConfig := config.GetDefaultLocal()
net := &httpTestPeerSource{}
Expand Down Expand Up @@ -531,7 +529,6 @@ func TestServiceFetchBlocksMultiBlocks(t *testing.T) {
localBlock, err := local.Block(i)
require.NoError(t, err)
require.Equal(t, *blk, localBlock)
return
}
}

Expand Down

0 comments on commit f70f0aa

Please sign in to comment.