From 8e6c16d4165d326c883d68ed87d4e3019fef8330 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sun, 15 Mar 2020 15:46:22 +0000 Subject: [PATCH] Tweak validator logging (#5103) * Tidy up logging --- validator/client/runner.go | 8 ++++++-- validator/client/validator_aggregate.go | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/validator/client/runner.go b/validator/client/runner.go index c11a50f9c..b1bbe3257 100644 --- a/validator/client/runner.go +++ b/validator/client/runner.go @@ -2,11 +2,13 @@ package client import ( "context" + "fmt" "sync" "time" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" + "github.com/prysmaticlabs/prysm/shared/bytesutil" "github.com/prysmaticlabs/prysm/shared/params" "go.opencensus.io/trace" "google.golang.org/grpc/codes" @@ -69,9 +71,11 @@ func run(ctx context.Context, v Validator) { return // Exit if context is canceled. case slot := <-v.NextSlot(): span.AddAttributes(trace.Int64Attribute("slot", int64(slot))) - slotCtx, cancel := context.WithDeadline(ctx, v.SlotDeadline(slot)) + deadline := v.SlotDeadline(slot) + slotCtx, cancel := context.WithDeadline(ctx, deadline) // Report this validator client's rewards and penalties throughout its lifecycle. log := log.WithField("slot", slot) + log.WithField("deadline", deadline).Debug("Set deadline for proposals and attestations") if err := v.LogValidatorGainsAndLosses(slotCtx, slot); err != nil { log.WithError(err).Error("Could not report validator's rewards/penalties") } @@ -109,7 +113,7 @@ func run(ctx context.Context, v Validator) { case pb.ValidatorRole_AGGREGATOR: go v.SubmitAggregateAndProof(slotCtx, slot, id) case pb.ValidatorRole_UNKNOWN: - log.Debug("No active roles, doing nothing") + log.WithField("pubKey", fmt.Sprintf("%#x", bytesutil.Trunc(id[:]))).Trace("No active roles, doing nothing") default: log.Warnf("Unhandled role %v", role) } diff --git a/validator/client/validator_aggregate.go b/validator/client/validator_aggregate.go index 1e03548c9..db364eb07 100644 --- a/validator/client/validator_aggregate.go +++ b/validator/client/validator_aggregate.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" @@ -115,7 +116,7 @@ func (v *validator) signSlot(ctx context.Context, pubKey [48]byte, slot uint64) sig, err := v.keyManager.Sign(pubKey, slotRoot, domain.SignatureDomain) if err != nil { - return nil, err + return nil, errors.Wrap(err, "Failed to sign slot") } return sig.Marshal(), nil