Skip to content

feat: checkpoint-sync-url now can be a list of checkpoint nodes #1411

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

LeanSerra
Copy link
Contributor

Motivation

We want the ability to download the state from multiple checkpoint nodes when performing a checkpoint sync then compare the downloaded states failing if any of them are different

Description

  • The flag --checkpoint-sync-url now parses a comma separated list of urls then fetch the state from each node finally compare them if any of them is different to the rest the program exits.

Note

  • When testing most checkpoint nodes returned error 500 when calling /eth/v1/beacon/deposit_snapshot as this endpoint will be deprecated in the Electra fork. For this reason I didn't add the comparison when downloading the snapshot as it was hard to find two nodes that agreed in the result.

How to try it

rm -rf level_db/mainnet
iex -S mix run -- --checkpoint-sync-url "https://mainnet-checkpoint-sync.stakely.io, https://sync.invis.tools"  --discovery-port 9009 --mode full

Closes #1085

@LeanSerra LeanSerra added the enhancement New feature or request label Mar 31, 2025
@LeanSerra LeanSerra self-assigned this Mar 31, 2025
@LeanSerra LeanSerra requested a review from a team as a code owner March 31, 2025 19:38
Copy link
Collaborator

@rodrigo-o rodrigo-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment

Comment on lines +164 to +179
if anchor_state.latest_block_header.parent_root != first_block.message.parent_root do
Logger.error(
"[Checkpoint sync] Root mismatch when comparing latest finalized block with downloaded state"
)

Logger.flush()
System.halt(1)
end

# We already checked block and state match
{:ok, store} = Store.get_forkchoice_store(anchor_state, anchor_block)

# Save store in DB
StoreDb.persist_store(store)

store
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fan of Halts, but given that it was already used in the previous state of the function we could just maintain it here, in any case i think it's better to go for the positive and halt in the else instead of simulating and early return.

    if anchor_state.latest_block_header.parent_root == first_block.message.parent_root do
      {:ok, store} = Store.get_forkchoice_store(anchor_state, anchor_block)
  
      # Save store in DB
      StoreDb.persist_store(store)
  
      store
    else
      Logger.error(
        "[Checkpoint sync] Root mismatch when comparing latest finalized block with downloaded state"
      )

      Logger.flush()
      System.halt(1)
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Allow multiple checkpoint sync urls
2 participants