mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
PendingAttestations: allow for request to specify a slot (#1922)
* PendingAttestations: allow for request to specify a slot * enhance the test
This commit is contained in:
parent
de22ef2bbd
commit
90225aac31
@ -75,10 +75,17 @@ func (ps *ProposerServer) PendingAttestations(ctx context.Context, req *pb.Pendi
|
||||
return nil, fmt.Errorf("could not retrieve pending attestations from operations service: %v", err)
|
||||
}
|
||||
|
||||
// Use the optional proposal block slot parameter as the current slot for
|
||||
// determining the validity window for attestations.
|
||||
currentSlot := req.ProposalBlockSlot
|
||||
if currentSlot == 0 {
|
||||
currentSlot = beaconState.Slot
|
||||
}
|
||||
|
||||
// Remove any attestation from the list if their slot is before the start of
|
||||
// the previous epoch. This should be handled in the operationService cleanup
|
||||
// method, but we should filter here in case it wasn't yet processed.
|
||||
boundary := beaconState.Slot - params.BeaconConfig().SlotsPerEpoch
|
||||
boundary := currentSlot - params.BeaconConfig().SlotsPerEpoch
|
||||
attsWithinBoundary := make([]*pbp2p.Attestation, 0, len(atts))
|
||||
for _, att := range atts {
|
||||
if att.Data.Slot > boundary {
|
||||
@ -90,7 +97,7 @@ func (ps *ProposerServer) PendingAttestations(ctx context.Context, req *pb.Pendi
|
||||
if req.FilterReadyForInclusion {
|
||||
var attsReadyForInclusion []*pbp2p.Attestation
|
||||
for _, val := range atts {
|
||||
if val.Data.Slot+params.BeaconConfig().MinAttestationInclusionDelay <= beaconState.Slot {
|
||||
if val.Data.Slot+params.BeaconConfig().MinAttestationInclusionDelay <= currentSlot {
|
||||
attsReadyForInclusion = append(attsReadyForInclusion, val)
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,12 @@ func TestPendingAttestations_FiltersExpiredAttestations(t *testing.T) {
|
||||
if err := db.SaveState(beaconState); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
res, err := proposerServer.PendingAttestations(context.Background(), &pb.PendingAttestationsRequest{})
|
||||
res, err := proposerServer.PendingAttestations(
|
||||
context.Background(),
|
||||
&pb.PendingAttestationsRequest{
|
||||
ProposalBlockSlot: currentSlot,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error fetching pending attestations: %v", err)
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ message AttestationDataResponse {
|
||||
|
||||
message PendingAttestationsRequest {
|
||||
bool filter_ready_for_inclusion = 1;
|
||||
uint64 proposal_block_slot = 2;
|
||||
}
|
||||
|
||||
message PendingAttestationsResponse {
|
||||
@ -146,4 +147,4 @@ enum ValidatorStatus {
|
||||
WITHDRAWABLE = 4;
|
||||
EXITED = 5;
|
||||
EXITED_SLASHED = 6;
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot uint64) {
|
||||
// Fetch pending attestations seen by the beacon node.
|
||||
attResp, err := v.proposerClient.PendingAttestations(ctx, &pb.PendingAttestationsRequest{
|
||||
FilterReadyForInclusion: true,
|
||||
ProposalBlockSlot: slot,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("Failed to fetch pending attestations from the beacon node: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user