-
Notifications
You must be signed in to change notification settings - Fork 12
[DO NOT SUBMIT] debug: add get_unstable_blocks #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this 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 debug PR introduces a new method for retrieving unstable block data and a set of visualization tools to represent blockchain data as graphs. Key changes include:
- New scripts for generating blockchain visualizations using Graphviz and Matplotlib/NetworkX.
- Addition of functions to parse and serve unstable blocks data in both Python and Rust.
- Updates to interface definitions and canister endpoints to support the new unstable blocks functionality.
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| visualize_blockchain_graphviz.py | New Graphviz-based visualization script for blockchain structures. |
| visualize_blockchain.py | New matplotlib/networkx visualization script for blockchain data. |
| unstable_blocks.py | New parser for unstable blocks output based on candid text input. |
| interface/src/lib.rs | Added BlockData and UnstableBlocksResult types to support outputs. |
| canister/src/unstable_blocks.rs | Added a function to retrieve block data from unstable blocks. |
| canister/src/main.rs | Exposed a new query endpoint get_unstable_blocks. |
| canister/src/lib.rs | Introduced a new get_unstable_blocks function returning block data. |
| canister/src/blocktree.rs | Extended BlockTree with a new method to extract block data recursively. |
Files not reviewed (2)
- canister/candid.did: Language not supported
- process_unstable_blocks.sh: Language not supported
| // let max_depth_diff = MAX_TESTNET_UNSTABLE_DEPTH_DIFFERENCE.get() as u32; | ||
| // let min_depth_diff = stability_threshold.min(max_depth_diff - 1); | ||
|
|
||
| if total_unstable_blocks >= MAX_UNSTABLE_BLOCKS { | ||
| return Depth::new(min_depth_diff as u64); | ||
| } | ||
| // if total_unstable_blocks >= MAX_UNSTABLE_BLOCKS { | ||
| // return Depth::new(min_depth_diff as u64); | ||
| // } | ||
|
|
||
| let range = (max_depth_diff - min_depth_diff) as f64; | ||
| let ratio = total_unstable_blocks as f64 / MAX_UNSTABLE_BLOCKS as f64; | ||
| let interpolated = max_depth_diff as f64 - ratio * range; | ||
| // let range = (max_depth_diff - min_depth_diff) as f64; | ||
| // let ratio = total_unstable_blocks as f64 / MAX_UNSTABLE_BLOCKS as f64; | ||
| // let interpolated = max_depth_diff as f64 - ratio * range; | ||
|
|
||
| Depth::new(interpolated.round() as u64) | ||
| // Depth::new(interpolated.round() as u64) |
Copilot
AI
May 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The function 'testnet_unstable_max_depth_difference' contains several commented-out lines which may reduce clarity. Consider removing or clearly documenting the purpose of this debug code once it is no longer needed.
| import sys | ||
| from graphviz import Digraph | ||
|
|
||
| def short_hash(hash_hex): |
Copilot
AI
May 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The 'short_hash' function is duplicated across multiple files. Consider centralizing its implementation to avoid code duplication and simplify future maintenance.
DO NOT SUBMIT!
this is a debug PR that adds an extra method to read unstable blocks from testnet4 and present them as a tree.