From 268505c56e6ab91a09e5747cb1aec8e1e981471a Mon Sep 17 00:00:00 2001 From: Manu NALEPA Date: Wed, 2 Oct 2024 10:11:26 +0200 Subject: [PATCH 1/2] `retrieveMissingDataColumnsFromPeers`: Search only for needed peers. --- beacon-chain/sync/initial-sync/blocks_fetcher.go | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index abfb6090b6d6..96835cbbdaed 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -1061,6 +1061,7 @@ func (f *blocksFetcher) retrieveMissingDataColumnsFromPeers( // Reduce blocks count until the total number of elements is less than the batch size. for missingDataColumnsCount*blocksCount > batchSize { blocksCount /= 2 + lastSlot = firstSlot + primitives.Slot(blocksCount-1) } // If no peer is specified, get all connected peers. From ed9f1ced2997ec60d0659adfe8da48152c679712 Mon Sep 17 00:00:00 2001 From: Manu NALEPA Date: Wed, 2 Oct 2024 10:48:03 +0200 Subject: [PATCH 2/2] Improve logging. --- .../sync/initial-sync/blocks_fetcher.go | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index 96835cbbdaed..66bfda83e429 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -1104,7 +1104,7 @@ func (f *blocksFetcher) retrieveMissingDataColumnsFromPeers( blockFromRoot := blockFromRoot(bwb[firstIndex : lastIndex+1]) // Iterate requests over all peers, and exits as soon as at least one data column is retrieved. - roDataColumns, _, err := f.requestDataColumnsFromPeers(ctx, request, filteredPeers) + roDataColumns, peer, err := f.requestDataColumnsFromPeers(ctx, request, filteredPeers) if err != nil { return errors.Wrap(err, "request data columns from peers") } @@ -1127,6 +1127,36 @@ func (f *blocksFetcher) retrieveMissingDataColumnsFromPeers( // Process the retrieved data columns. processRetrievedDataColumns(roDataColumns, blockFromRoot, indicesFromRoot, missingColumnsFromRoot, bwb, f.cv) + + // Log missing columns after request. + if len(missingColumnsFromRoot) > 0 { + for root, missingColumns := range missingColumnsFromRoot { + slot := blockFromRoot[root].Block().Slot() + + // It's normal to have missing columns for slots higher than the last requested slot. + // Skip logging those. + if slot > lastSlot { + continue + } + + missingColumnsCount := uint64(len(missingColumns)) + var missingColumnsLog interface{} = "all" + + if missingColumnsCount < numberOfColumns { + missingColumnsLog = sortedSliceFromMap(missingColumns) + } + + log.WithFields(logrus.Fields{ + "peer": peer, + "root": fmt.Sprintf("%#x", root), + "slot": slot, + "missingColumns": missingColumnsLog, + "requestedColumns": requestedColumnsLog, + "requestedStart": startSlot, + "requestedCount": blocksCount, + }).Debug("Peer did not return all requested data columns") + } + } } log.WithField("duration", time.Since(start)).Debug("Retrieving missing data columns from peers - success")