mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
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:
parent
0f95b797af
commit
0704ba685a
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -24,7 +24,7 @@ var (
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
validatorAggFailVec = promauto.NewCounterVec(
|
||||
@ -34,7 +34,7 @@ var (
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ var (
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
validatorAttestFailVec = promauto.NewCounterVec(
|
||||
@ -40,7 +40,7 @@ var (
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ var validatorBalancesGaugeVec = promauto.NewGaugeVec(
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -29,7 +29,7 @@ var (
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
validatorProposeFailVec = promauto.NewCounterVec(
|
||||
@ -39,7 +39,7 @@ var (
|
||||
},
|
||||
[]string{
|
||||
// validator pubkey
|
||||
"pkey",
|
||||
"pubkey",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user