From 7dd187c2aec5e4219a10c1a380ab9f155fff2005 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Thu, 28 May 2020 10:24:54 -0400 Subject: [PATCH] Small fixes for slasher (#6021) * Small fixes for slasher * Remove useless log * Fix test Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- slasher/beaconclient/historical_data_retrieval.go | 6 +----- slasher/detection/listeners.go | 1 - slasher/detection/listeners_test.go | 1 - slasher/detection/service.go | 7 ++++++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/slasher/beaconclient/historical_data_retrieval.go b/slasher/beaconclient/historical_data_retrieval.go index 359ca7fda..a9fa2dfe9 100644 --- a/slasher/beaconclient/historical_data_retrieval.go +++ b/slasher/beaconclient/historical_data_retrieval.go @@ -3,7 +3,6 @@ package beaconclient import ( "context" - "github.com/pkg/errors" ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" @@ -36,7 +35,7 @@ func (bs *Service) RequestHistoricalAttestations( }) if err != nil { log.WithError(err).Errorf("could not request indexed attestations for epoch: %d", epoch) - continue + break } indexedAtts = append(indexedAtts, res.IndexedAttestations...) log.Infof( @@ -49,8 +48,5 @@ func (bs *Service) RequestHistoricalAttestations( break } } - if err := bs.slasherDB.SaveIndexedAttestations(ctx, indexedAtts); err != nil { - return nil, errors.Wrap(err, "could not save indexed attestations") - } return indexedAtts, nil } diff --git a/slasher/detection/listeners.go b/slasher/detection/listeners.go index 744c420e2..5638b2b36 100644 --- a/slasher/detection/listeners.go +++ b/slasher/detection/listeners.go @@ -26,7 +26,6 @@ func (ds *Service) detectIncomingBlocks(ctx context.Context, ch chan *ethpb.Sign for { select { case signedBlock := <-ch: - log.Debug("Running detection on block...") signedBlkHdr, err := blockutil.SignedBeaconBlockHeaderFromBlock(signedBlock) if err != nil { log.WithError(err).Error("Could not get block header from block") diff --git a/slasher/detection/listeners_test.go b/slasher/detection/listeners_test.go index 6b3a441ce..0929a3772 100644 --- a/slasher/detection/listeners_test.go +++ b/slasher/detection/listeners_test.go @@ -55,7 +55,6 @@ func TestService_DetectIncomingBlocks(t *testing.T) { blocksChan <- blk cancel() exitRoutine <- true - testutil.AssertLogsContain(t, hook, "Running detection on block") testutil.AssertLogsContain(t, hook, "Context canceled") } diff --git a/slasher/detection/service.go b/slasher/detection/service.go index e827a61cc..20ed82c4a 100644 --- a/slasher/detection/service.go +++ b/slasher/detection/service.go @@ -114,6 +114,7 @@ func (ds *Service) detectHistoricalChainData(ctx context.Context) { if latestStoredHead != nil { latestStoredEpoch = latestStoredHead.HeadEpoch } + log.Infof("Performing historical detection from epoch %d to %d", latestStoredEpoch, currentChainHead.HeadEpoch) // We retrieve historical chain data from the last persisted chain head in the // slasher DB up to the current beacon node's head epoch we retrieved via gRPC. @@ -124,7 +125,11 @@ func (ds *Service) detectHistoricalChainData(ctx context.Context) { indexedAtts, err := ds.beaconClient.RequestHistoricalAttestations(ctx, epoch) if err != nil { log.WithError(err).Errorf("Could not fetch attestations for epoch: %d", epoch) - break + continue + } + if err := ds.slasherDB.SaveIndexedAttestations(ctx, indexedAtts); err != nil { + log.WithError(err).Error("could not save indexed attestations") + continue } for _, att := range indexedAtts {