fix(forkchoice-viz): always render finalized block as fully filled#339
fix(forkchoice-viz): always render finalized block as fully filled#339conache wants to merge 2 commits intolambdaclass:mainfrom
Conversation
Greptile SummaryThis PR updates the fork-choice visualization so that finalized blocks render as fully filled green discs and display
Confidence Score: 3/5Safe to merge with reservations — a newly introduced visual feature ( One P1 (dead crates/net/rpc/static/fork_choice.html — specifically the
|
| Filename | Overview |
|---|---|
| crates/net/rpc/static/fork_choice.html | Visualization-only change: finalized blocks now render as fully filled green discs with "status: finalized" tooltip; introduces _stroke (computed but never applied to the outer circle), drops weight percentage from non-finalized tooltips, and contains a redundant guard in nodeRatio. |
Comments Outside Diff (1)
-
crates/net/rpc/static/fork_choice.html, line 229-230 (link)!validatorCountalready returnstruewhenvalidatorCountis0(since!0 === true), so the|| validatorCount === 0branch is unreachable dead code.Prompt To Fix With AI
This is a comment left during a code review. Path: crates/net/rpc/static/fork_choice.html Line: 229-230 Comment: **Redundant guard in `nodeRatio`** `!validatorCount` already returns `true` when `validatorCount` is `0` (since `!0 === true`), so the `|| validatorCount === 0` branch is unreachable dead code. How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
crates/net/rpc/static/fork_choice.html:322
**`_stroke` is computed but never applied**
`_stroke` is stored on each flat node but the render code references `d._color` for both the initial enter and the transition update of `.node-outer`. The `nodeStroke` function (and this property) are therefore dead code — the darker outline never actually appears.
### Issue 2 of 3
crates/net/rpc/static/fork_choice.html:229-230
**Redundant guard in `nodeRatio`**
`!validatorCount` already returns `true` when `validatorCount` is `0` (since `!0 === true`), so the `|| validatorCount === 0` branch is unreachable dead code.
```suggestion
if (!validatorCount) return 0;
```
### Issue 3 of 3
crates/net/rpc/static/fork_choice.html:350-356
**Non-finalized tooltip silently drops the weight percentage**
The old tooltip rendered `weight: X/total (pct%)` for non-finalized blocks; the new version shows only `weight: X`. The `total` and percentage were useful for understanding a node's relative support — this is a quiet regression for all non-finalized nodes in the tree.
Reviews (1): Last reviewed commit: "Completely fill the finalized block node..." | Re-trigger Greptile
| y: d.y, | ||
| _color: nodeColor(d.data, data), | ||
| _ratio: weightRatio(d.data, data.validator_count) | ||
| _stroke: nodeStroke(d.data, data), |
There was a problem hiding this comment.
_stroke is computed but never applied
_stroke is stored on each flat node but the render code references d._color for both the initial enter and the transition update of .node-outer. The nodeStroke function (and this property) are therefore dead code — the darker outline never actually appears.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/net/rpc/static/fork_choice.html
Line: 322
Comment:
**`_stroke` is computed but never applied**
`_stroke` is stored on each flat node but the render code references `d._color` for both the initial enter and the transition update of `.node-outer`. The `nodeStroke` function (and this property) are therefore dead code — the darker outline never actually appears.
How can I resolve this? If you propose a fix, please make it concise.| const weightLine = isFinalized | ||
| ? `<span class="tt-label">status:</span> finalized` | ||
| : `<span class="tt-label">weight:</span> ${d.weight}`; | ||
| return `<span class="tt-label">root:</span> ${truncateRoot(d.root)}<br>` + | ||
| `<span class="tt-label">slot:</span> ${d.slot}<br>` + | ||
| `<span class="tt-label">proposer:</span> ${d.proposer_index}<br>` + | ||
| `<span class="tt-label">weight:</span> ${d.weight}${total != null ? `/${total} (${pct}%)` : ''}`; | ||
| weightLine; |
There was a problem hiding this comment.
Non-finalized tooltip silently drops the weight percentage
The old tooltip rendered weight: X/total (pct%) for non-finalized blocks; the new version shows only weight: X. The total and percentage were useful for understanding a node's relative support — this is a quiet regression for all non-finalized nodes in the tree.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/net/rpc/static/fork_choice.html
Line: 350-356
Comment:
**Non-finalized tooltip silently drops the weight percentage**
The old tooltip rendered `weight: X/total (pct%)` for non-finalized blocks; the new version shows only `weight: X`. The `total` and percentage were useful for understanding a node's relative support — this is a quiet regression for all non-finalized nodes in the tree.
How can I resolve this? If you propose a fix, please make it concise.
🗒️ Description / Motivation
The fork choice visualization currently renders the finalized block as empty. This happens because each node is filled proportionally to its
weightvalue. This value is computed by the compute_block_weights() method, which returns 0 for thestart_slot(which is always the finalized block's slot).The reported
0is technically accurate but misleading: a finalized block has full validator support by definition (2/3 supermajority and unbroken justified chain). However, this is only misleading for the visualisation, sincecompute_block_weights()correctly skips the finalized block because LMD GHOST treats it as the root of the fork-choice tree, not a candidate, so weighing it adds no information to head selection.Proposed solution: render finalized blocks as fully filled green discs and show
status: finalizedin the tooltip instead ofweight: 0.What Changed
crates/net/rpc/static/fork_choice.html:nodeRatio: returns1for blocks at or belowfinalized.slot, so they render as solid green discs.status: finalizedfor finalized blocks instead ofweight: 0.Correctness / Behavior Guarantees
weight / validator_count.status: finalized.Tests Run
status: finalizedin the tooltip.Related Issues / PRs