Skip to content

Conversation

@hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Aug 20, 2025

Summary of changes

Changes introduced in this pull request:

  • add forest-tool archive f3-header command for inspecting header of a standalone F3 snapshot
➜  snapshots forest-tool archive f3-header f3_snap_mainnet.bin
F3 snapshot version:        1
F3 snapshot first instance: 0
F3 snapshot last instance:  200675
➜  snapshots forest-tool archive f3-header f3_snap_calibnet_552628.bin
F3 snapshot version:        1
F3 snapshot first instance: 0
F3 snapshot last instance:  552628

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.

Summary by CodeRabbit

  • New Features

    • Added CLI subcommand to inspect the header of standalone F3 snapshots: archive f3-header (FRC-0108).
  • Documentation

    • Updated CLI docs to include archive f3-header, archive diff, and archive sync-bucket.
    • Added Unreleased changelog entry noting the new F3 header inspection command.
  • Tests

    • Enhanced pre-merge snapshot checks to inspect v1 and F3 snapshots.
    • Clarified log messages for v2 snapshot inspections.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

Walkthrough

Adds a new forest-tool subcommand archive f3-header to print F3 snapshot headers, updates CLI docs to include new archive commands, adjusts the test harness to inspect v1 and F3 snapshots and renames v2 log messages, and appends a changelog entry. No other public APIs or control flow changes.

Changes

Cohort / File(s) Summary
Changelog update
CHANGELOG.md
Adds unreleased entry noting new forest-tool archive f3-header subcommand (FRC-0108).
CLI docs generation
docs/docs/users/reference/cli.sh
Registers three archive subcommands for docs: archive f3-header, archive diff, and archive sync-bucket; added after existing archive entries.
Test harness inspections
scripts/tests/harness.sh
Adds inspection step for v1.forest.car.zst and an f3.bin inspection invoking archive f3-header; updates log messages for v2 snapshot info/metadata; no control-flow changes.
Archive subcommand implementation
src/tool/subcommands/archive_cmd.rs
Adds F3Header { snapshot: PathBuf } variant to ArchiveCommands; opens the snapshot file, decodes a F3SnapshotHeader via decode_from_snapshot, and prints it.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant CLI as forest-tool
  participant AC as ArchiveCommands
  participant FS as Filesystem
  participant DEC as F3 Decoder

  U->>CLI: archive f3-header <snapshot_path>
  CLI->>AC: parse & match F3Header
  AC->>FS: open snapshot file (read)
  FS-->>AC: reader/handle
  AC->>DEC: decode_from_snapshot(reader)
  DEC-->>AC: F3SnapshotHeader
  AC-->>CLI: print header
  CLI-->>U: header output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • LesnyRumcajs
  • elmattic
  • sudo-shashank

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ace1d61 and 1296b96.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • src/tool/subcommands/archive_cmd.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/tool/subcommands/archive_cmd.rs
  • CHANGELOG.md
⏰ 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: Build forest binaries on Linux AMD64
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Deploy to Cloudflare Pages
  • GitHub Check: All lint checks
  • GitHub Check: Check
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (rust)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hm/f3-header

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hanabi1224 hanabi1224 marked this pull request as ready for review August 20, 2025 12:42
@hanabi1224 hanabi1224 requested a review from a team as a code owner August 20, 2025 12:42
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and elmattic and removed request for a team August 20, 2025 12:42
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: 0

🧹 Nitpick comments (5)
CHANGELOG.md (1)

36-37: Link to PR instead of issue for 5956 (per changelog guidance).

The entry uses an issue link but there’s no linked issue; the guidelines say to use the PR number when no issue exists. Switch the URL to /pull/5956.

-- [#5956](https://github.com/ChainSafe/forest/issues/5956) Add `forest-tool archive f3-header` subcommand for inspecting the header of a standalone F3 snapshot(FRC-0108).
+- [#5956](https://github.com/ChainSafe/forest/pull/5956) Add `forest-tool archive f3-header` subcommand for inspecting the header of a standalone F3 snapshot(FRC-0108).
src/tool/subcommands/archive_cmd.rs (1)

238-243: Add contextual error messages for easier troubleshooting.

Wrap File::open and header decoding with context so users see which path failed and whether it was I/O vs decode.

-            Self::F3Header { snapshot } => {
-                let mut r = BufReader::new(File::open(&snapshot)?);
-                let f3_snap_header = F3SnapshotHeader::decode_from_snapshot(&mut r)?;
-                println!("{f3_snap_header}");
-                Ok(())
-            }
+            Self::F3Header { snapshot } => {
+                let mut r = BufReader::new(
+                    File::open(&snapshot)
+                        .with_context(|| format!("failed to open F3 snapshot '{}'", snapshot.display()))?,
+                );
+                let f3_snap_header = F3SnapshotHeader::decode_from_snapshot(&mut r)
+                    .with_context(|| {
+                        format!("failed to decode F3 snapshot header from '{}'", snapshot.display())
+                    })?;
+                println!("{f3_snap_header}");
+                Ok(())
+            }
scripts/tests/harness.sh (3)

33-35: Fail fast if inspection of v1 snapshot info fails.

Guard the command to align with the project’s preference for hard failures in pre-merge checks.

-  echo "Inspecting v1 snapshot"
-  $FOREST_TOOL_PATH archive info v1.forest.car.zst
+  echo "Inspecting v1 snapshot"
+  $FOREST_TOOL_PATH archive info v1.forest.car.zst || return 1

37-38: Fail fast on F3 header inspection to surface corrupt/malformed snapshots early.

If header decoding fails, the function should stop and report failure.

-  echo "Inspecting F3 snapshot"
-  $FOREST_TOOL_PATH archive f3-header f3.bin
+  echo "Inspecting F3 snapshot"
+  $FOREST_TOOL_PATH archive f3-header f3.bin || return 1

41-44: Also guard v2 post-merge inspections.

Continue the fail-fast pattern for info and metadata checks to catch issues immediately.

-  echo "Inspecting v2 snapshot info"
-  $FOREST_TOOL_PATH archive info v2.forest.car.zst
-  echo "Inspecting v2 snapshot metadata"
-  $FOREST_TOOL_PATH archive metadata v2.forest.car.zst
+  echo "Inspecting v2 snapshot info"
+  $FOREST_TOOL_PATH archive info v2.forest.car.zst || return 1
+  echo "Inspecting v2 snapshot metadata"
+  $FOREST_TOOL_PATH archive metadata v2.forest.car.zst || return 1
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0c296cd and ace1d61.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • docs/docs/users/reference/cli.sh (1 hunks)
  • scripts/tests/harness.sh (1 hunks)
  • src/tool/subcommands/archive_cmd.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: hanabi1224
PR: ChainSafe/forest#5930
File: build.rs:64-77
Timestamp: 2025-08-13T09:43:20.301Z
Learning: hanabi1224 prefers hard compile-time errors in build scripts rather than runtime safeguards or collision detection, believing it's better to fail fast and fix root causes of issues like malformed snapshot names.
📚 Learning: 2025-08-11T14:00:47.060Z
Learnt from: hanabi1224
PR: ChainSafe/forest#5886
File: src/daemon/db_util.rs:236-259
Timestamp: 2025-08-11T14:00:47.060Z
Learning: In Forest's snapshot import (`src/daemon/db_util.rs`), when F3 CID is present in snapshot metadata but the actual F3 data is missing, this should cause a hard error as it indicates snapshot corruption. Only errors during the F3 import process itself (after data is successfully retrieved) should be non-fatal and logged.

Applied to files:

  • src/tool/subcommands/archive_cmd.rs
  • scripts/tests/harness.sh
🧬 Code Graph Analysis (1)
src/tool/subcommands/archive_cmd.rs (1)
src/f3/snapshot.rs (1)
  • decode_from_snapshot (30-42)
⏰ 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: cargo-publish-dry-run
  • GitHub Check: Build Ubuntu
  • GitHub Check: Build MacOS
  • GitHub Check: All lint checks
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests
  • GitHub Check: tests-release
  • GitHub Check: Check
  • GitHub Check: Deploy to Cloudflare Pages
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
src/tool/subcommands/archive_cmd.rs (2)

61-61: Importing BufReader and Seek is correct and necessary.

BufReader is used to stream the F3 header and Seek/SeekFrom are used in merge_f3. This resolves compile-time trait-method availability.


100-105: New archive f3-header subcommand fits existing CLI design.

Clear help text and argument naming align with other archive subcommands.

docs/docs/users/reference/cli.sh (1)

122-122: Docs entry for archive f3-header is added in the right section.

This ensures --help output gets captured in CLI docs alongside other archive commands.

@hanabi1224 hanabi1224 enabled auto-merge August 21, 2025 09:20
@hanabi1224 hanabi1224 added this pull request to the merge queue Aug 21, 2025
Merged via the queue into main with commit 18edbdb Aug 21, 2025
55 checks passed
@hanabi1224 hanabi1224 deleted the hm/f3-header branch August 21, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants