Skip to content

Commit

Permalink
Merge branch 'historical-summaries' of github.com:prysmaticlabs/prysm…
Browse files Browse the repository at this point in the history
… into historical-summaries
  • Loading branch information
terencechain committed Jan 11, 2023
2 parents 782d500 + 77b00ab commit c0e35d3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
3 changes: 0 additions & 3 deletions beacon-chain/rpc/statefetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ func (p *StateProvider) StateBySlot(ctx context.Context, target types.Slot) (sta
if target > p.GenesisTimeFetcher.CurrentSlot() {
return nil, errors.New("requested slot is in the future")
}
if target > p.ChainInfoFetcher.HeadSlot() {
return nil, errors.New("requested slot number is higher than head slot number")
}

st, err := p.ReplayerBuilder.ReplayerForSlot(target).ReplayBlocks(ctx)
if err != nil {
Expand Down
15 changes: 10 additions & 5 deletions beacon-chain/rpc/statefetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,16 @@ func TestStateBySlot_FutureSlot(t *testing.T) {
}

func TestStateBySlot_AfterHeadSlot(t *testing.T) {
st, err := statenative.InitializeFromProtoPhase0(&ethpb.BeaconState{Slot: 100})
headSt, err := statenative.InitializeFromProtoPhase0(&ethpb.BeaconState{Slot: 100})
require.NoError(t, err)
slotSt, err := statenative.InitializeFromProtoPhase0(&ethpb.BeaconState{Slot: 101})
require.NoError(t, err)
currentSlot := types.Slot(102)
mock := &chainMock.ChainService{State: st, Slot: &currentSlot}
p := StateProvider{ChainInfoFetcher: mock, GenesisTimeFetcher: mock}
_, err = p.StateBySlot(context.Background(), 101)
assert.ErrorContains(t, "requested slot number is higher than head slot number", err)
mock := &chainMock.ChainService{State: headSt, Slot: &currentSlot}
mockReplayer := mockstategen.NewMockReplayerBuilder()
mockReplayer.SetMockStateForSlot(slotSt, 101)
p := StateProvider{ChainInfoFetcher: mock, GenesisTimeFetcher: mock, ReplayerBuilder: mockReplayer}
st, err := p.StateBySlot(context.Background(), 101)
require.NoError(t, err)
assert.Equal(t, types.Slot(101), st.Slot())
}
11 changes: 11 additions & 0 deletions validator/client/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ var (
"pubkey",
},
)
// ValidatorInSyncCommitteeGaugeVec used to track validator statuses by public key.
ValidatorInSyncCommitteeGaugeVec = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "validator",
Name: "in_sync_committee",
Help: "validator sync committee.New in Altair hardfork",
},
[]string{
"pubkey",
},
)
// ValidatorInactivityScoreGaugeVec used to track validator inactivity scores.
ValidatorInactivityScoreGaugeVec = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Expand Down
3 changes: 3 additions & 0 deletions validator/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,9 @@ func (v *validator) logDuties(slot types.Slot, duties []*ethpb.DutiesResponse_Du
ValidatorNextAttestationSlotGaugeVec.WithLabelValues(validatorNotTruncatedKey).Set(float64(duty.AttesterSlot))
}
}
if v.emitAccountMetrics && duty.IsSyncCommittee {
ValidatorInSyncCommitteeGaugeVec.WithLabelValues(validatorNotTruncatedKey).Set(float64(1))
}

for _, proposerSlot := range duty.ProposerSlots {
proposerIndex := proposerSlot - slotOffset
Expand Down

0 comments on commit c0e35d3

Please sign in to comment.