Open
Conversation
Add new JSON endpoint that returns the full fork choice state including: - Head block (slot and root) - Justified checkpoint (slot and root) - Finalized checkpoint (slot and root) - Safe target root - Validator count - All proto nodes in the fork choice tree Reuses existing ForkChoice.snapshot() method for thread-safe data access. Extends Snapshot struct with additional fields (slots, safe_target, validator_count) without breaking existing usages.
Zig's package manager can fail with HttpConnectionClosing when fetching transitive dependencies (e.g., bitcoin-core/secp256k1) from GitHub. This is a transient network issue, not a code problem. Add retry logic to build steps (not just fetch) since Zig may lazily fetch dependencies during build that weren't fetched during --fetch.
Fork choice rejects blocks whose slot is ahead of its clock (FutureSlot). The test calls produceBlock(slot=4) without ticking the clock; advance to slot 4 via onInterval before produceBlock so the block is accepted.
Reduce number of write calls by combining all top-level JSON fields into a single print statement for better efficiency.
g11tech
reviewed
Mar 3, 2026
g11tech
reviewed
Mar 3, 2026
| pub const Snapshot = struct { | ||
| head: ProtoNode, | ||
| latest_justified_root: [32]u8, | ||
| latest_justified_slot: types.Slot, |
Member
There was a problem hiding this comment.
@zclawz do a PR to refctor latest_justified_slot, latest_justified_root as a combined checkpoint object. similarly for latest_finalized_root, latest_finalized_slot
zclawz
pushed a commit
that referenced
this pull request
Mar 6, 2026
…rkChoice Snapshot Replace separate latest_justified_root/latest_finalized_root [32]u8 fields in ForkChoice.Snapshot with unified types.Checkpoint objects (latest_justified / latest_finalized), mirroring the ForkChoiceStore fields they are derived from. - forkchoice.zig: Snapshot struct updated; construction sites use fcStore checkpoints directly - tree_visualizer.zig: updated callers to use .latest_justified.root / .latest_finalized.root Requested by g11tech in PR #607 review comment (pkgs/node/src/forkchoice.zig).
1 task
zclawz
pushed a commit
that referenced
this pull request
Mar 6, 2026
…rkChoice Snapshot Replace 4 separate latest_justified_root/slot, latest_finalized_root/slot fields in ForkChoice.Snapshot with unified types.Checkpoint objects (latest_justified / latest_finalized), mirroring the ForkChoiceStore fields they are derived from. - forkchoice.zig: Snapshot struct updated; construction sites use fcStore checkpoints directly - tree_visualizer.zig: updated all callers to use .latest_justified/.latest_finalized checkpoint fields Requested by g11tech in PR #607 review comment (pkgs/node/src/forkchoice.zig).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /lean/v0/fork_choicethat returns the full fork choice stateSnapshotstruct with additional fields without breaking existing usagesForkChoice.snapshot()method for thread-safe data accessResponse format
{ "head": {"slot": 100, "root": "0x..."}, "justified": {"slot": 96, "root": "0x..."}, "finalized": {"slot": 64, "root": "0x..."}, "safe_target": {"root": "0x..."}, "validator_count": 4, "nodes": [ {"slot": 64, "root": "0x...", "parent_root": "0x...", "weight": 4}, ... ] }Implements: leanEthereum/leanSpec#418
Test plan
zig build)curl http://localhost:8084/lean/v0/fork_choice