Skip to content

Conversation

@kamiyaa
Copy link
Contributor

@kamiyaa kamiyaa commented Oct 15, 2025

Description

  • report reorg if checkpoint index decreased but block height stayed the same or increased

Related issues

Summary by CodeRabbit

  • New Features

    • Persist latest checkpoint index and block height for improved restart reliability and state recovery.
    • Reorg events now include both local and canonical checkpoint indices for clearer diagnostics.
  • Bug Fixes

    • Centralized and strengthened reorg detection/handling with consistent state updates and clearer reporting.
    • Added checkpoint verification and warnings on index/height inconsistencies.
  • Tests

    • Updated mocks and tests to cover storing/retrieving latest checkpoint info and new reorg fields.

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

⚠️ No Changeset found

Latest commit: 0194c6b

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 15, 2025

📝 Walkthrough

Walkthrough

Adds a new public CheckpointInfo type and DB APIs to store/retrieve it, implements them in RocksDB and test mocks, updates ValidatorSubmitter to load/track/persist latest checkpoint info and centralizes reorg detection/reporting, and changes ReorgEvent to carry local vs canonical indices.

Changes

Cohort / File(s) Summary
Core types
rust/main/hyperlane-core/src/types/checkpoint.rs, rust/main/hyperlane-core/src/types/reorg.rs
Introduces public CheckpointInfo { block_height: u64, checkpoint_index: u32 } with Encode/Decode. Modifies ReorgEvent by replacing checkpoint_index with local_checkpoint_index and canonical_checkpoint_index.
DB trait
rust/main/hyperlane-base/src/db/mod.rs
Adds HyperlaneDb trait methods: store_latest_checkpoint_info(&self, &CheckpointInfo) -> DbResult<()> and retrieve_latest_checkpoint_info(&self) -> DbResult<Option<CheckpointInfo>> with doc comments.
RocksDB impl
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs
Adds LATEST_CHECKPOINT_INFO key and implements store_latest_checkpoint_info / retrieve_latest_checkpoint_info using existing store/retrieve-by-key helpers.
Validator submit logic
rust/main/agents/validator/src/submit.rs
Loads persisted latest checkpoint info at startup, tracks latest_seen_checkpoint (index + block height), centralizes reorg detection into panic_with_reorg and report_reorg_with_checkpoint, and persists advances to DB.
Tests & mocks
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
Exposes CheckpointInfo in test imports and extends test/mock HyperlaneDb implementations with the two new methods so tests can stub storage/retrieval of CheckpointInfo.
Settings tests
rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs
Tests updated to construct ReorgEvent with local_checkpoint_index and canonical_checkpoint_index instead of the old single checkpoint_index.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant VS as ValidatorSubmitter
  participant DB as HyperlaneDb
  participant L as Logger

  Note over VS,DB: startup — load persisted latest checkpoint info
  VS->>DB: retrieve_latest_checkpoint_info()
  DB-->>VS: Option<CheckpointInfo>

  Note over VS: on new on-chain checkpoint
  VS->>VS: compare incoming.checkpoint_index vs latest_seen.checkpoint_index
  alt regression (incoming < latest_seen)
    VS->>VS: panic_with_reorg(incoming, latest_seen)
    VS->>L: report_reorg_with_checkpoint(...)
    VS-->>VS: abort/panic
  else advance (incoming > latest_seen)
    VS->>DB: store_latest_checkpoint_info(CheckpointInfo{checkpoint_index, block_height})
    VS->>L: log advancement
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • yjamin
  • ameten

Poem

A wee checkpoint tucked in DB and stone,
Index and height remembered on their own,
If indexes slip and paths are torn,
Helpers cry "Reorg!" before the morn,
Rocks hum true till systems are reborn.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description includes the core change and related issue but omits required template sections for drive-by changes, backward compatibility, and testing. Please fill in the “Drive-by changes,” “Backward compatibility,” and “Testing” sections in the template so reviewers can understand ancillary edits, compatibility implications, and how the change has been validated.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 clearly describes the main new behavior—reporting a reorg when the checkpoint index drops while block height does not—and avoids extraneous detail or noise.
✨ 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-block-height

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d13fbdc and 8dabc84.

📒 Files selected for processing (1)
  • rust/main/agents/validator/src/submit.rs (6 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 (2)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (3)
  • tree (301-311)
  • latest_checkpoint (253-277)
  • block_height (326-331)
rust/main/agents/validator/src/submit/tests.rs (1)
  • verify_checkpoint (587-660)
⏰ 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). (10)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: e2e-matrix (starknet)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (evm)
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: e2e-matrix (cosmwasm)
  • GitHub Check: lint-rs
  • GitHub Check: test-rs
  • GitHub Check: lander-coverage
  • GitHub Check: build-and-push-to-gcr
🔇 Additional comments (4)
rust/main/agents/validator/src/submit.rs (4)

19-20: Imports look good.

The new types support the checkpoint verification and reorg detection features.


268-276: Nice consolidation.

Moving reorg handling into a shared helper keeps things tidy and consistent.


340-374: Solid reorg handling consolidation.

Centralizing the reorg response logic makes it easier to maintain and ensures consistent behavior across different detection points.


376-387: Good fallback strategy.

Using block height when available and falling back to reorg period for chains that don't support it is the right approach.


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.

@codecov
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

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

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

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc53c7e and 43ddb1f.

📒 Files selected for processing (6)
  • rust/main/agents/relayer/src/msg/db_loader.rs (1 hunks)
  • rust/main/agents/relayer/src/msg/pending_message.rs (1 hunks)
  • rust/main/agents/validator/src/submit.rs (5 hunks)
  • rust/main/agents/validator/src/submit/tests.rs (1 hunks)
  • rust/main/hyperlane-base/src/db/mod.rs (1 hunks)
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
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/agents/validator/src/submit/tests.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
  • rust/main/agents/validator/src/submit/tests.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/relayer/src/msg/pending_message.rs
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-base/src/db/mod.rs
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.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/relayer/src/msg/pending_message.rs
🧬 Code graph analysis (6)
rust/main/agents/validator/src/submit.rs (3)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (3)
  • latest_checkpoint (253-277)
  • block_height (326-331)
  • tree (301-311)
rust/main/chains/hyperlane-starknet/src/merkle_tree_hook.rs (3)
  • latest_checkpoint (67-91)
  • tree (95-130)
  • tree (107-111)
rust/main/hyperlane-core/src/traits/merkle_tree_hook.rs (2)
  • latest_checkpoint (49-50)
  • tree (37-37)
rust/main/agents/validator/src/submit/tests.rs (2)
rust/main/hyperlane-base/src/db/mod.rs (4)
  • store_latest_checkpoint_block_height (178-178)
  • retrieve_latest_checkpoint_block_height (180-180)
  • store_latest_checkpoint_index (183-183)
  • retrieve_latest_checkpoint_index (185-185)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (4)
  • store_latest_checkpoint_block_height (704-710)
  • retrieve_latest_checkpoint_block_height (711-713)
  • store_latest_checkpoint_index (715-717)
  • retrieve_latest_checkpoint_index (718-720)
rust/main/hyperlane-base/src/db/mod.rs (1)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (4)
  • store_latest_checkpoint_block_height (704-710)
  • retrieve_latest_checkpoint_block_height (711-713)
  • store_latest_checkpoint_index (715-717)
  • retrieve_latest_checkpoint_index (718-720)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (1)
rust/main/hyperlane-base/src/db/mod.rs (4)
  • store_latest_checkpoint_block_height (178-178)
  • retrieve_latest_checkpoint_block_height (180-180)
  • store_latest_checkpoint_index (183-183)
  • retrieve_latest_checkpoint_index (185-185)
rust/main/agents/relayer/src/msg/db_loader.rs (2)
rust/main/hyperlane-base/src/db/mod.rs (4)
  • store_latest_checkpoint_block_height (178-178)
  • retrieve_latest_checkpoint_block_height (180-180)
  • store_latest_checkpoint_index (183-183)
  • retrieve_latest_checkpoint_index (185-185)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (4)
  • store_latest_checkpoint_block_height (704-710)
  • retrieve_latest_checkpoint_block_height (711-713)
  • store_latest_checkpoint_index (715-717)
  • retrieve_latest_checkpoint_index (718-720)
rust/main/agents/relayer/src/msg/pending_message.rs (2)
rust/main/hyperlane-base/src/db/mod.rs (4)
  • store_latest_checkpoint_block_height (178-178)
  • retrieve_latest_checkpoint_block_height (180-180)
  • store_latest_checkpoint_index (183-183)
  • retrieve_latest_checkpoint_index (185-185)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (4)
  • store_latest_checkpoint_block_height (704-710)
  • retrieve_latest_checkpoint_block_height (711-713)
  • store_latest_checkpoint_index (715-717)
  • retrieve_latest_checkpoint_index (718-720)
⏰ 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). (51)
  • GitHub Check: infra-test
  • GitHub Check: cli-evm-e2e-matrix (warp-read)
  • GitHub Check: env-test-matrix (mainnet3, inevm, igp)
  • GitHub Check: cli-evm-e2e-matrix (warp-send)
  • GitHub Check: cli-evm-e2e-matrix (warp-extend-config)
  • GitHub Check: env-test-matrix (mainnet3, ethereum, core)
  • GitHub Check: env-test-matrix (testnet4, sepolia, core)
  • GitHub Check: env-test-matrix (mainnet3, inevm, core)
  • GitHub Check: env-test-matrix (mainnet3, ethereum, igp)
  • GitHub Check: env-test-matrix (mainnet3, arbitrum, core)
  • GitHub Check: env-test-matrix (mainnet3, optimism, igp)
  • GitHub Check: cli-evm-e2e-matrix (warp-deploy)
  • GitHub Check: env-test-matrix (mainnet3, arbitrum, igp)
  • GitHub Check: cli-evm-e2e-matrix (warp-extend-recovery)
  • GitHub Check: cli-evm-e2e-matrix (warp-check-3)
  • GitHub Check: env-test-matrix (mainnet3, optimism, core)
  • GitHub Check: cli-evm-e2e-matrix (warp-check-2)
  • GitHub Check: cli-evm-e2e-matrix (warp-extend-basic)
  • GitHub Check: cli-evm-e2e-matrix (warp-init)
  • GitHub Check: cli-evm-e2e-matrix (warp-rebalancer)
  • GitHub Check: cli-evm-e2e-matrix (warp-bridge-2)
  • GitHub Check: cli-evm-e2e-matrix (warp-bridge-1)
  • GitHub Check: cli-evm-e2e-matrix (core-init)
  • GitHub Check: cli-evm-e2e-matrix (warp-apply-2)
  • GitHub Check: cli-evm-e2e-matrix (core-read)
  • GitHub Check: cli-evm-e2e-matrix (warp-check-1)
  • GitHub Check: cli-evm-e2e-matrix (warp-apply-submitters)
  • GitHub Check: cli-evm-e2e-matrix (core-check)
  • GitHub Check: cli-evm-e2e-matrix (core-apply)
  • GitHub Check: cli-evm-e2e-matrix (relay)
  • GitHub Check: cli-evm-e2e-matrix (warp-apply-1)
  • GitHub Check: cli-evm-e2e-matrix (core-deploy)
  • GitHub Check: cli-cross-chain-e2e-matrix (warp-apply)
  • GitHub Check: cli-cross-chain-e2e-matrix (warp-deploy)
  • GitHub Check: cosmos-sdk-e2e-run
  • GitHub Check: cli-cosmos-e2e-matrix (core-apply)
  • GitHub Check: cli-cosmos-e2e-matrix (warp-read)
  • GitHub Check: cli-cosmos-e2e-matrix (core-read)
  • GitHub Check: cli-cosmos-e2e-matrix (core-deploy)
  • GitHub Check: cli-cosmos-e2e-matrix (warp-deploy)
  • GitHub Check: cli-cosmos-e2e-matrix (core-check)
  • GitHub Check: build-and-push-to-gcr
  • GitHub Check: lander-coverage
  • GitHub Check: lint-rs
  • GitHub Check: test-rs
  • GitHub Check: e2e-matrix (starknet)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (evm)
  • GitHub Check: e2e-matrix (cosmwasm)

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43ddb1f and 50aae97.

📒 Files selected for processing (5)
  • rust/main/agents/relayer/src/msg/db_loader.rs (1 hunks)
  • rust/main/agents/relayer/src/msg/pending_message.rs (1 hunks)
  • rust/main/agents/validator/src/submit.rs (5 hunks)
  • rust/main/agents/validator/src/submit/tests.rs (1 hunks)
  • rust/main/hyperlane-base/src/db/mod.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • rust/main/agents/relayer/src/msg/pending_message.rs
  • rust/main/agents/validator/src/submit/tests.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-base/src/db/mod.rs
rust/main/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Run cargo clippy for Rust code linting

Files:

  • rust/main/hyperlane-base/src/db/mod.rs
  • rust/main/agents/relayer/src/msg/db_loader.rs
  • rust/main/agents/validator/src/submit.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.rs
🧬 Code graph analysis (3)
rust/main/hyperlane-base/src/db/mod.rs (1)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (4)
  • store_latest_checkpoint_block_height (704-710)
  • retrieve_latest_checkpoint_block_height (711-713)
  • store_latest_checkpoint_index (715-717)
  • retrieve_latest_checkpoint_index (718-720)
rust/main/agents/relayer/src/msg/db_loader.rs (2)
rust/main/hyperlane-base/src/db/mod.rs (4)
  • store_latest_checkpoint_block_height (178-178)
  • retrieve_latest_checkpoint_block_height (180-180)
  • store_latest_checkpoint_index (183-183)
  • retrieve_latest_checkpoint_index (185-185)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (4)
  • store_latest_checkpoint_block_height (704-710)
  • retrieve_latest_checkpoint_block_height (711-713)
  • store_latest_checkpoint_index (715-717)
  • retrieve_latest_checkpoint_index (718-720)
rust/main/agents/validator/src/submit.rs (3)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (3)
  • latest_checkpoint (253-277)
  • block_height (326-331)
  • tree (301-311)
rust/main/chains/hyperlane-starknet/src/merkle_tree_hook.rs (3)
  • latest_checkpoint (67-91)
  • tree (95-130)
  • tree (107-111)
rust/main/hyperlane-core/src/traits/merkle_tree_hook.rs (2)
  • latest_checkpoint (49-50)
  • tree (37-37)
🔇 Additional comments (6)
rust/main/agents/relayer/src/msg/db_loader.rs (1)

740-749: Mock methods match the trait interface.

The four checkpoint persistence methods are properly declared in the mock, following the existing mockall pattern. These'll work just fine for testing the new checkpoint tracking behavior.

rust/main/agents/validator/src/submit.rs (5)

141-162: Reorg detection logic looks solid.

The check catches the case where the checkpoint index goes backwards but the block height doesn't - that's exactly what we're after. The nested conditionals make sense since not all chains provide block_height.


164-194: Checkpoint persistence addresses the previous review.

Good work persisting both index and block_height after updates. The in-memory state stays consistent, and we'll still detect reorgs on the next loop even if the writes fail. The error logs give us visibility into storage issues without crashing the validator.

Based on learnings (past review comment).


307-316: Clean refactor to use the new helper.

Consolidating the reorg panic logic here makes sense. All the necessary context is passed through properly.


339-385: Helpers centralize reorg handling nicely.

The panic_with_reorg function pulls together all the reorg response logic in one spot - building the event, logging, reporting, and writing status. The report_reorg_with_checkpoint helper handles the block-height-or-period decision cleanly. These make the code easier to follow and maintain.


121-130: Verify logging of DB retrieval failures: at lines 121–130 we call retrieve_latest_checkpoint_index() and retrieve_latest_checkpoint_block_height() then unwrap_or_default(), which swallows errors and defaults to 0; log or propagate failures so we don’t silently reset our checkpoint state.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70675c4 and 5822932.

📒 Files selected for processing (9)
  • rust/main/agents/relayer/src/msg/db_loader.rs (2 hunks)
  • rust/main/agents/relayer/src/msg/pending_message.rs (1 hunks)
  • rust/main/agents/validator/src/submit.rs (5 hunks)
  • rust/main/agents/validator/src/submit/tests.rs (3 hunks)
  • rust/main/hyperlane-base/src/db/mod.rs (2 hunks)
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (3 hunks)
  • rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs (1 hunks)
  • rust/main/hyperlane-core/src/types/checkpoint.rs (2 hunks)
  • rust/main/hyperlane-core/src/types/reorg.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • rust/main/agents/relayer/src/msg/db_loader.rs
  • rust/main/hyperlane-base/src/db/rocks/hyperlane_db.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/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/agents/relayer/src/msg/pending_message.rs
  • rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs
  • rust/main/agents/validator/src/submit/tests.rs
  • rust/main/agents/validator/src/submit.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/pending_message.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
🧬 Code graph analysis (6)
rust/main/hyperlane-core/src/types/checkpoint.rs (1)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (1)
  • block_height (326-331)
rust/main/hyperlane-base/src/db/mod.rs (1)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (2)
  • store_latest_checkpoint_info (703-705)
  • retrieve_latest_checkpoint_info (706-708)
rust/main/agents/relayer/src/msg/pending_message.rs (2)
rust/main/hyperlane-base/src/db/mod.rs (2)
  • store_latest_checkpoint_info (178-178)
  • retrieve_latest_checkpoint_info (180-180)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (2)
  • store_latest_checkpoint_info (703-705)
  • retrieve_latest_checkpoint_info (706-708)
rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs (1)
rust/main/hyperlane-core/src/chain.rs (1)
  • from_blocks (53-57)
rust/main/agents/validator/src/submit/tests.rs (3)
rust/main/hyperlane-core/src/test_utils.rs (1)
  • dummy_domain (44-53)
rust/main/hyperlane-base/src/db/mod.rs (2)
  • store_latest_checkpoint_info (178-178)
  • retrieve_latest_checkpoint_info (180-180)
rust/main/hyperlane-base/src/db/rocks/hyperlane_db.rs (2)
  • store_latest_checkpoint_info (703-705)
  • retrieve_latest_checkpoint_info (706-708)
rust/main/agents/validator/src/submit.rs (4)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (3)
  • block_height (326-331)
  • latest_checkpoint (253-277)
  • tree (301-311)
rust/main/chains/hyperlane-starknet/src/merkle_tree_hook.rs (3)
  • latest_checkpoint (67-91)
  • tree (95-130)
  • tree (107-111)
rust/main/chains/hyperlane-sealevel/src/merkle_tree_hook.rs (2)
  • latest_checkpoint (31-41)
  • tree (20-27)
rust/main/hyperlane-core/src/traits/merkle_tree_hook.rs (2)
  • latest_checkpoint (49-50)
  • tree (37-37)
⏰ 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: lander-coverage
  • GitHub Check: lint-rs
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: test-rs
  • GitHub Check: e2e-matrix (cosmwasm)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: e2e-matrix (evm)
  • GitHub Check: e2e-matrix (starknet)
🔇 Additional comments (11)
rust/main/hyperlane-core/src/types/reorg.rs (1)

13-16: LGTM! Field renaming clarifies local vs. canonical perspective.

Splitting checkpoint_index into local_checkpoint_index and canonical_checkpoint_index makes it clear which checkpoint index we're talking about. The comments match up nicely too.

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

210-221: Test updates look solid.

The test now uses local_checkpoint_index and canonical_checkpoint_index, matching the updated ReorgEvent structure. Variable names are clear and consistent.

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

1206-1207: Mock methods properly extend the test harness.

These additions align with the new CheckpointInfo storage methods added to the HyperlaneDb trait. Test-only, no impact on production.

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

177-180: Trait extension looks good.

The new store_latest_checkpoint_info and retrieve_latest_checkpoint_info methods follow the existing DB trait patterns. Doc comments are clear and accurate.

rust/main/hyperlane-core/src/types/checkpoint.rs (2)

122-135: Decode implementation follows the pattern correctly.

The deserialization order (checkpoint_index first, then block_height) matches the serialization order in the Encode implementation. Error propagation using ? is appropriate.


111-120: Keep saturating_add for byte counting
The swamp’s Encode implementations consistently use saturating_add to aggregate written bytes; switching to checked_add would diverge from project conventions.

Likely an incorrect or invalid review comment.

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

135-136: Mock DB methods properly implemented.

These methods complete the test harness for the new CheckpointInfo storage functionality.


225-236: Test assertions updated correctly.

The assertions now check canonical_checkpoint_index against the on-chain merkle tree index (lines 225-228) and local_checkpoint_index against the expected local tree (line 234). This aligns with the new ReorgEvent structure.

rust/main/agents/validator/src/submit.rs (3)

121-125: Database initialization looks good.

Loading the latest checkpoint info from the DB with a sensible default fallback is the right approach. This lets the validator resume from where it left off.


315-349: Helper method centralizes reorg handling nicely.

The panic_with_reorg method consolidates reorg event construction, logging, reporting, and checkpoint syncer updates in one place. Clean separation of concerns.


351-362: Reporting helper handles block height availability gracefully.

Using block height when available, falling back to reorg period otherwise, is a pragmatic approach for chains that don't support block height queries.

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

♻️ Duplicate comments (1)
rust/main/agents/validator/src/submit.rs (1)

174-190: Missing persistence after checkpoint update.

The checkpoint fields get updated in memory, but there's no call to persist them back to the DB. After a restart, you're back to comparing against whatever was there before—or defaults if nothing was stored. That means a reorg that happened while things were down won't ring any bells.

Add persistence right after updating the fields:

                 latest_seen_checkpoint.block_height = block_height;
                 latest_seen_checkpoint.checkpoint_index = latest_checkpoint.index;
+                
+                if let Err(err) = self
+                    .db
+                    .store_latest_checkpoint_info(&latest_seen_checkpoint)
+                {
+                    tracing::warn!(
+                        ?err,
+                        ?latest_seen_checkpoint,
+                        "Failed to persist latest checkpoint info"
+                    );
+                }
             }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c88f7ce and d13fbdc.

📒 Files selected for processing (2)
  • rust/main/agents/validator/src/submit.rs (6 hunks)
  • rust/main/agents/validator/src/submit/tests.rs (10 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • rust/main/agents/validator/src/submit/tests.rs
🧰 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 (4)
rust/main/chains/hyperlane-starknet/src/merkle_tree_hook.rs (3)
  • tree (95-130)
  • tree (107-111)
  • latest_checkpoint (67-91)
rust/main/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs (3)
  • tree (301-311)
  • latest_checkpoint (253-277)
  • block_height (326-331)
rust/main/hyperlane-core/src/traits/merkle_tree_hook.rs (2)
  • tree (37-37)
  • latest_checkpoint (49-50)
rust/main/agents/validator/src/submit/tests.rs (1)
  • verify_checkpoint (587-660)
⏰ 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). (6)
  • GitHub Check: e2e-matrix (radix)
  • GitHub Check: e2e-matrix (starknet)
  • GitHub Check: e2e-matrix (cosmosnative)
  • GitHub Check: e2e-matrix (cosmwasm)
  • GitHub Check: e2e-matrix (sealevel)
  • GitHub Check: e2e-matrix (evm)
🔇 Additional comments (6)
rust/main/agents/validator/src/submit.rs (6)

19-20: Import changes look solid.

The CheckpointInfo addition supports the new checkpoint tracking, and the reorg handling setup is clean.


122-126: Neat handling of the DB retrieval.

The double unwrap_or_default covers both the retrieval error and the missing data cases cleanly. This'll keep things rolling even when the DB's empty or having a bad day.


137-138: Good call extracting the verification.

Moving this logic into its own helper keeps the main loop from getting too swampy. Nice and tidy.


268-277: Centralizing the reorg handling makes sense.

Moving this into panic_with_reorg keeps the error handling consistent and cuts down on repeated code. Much better than having it scattered around.


340-374: Solid consolidation of the reorg panic path.

Bringing all the reorg handling into one place keeps things consistent. The error messages are clear about what went wrong, and you're handling the write_reorg_status failure gracefully by appending it to the panic message. Good stuff.


376-387: Clean separation for the reporting logic.

Handling both block-height-based and reorg-period-based reporting in one helper keeps things flexible. The fallback with the log message is a nice touch for when block height isn't available.

@kamiyaa kamiyaa requested a review from ameten October 17, 2025 13:53
@kamiyaa kamiyaa enabled auto-merge October 21, 2025 13:20
@kamiyaa kamiyaa added this pull request to the merge queue Oct 21, 2025
Merged via the queue into main with commit 8fc8325 Oct 21, 2025
39 checks passed
@kamiyaa kamiyaa deleted the jeff/validator-block-height branch October 21, 2025 13:50
@github-project-automation github-project-automation bot moved this from In Review to Done in Hyperlane Tasks Oct 21, 2025
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