Tweak validator logging (#5103)

* Tidy up logging
This commit is contained in:
Jim McDonald 2020-03-15 15:46:22 +00:00 committed by GitHub
parent 8143cc36bc
commit 8e6c16d416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -2,11 +2,13 @@ package client
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"time" "time"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1" pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params" "github.com/prysmaticlabs/prysm/shared/params"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
@ -69,9 +71,11 @@ func run(ctx context.Context, v Validator) {
return // Exit if context is canceled. return // Exit if context is canceled.
case slot := <-v.NextSlot(): case slot := <-v.NextSlot():
span.AddAttributes(trace.Int64Attribute("slot", int64(slot))) 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. // Report this validator client's rewards and penalties throughout its lifecycle.
log := log.WithField("slot", slot) log := log.WithField("slot", slot)
log.WithField("deadline", deadline).Debug("Set deadline for proposals and attestations")
if err := v.LogValidatorGainsAndLosses(slotCtx, slot); err != nil { if err := v.LogValidatorGainsAndLosses(slotCtx, slot); err != nil {
log.WithError(err).Error("Could not report validator's rewards/penalties") 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: case pb.ValidatorRole_AGGREGATOR:
go v.SubmitAggregateAndProof(slotCtx, slot, id) go v.SubmitAggregateAndProof(slotCtx, slot, id)
case pb.ValidatorRole_UNKNOWN: 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: default:
log.Warnf("Unhandled role %v", role) log.Warnf("Unhandled role %v", role)
} }

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" 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) sig, err := v.keyManager.Sign(pubKey, slotRoot, domain.SignatureDomain)
if err != nil { if err != nil {
return nil, err return nil, errors.Wrap(err, "Failed to sign slot")
} }
return sig.Marshal(), nil return sig.Marshal(), nil