Skip to content

Commit 7ed3e26

Browse files
authored
fix: stop appending endpoint path to checkpoint sync URL (#148)
## Summary - `--checkpoint-sync-url` now expects the full URL (e.g., `http://peer:5052/lean/v0/states/finalized`) instead of just the base URL with `/lean/v0/states/finalized` appended automatically - Decouples the CLI from a specific API path convention, so it works with any checkpoint provider regardless of endpoint layout ## Test plan - [x] `cargo check` passes - [ ] Verify checkpoint sync works end-to-end with the full URL in a devnet
1 parent 0f5ea11 commit 7ed3e26

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

bin/ethlambda/src/checkpoint_sync.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ pub enum CheckpointSyncError {
6363
/// disconnect even for valid downloads if the state is simply too large to
6464
/// transfer within the time limit.
6565
pub async fn fetch_checkpoint_state(
66-
base_url: &str,
66+
url: &str,
6767
expected_genesis_time: u64,
6868
expected_validators: &[Validator],
6969
) -> Result<State, CheckpointSyncError> {
70-
let base_url = base_url.trim_end_matches('/');
71-
let url = format!("{base_url}/lean/v0/states/finalized");
7270
// Use .read_timeout() to detect stalled downloads (inactivity timer).
7371
// This allows large states to complete as long as data keeps flowing.
7472
let client = Client::builder()
@@ -77,7 +75,7 @@ pub async fn fetch_checkpoint_state(
7775
.build()?;
7876

7977
let response = client
80-
.get(&url)
78+
.get(url)
8179
.header("Accept", "application/octet-stream")
8280
.send()
8381
.await?

bin/ethlambda/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct CliOptions {
4747
/// The node ID to look up in annotated_validators.yaml (e.g., "ethlambda_0")
4848
#[arg(long)]
4949
node_id: String,
50-
/// URL of a peer to download checkpoint state from (e.g., http://peer:5052)
50+
/// URL to download checkpoint state from (e.g., http://peer:5052/lean/v0/states/finalized)
5151
/// When set, skips genesis initialization and syncs from checkpoint.
5252
#[arg(long)]
5353
checkpoint_sync_url: Option<String>,

docs/checkpoint_sync.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ When `--checkpoint-sync-url` is omitted, the node initializes from genesis.
2626

2727
### Direct peer
2828

29-
Any running node that serves the `/lean/v0/states/finalized` endpoint can be used as a checkpoint source, not just ethlambda.
29+
Any running node that serves the finalized state as SSZ can be used as a checkpoint source, not just ethlambda. For ethlambda nodes, the endpoint is `/lean/v0/states/finalized`.
3030

3131
This is the simplest option, with no additional infrastructure needed. The trade-off is that you trust a single peer to provide a correct finalized state.
3232

@@ -38,7 +38,7 @@ This is the recommended option for production deployments since it reduces trust
3838

3939
## How It Works
4040

41-
1. **Fetch and verify**: The node sends an HTTP GET to `{url}/lean/v0/states/finalized` requesting the SSZ-encoded finalized state. Once downloaded, the state is decoded and verified against the local genesis config (see [Verification Checks](#verification-checks) below).
41+
1. **Fetch and verify**: The node sends an HTTP GET to the provided URL requesting the SSZ-encoded finalized state. Once downloaded, the state is decoded and verified against the local genesis config (see [Verification Checks](#verification-checks) below).
4242

4343
Timeouts:
4444
- **Connect**: 15 seconds (fail fast if peer is unreachable)

0 commit comments

Comments
 (0)