mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 15:31:20 +00:00
Beacon api: get duties prune payload id cache (#11568)
* Beacon api: get duties prune payload id cache * Fix complains and bad test Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
c24016f006
commit
968dc5d1e8
@ -183,6 +183,12 @@ func (vs *Server) GetProposerDuties(ctx context.Context, req *ethpbv1.ProposerDu
|
||||
return nil, status.Errorf(codes.Internal, "Could not get dependent root: %v", err)
|
||||
}
|
||||
|
||||
slot, err := slots.EpochStart(req.Epoch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vs.ProposerSlotIndexCache.PrunePayloadIDs(slot)
|
||||
|
||||
return ðpbv1.ProposerDutiesResponse{
|
||||
DependentRoot: root,
|
||||
Data: duties,
|
||||
@ -673,7 +679,7 @@ func (vs *Server) ProduceAttestationData(ctx context.Context, req *ethpbv1.Produ
|
||||
|
||||
// GetAggregateAttestation aggregates all attestations matching the given attestation data root and slot, returning the aggregated result.
|
||||
func (vs *Server) GetAggregateAttestation(ctx context.Context, req *ethpbv1.AggregateAttestationRequest) (*ethpbv1.AggregateAttestationResponse, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "validator.GetAggregateAttestation")
|
||||
_, span := trace.StartSpan(ctx, "validator.GetAggregateAttestation")
|
||||
defer span.End()
|
||||
|
||||
allAtts := vs.AttestationsPool.AggregatedAttestations()
|
||||
|
@ -322,6 +322,28 @@ func TestGetProposerDuties(t *testing.T) {
|
||||
assert.DeepEqual(t, pubKeys[9982], expectedDuty.Pubkey)
|
||||
})
|
||||
|
||||
t.Run("Prune payload ID cache ok", func(t *testing.T) {
|
||||
req := ðpbv1.ProposerDutiesRequest{
|
||||
Epoch: 1,
|
||||
}
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(1, 1, [8]byte{1}, [32]byte{2})
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(31, 2, [8]byte{2}, [32]byte{3})
|
||||
vs.ProposerSlotIndexCache.SetProposerAndPayloadIDs(32, 4309, [8]byte{3}, [32]byte{4})
|
||||
|
||||
_, err := vs.GetProposerDuties(ctx, req)
|
||||
require.NoError(t, err)
|
||||
|
||||
vid, _, has := vs.ProposerSlotIndexCache.GetProposerPayloadIDs(1, [32]byte{})
|
||||
require.Equal(t, false, has)
|
||||
require.Equal(t, types.ValidatorIndex(0), vid)
|
||||
vid, _, has = vs.ProposerSlotIndexCache.GetProposerPayloadIDs(2, [32]byte{})
|
||||
require.Equal(t, false, has)
|
||||
require.Equal(t, types.ValidatorIndex(0), vid)
|
||||
vid, _, has = vs.ProposerSlotIndexCache.GetProposerPayloadIDs(32, [32]byte{})
|
||||
require.Equal(t, true, has)
|
||||
require.Equal(t, types.ValidatorIndex(4309), vid)
|
||||
})
|
||||
|
||||
t.Run("Require slot processing", func(t *testing.T) {
|
||||
// We create local variables to not interfere with other tests.
|
||||
// Slot processing might have unexpected side-effects.
|
||||
|
Loading…
Reference in New Issue
Block a user