Validator: add a DEBUG log to show batch attestation save duration (#8432)

* Add a debug log to show duration

* Autofix issues in 1 file

Resolved issues in validator/db/kv/attester_protection.go via DeepSource Autofix

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
Preston Van Loon 2021-02-11 12:27:35 -06:00 committed by GitHub
parent 2fd2bafdfa
commit d551c8e1d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import (
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prysmaticlabs/eth2-types" types "github.com/prysmaticlabs/eth2-types"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/slashutil" "github.com/prysmaticlabs/prysm/shared/slashutil"
@ -259,10 +259,11 @@ func (s *Store) batchAttestationWrites(ctx context.Context) {
// This function notifies all subscribers for flushed attestations // This function notifies all subscribers for flushed attestations
// of the result of the save operation. // of the result of the save operation.
func (s *Store) flushAttestationRecords(ctx context.Context) { func (s *Store) flushAttestationRecords(ctx context.Context) {
start := time.Now()
err := s.saveAttestationRecords(ctx, s.batchedAttestations) err := s.saveAttestationRecords(ctx, s.batchedAttestations)
// If there was no error, we reset the batched attestations slice. // If there was no error, we reset the batched attestations slice.
if err == nil { if err == nil {
log.Debug("Successfully flushed batched attestations to DB") log.WithField("duration", time.Since(start)).Debug("Successfully flushed batched attestations to DB")
s.batchedAttestations = make([]*AttestationRecord, 0, attestationBatchCapacity) s.batchedAttestations = make([]*AttestationRecord, 0, attestationBatchCapacity)
} }
// Forward the error, if any, to all subscribers via an event feed. // Forward the error, if any, to all subscribers via an event feed.