From fbdb6eeea655068544cbcc5123c9c1ae7e7d9761 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 10 Dec 2021 09:06:55 -0500 Subject: [PATCH 1/2] enumerate conditions that might cause this fetchAndWrite to return false --- catchup/service.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/catchup/service.go b/catchup/service.go index de4a52a94f..9cd08c6c42 100644 --- a/catchup/service.go +++ b/catchup/service.go @@ -195,7 +195,11 @@ func (s *Service) innerFetch(r basics.Round, peer network.Peer) (blk *bookkeepin } // fetchAndWrite fetches a block, checks the cert, and writes it to the ledger. Cert checking and ledger writing both wait for the ledger to advance if necessary. -// Returns false if we couldn't fetch or write (i.e., if we failed even after a given number of retries or if we were told to abort.) +// Returns false if we should stop trying to catch up. This may occur for several reasons: +// - If the context is canceled (e.g. if the node is shutting down) +// - If we couldn't fetch the block (e.g. if there are no peers available or we've reached the catchupRetryLimit) +// - If the block is already in the ledger (e.g. if agreement service has already written it) +// - If there is an issue validating the block (e.g. if we receive a malformed block) func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool, lookbackComplete chan bool, peerSelector *peerSelector) bool { i := 0 hasLookback := false From ba27634ed5e84ecaa643d863f108d752a1699ea6 Mon Sep 17 00:00:00 2001 From: Ben Guidarelli Date: Fri, 10 Dec 2021 11:26:05 -0500 Subject: [PATCH 2/2] replacing incorrect comment --- catchup/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catchup/service.go b/catchup/service.go index 9cd08c6c42..ff3df36095 100644 --- a/catchup/service.go +++ b/catchup/service.go @@ -199,7 +199,7 @@ func (s *Service) innerFetch(r basics.Round, peer network.Peer) (blk *bookkeepin // - If the context is canceled (e.g. if the node is shutting down) // - If we couldn't fetch the block (e.g. if there are no peers available or we've reached the catchupRetryLimit) // - If the block is already in the ledger (e.g. if agreement service has already written it) -// - If there is an issue validating the block (e.g. if we receive a malformed block) +// - If the retrieval of the previous block was unsuccessful func (s *Service) fetchAndWrite(r basics.Round, prevFetchCompleteChan chan bool, lookbackComplete chan bool, peerSelector *peerSelector) bool { i := 0 hasLookback := false