Skip to content

Conversation

@patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Jan 6, 2026

Related: #1921 (production-use adaption)

Add a family gauge metric to track the view of the last vote received from each participant in the batcher actor. This enables monitoring peer activity and computing instantaneous lag (current_view - last_vote).

  • Add Peer label struct to metrics.rs
  • Initialize all participants to view 0 at startup
  • Update metric when valid votes are received
  • Add test verifying metric tracking including late votes after quorum

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 6, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
commonware-mcp cf2cc46 Jan 06 2026, 07:25 PM

@patrick-ogrady patrick-ogrady marked this pull request as draft January 6, 2026 02:19
@patrick-ogrady patrick-ogrady force-pushed the patrick/consensus-metrics branch from e2638a1 to f842cdb Compare January 6, 2026 02:45
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 6, 2026

Deploying monorepo with  Cloudflare Pages  Cloudflare Pages

Latest commit: cf2cc46
Status: ✅  Deploy successful!
Preview URL: https://8a8afa05.monorepo-eu0.pages.dev
Branch Preview URL: https://patrick-consensus-metrics.monorepo-eu0.pages.dev

View logs

@patrick-ogrady patrick-ogrady force-pushed the patrick/consensus-metrics branch from f842cdb to 545ed1b Compare January 6, 2026 02:47
@patrick-ogrady patrick-ogrady marked this pull request as ready for review January 6, 2026 02:48
@patrick-ogrady
Copy link
Contributor Author

While honest voters should never vote for views lower than latest, we want this metric to be robust to such behavior.

Add a family gauge metric to track the view of the latest vote received
from each participant in the batcher actor. This enables monitoring
peer activity and computing instantaneous lag (current_view - latest_vote).

- Add Peer label struct to metrics.rs
- Add GaugeExt::set_max helper to update gauge only if value is higher
- Initialize all participants to view 0 at startup
- Update metric when valid votes are received (after epoch check)
- Add test verifying metric tracking including late votes after quorum
  and ensuring lower view votes don't decrease the metric

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@patrick-ogrady patrick-ogrady force-pushed the patrick/consensus-metrics branch 2 times, most recently from 2c3ea3f to 1ca9845 Compare January 6, 2026 14:53
let latest_vote = Family::<Peer, Gauge>::default();
context.register(
"latest_vote",
"view of latest vote received per peer",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be annoying to work with in practice in something like reshare because we namespace metrics by epoch (so you'd have to constantly be updating your dashboard I think?)

But that should be considered in a follow-up.

andresilva
andresilva previously approved these changes Jan 6, 2026
- Rename set_max to try_set_max for consistency with try_set
- Inline participants clone where needed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
patrick-ogrady and others added 2 commits January 6, 2026 11:06
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
let _ = self
.latest_vote
.get_or_create(&peer)
.try_set_max(view.get());
Copy link
Contributor Author

@patrick-ogrady patrick-ogrady Jan 6, 2026

Choose a reason for hiding this comment

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

Opted to move into post-network validation to avoid duplicating its checks (to ensure a peer, for example is in participants -> thank you based bugbot).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shouldn't happen with our current p2p but we should be defensive.

@patrick-ogrady patrick-ogrady merged commit 1e0d536 into main Jan 6, 2026
126 checks passed
@patrick-ogrady patrick-ogrady deleted the patrick/consensus-metrics branch January 6, 2026 20:18
@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 95.60440% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.82%. Comparing base (fcb1f0f) to head (cf2cc46).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
consensus/src/simplex/actors/batcher/mod.rs 94.93% 8 Missing ⚠️
@@           Coverage Diff            @@
##             main    #2708    +/-   ##
========================================
  Coverage   92.81%   92.82%            
========================================
  Files         361      361            
  Lines      107038   107218   +180     
========================================
+ Hits        99352    99527   +175     
- Misses       7686     7691     +5     
Files with missing lines Coverage Δ
consensus/src/simplex/actors/batcher/actor.rs 94.75% <100.00%> (+0.21%) ⬆️
consensus/src/simplex/metrics.rs 100.00% <100.00%> (ø)
runtime/src/telemetry/metrics/status.rs 100.00% <100.00%> (ø)
consensus/src/simplex/actors/batcher/mod.rs 97.07% <94.93%> (-0.38%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcb1f0f...cf2cc46. Read the comment docs.

🚀 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants