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>
This commit is contained in:
Ivan Martinez 2020-05-28 10:24:54 -04:00 committed by GitHub
parent e3180cf977
commit 7dd187c2ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -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
}

View File

@ -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")

View File

@ -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")
}

View File

@ -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 {