Return statuses on duties (#5069)

* try to return somethign for everything
* default to unknown
* debug
* moar debug
* move else to outer check
* working
* reorder imports
* cleanup
* fix TestGetDuties_NextEpoch_CantFindValidatorIdx
* Merge branch 'master' into return-statuses-on-duties
* Update validator/client/validator.go
* Merge branch 'master' into return-statuses-on-duties
* Merge branch 'master' into return-statuses-on-duties
This commit is contained in:
tzapu 2020-03-12 21:07:37 +02:00 committed by GitHub
parent 0f95b797af
commit 0704ba685a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 8 deletions

View File

@ -64,8 +64,10 @@ func (vs *Server) GetDuties(ctx context.Context, req *ethpb.DutiesRequest) (*eth
assignment.ProposerSlot = proposerIndexToSlot[idx]
assignment.CommitteeIndex = ca.CommitteeIndex
}
} else {
vs := vs.validatorStatus(ctx, pubKey, s)
assignment.Status = vs.Status
}
validatorAssignments = append(validatorAssignments, assignment)
}

View File

@ -6,10 +6,13 @@ import (
"fmt"
"strings"
"testing"
"time"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
mockChain "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/cache/depositcache"
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
blk "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
@ -67,10 +70,19 @@ func TestGetDuties_NextEpoch_CantFindValidatorIdx(t *testing.T) {
t.Fatalf("Could not get signing root %v", err)
}
height := time.Unix(int64(params.BeaconConfig().Eth1FollowDistance), 0).Unix()
p := &mockPOW.POWChain{
TimesByHeight: map[int]uint64{
0: uint64(height),
},
}
vs := &Server{
BeaconDB: db,
HeadFetcher: &mockChain.ChainService{State: beaconState, Root: genesisRoot[:]},
SyncChecker: &mockSync.Sync{IsSyncing: false},
Eth1InfoFetcher: p,
DepositFetcher: depositcache.NewDepositCache(),
}
pubKey := pubKey(99999)

View File

@ -28,6 +28,8 @@ import (
"github.com/prysmaticlabs/prysm/validator/keymanager"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type validator struct {
@ -49,6 +51,18 @@ type validator struct {
domainDataCache *ristretto.Cache
}
var validatorStatusesGaugeVec = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "validator",
Name: "statuses",
Help: "validator statuses: 0 UNKNOWN, 1 DEPOSITED, 2 PENDING, 3 ACTIVE, 4 EXITING, 5 SLASHING, 6 EXITED",
},
[]string{
// Validator pubkey.
"pubkey",
},
)
// Done cleans up the validator.
func (v *validator) Done() {
v.ticker.Done()
@ -175,6 +189,10 @@ func (v *validator) checkAndLogValidatorStatus(validatorStatuses []*ethpb.Valida
"pubKey": fmt.Sprintf("%#x", bytesutil.Trunc(status.PublicKey[:])),
"status": status.Status.Status.String(),
})
if v.emitAccountMetrics {
fmtKey := fmt.Sprintf("%#x", status.PublicKey[:])
validatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(status.Status.Status))
}
if status.Status.Status == ethpb.ValidatorStatus_ACTIVE {
activatedKeys = append(activatedKeys, status.PublicKey)
continue
@ -269,6 +287,11 @@ func (v *validator) UpdateDuties(ctx context.Context, slot uint64) error {
"status": duty.Status,
}
if v.emitAccountMetrics {
fmtKey := fmt.Sprintf("%#x", duty.PublicKey[:])
validatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(duty.Status))
}
if duty.Status == ethpb.ValidatorStatus_ACTIVE {
if duty.ProposerSlot > 0 {
lFields["proposerSlot"] = duty.ProposerSlot

View File

@ -24,7 +24,7 @@ var (
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)
validatorAggFailVec = promauto.NewCounterVec(
@ -34,7 +34,7 @@ var (
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)
)

View File

@ -30,7 +30,7 @@ var (
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)
validatorAttestFailVec = promauto.NewCounterVec(
@ -40,7 +40,7 @@ var (
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)
)

View File

@ -20,7 +20,7 @@ var validatorBalancesGaugeVec = promauto.NewGaugeVec(
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)

View File

@ -29,7 +29,7 @@ var (
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)
validatorProposeFailVec = promauto.NewCounterVec(
@ -39,7 +39,7 @@ var (
},
[]string{
// validator pubkey
"pkey",
"pubkey",
},
)
)