Commit a2f6d13
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
394 | 396 | | |
395 | 397 | | |
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
399 | | - | |
| 401 | + | |
400 | 402 | | |
401 | 403 | | |
402 | 404 | | |
| |||
0 commit comments