mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Blocks filtering should return genesis when startSlot=0 and endSlot=0 (#8270)
Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
parent
b6c4bc197f
commit
d7d2c6354b
@ -442,6 +442,11 @@ func fetchBlockRootsBySlotRange(
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.fetchBlockRootsBySlotRange")
|
||||
defer span.End()
|
||||
|
||||
// Return nothing when all slot parameters are missing
|
||||
if startSlotEncoded == nil && endSlotEncoded == nil && startEpochEncoded == nil && endEpochEncoded == nil {
|
||||
return [][]byte{}, nil
|
||||
}
|
||||
|
||||
var startSlot, endSlot, step uint64
|
||||
var ok bool
|
||||
if startSlot, ok = startSlotEncoded.(uint64); !ok {
|
||||
@ -476,10 +481,6 @@ func fetchBlockRootsBySlotRange(
|
||||
if endSlot < startSlot {
|
||||
return nil, errInvalidSlotRange
|
||||
}
|
||||
// Return nothing with an end slot of 0.
|
||||
if endSlot == 0 {
|
||||
return [][]byte{}, nil
|
||||
}
|
||||
rootsRange := (endSlot - startSlot) / step
|
||||
roots := make([][]byte, 0, rootsRange)
|
||||
c := bkt.Cursor()
|
||||
|
@ -118,7 +118,7 @@ func TestStore_BlocksHandleZeroCase(t *testing.T) {
|
||||
zeroFilter := filters.NewFilter().SetStartSlot(0).SetEndSlot(0)
|
||||
retrieved, _, err := db.Blocks(ctx, zeroFilter)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 0, len(retrieved), "Unexpected number of blocks received, expected none")
|
||||
assert.Equal(t, 1, len(retrieved), "Unexpected number of blocks received, expected one")
|
||||
}
|
||||
|
||||
func TestStore_BlocksHandleInvalidEndSlot(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user