Skip to content

Conversation

@ScottyPoi
Copy link
Contributor

adds a visualization for the fork choice tree to the printSlot logging function as described in issue: #191.

The visualization is configurable with tree_depth limit. A tree_depth limit of null equals no depth limit.

A visualization with tree_depth = 2 should look something like:

0x1234 (0) // has 2 child branches
    ├── 0x2345 (1) // has 1 child branch
    │   └── 0x3456 (2) // ... (truncated at depth 2)
    └── [slots 3..4] ─┘ 0x5678 (5)

Copilot AI review requested due to automatic review settings September 16, 2025 23:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a configurable tree visualization feature to the fork choice logging system to help visualize the blockchain's fork structure. The visualization displays nodes with their block roots and slots, showing parent-child relationships using ASCII tree characters.

  • Adds a new tree_visualizer.zig module with functions to build ASCII tree representations of the fork choice tree
  • Updates the printSlot function to include an optional tree depth parameter and display the fork choice tree visualization
  • Integrates the tree visualization into the existing chain status logging output

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
pkgs/node/src/tree_visualizer.zig New module implementing tree visualization logic with depth limiting and ASCII tree formatting
pkgs/node/src/chain.zig Updates printSlot function signature and integrates tree visualization into logging output

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@g11tech
Copy link
Member

g11tech commented Sep 17, 2025

looks cool! some changes to make it look small and easy for eyes:

  1. remove // comments, we can have a readme section to explain how to understand it
  2. remove slots just [4..5] is sufficient, if only one slot is missing, just use [4]
  3. remove spacing before brackets () and [] both,
  4. remove redundant 0x
  5. use just two digits to represent root

@g11tech
Copy link
Member

g11tech commented Sep 26, 2025

@ScottyPoi can you resolve the conflicts

@ScottyPoi ScottyPoi force-pushed the forkchoice-visual branch 5 times, most recently from 7b650c0 to a8906ec Compare October 4, 2025 01:07
@g11tech
Copy link
Member

g11tech commented Oct 7, 2025

@ScottyPoi can we truncate in opposite direction because most of the time relevance is to see the leaf forking, and if there are too many leaves include 3 by heaviest weight, and include 3 by most recent, so total 6 but keep this 3 number as a param

also relevant to know is justified is a parent in which of these branches

Copilot AI review requested due to automatic review settings November 28, 2025 19:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants