-
Notifications
You must be signed in to change notification settings - Fork 182
feat: add forest-tool archive f3-header command
#5956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a new forest-tool subcommand Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
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 detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ 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)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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.
📒 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.rsscripts/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: Newarchive f3-headersubcommand 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 forarchive f3-headeris added in the right section.This ensures
--helpoutput gets captured in CLI docs alongside other archive commands.
Summary of changes
Changes introduced in this pull request:
forest-tool archive f3-headercommand for inspecting header of a standalone F3 snapshotReference issue to close (if applicable)
Closes
Other information and links
Change checklist
Summary by CodeRabbit
New Features
Documentation
Tests