Skip to content

Commit a2f6d13

Browse files
conachepablodeymo
andauthored
fix(forkchoice-viz): always render finalized block as fully filled (lambdaclass#339)
## 🗒️ Description / Motivation The fork choice visualization currently renders the finalized block as empty. This happens because each node is filled proportionally to its `weight` value. This value is computed by the [compute_block_weights()](https://github.com/lambdaclass/ethlambda/blob/main/crates/blockchain/fork_choice/src/lib.rs#L5-L27) method, which returns 0 for the `start_slot` (which is always the finalized block's slot). The reported `0` is 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, since `compute_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: finalized` in the tooltip instead of `weight: 0`. <img width="311" height="154" alt="Screenshot 2026-05-01 at 14 31 15" src="https://github.com/user-attachments/assets/13dfcae7-0178-49ca-9308-4dd3a82019a4" /> ## What Changed - `crates/net/rpc/static/fork_choice.html`: - `nodeRatio`: returns `1` for blocks at or below `finalized.slot`, so they render as solid green discs. - Tooltip shows `status: finalized` for finalized blocks instead of `weight: 0`. ## Correctness / Behavior Guarantees - Only the forkchoice visualization changes; consensus and weight computation are unchanged. - Non-finalized blocks still fill proportionally to `weight / validator_count`. - Finalized blocks show up as fully filled. When hovering on a finalized block, there's a status field associated showing: `status: finalized`. ## Tests Run - Manual: ran a single-node devnet and confirmed finalized blocks render as solid green discs with `status: finalized` in the tooltip. ## Related Issues / PRs - Closes lambdaclass#333 --------- Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
1 parent 1f0a0be commit a2f6d13

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

crates/net/rpc/static/fork_choice.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,14 @@
391391

392392
const flatNodes = allDescendants.map(d => {
393393
const roles = nodeRoles(d.data, data);
394+
// Finalized blocks are filled by default, otherwise scale by fork-choice weight.
395+
const isFinalized = roles.includes("finalized");
394396
return {
395397
...d.data,
396398
x: d.x,
397399
y: d.y,
398400
_color: roles.length > 0 ? COLORS[roles[0]] : COLORS.default,
399-
_ratio: weightRatio(d.data, data.validator_count),
401+
_ratio: isFinalized ? 1 : weightRatio(d.data, data.validator_count),
400402
// Colors of secondary roles, in priority order (after the primary).
401403
_haloColors: roles.slice(1).map(r => COLORS[r])
402404
};

0 commit comments

Comments
 (0)