Slasher lag fix (#5124)

* Slasher fixes

* fix
This commit is contained in:
Ivan Martinez 2020-03-17 17:53:08 -04:00 committed by GitHub
parent 431762164e
commit 1be8b3aa5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -79,7 +79,7 @@ func (bs *Service) collectReceivedAttestations(ctx context.Context) {
defer span.End()
var atts []*ethpb.IndexedAttestation
ticker := time.NewTicker(2 * time.Second)
ticker := time.NewTicker(500 * time.Millisecond)
for {
select {
case <-ticker.C:

View File

@ -59,7 +59,7 @@ func (ds *Service) detectIncomingAttestations(ctx context.Context, ch chan *ethp
log.WithError(err).Error("Could not update spans")
}
}
ds.submitAttesterSlashings(ctx, slashings, indexedAtt.Data.Target.Epoch)
ds.submitAttesterSlashings(ctx, slashings)
case <-sub.Err():
log.Error("Subscriber closed, exiting goroutine")
return

View File

@ -130,7 +130,7 @@ func (ds *Service) detectHistoricalChainData(ctx context.Context) {
log.WithError(err).Error("Could not detect attester slashings")
continue
}
ds.submitAttesterSlashings(ctx, slashings, att.Data.Target.Epoch)
ds.submitAttesterSlashings(ctx, slashings)
}
}
@ -140,7 +140,7 @@ func (ds *Service) detectHistoricalChainData(ctx context.Context) {
log.Infof("Completed slashing detection on historical chain data up to epoch %d", currentChainHead.HeadEpoch)
}
func (ds *Service) submitAttesterSlashings(ctx context.Context, slashings []*ethpb.AttesterSlashing, epoch uint64) {
func (ds *Service) submitAttesterSlashings(ctx context.Context, slashings []*ethpb.AttesterSlashing) {
ctx, span := trace.StartSpan(ctx, "detection.submitAttesterSlashings")
defer span.End()
for i := 0; i < len(slashings); i++ {
@ -148,9 +148,11 @@ func (ds *Service) submitAttesterSlashings(ctx context.Context, slashings []*eth
if slash != nil && slash.Attestation_1 != nil && slash.Attestation_2 != nil {
slashableIndices := sliceutil.IntersectionUint64(slashings[i].Attestation_1.AttestingIndices, slashings[i].Attestation_2.AttestingIndices)
log.WithFields(logrus.Fields{
"targetEpoch": epoch,
"indices": slashableIndices,
}).Infof("Found %d attester slashings! Submitting to beacon node", len(slashings))
"sourceEpoch": slash.Attestation_1.Data.Source.Epoch,
"targetEpoch": slash.Attestation_1.Data.Target.Epoch,
"surroundVote": isSurrounding(slash.Attestation_1, slash.Attestation_2),
"indices": slashableIndices,
}).Info("Found an attester slashing! Submitting to beacon node")
ds.attesterSlashingsFeed.Send(slashings[i])
}
}