Skip to content

Conversation

@kamiyaa
Copy link
Contributor

@kamiyaa kamiyaa commented Oct 23, 2025

Reverts #7212

Summary by CodeRabbit

  • Refactoring
    • Simplified checkpoint index tracking in reorg event structure by consolidating duplicate fields.
    • Removed checkpoint persistence APIs from the database layer.
    • Streamlined reorg detection and reporting flow in the validator.

@linear
Copy link

linear bot commented Oct 23, 2025

@changeset-bot
Copy link

changeset-bot bot commented Oct 23, 2025

⚠️ No Changeset found

Latest commit: 76453e1

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
Contributor

coderabbitai bot commented Oct 23, 2025

📝 Walkthrough

Walkthrough

This PR simplifies checkpoint handling by removing the CheckpointInfo type entirely and eliminating checkpoint persistence APIs from the HyperlaneDb trait. The ReorgEvent struct is refactored to use a single checkpoint_index field instead of separate local and canonical indices. Checkpoint verification logic in the validator is reorganized with inline error handling replacing helper functions.

Changes

Cohort / File(s) Summary
Checkpoint API removal (trait & implementations)
rust/main/hyperlane-base/src/db/mod.rs, rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs
Removed store_latest_checkpoint_info() and retrieve_latest_checkpoint_info() methods from HyperlaneDb trait; removed CheckpointInfo re-export and LATEST_CHECKPOINT_INFO constant from implementation.
Checkpoint type removal
rust/main/hyperlane-core/src/types/checkpoint.rs
Deleted CheckpointInfo struct and its Encode/Decode trait implementations entirely.
ReorgEvent refactoring
rust/main/hyperlane-core/src/types/reorg.rs
Consolidated local_checkpoint_index and canonical_checkpoint_index fields into single checkpoint_index field with updated documentation.
Validator submission changes
rust/main/agents/validator/src/submit.rs
Removed checkpoint verification functions (verify_checkpoint, panic_with_reorg, report_reorg_with_checkpoint) and latest checkpoint tracking; replaced with inline reorg event creation and error handling.
Test mock updates
rust/main/agents/relayer/src/msg/db_loader.rs, rust/main/agents/relayer/src/msg/pending_message.rs, rust/main/agents/validator/src/submit/tests.rs
Removed checkpoint-related trait methods from all test mocks; updated checkpoint field references in ReorgEvent instantiations and variable naming.
Checkpoint syncer tests
rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs
Updated test ReorgEvent construction to use single checkpoint_index field instead of separate local/canonical indices.

Sequence Diagram(s)

sequenceDiagram
    participant Validator as Validator Submit
    participant Reporter as Reorg Reporter
    participant Storage as Checkpoint Storage
    
    Note over Validator: Before: verify_checkpoint phase
    Validator->>Storage: retrieve_latest_checkpoint_info()
    Storage-->>Validator: CheckpointInfo
    Note over Validator: After: inline handling
    Validator->>Validator: Create ReorgEvent(checkpoint_index)
    Validator->>Validator: Log error
    alt Mismatch detected
        Validator->>Reporter: report_reorg(height or period)
        Validator->>Storage: write reorg status
        Storage-->>Validator: result
        alt Write fails
            Validator->>Validator: panic with message
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The changes span multiple files with varied modifications: type removal, trait API simplification, struct field consolidation, and control flow reorganization in the validator. The changes are mostly cohesive in purpose (checkpoint simplification) but require separate reasoning for each file's context, particularly the validator's refactored error-handling logic. Test updates are largely mechanical (variable renames, mock adjustments) but contribute to overall complexity.

Possibly related PRs

Suggested reviewers

  • ameten
  • yjamin

Poem

🟢 Like layers in an ogre's realm, we peeled back the excess—
Two checkpoint fields collapsed to one, the code now confess.
No more storing whispers in the stone, just the moment caught,
Reorg detection, lean and keen, is all we've got.
Simpler paths, like swamps at dawn, no helpers needed here! 🧅

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description provided is "Reverts #7212," which is extremely minimal and does not follow the repository's description template. The description fails to include the required sections: it lacks details about what's included in the revert, does not address drive-by changes, provides no explicit backward compatibility assessment, and includes no information about testing. While the description does reference the related PR number, this single sentence falls far short of the template's expectations for a complete pull request description and leaves reviewers without crucial context about the scope and implications of the revert.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title Check ✅ Passed The title "fix: Revert 'feat: report reorg if checkpoint index decreased but block height stayed the same or increased'" directly and specifically describes what this PR does. The changeset shows a systematic removal of checkpoint verification logic, elimination of the CheckpointInfo struct, removal of helper functions like verify_checkpoint, and restructuring of the ReorgEvent fields—all consistent with reverting that specific feature. The title is clear and specific enough that someone glancing at the commit history would immediately understand this is a revert of PR #7212, not a vague or misleading statement.
✨ 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 revert-7212-jeff/validator-block-height

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
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
rust/main/agents/relayer/src/msg/db_loader.rs (1)

55-66: Bug: wrong type passed to DirectionalNonceIterator::new (u32.into() vs Option)

unwrap_or_default().into() yields a u32, not an Option<u32>. This won’t compile. Wrap explicitly.

Apply one of these minimal fixes:

-        let high_nonce_iter = DirectionalNonceIterator::new(
-            // If the high nonce is None, we start from the beginning
-            high_nonce.unwrap_or_default().into(),
+        let high_nonce_iter = DirectionalNonceIterator::new(
+            // If the high nonce is None, we start from the beginning (nonce = 0)
+            high_nonce.or(Some(0)),
             NonceDirection::High,
             db.clone(),
             domain.clone(),
         );

Alternative:

-            high_nonce.unwrap_or_default().into(),
+            Some(high_nonce.unwrap_or_default()),
rust/main/agents/validator/src/submit/tests.rs (1)

573-573: Align expected log text with implementation

Code logs “different values, overwriting”, not “different signature”. Update the assertion so the test stops bellyaching.

-    logs_contain("Checkpoint already submitted, but with different signature, overwriting");
+    logs_contain("Checkpoint already submitted, but with different values, overwriting");
🧹 Nitpick comments (3)
rust/main/agents/validator/src/submit.rs (1)

264-275: Enrich panic context (indices) for faster ops triage

Include local vs correctness indices in the panic to cut through the muck during incidents. Optional, but helpful.

-            let mut panic_message = "Incorrect tree root. Most likely a reorg has occurred. Please reach out for help, this is a potentially serious error impacting signed messages. Do NOT forcefully resume operation of this validator. Keep it crashlooping or shut down until you receive support.".to_owned();
+            let mut panic_message = format!(
+                "Incorrect tree root (local idx {}, correctness idx {}). Most likely a reorg has occurred. Please reach out for help, this is a potentially serious error impacting signed messages. Do NOT forcefully resume operation of this validator. Keep it crashlooping or shut down until you receive support.",
+                checkpoint.index,
+                correctness_checkpoint.index
+            );
rust/main/agents/validator/src/submit/tests.rs (2)

244-251: Fix repeated typo: merke → merkle

Minor clean-up; makes the tests easier to read.

-    let pre_reorg_merke_insertions = [
+    let pre_reorg_merkle_insertions = [
@@
-    for insertion in pre_reorg_merke_insertions.iter() {
+    for insertion in pre_reorg_merkle_insertions.iter() {
@@
-        pre_reorg_merke_insertions[0],
-        pre_reorg_merke_insertions[1],
+        pre_reorg_merkle_insertions[0],
+        pre_reorg_merkle_insertions[1],
@@
-        .returning(move |sequence| Ok(Some(pre_reorg_merke_insertions[*sequence as usize])));
+        .returning(move |sequence| Ok(Some(pre_reorg_merkle_insertions[*sequence as usize])));
@@
-    let pre_reorg_merke_insertions = [
+    let pre_reorg_merkle_insertions = [
@@
-    for insertion in pre_reorg_merke_insertions.iter() {
+    for insertion in pre_reorg_merkle_insertions.iter() {
@@
-        pre_reorg_merke_insertions[0],
-        pre_reorg_merke_insertions[1],
+        pre_reorg_merkle_insertions[0],
+        pre_reorg_merkle_insertions[1],
@@
-        .returning(move |sequence| Ok(Some(pre_reorg_merke_insertions[*sequence as usize])));
+        .returning(move |sequence| Ok(Some(pre_reorg_merkle_insertions[*sequence as usize])));
@@
-    let pre_reorg_merke_insertions = [
+    let pre_reorg_merkle_insertions = [
@@
-    for insertion in pre_reorg_merke_insertions.iter() {
+    for insertion in pre_reorg_merkle_insertions.iter() {
@@
-        pre_reorg_merke_insertions[0],
-        pre_reorg_merke_insertions[1],
+        pre_reorg_merkle_insertions[0],
+        pre_reorg_merkle_insertions[1],
@@
-        .returning(move |sequence| Ok(Some(pre_reorg_merke_insertions[*sequence as usize])));
+        .returning(move |sequence| Ok(Some(pre_reorg_merkle_insertions[*sequence as usize])));

Also applies to: 256-257, 274-274, 357-364, 369-371, 387-387, 462-469, 474-476, 492-492


230-231: Deflake timestamp assertion

The 1‑second window is tight and can flake under load. Widen slightly.

-    assert!(timestamp_diff.abs() < 1);
+    assert!(timestamp_diff.abs() <= 2);

If you want me to verify flakiness locally with a stress loop, I can script it.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21532b6 and 76453e1.

📒 Files selected for processing (9)
  • rust/main/agents/relayer/src/msg/db_loader.rs (1 hunks)
  • rust/main/agents/relayer/src/msg/pending_message.rs (0 hunks)
  • rust/main/agents/validator/src/submit.rs (2 hunks)
  • rust/main/agents/validator/src/submit/tests.rs (8 hunks)
  • rust/main/hyperlane-base/src/db/mod.rs (1 hunks)
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (1 hunks)
  • rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs (1 hunks)
  • rust/main/hyperlane-core/src/types/checkpoint.rs (1 hunks)
  • rust/main/hyperlane-core/src/types/reorg.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • rust/main/agents/relayer/src/msg/pending_message.rs
🧰 Additional context used
📓 Path-based instructions (4)
rust/main/{hyperlane-core,hyperlane-base}/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Keep shared Rust core crates in rust/main/{hyperlane-core,hyperlane-base}

Files:

  • rust/main/hyperlane-core/src/types/checkpoint.rs
  • rust/main/hyperlane-base/src/db/mod.rs
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs
  • rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs
  • rust/main/hyperlane-core/src/types/reorg.rs
rust/main/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Run cargo clippy for Rust code linting

Files:

  • rust/main/hyperlane-core/src/types/checkpoint.rs
  • rust/main/hyperlane-base/src/db/mod.rs
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs
  • rust/main/agents/relayer/src/msg/db_loader.rs
  • rust/main/agents/validator/src/submit/tests.rs
  • rust/main/agents/validator/src/submit.rs
  • rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs
  • rust/main/hyperlane-core/src/types/reorg.rs
rust/main/agents/relayer/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • rust/main/agents/relayer/src/msg/db_loader.rs
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/tests.rs
  • rust/main/agents/validator/src/submit.rs
🧠 Learnings (1)
📚 Learning: 2025-09-02T18:44:06.598Z
Learnt from: CR
PR: hyperlane-xyz/hyperlane-monorepo#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-02T18:44:06.598Z
Learning: Applies to rust/main/chains/{hyperlane-ethereum,hyperlane-cosmos,hyperlane-sealevel,hyperlane-fuel}/**/src/**/*.rs : Keep chain support implementations within rust/main/chains/{hyperlane-ethereum,hyperlane-cosmos,hyperlane-sealevel,hyperlane-fuel}

Applied to files:

  • rust/main/agents/validator/src/submit/tests.rs
🧬 Code graph analysis (4)
rust/main/agents/relayer/src/msg/db_loader.rs (1)
rust/main/hyperlane-core/src/test_utils.rs (1)
  • dummy_domain (44-53)
rust/main/agents/validator/src/submit/tests.rs (2)
rust/main/hyperlane-core/src/test_utils.rs (1)
  • dummy_domain (44-53)
rust/main/agents/validator/src/submit.rs (2)
  • new (42-66)
  • new (485-499)
rust/main/agents/validator/src/submit.rs (4)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (1)
  • tree (301-311)
rust/main/chains/hyperlane-starknet/src/merkle_tree_hook.rs (2)
  • tree (95-130)
  • tree (107-111)
rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs (1)
  • tree (20-27)
rust/main/hyperlane-core/src/traits/merkle_tree_hook.rs (1)
  • tree (37-37)
rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs (1)
rust/main/hyperlane-core/src/chain.rs (1)
  • from_blocks (53-57)
⏰ 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 (cosmwasm)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (starknet)
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: e2e-matrix (evm)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: test-rs
  • GitHub Check: lint-rs
  • GitHub Check: lander-coverage
🔇 Additional comments (7)
rust/main/hyperlane-core/src/types/checkpoint.rs (1)

7-7: LGTM on the import shift

Dropping CheckpointInfo dependencies here aligns with the revert. No functional changes to signing hash. Smells right.

rust/main/agents/relayer/src/msg/db_loader.rs (1)

425-426: Import tweak is fine

Bringing in UniqueIdentifier fits the mock API changes. No ogre-sized concerns.

rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs (1)

210-217: Test update to checkpoint_index looks correct

Switch to the unified checkpoint_index field is consistent with the core type change; the rest of the struct fields stay intact.

Please run tests touching ReorgEvent to confirm no stale field names remain.

rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (1)

8-12: Imports aligned with encode/decode helpers

Adding Encode/Decode and UniqueIdentifier matches usage below. All good from the bog.

rust/main/hyperlane-base/src/db/mod.rs (1)

6-8: Import cleanup verified clean

The sweep turned up nothin'—no stragglers lurking about. All those checkpoint-related types got properly removed, no loose ends left in the swamp. The import realignment is solid and complete.

rust/main/hyperlane-core/src/types/reorg.rs (1)

13-15: Docs and field rename look good

Single checkpoint_index is clearer and matches validator usage. Smells fresh.

rust/main/agents/validator/src/submit/tests.rs (1)

226-227: Assertion update matches new API

Using reorg_event.checkpoint_index is correct here.

@kamiyaa kamiyaa enabled auto-merge October 23, 2025 19:55
@ameten ameten changed the title Revert "feat: report reorg if checkpoint index decreased but block height stayed the same or increased" fix: Revert "feat: report reorg if checkpoint index decreased but block height stayed the same or increased" Oct 23, 2025
@kamiyaa kamiyaa added this pull request to the merge queue Oct 23, 2025
Merged via the queue into main with commit 3c84b8b Oct 23, 2025
39 of 41 checks passed
@kamiyaa kamiyaa deleted the revert-7212-jeff/validator-block-height branch October 23, 2025 20:19
@github-project-automation github-project-automation bot moved this from In Review to Done in Hyperlane Tasks Oct 23, 2025
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

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

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #7252   +/-   ##
=====================================
  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

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants