Skip to content

Commit 327559c

Browse files
committed
fix: handle negative slots in SyncBlocks
1 parent 9d2afab commit 327559c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/lambda_ethereum_consensus/beacon/sync_blocks.ex

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ defmodule LambdaEthereumConsensus.Beacon.SyncBlocks do
2929
initial_slot = Misc.compute_start_slot_at_epoch(checkpoint.epoch) + 1
3030
last_slot = BeaconChain.get_current_slot()
3131

32-
chunks =
33-
Enum.chunk_every(initial_slot..last_slot, @blocks_per_chunk)
34-
|> Enum.map(fn chunk ->
35-
first_slot = List.first(chunk)
36-
last_slot = List.last(chunk)
37-
count = last_slot - first_slot + 1
38-
%{from: first_slot, count: count}
39-
end)
40-
41-
perform_sync(chunks)
32+
if last_slot > 0 do
33+
chunks =
34+
Enum.chunk_every(initial_slot..last_slot, @blocks_per_chunk)
35+
|> Enum.map(fn chunk ->
36+
first_slot = List.first(chunk)
37+
last_slot = List.last(chunk)
38+
count = last_slot - first_slot + 1
39+
%{from: first_slot, count: count}
40+
end)
41+
42+
perform_sync(chunks)
43+
end
4244
end
4345

4446
@spec perform_sync([chunk()]) :: :ok

0 commit comments

Comments
 (0)