Skip to content

feat: add --augmented-data and --tipset-lookup to forestcli snapshot export#7376

Open
hanabi1224 wants to merge 7 commits into
mainfrom
hm/export-augmented-data
Open

feat: add --augmented-data and --tipset-lookup to forestcli snapshot export#7376
hanabi1224 wants to merge 7 commits into
mainfrom
hm/export-augmented-data

Conversation

@hanabi1224

@hanabi1224 hanabi1224 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Stats:

# calibnet (2000 state trees)
-rw-r--r--. 1 me me 8.1G Jul 16 17:37 forest_snapshot_calibnet_2026-07-16_height_3895600.forest.car.zst
-rw-r--r--. 1 me me 5.3M Jul 16 17:37 forest_snapshot_calibnet_2026-07-16_height_3895600_receipts_events.forest.car.zst
-rw-r--r--. 1 me me  22M Jul 16 17:37 forest_snapshot_calibnet_2026-07-16_height_3895600_tipset_lookup.forest.car.zst

❯ forest-tool snapshot validate-extended --base forest_snapshot_calibnet_2026-07-16_height_3895600.forest.car.zst --augmented forest_snapshot_calibnet_2026-07-16_height_3895600_receipts_events.forest.car.zst --tipset-lookup forest_snapshot_calibnet_2026-07-16_height_3895600_tipset_lookup.forest.car.zst
Importing augmented snapshot...
Verifying message receipts and events can be loaded...
Augmented snapshot is valid, 1993 tipsets validated
Importing tipset lookup snapshot...
Verifying lookup checkpoints can be loaded...
Tipset lookup snapshot is valid, 191843 checkpoints validated

# mainnet (2000 state trees)
-rw-r--r--. 1 me me 80G Jul 17 02:53 forest_snapshot_mainnet_2026-07-16_height_6196879.forest.car.zst
-rw-r--r--. 1 me me 13M Jul 17 02:54 forest_snapshot_mainnet_2026-07-16_height_6196879_receipts_events.forest.car.zst
-rw-r--r--. 1 me me 54M Jul 17 02:54 forest_snapshot_mainnet_2026-07-16_height_6196879_tipset_lookup.forest.car.zst

❯ forest-tool snapshot validate-extended --base forest_snapshot_mainnet_2026-07-16_height_6196879.forest.car.zst --augmented forest_snapshot_mainnet_2026-07-16_height_6196879_receipts_events.forest.car.zst --tipset-lookup forest_snapshot_mainnet_2026-07-16_height_6196879_tipset_lookup.forest.car.zst
Importing augmented snapshot...
Verifying message receipts and events can be loaded...
Augmented snapshot is valid, 1982 tipsets validated
Importing tipset lookup snapshot...
Verifying lookup checkpoints can be loaded...
Tipset lookup snapshot is valid, 307466 checkpoints validated

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

  • 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 optional augmented-data and tipset-lookup outputs to snapshot export workflows.
    • Added extended snapshot validation (validate-extended) to verify receipts/events and tipset-lookup contents from a base CAR plus optional auxiliary CARs.
    • Added a dedicated receipts/events export operation for forest CAR outputs.
  • Bug Fixes
    • Improved post-export integrity verification for tipset-lookup artifacts and snapshot outputs.
  • Tests
    • Added/expanded test coverage for CAR output filename suffix handling.

@hanabi1224 hanabi1224 added the Snapshot Run snapshot tests label Jul 16, 2026
@hanabi1224
hanabi1224 marked this pull request as ready for review July 17, 2026 06:13
@hanabi1224
hanabi1224 requested a review from a team as a code owner July 17, 2026 06:13
@hanabi1224
hanabi1224 requested review from LesnyRumcajs and akaladarshi and removed request for a team July 17, 2026 06:13
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (3)
  • src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v2.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e15dbe92-12b5-4b24-a7cb-376d956427c1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Snapshot export now accepts augmented-data and tipset-lookup options, generates additional CAR files through RPC, exposes extended validation for those files, and updates calibration checks to exercise the new outputs.

Changes

Snapshot export and validation

Layer / File(s) Summary
Export contracts and CLI wiring
src/rpc/methods/chain.rs, src/cli/subcommands/snapshot_cmd.rs, src/rpc/mod.rs, src/db/car/forest.rs
Export parameters and CLI flags now support augmented data and tipset lookup, with output filename suffix handling and updated legacy mappings.
Receipts/events and tipset-lookup generation
src/chain/mod.rs, src/ipld/util.rs, src/rpc/methods/chain.rs
Chain export generates receipts/events CAR data and conditionally writes augmented and tipset-lookup CAR files.
Extended validation and integration checks
src/tool/subcommands/snapshot_cmd.rs, scripts/tests/calibnet_export_check.sh
snapshot validate-extended verifies receipts/events and tipset-lookup checkpoints, while calibration checks invoke and inspect the new exports.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SnapshotCLI
  participant ForestChainExport
  participant ReceiptsEventsExporter
  participant ForestCAR
  SnapshotCLI->>ForestChainExport: request augmented_data and tipset_lookup
  ForestChainExport->>ForestCAR: persist standard snapshot
  ForestChainExport->>ReceiptsEventsExporter: export receipts and events
  ReceiptsEventsExporter->>ForestCAR: write receipts/events CAR
  ForestChainExport->>ForestCAR: write tipset-lookup CAR
  SnapshotCLI->>ForestCAR: run extended validation
Loading

Possibly related PRs

Suggested reviewers: lesnyrumcajs, sudo-shashank

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding --augmented-data and --tipset-lookup to forestcli snapshot export.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hm/export-augmented-data
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/export-augmented-data

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

@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: 3

Caution

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

⚠️ Outside diff range comments (1)
src/rpc/methods/chain.rs (1)

445-519: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Stage every requested CAR before publishing final paths.

The base snapshot is persisted first, while auxiliary CARs are written directly to their final paths. A later error or cancellation therefore leaves a completed base file and potentially truncated auxiliary files even though the RPC reports failure. Write all outputs to temporary paths, then persist them only after every export succeeds.

🤖 Prompt for 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.

In `@src/rpc/methods/chain.rs` around lines 445 - 519, Update the export flow
around the base snapshot persistence, tipset lookup export, and augmented-data
export so every requested CAR is written to a temporary path first. Defer
persisting or publishing the base and auxiliary outputs until all exports
complete successfully, then atomically persist each temporary file to its final
path; ensure errors or cancellation leave no completed or truncated final
auxiliary files.
🧹 Nitpick comments (1)
src/chain/mod.rs (1)

265-270: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the new public snapshot APIs.

Add rustdoc describing their purpose and important semantics.

  • src/chain/mod.rs#L265-L270: document depth boundaries, output contents, and placeholder CAR root.
  • src/rpc/methods/chain.rs#L1634-L1643: document the receipts/events export parameter schema.
  • src/ipld/util.rs#L580-L586: document the stream’s role and expected generic parameters.

As per coding guidelines, “Document public functions and structs with doc comments.”

🤖 Prompt for 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.

In `@src/chain/mod.rs` around lines 265 - 270, Document the public snapshot APIs
with rustdoc: in src/chain/mod.rs lines 265-270, describe export depth
boundaries, output contents, and the placeholder CAR root; in
src/rpc/methods/chain.rs lines 1634-1643, document the receipts/events export
parameter schema; and in src/ipld/util.rs lines 580-586, describe the stream’s
role and expected generic parameters.

Source: Coding guidelines

🤖 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 `@scripts/tests/calibnet_export_check.sh`:
- Around line 94-101: Update the snapshot validation command in the calibration
check to invoke the harness-configured FOREST_TOOL_PATH instead of the literal
forest-tool executable, preserving the existing validate-extended arguments and
flow.

In `@src/rpc/mod.rs`:
- Line 101: Prevent the internal testing RPC from being available in production:
update the ForestChainExportReceiptsEvents registration in src/rpc/mod.rs lines
101-101 to gate or remove it, and restrict the corresponding method in
src/rpc/methods/chain.rs lines 276-282 to test/feature builds rather than
production API paths.

In `@src/tool/subcommands/snapshot_cmd.rs`:
- Around line 282-293: Update the checkpoint validation loop around
heaviest_tipset and hamt.get to derive each expected checkpoint tipset from the
base chain, require a HAMT entry for every checkpoint, and compare the stored
TipsetKey with the base tipset’s key. Reject missing entries or mismatches
before counting the checkpoint as validated, while preserving the existing load
validation and error context.

---

Outside diff comments:
In `@src/rpc/methods/chain.rs`:
- Around line 445-519: Update the export flow around the base snapshot
persistence, tipset lookup export, and augmented-data export so every requested
CAR is written to a temporary path first. Defer persisting or publishing the
base and auxiliary outputs until all exports complete successfully, then
atomically persist each temporary file to its final path; ensure errors or
cancellation leave no completed or truncated final auxiliary files.

---

Nitpick comments:
In `@src/chain/mod.rs`:
- Around line 265-270: Document the public snapshot APIs with rustdoc: in
src/chain/mod.rs lines 265-270, describe export depth boundaries, output
contents, and the placeholder CAR root; in src/rpc/methods/chain.rs lines
1634-1643, document the receipts/events export parameter schema; and in
src/ipld/util.rs lines 580-586, describe the stream’s role and expected generic
parameters.
🪄 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: f0b8604c-8331-4b98-bdbf-d67800bf11be

📥 Commits

Reviewing files that changed from the base of the PR and between 516fe70 and f5acf16.

📒 Files selected for processing (8)
  • scripts/tests/calibnet_export_check.sh
  • src/chain/mod.rs
  • src/cli/subcommands/snapshot_cmd.rs
  • src/db/car/forest.rs
  • src/ipld/util.rs
  • src/rpc/methods/chain.rs
  • src/rpc/mod.rs
  • src/tool/subcommands/snapshot_cmd.rs
🔗 Linked repositories identified

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

  • filecoin-project/lotus (manual)

Comment thread scripts/tests/calibnet_export_check.sh
Comment thread src/rpc/mod.rs Outdated
Comment thread src/tool/subcommands/snapshot_cmd.rs Outdated
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 5.44554% with 191 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.85%. Comparing base (c76868f) to head (f8111df).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/tool/subcommands/snapshot_cmd.rs 0.00% 74 Missing ⚠️
src/rpc/methods/chain.rs 0.00% 71 Missing ⚠️
src/chain/mod.rs 0.00% 42 Missing ⚠️
src/cli/subcommands/snapshot_cmd.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/db/car/forest.rs 84.45% <100.00%> (+0.45%) ⬆️
src/ipld/util.rs 76.26% <ø> (ø)
src/rpc/mod.rs 92.83% <ø> (ø)
src/cli/subcommands/snapshot_cmd.rs 0.00% <0.00%> (ø)
src/chain/mod.rs 66.49% <0.00%> (-18.75%) ⬇️
src/rpc/methods/chain.rs 53.80% <0.00%> (-3.53%) ⬇️
src/tool/subcommands/snapshot_cmd.rs 0.00% <0.00%> (ø)

... and 7 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c76868f...f8111df. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@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.

Caution

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

⚠️ Outside diff range comments (1)
scripts/tests/calibnet_export_check.sh (1)

64-66: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Wait for export status instead of sleeping for a fixed five seconds.

On fast nodes, the export can finish before the second export attempt, causing this test to fail even though the implementation is correct. Poll snapshot export-status with the existing retry/timeout pattern before asserting that concurrent exports are rejected.

🤖 Prompt for 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.

In `@scripts/tests/calibnet_export_check.sh` around lines 64 - 66, Replace the
fixed sleep after launching the first export in the snapshot export test with
polling via snapshot export-status, using the script’s existing retry and
timeout pattern. Continue only once the export is confirmed active, then
preserve the concurrent-export rejection assertion.
🤖 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.

Outside diff comments:
In `@scripts/tests/calibnet_export_check.sh`:
- Around line 64-66: Replace the fixed sleep after launching the first export in
the snapshot export test with polling via snapshot export-status, using the
script’s existing retry and timeout pattern. Continue only once the export is
confirmed active, then preserve the concurrent-export rejection assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 868017cd-d7a4-4034-90b5-17feb4768ca3

📥 Commits

Reviewing files that changed from the base of the PR and between f5acf16 and 492ae16.

⛔ Files ignored due to path filters (3)
  • src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap is excluded by !**/*.snap
  • src/rpc/snapshots/forest__rpc__tests__rpc__v2.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • scripts/tests/calibnet_export_check.sh
  • src/tool/subcommands/snapshot_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/snapshot_cmd.rs

@hanabi1224
hanabi1224 force-pushed the hm/export-augmented-data branch from 220b4a0 to 042f4c0 Compare July 17, 2026 07:55
@LesnyRumcajs

Copy link
Copy Markdown
Member

no green checkmark, no review!

Comment thread src/rpc/mod.rs
$callback!($crate::rpc::chain::ForestChainExportDiff);
$callback!($crate::rpc::chain::ForestChainExportStatus);
$callback!($crate::rpc::chain::ForestChainExportCancel);
// $callback!($crate::rpc::chain::ForestChainExportReceiptsEvents);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

Comment thread src/rpc/methods/chain.rs
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ForestChainExportReceiptsEventsParams {
pub epoch: ChainEpoch,
pub recent_roots: i64,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unsigned? I guess it can't be negative?

Comment on lines +223 to +226
anyhow::ensure!(
augmented.is_some() || tipset_lookup.is_some(),
"either `--augmented` or `--tipset-lookup` needs to be specified"
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a huge deal, but AFAIK this could be specified via clap derive sorcery.

Comment on lines +241 to +242
if !store.has(ts.parent_state())? {
break;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't get it. If it can't find the parent state, then it will break... but the command itself will succeed, no?

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