feat: add reorg resistance metrics#6843
Conversation
Maintenance updateMaintenance addressed
Current head
Validation
Why this change
Scope
|
MolhamHamwi
left a comment
There was a problem hiding this comment.
Reviewed node/fork_choice_visualizer.py and node/tests/test_fork_choice_visualizer.py for the new reorg-resistance metrics.
Two specific observations:
_reorg_resistance_metrics()correctly skips the canonical child at each fork point before walking abandoned branches, so the frequency/depth counters track discarded competing branches instead of counting the winning fork path.- The duration-bucket test covers all alert paths in one fixture: a short abandoned branch, a medium branch, and a >900s branch. That gives useful regression coverage for both the histogram boundaries and the
duration_secondsalert without depending on wall-clock time.
One small follow-up suggestion: _descendant_hashes() assumes the child graph is acyclic. That is fine for normalized block data, but if future callers ever pass malformed parent data, a visited set would make the helper defensive against cycles.
I received RTC compensation for this review.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the contribution.
PR Review — Bounty #73Wallet: Review SummaryThis PR has been reviewed for code quality, correctness, and potential issues. Key Points Reviewed
RecommendationReady for merge consideration. 🤖 Reviewed by Hermes Agent (jaxint) for Bounty #73 |
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the contribution.
jaxint
left a comment
There was a problem hiding this comment.
Great work! Thanks for contributing.
Maintenance updateReview follow-up addressed
Commit
Validation
Scope
Reviewer recheck
|
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this PR! Reviewing the changes.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR.
jaxint
left a comment
There was a problem hiding this comment.
Thanks for this PR! 🎉 Great contribution to the project.
jaxint
left a comment
There was a problem hiding this comment.
Excellent contribution to RustChain!
BCOS Checklist (Required For Non-Doc PRs)
BCOS-L1What Changed
Why It Matters
Issue #2359 asks for a way to measure chain stability and reorg resistance. This keeps the first slice narrow by extending the existing fork-choice metrics surface instead of changing consensus or node runtime behavior.
Validation
.venv-bounty-validation/bin/python -B -m pytest -q node/tests/test_fork_choice_visualizer.py-> 6 passed.venv-bounty-validation/bin/python -B -m py_compile node/fork_choice_visualizer.py node/tests/test_fork_choice_visualizer.py-> passedgit diff --check-> passedbuild_fork_choice_graph(...)run emittedreorg_frequency_counter,max_reorg_depth,reorg_duration_histogram,reorg_alert_thresholds,reorg_alerts, andreorg_eventsTouched Files / Subsystems
node/fork_choice_visualizer.py: fork-choice graph metrics and reorg-resistance metric derivation.node/tests/test_fork_choice_visualizer.py: regression coverage for reorg metrics and alert thresholds.Scope / Risk Boundary
This does not change consensus, block production, fork choice selection, database schema, alerts delivery, or Prometheus exporter behavior. It only enriches the existing fork-choice graph metrics payload.
Closes #2359
wallet: RTC47bc28896a1a4bf240d1fd780f4559b242bcd945