feat: add metric for observed block height of checkpoints#7146
Conversation
- log warning when the block height decreases in height
|
📝 WalkthroughWalkthroughAdds a block-height-aware metric and setter to validator submission: introduces Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 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
IntGaugefield 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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
Description
Related issues
Summary by CodeRabbit
New Features
Refactor
Chores