Skip to content

feat: add metric for observed block height of checkpoints#7146

Merged
kamiyaa merged 5 commits intomainfrom
jeff/validator-checkpoint
Oct 10, 2025
Merged

feat: add metric for observed block height of checkpoints#7146
kamiyaa merged 5 commits intomainfrom
jeff/validator-checkpoint

Conversation

@kamiyaa
Copy link
Copy Markdown
Contributor

@kamiyaa kamiyaa commented Oct 2, 2025

Description

  • log warning when the block height decreases in height

Related issues

Summary by CodeRabbit

  • New Features

    • Added a metric for the latest observed checkpoint’s block height to improve monitoring visibility.
    • Emits warnings on block-height regressions during checkpoint processing to aid detection of anomalies.
  • Refactor

    • Streamlined the checkpoint metrics update flow to ensure consistent, block-height-aware reporting.
  • Chores

    • Updated metrics initialization to include the new block-height gauge with appropriate labeling.

 - log warning when the block height decreases in height
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Oct 2, 2025

⚠️ No Changeset found

Latest commit: ea8ad31

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 2, 2025

📝 Walkthrough

Walkthrough

Adds a block-height-aware metric and setter to validator submission: introduces latest_checkpoint_observed_block_height (IntGauge), a set_latest_checkpoint_observed(&CheckpointAtBlock) method that updates index and optional block height (with regression warning), and replaces direct index metric sets with the new setter.

Changes

Cohort / File(s) Summary
Validator metrics update
rust/main/agents/validator/src/submit.rs
Added IntGauge latest_checkpoint_observed_block_height; implemented set_latest_checkpoint_observed(&CheckpointAtBlock) to set latest index and, when present, compare/update block height with a regression warning; initialized new gauge in ValidatorSubmitterMetrics::new; replaced direct metric index set with the new setter in submission/backfill flow.

Sequence Diagram(s)

sequenceDiagram
    participant V as ValidatorSubmitter
    participant M as ValidatorSubmitterMetrics

    Note over V: Checkpoint observed (may include block_height)
    V->>M: set_latest_checkpoint_observed(checkpoint)
    activate M
    M->>M: Update latest_checkpoint_observed (index)
    alt block_height present
        M->>M: Compare with previous block_height
        opt regression detected
            Note over M: Log warning on block-height regression
        end
        M->>M: Update latest_checkpoint_observed_block_height
    end
    deactivate M
    Note over V: Continue processing/backfill flow
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • daniel-savu
  • tkporter

Poem

A wee metric wakes in morning mist,
Counts checkpoints true, keeps heights on the list.
If heights slide back, a gruff warning chimes—
Keeps the ledger tidy through swampy times. 🐸

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description only fills the Description and Related issues sections while omitting the Drive-by changes, Backward compatibility, and Testing headings from the repository template, leaving key context and validation details undefined. Please update the description to include Drive-by changes if any minor updates are bundled, confirm backward compatibility or note breaking changes, and detail the testing performed to validate the new metric and warning logic.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly captures the main change by noting the addition of a metric for observed checkpoint block height, reflecting the core functionality introduced in the PR without extraneous detail.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jeff/validator-checkpoint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
rust/main/agents/validator/src/submit.rs (1)

505-528: The regression detection logic is sound.

The warnings fire when either index or block height goes backward - exactly what you'd want for catching reorgs or RPC inconsistencies. The comparison logic handles edge cases properly (initial state, same values, normal increases all work correctly).

One thing: consider adding a doc comment to explain that this method logs warnings when it detects potential reorgs (checkpoint regression). Makes it easier for the next person poking around in here.

Add a doc comment above the method:

+    /// Updates the observed checkpoint metrics.
+    ///
+    /// Logs a warning if the checkpoint index or block height decreases compared to the
+    /// previous observation, which may indicate a reorg or RPC inconsistency.
     fn set_latest_checkpoint_observed(&self, checkpoint: &CheckpointAtBlock) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7ce5a3 and 2a60a86.

📒 Files selected for processing (1)
  • rust/main/agents/validator/src/submit.rs (4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
rust/main/agents/validator/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Maintain validator agent Rust sources under rust/main/agents/validator

Files:

  • rust/main/agents/validator/src/submit.rs
rust/main/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Run cargo clippy for Rust code linting

Files:

  • rust/main/agents/validator/src/submit.rs
🧬 Code graph analysis (1)
rust/main/agents/validator/src/submit.rs (5)
rust/main/hyperlane-base/src/metrics/core.rs (1)
  • latest_checkpoint (550-552)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (2)
  • latest_checkpoint (253-277)
  • block_height (326-331)
rust/main/chains/hyperlane-starknet/src/merkle_tree_hook.rs (1)
  • latest_checkpoint (67-91)
rust/main/hyperlane-core/src/traits/merkle_tree_hook.rs (1)
  • latest_checkpoint (49-50)
rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs (1)
  • latest_checkpoint (31-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: infra-test
  • GitHub Check: build-and-push-to-gcr
  • GitHub Check: e2e-matrix (evm)
  • GitHub Check: e2e-matrix (starknet)
  • GitHub Check: e2e-matrix (cosmwasm)
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: lander-coverage
  • GitHub Check: test-rs
  • GitHub Check: lint-rs
🔇 Additional comments (3)
rust/main/agents/validator/src/submit.rs (3)

478-478: Looks good - proper metric field addition.

The new IntGauge field fits right in with the existing metrics structure.


489-491: Initialization looks solid.

The metric label distinguishes this from the index-based observation, and the initialization pattern matches the rest of the struct.


131-131: Nice encapsulation of the metric update logic.

Moving from direct metric setting to a dedicated method gives you one place to handle both index and block height updates, plus the regression warnings.

@kamiyaa kamiyaa enabled auto-merge October 10, 2025 15:22
@kamiyaa kamiyaa added this pull request to the merge queue Oct 10, 2025
Merged via the queue into main with commit 283b2f0 Oct 10, 2025
39 checks passed
@kamiyaa kamiyaa deleted the jeff/validator-checkpoint branch October 10, 2025 15:39
@github-project-automation github-project-automation Bot moved this from In Review to Done in Hyperlane Tasks Oct 10, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (132bf04) to head (ea8ad31).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #7146   +/-   ##
=====================================
  Coverage   0.00%       0           
=====================================
  Files          1       0    -1     
  Lines         14       0   -14     
=====================================
+ Misses        14       0   -14     
Components Coverage Δ
core ∅ <ø> (∅)
hooks ∅ <ø> (∅)
isms ∅ <ø> (∅)
token ∅ <ø> (∅)
middlewares ∅ <ø> (∅)
🚀 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

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants