Skip to content

feat: add stake weight histogram to validation stats#2508

Merged
rockysingh merged 6 commits intomainfrom
2504-stake-weight-histogram-stats
Apr 10, 2026
Merged

feat: add stake weight histogram to validation stats#2508
rockysingh merged 6 commits intomainfrom
2504-stake-weight-histogram-stats

Conversation

@rockysingh
Copy link
Copy Markdown
Contributor

@rockysingh rockysingh commented Apr 2, 2026

Summary

  • Extract DayStatistics and SignatureStats from ValidateWithStats into reusable SignatureStatsCollector class
  • Add SignatureBlockStats record for per-block signature validation data with NodeResult enum and fromPreVerifiedData() factory
  • Extend CSV output with 17 new stake weight columns: mode, total_stake, validated stake % (min/max/mean), closest threshold margin, signing node counts (min/max/mean), node stake distribution (min/max/mean/median/stddev), top-3 concentration %, missing signers, reliable signers
  • Wire stats collection into ValidateBlocksCommand, LiveSequential, and ToWrappedBlocksCommand with command-specific CSV filenames
  • Add StakeMapWithTotal to NodeStakeRegistry to avoid recomputing total stake per block
  • Optimize SignatureValidation with lazy diagnostics — no string formatting on the happy path
  • Stats collection enabled by default on the 2-arg constructor

closes: #2504

@rockysingh rockysingh requested review from a team as code owners April 2, 2026 23:27
@rockysingh rockysingh requested a review from jasperpotts April 2, 2026 23:27
@rockysingh rockysingh marked this pull request as draft April 2, 2026 23:28
@rockysingh rockysingh self-assigned this Apr 2, 2026
@rockysingh rockysingh added the Block Node Tools Additional tools related to, but not part of, the Block Node label Apr 2, 2026
@rockysingh rockysingh added this to the 0.32.0 milestone Apr 2, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Hiero CLI Apr 2, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 2, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 138 complexity · 26 duplication

Metric Results
Complexity 138
Duplication 26

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@rockysingh rockysingh force-pushed the 2504-stake-weight-histogram-stats branch 2 times, most recently from fd74b2c to 30c7d0f Compare April 8, 2026 00:33
@rockysingh rockysingh marked this pull request as ready for review April 8, 2026 18:00
jsync-swirlds
jsync-swirlds previously approved these changes Apr 9, 2026
Copy link
Copy Markdown
Contributor

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

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

Just some possible improvements using a Formatter instead of combining StringBuilder and String.format.

@rockysingh
Copy link
Copy Markdown
Contributor Author

rockysingh commented Apr 9, 2026

Just some possible improvements using a Formatter instead of combining StringBuilder and String.format.

Thanks. I took the commit proposed and then made a few adjustments to it after.

rockysingh and others added 5 commits April 9, 2026 16:56
Extract DayStatistics and SignatureStats from ValidateWithStats into
reusable SignatureStatsCollector. Add SignatureBlockStats record for
per-block signature data. Extend CSV output with 17 stake weight
columns including validated stake percentages, threshold margins,
signing node counts, stake distribution stats, and signer reliability.

Wire stats collection into ValidateBlocksCommand, LiveSequential,
and ToWrappedBlocksCommand with command-specific CSV filenames.
Optimize SignatureValidation with lazy diagnostics (no string
formatting on happy path) and cached total stake computation.

Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
…ks/validation/SignatureStatsCollector.java

Co-authored-by: Joseph S. <121976561+jsync-swirlds@users.noreply.github.com>
Signed-off-by: Rocky Singh <rockysingh@users.noreply.github.com>
Fix field vs method access (totalBlocks, totalValidSignatures), missing
format argument in histogram loop, garbled format call for missing/reliable
signers, restore else branch for empty stake columns, and update
appendNodeStakeDistribution to accept Formatter.

Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
@rockysingh rockysingh force-pushed the 2504-stake-weight-histogram-stats branch from 7832c0e to cd38ab6 Compare April 10, 2026 00:03
Copy link
Copy Markdown
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

A few minor considerations

- ValidateBlocksCommand: fix stats output directory fallback when
  files[0] is a regular file (e.g. a .blk.zip) by using the file's
  parent directory instead of the file itself
- ValidateBlocksCommand: wrap SignatureStatsCollector in
  try-with-resources so close() is guaranteed on all exit paths
- SignatureValidation: remove the two-arg constructor to eliminate
  the hidden collectDetailedStats default; callers must now be
  explicit about whether they want stats collection

Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
Copy link
Copy Markdown
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

LG

Copy link
Copy Markdown
Contributor

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

LGTM

@rockysingh rockysingh merged commit 536b453 into main Apr 10, 2026
17 checks passed
@rockysingh rockysingh deleted the 2504-stake-weight-histogram-stats branch April 10, 2026 22:07
@github-project-automation github-project-automation Bot moved this from Todo to Done in Hiero CLI Apr 10, 2026
ivannov pushed a commit to ivannov/hiero-block-node that referenced this pull request Apr 20, 2026
Signed-off-by: Rocky Thind <harpender.t@swirldslabs.com>
Signed-off-by: Rocky Singh <rockysingh@users.noreply.github.com>
Co-authored-by: Joseph S. <121976561+jsync-swirlds@users.noreply.github.com>
@AlfredoG87 AlfredoG87 added the New Feature A new feature, service, or documentation. Major changes that are not backwards compatible. label Apr 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff              @@
##               main    #2508      +/-   ##
============================================
- Coverage     81.27%   81.20%   -0.08%     
+ Complexity     1512     1509       -3     
============================================
  Files           139      139              
  Lines          7131     7131              
  Branches        754      754              
============================================
- Hits           5796     5791       -5     
- Misses         1010     1016       +6     
+ Partials        325      324       -1     

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

Block Node Tools Additional tools related to, but not part of, the Block Node New Feature A new feature, service, or documentation. Major changes that are not backwards compatible.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add stake weight histogram to validation stats

5 participants