mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Properly Return Finalized Epoch in GetValidatorParticipation Archival Endpoint (#4091)
* properly handle retrieving archived finalized epochs * test passes for determining if epoch finalized * Merge branch 'master' into archive-finality * Merge refs/heads/master into archive-finality * Merge refs/heads/master into archive-finality * Merge refs/heads/master into archive-finality * Merge refs/heads/master into archive-finality * Merge refs/heads/master into archive-finality * Merge branch 'master' into archive-finality * prevent setup panic * Merge branch 'archive-finality' of github.com:prysmaticlabs/prysm into archive-finality * Merge refs/heads/master into archive-finality
This commit is contained in:
parent
7a9c297206
commit
feb1267fee
@ -371,7 +371,7 @@ func (bs *Server) GetValidatorParticipation(
|
||||
}
|
||||
return ðpb.ValidatorParticipationResponse{
|
||||
Epoch: requestedEpoch,
|
||||
Finalized: true,
|
||||
Finalized: requestedEpoch <= headState.FinalizedCheckpoint.Epoch,
|
||||
Participation: participation,
|
||||
}, nil
|
||||
} else if requestedEpoch > currentEpoch {
|
||||
|
@ -1134,11 +1134,11 @@ func TestServer_GetValidatorParticipation_FromArchive(t *testing.T) {
|
||||
bs := &Server{
|
||||
BeaconDB: db,
|
||||
HeadFetcher: &mock.ChainService{
|
||||
State: &pbp2p.BeaconState{Slot: helpers.StartSlot(epoch + 1)},
|
||||
},
|
||||
FinalizationFetcher: &mock.ChainService{
|
||||
FinalizedCheckPoint: ðpb.Checkpoint{
|
||||
Epoch: epoch + 1,
|
||||
State: &pbp2p.BeaconState{
|
||||
Slot: helpers.StartSlot(epoch + 1),
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{
|
||||
Epoch: epoch + 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1176,6 +1176,53 @@ func TestServer_GetValidatorParticipation_FromArchive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_GetValidatorParticipation_FromArchive_FinalizedEpoch(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
defer dbTest.TeardownDB(t, db)
|
||||
ctx := context.Background()
|
||||
part := ðpb.ValidatorParticipation{
|
||||
GlobalParticipationRate: 1.0,
|
||||
VotedEther: 20,
|
||||
EligibleEther: 20,
|
||||
}
|
||||
epoch := uint64(1)
|
||||
// We archive data for epoch 1.
|
||||
if err := db.SaveArchivedValidatorParticipation(ctx, epoch, part); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
bs := &Server{
|
||||
BeaconDB: db,
|
||||
HeadFetcher: &mock.ChainService{
|
||||
// 10 epochs into the future.
|
||||
State: &pbp2p.BeaconState{
|
||||
Slot: helpers.StartSlot(epoch + 10),
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{
|
||||
// We say there have been 5 epochs since finality.
|
||||
Epoch: epoch + 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
want := ðpb.ValidatorParticipationResponse{
|
||||
Epoch: epoch,
|
||||
Finalized: true,
|
||||
Participation: part,
|
||||
}
|
||||
// We request epoch 1.
|
||||
res, err := bs.GetValidatorParticipation(ctx, ðpb.GetValidatorParticipationRequest{
|
||||
QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{
|
||||
Epoch: epoch,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !proto.Equal(want, res) {
|
||||
t.Errorf("Wanted %v, received %v", want, res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServer_GetValidatorParticipation_CurrentEpoch(t *testing.T) {
|
||||
helpers.ClearAllCaches()
|
||||
db := dbTest.SetupDB(t)
|
||||
|
Loading…
Reference in New Issue
Block a user