mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 20:50:05 +00:00
GetValidatorPerformance
return Unavailable
when syncing (#5795)
This commit is contained in:
parent
e53452a437
commit
c000509bdb
@ -38,6 +38,7 @@ go_library(
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//beacon-chain/sync:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/beacon/rpc/v1:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
@ -97,6 +98,7 @@ go_test(
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stategen:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//beacon-chain/sync/initial-sync/testing:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//proto/beacon/rpc/v1:go_default_library",
|
||||
"//shared/attestationutil:go_default_library",
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/powchain"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
)
|
||||
|
||||
@ -46,4 +47,5 @@ type Server struct {
|
||||
ReceivedAttestationsBuffer chan *ethpb.Attestation
|
||||
CollectedAttestationsBuffer chan []*ethpb.Attestation
|
||||
StateGen *stategen.State
|
||||
SyncChecker sync.Checker
|
||||
}
|
||||
|
@ -932,6 +932,10 @@ func (bs *Server) GetValidatorQueue(
|
||||
func (bs *Server) GetValidatorPerformance(
|
||||
ctx context.Context, req *ethpb.ValidatorPerformanceRequest,
|
||||
) (*ethpb.ValidatorPerformanceResponse, error) {
|
||||
if bs.SyncChecker.Syncing() {
|
||||
return nil, status.Errorf(codes.Unavailable, "Syncing to latest head, not ready to respond")
|
||||
}
|
||||
|
||||
validatorSummary := state.ValidatorSummary
|
||||
|
||||
reqPubKeysCount := len(req.PublicKeys)
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
|
||||
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
|
||||
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
@ -1863,6 +1864,19 @@ func TestServer_GetValidatorParticipation_FromArchive_FinalizedEpoch(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetValidatorPerformance_Syncing(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
bs := &Server{
|
||||
SyncChecker: &mockSync.Sync{IsSyncing: true},
|
||||
}
|
||||
|
||||
wanted := "Syncing to latest head, not ready to respond"
|
||||
if _, err := bs.GetValidatorPerformance(ctx, nil); err == nil || !strings.Contains(err.Error(), wanted) {
|
||||
t.Error("Did not receive wanted error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetValidatorPerformance_OK(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
epoch := uint64(1)
|
||||
@ -1932,6 +1946,7 @@ func TestGetValidatorPerformance_OK(t *testing.T) {
|
||||
// 10 epochs into the future.
|
||||
State: headState,
|
||||
},
|
||||
SyncChecker: &mockSync.Sync{IsSyncing: false},
|
||||
}
|
||||
want := ðpb.ValidatorPerformanceResponse{
|
||||
CurrentEffectiveBalances: []uint64{params.BeaconConfig().MaxEffectiveBalance, params.BeaconConfig().MaxEffectiveBalance},
|
||||
|
@ -269,6 +269,7 @@ func (s *Service) Start() {
|
||||
AttestationNotifier: s.operationNotifier,
|
||||
Broadcaster: s.p2p,
|
||||
StateGen: s.stateGen,
|
||||
SyncChecker: s.syncService,
|
||||
ReceivedAttestationsBuffer: make(chan *ethpb.Attestation, 100),
|
||||
CollectedAttestationsBuffer: make(chan []*ethpb.Attestation, 100),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user