Skip to content

feat: forest-tool db import-tipset-lookup - #7426

Merged
hanabi1224 merged 4 commits into
mainfrom
hm/forest-tool-db-import-tipset-lookup
Jul 30, 2026
Merged

feat: forest-tool db import-tipset-lookup#7426
hanabi1224 merged 4 commits into
mainfrom
hm/forest-tool-db-import-tipset-lookup

Conversation

@hanabi1224

@hanabi1224 hanabi1224 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • This pull request is based on an issue that a maintainer has accepted (see Before Opening a Pull Request).
  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • New Features
    • Added the forest-tool db import-tipset-lookup command to import and validate tipset lookup snapshots, with clearer loading output and improved import progress.
  • Bug Fixes
    • Improved missing-tipset errors by including the specific required tipset key in the message.
  • Documentation
    • Updated the unreleased changelog and generated CLI reference docs for the new command.
  • Tests
    • Added an end-to-end check to ensure the generated tipset-lookup snapshot can be imported into the database.
  • API Improvements
    • Exposed direct access to the stored CARv1 header via new header_v1 accessors.

@hanabi1224 hanabi1224 added the Snapshot Run snapshot tests label Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c8979103-438e-4539-bf04-2c7bd97b9996

📥 Commits

Reviewing files that changed from the base of the PR and between 8f0d419 and 36a0812.

📒 Files selected for processing (1)
  • src/tool/subcommands/db_cmd.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tool/subcommands/db_cmd.rs

Walkthrough

Adds forest-tool db import-tipset-lookup, CARv1 header accessors, HAMT entry validation and database import logic, CLI documentation generation, changelog coverage, and calibnet import verification.

Changes

Tipset lookup snapshot import

Layer / File(s) Summary
CAR header access
src/db/car/any.rs, src/db/car/plain.rs
Adds header_v1 accessors for AnyCar and PlainCar.
Import command and validation
src/tool/subcommands/db_cmd.rs, src/blocks/tipset.rs
Adds the ImportTipsetLookup command, validates referenced tipset epochs before writing mappings, imports entries with progress reporting, and includes the missing TipsetKey in load errors.
Import documentation and verification
docs/docs/users/reference/cli.sh, CHANGELOG.md, scripts/tests/calibnet_export_check.sh
Generates CLI documentation, records the command in the changelog, and verifies snapshot import on calibnet.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ForestTool as forest-tool db import-tipset-lookup
  participant AnyCar
  participant Tipset
  participant Database
  ForestTool->>AnyCar: Load tipset lookup HAMT snapshot
  AnyCar-->>ForestTool: Return HAMT entries
  ForestTool->>Tipset: Load referenced tipsets
  Tipset-->>ForestTool: Return tipset epochs
  ForestTool->>Database: Store validated tipset keys by epoch
Loading

Suggested reviewers: akaladarshi, sudo-shashank

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely names the main change: adding the forest-tool db import-tipset-lookup command.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hm/forest-tool-db-import-tipset-lookup
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/forest-tool-db-import-tipset-lookup

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

@hanabi1224
hanabi1224 marked this pull request as ready for review July 30, 2026 07:45
@hanabi1224
hanabi1224 requested a review from a team as a code owner July 30, 2026 07:45
@hanabi1224
hanabi1224 requested review from akaladarshi and sudo-shashank and removed request for a team July 30, 2026 07:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tool/subcommands/db_cmd.rs`:
- Around line 170-205: Update the HAMT traversal around
`hamt.for_each_cacheless` and `set_tipset_key_at_epoch` so all entries are
validated, including tipset existence and epoch consistency, before persisting
any lookup changes. Stage the validated tipset keys or use an atomic batch, then
apply writes only after traversal succeeds; preserve propagation of validation
and write errors.
- Around line 170-205: Enhance error reporting in the import flow around HAMT
loading, database setup, and the hamt.for_each_cacheless callback. Add
context/with_context to snapshot conversion and root validation, database
opening and forest CAR loading, and per-epoch Tipset::load_required plus
db.set_tipset_key_at_epoch calls, including the snapshot/database paths or epoch
and TipsetKey where available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd2e8ef1-c850-422a-87a1-f54cb20238c0

📥 Commits

Reviewing files that changed from the base of the PR and between 256a920 and 633c5f4.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • docs/docs/users/reference/cli.sh
  • scripts/tests/calibnet_export_check.sh
  • src/blocks/tipset.rs
  • src/db/car/any.rs
  • src/db/car/plain.rs
  • src/tool/subcommands/db_cmd.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

Comment thread src/tool/subcommands/db_cmd.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tool/subcommands/db_cmd.rs`:
- Around line 203-206: Correct the status message in the tipset lookup
validation flow to spell “Successfully” properly, and update the progress bar’s
count label to describe lookup entries rather than blocks. Preserve the existing
spinner style and validation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5db9c486-6c42-43d8-9280-a5b2491458d0

📥 Commits

Reviewing files that changed from the base of the PR and between 633c5f4 and 8f0d419.

📒 Files selected for processing (1)
  • src/tool/subcommands/db_cmd.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

Comment thread src/tool/subcommands/db_cmd.rs Outdated
@hanabi1224
hanabi1224 added this pull request to the merge queue Jul 30, 2026
Merged via the queue into main with commit 165e30e Jul 30, 2026
46 checks passed
@hanabi1224
hanabi1224 deleted the hm/forest-tool-db-import-tipset-lookup branch July 30, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Snapshot Run snapshot tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants