Skip to content

Conversation

@tclemos
Copy link
Contributor

@tclemos tclemos commented Dec 29, 2025

closes https://github.com/0xPolygon/devtools/issues/479

Adds a new report command to generate comprehensive blockchain analysis reports for Ethereum-compatible chains. Supports JSON, HTML, and PDF output formats with statistics, visualizations, and performance optimizations.

Features

  • Multiple output formats: JSON, HTML and PDF
  • Comprehensive metrics: Block/transaction counts, gas usage patterns, unique addresses, base fee analysis
  • Top 10 analysis: Highest transaction/gas blocks, most used gas prices/limits
  • Performance optimizations:
    • Concurrent RPC requests (configurable, default: 10)
    • Rate limiting (default: 4 req/s)
    • Batch receipt fetching per block

Usage

JSON

polycli report --rpc-url http://localhost:8545 --start-block 1000 --end-block 2000

HTML

polycli report --rpc-url http://localhost:8545 --start-block 1000 --end-block 2000 --format html

PDF

polycli report --rpc-url http://localhost:8545 --start-block 1000 --end-block 2000 --format pdf -o report.pdf

@tclemos tclemos self-assigned this Dec 29, 2025
@tclemos tclemos changed the title Thiago/cmd report feat: add new report cmd Dec 29, 2025
Copy link

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 new report command to generate comprehensive blockchain analysis reports for Ethereum-compatible chains. The command fetches block and transaction data via RPC, calculates statistics, and outputs results in JSON, HTML, or PDF format with support for concurrent requests and rate limiting.

Key changes:

  • New report command with JSON/HTML/PDF output formats
  • Concurrent block fetching (configurable, default 10 workers) with rate limiting (default 4 req/s)
  • Comprehensive metrics including transaction counts, gas usage, unique addresses, and top-10 analyses
  • HTML visualizations with SVG charts and interactive tooltips
  • PDF generation using chromedp for headless browser rendering

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
go.mod / go.sum Added chromedp dependencies for PDF generation and viper v1.19.0 (moved from direct to indirect dependency) with related transitive dependency version adjustments
cmd/root.go Registered the new report command in the CLI
cmd/report/report.go Core implementation: flag validation, concurrent RPC fetching with rate limiting, block/transaction data processing, and output generation
cmd/report/types.go Data structures for report, summary statistics, block info, transaction info, and top-10 analyses
cmd/report/html.go HTML generation functions including stat cards, SVG line charts for transactions and gas usage, and top-10 tables
cmd/report/pdf.go PDF generation using chromedp to render HTML to PDF with page settings
cmd/report/template.html HTML template with embedded CSS for styling and JavaScript for chart tooltips
cmd/report/usage.md Documentation covering features, usage examples, and report contents

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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

Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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

Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Move github.com/spf13/viper from a separate require block back to the
main require block where it belongs. This restores consistency with the
go.mod structure in the main branch. The viper dependency is a direct
dependency used for configuration management and should be grouped with
other direct dependencies like cobra and pflag.
Copy link

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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add validation in generateReport to ensure start and end blocks are
not BlockNotSet (math.MaxUint64) before entering the block fetching
loop. If endBlock is math.MaxUint64, the loop condition
(blockNum <= report.EndBlock) would cause an overflow when blockNum
increments past MaxUint64, resulting in an infinite loop.

This is defensive programming since the RunE function already resolves
BlockNotSet values to actual block numbers before calling
generateReport. However, this validation prevents potential bugs if
generateReport is called directly or if the smart defaults logic is
bypassed.

Added comprehensive tests to verify the validation catches all invalid
block range scenarios.
Copy link

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

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

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

Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

leovct
leovct previously approved these changes Dec 31, 2025
Copy link
Member

@leovct leovct left a comment

Choose a reason for hiding this comment

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

lgtm

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.

3 participants