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(api): restore /lean/v0/blocks/finalized for checkpoint-sync anchor block (leanEthereum#974)
* feat(api): restore /lean/v0/blocks/finalized for checkpoint-sync anchor block
PR leanEthereum#713 added this endpoint so a checkpoint-syncing peer can fetch the
(state, signed block) anchor pair. PR leanEthereum#751 removed it as dead code
because it has no callers inside this repository. The callers are
external: the hive lean simulator gates every checkpoint-sync scenario
on this endpoint, and client implementations serve it for interop.
Since the removal shipped, all hive checkpoint-sync-based reqresp tests
fail for every client with a permanent 404 from the helper node.
Restores the endpoint and the injectable signed-block source on the API
server, since the fork-choice store only retains unsigned blocks. The
handler and field docstrings now name the external consumers so the
next dead-code sweep has the missing context.
* feat(sync): fetch the finalized block during checkpoint sync
The anchor builder previously rebuilt the anchor block from the header
embedded in the state with an empty body. The anchor root is the hash of
the full block, so whenever the finalized block carried attestations the
rebuilt root diverged from the finalized root the rest of the network
agrees on. This is the gap issue leanEthereum#712 originally described.
Fetch the real signed block from the finalized block endpoint and anchor
the store on it. The block is fetched before the state: it is small, so
a source that cannot serve it fails fast before the multi-megabyte state
download starts. A block that does not pair with the fetched state
raises, since that means the source advanced finalization between the
two requests and a retry is the fix.
This also gives the restored endpoint an in-repo production caller.
* feat(node): wire the finalized signed-block source into the API server
The API exposes /lean/v0/blocks/finalized so checkpoint-syncing peers can
fetch the (state, signed block) anchor pair, but the live node never
supplied a signed-block source, so the endpoint always returned 503.
The store and database retain only unsigned blocks, and the receiving peer
pairs the block with the finalized state without verifying its proof. Wrap
the looked-up block in an empty proof, matching the genesis anchor that no
proposer ever signed.
* docs: simplify doc
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
* docs: apply suggestions
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
* test(api,sync): address review feedback on finalized-block endpoint
Reviewer feedback from PR leanEthereum#974:
- Document the retryable block/state pairing mismatch in the anchor
builder's Raises list, so callers know that case is worth a refetch.
- Pin full error messages with equality instead of match=/startswith
fragments in the checkpoint-sync and anchor tests, matching the
project's full-message assertion rule.
- Assert the fetched anchor block actually lands in the store, making
the intent of the keyed-by-fetched-block change explicit.
- Replace the weak deserialize-and-not-None block test with a full
object equality against the block rebuilt from the finalized state.
- Hoist the "wrap an unsigned block in an empty proof" helper and the
store-backed signed-block getter into consensus_testing, reused
across the API, sync, and anchor tests.
- Bind test servers to port 0 and read the OS-assigned port via a new
ApiServer.bound_port, removing hardcoded ports that could collide
under parallel runs.
* fix(vulture): whitelist the validator index-position model validator
The index/position invariant validator added in leanEthereum#1147 is invoked by
Pydantic during validation, so vulture cannot see the call and reports
it as dead code. Whitelist it alongside the other model validators.
---------
Co-authored-by: Thomas Coratger <60488569+tcoratger@users.noreply.github.com>
0 commit comments