You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(checkpoint-sync): fetch finalized block during checkpoint-sync (lambdaclass#363)
## Summary
- New `fetch_finalized_anchor(url, ...)` issues
`/lean/v0/states/finalized` and `/lean/v0/blocks/finalized` in parallel
and verifies the pair via the canonical `block.state_root ==
hash_tree_root(state)` invariant. On mismatch the caller is expected to
retry (e.g. the peer advanced finalization between the two requests).
- The fetched `SignedBlock` is persisted via
`Store::insert_signed_block`, so the local node can serve a valid anchor
over `BlocksByRoot` instead of synthesizing a block whose hash differs
from `latest_finalized.root` (the scenario leanSpec PR #713 addresses).
- The anchor-pair invariant check (`anchor_pair_is_consistent`) is
hoisted into `ethlambda_types::state`. `Store::get_forkchoice_store`,
the hive test driver, and the new checkpoint-sync client all delegate to
it. Notably, the panic path in `get_forkchoice_store` previously checked
only header equality + state self-consistency; it now also enforces
`block.state_root == hash_tree_root(state)`.
## Compat
`--checkpoint-sync-url` is now documented as a base URL (e.g.
`http://peer:5052`). The legacy `.../lean/v0/states/finalized` form is
still accepted and the trailing path is stripped, so existing devnet
scripts keep working.
Closeslambdaclass#354.
## Test plan
- [x] `cargo clippy --workspace --all-targets -- -D warnings`
- [x] `cargo test -p ethlambda` (26 passed)
- [x] `cargo test -p ethlambda-rpc --tests` (8 passed, incl. anchor-pair
regression coverage)
- [x] `cargo test -p ethlambda-storage` (33 passed)
- [ ] Smoke test in a multi-node devnet: stop one node, restart it with
`--checkpoint-sync-url` pointing at a peer's API, confirm it boots,
requests blocks, and stays in sync.
---------
Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
0 commit comments