Skip to content

refactor: improve checkpoint-sync algorithm #1277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/lambda_ethereum_consensus/beacon/store_setup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule LambdaEthereumConsensus.Beacon.StoreSetup do
end

@doc """
Gets a {store, genesis_validators_root} tuple with the configured strategy.
Gets a store with the configured strategy.
"""
@spec setup!() :: Store.t()
def setup!(), do: setup!(get_strategy!())
Expand Down
6 changes: 2 additions & 4 deletions lib/lambda_ethereum_consensus/beacon/sync_blocks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule LambdaEthereumConsensus.Beacon.SyncBlocks do
alias LambdaEthereumConsensus.ForkChoice
alias LambdaEthereumConsensus.Libp2pPort
alias LambdaEthereumConsensus.P2P.BlockDownloader
alias LambdaEthereumConsensus.StateTransition.Misc

@blocks_per_chunk 16
@retries 50
Expand All @@ -23,9 +22,8 @@ defmodule LambdaEthereumConsensus.Beacon.SyncBlocks do
"""
@spec run() :: non_neg_integer()
def run() do
# Initial sleep for faster app start
checkpoint = ForkChoice.get_finalized_checkpoint()
initial_slot = Misc.compute_start_slot_at_epoch(checkpoint.epoch) + 1
%{head_slot: head_slot} = ForkChoice.get_current_status_message()
initial_slot = head_slot + 1
last_slot = ForkChoice.get_current_chain_slot()

# If we're around genesis, we consider ourselves synced
Expand Down
2 changes: 1 addition & 1 deletion lib/lambda_ethereum_consensus/fork_choice/fork_choice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do
Logger.info("Pruning states before slot #{new_finalized_epoch}")

new_finalized_slot =
new_finalized_epoch * ChainSpec.get("SLOTS_PER_EPOCH")
Misc.compute_start_slot_at_epoch(new_finalized_epoch)

Task.Supervisor.start_child(
PruneStatesSupervisor,
Expand Down
Loading