Skip to content

Commit eab7a05

Browse files
authored
refactor: improve checkpoint-sync algorithm (#1277)
1 parent 43a40d4 commit eab7a05

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

lib/lambda_ethereum_consensus/beacon/store_setup.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule LambdaEthereumConsensus.Beacon.StoreSetup do
3838
end
3939

4040
@doc """
41-
Gets a {store, genesis_validators_root} tuple with the configured strategy.
41+
Gets a store with the configured strategy.
4242
"""
4343
@spec setup!() :: Store.t()
4444
def setup!(), do: setup!(get_strategy!())

lib/lambda_ethereum_consensus/beacon/sync_blocks.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ defmodule LambdaEthereumConsensus.Beacon.SyncBlocks do
88
alias LambdaEthereumConsensus.ForkChoice
99
alias LambdaEthereumConsensus.Libp2pPort
1010
alias LambdaEthereumConsensus.P2P.BlockDownloader
11-
alias LambdaEthereumConsensus.StateTransition.Misc
1211

1312
@blocks_per_chunk 16
1413
@retries 50
@@ -23,9 +22,8 @@ defmodule LambdaEthereumConsensus.Beacon.SyncBlocks do
2322
"""
2423
@spec run() :: non_neg_integer()
2524
def run() do
26-
# Initial sleep for faster app start
27-
checkpoint = ForkChoice.get_finalized_checkpoint()
28-
initial_slot = Misc.compute_start_slot_at_epoch(checkpoint.epoch) + 1
25+
%{head_slot: head_slot} = ForkChoice.get_current_status_message()
26+
initial_slot = head_slot + 1
2927
last_slot = ForkChoice.get_current_chain_slot()
3028

3129
# If we're around genesis, we consider ourselves synced

lib/lambda_ethereum_consensus/fork_choice/fork_choice.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do
176176
Logger.info("Pruning states before slot #{new_finalized_epoch}")
177177

178178
new_finalized_slot =
179-
new_finalized_epoch * ChainSpec.get("SLOTS_PER_EPOCH")
179+
Misc.compute_start_slot_at_epoch(new_finalized_epoch)
180180

181181
Task.Supervisor.start_child(
182182
PruneStatesSupervisor,

0 commit comments

Comments
 (0)