refactor(tool): extract snapshot export into a shared module#7319
refactor(tool): extract snapshot export into a shared module#73190xDevNinja wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughSnapshot export logic is moved into ChangesExport logic relocation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant RPC as ForestChainExportDiff
participant CLI as archive_cmd
participant Export as tool::export::do_export
participant Chain as crate::chain::export
RPC->>Export: do_export(...)
CLI->>Export: do_export(...)
Export->>Export: resolve genesis, validate depth, build seen set
Export->>Chain: export(writer, seen, options)
Chain-->>Export: completion
Export-->>RPC: Ok(())
Export-->>CLI: Ok(())
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/tool/export.rs (1)
52-66: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a doc comment for the public
do_exportAPI.
do_exportis now a shared entrypoint with 9 positional parameters (epoch_option,depth,diff,diff_depth,force, …) whose meaning is not obvious from the name alone. A brief///doc describing the parameters and the diff/full export semantics would help both the CLI and RPC callers.build_output_pathis self-explanatory and can keep its existing comment.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/tool/export.rs` around lines 52 - 66, The public do_export API is missing a doc comment, making its many positional parameters and full-vs-diff export behavior hard to understand. Add a brief /// comment above do_export that explains what the function does, summarizes the roles of the key parameters like epoch_option, depth, diff, diff_depth, and force, and clarifies the semantics of full versus diff exports. Leave build_output_path as-is since it already has a clear comment.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 `@src/tool/export.rs`:
- Around line 4-5: Update the module doc in export.rs to use the correct RPC
method name: the shared snapshot export logic comment currently references
Filecoin.ChainExportDiff, but it should say Forest.ChainExportDiff. Make this
change in the top-level documentation comment so the symbol description matches
the actual RPC method name used by the export flow.
---
Nitpick comments:
In `@src/tool/export.rs`:
- Around line 52-66: The public do_export API is missing a doc comment, making
its many positional parameters and full-vs-diff export behavior hard to
understand. Add a brief /// comment above do_export that explains what the
function does, summarizes the roles of the key parameters like epoch_option,
depth, diff, diff_depth, and force, and clarifies the semantics of full versus
diff exports. Leave build_output_path as-is since it already has a clear
comment.
🪄 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: 50878905-b51d-46b0-980e-4b1562bfaf6c
📒 Files selected for processing (4)
src/rpc/methods/chain.rssrc/tool/export.rssrc/tool/mod.rssrc/tool/subcommands/archive_cmd.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
filecoin-project/lotus(manual)
`Filecoin.ChainExportDiff` (in the RPC layer) called `do_export` directly from the `archive_cmd` CLI subcommand module, coupling the RPC layer to a CLI subcommand. Move `do_export` and its `build_output_path` helper into a dedicated `crate::tool::export` module that both the CLI subcommands and the RPC method import. No behaviour change. Closes ChainSafe#6096
8e863a5 to
5363567
Compare
Summary of changes
The
Filecoin.ChainExportDiffRPC method calleddo_exportdirectly from thearchive_cmdCLI subcommand module, coupling the RPC layer to a CLI subcommand (flagged during review of #6074).Changes introduced in this pull request:
do_exportand itsbuild_output_pathhelper out oftool::subcommands::archive_cmdinto a dedicatedcrate::tool::exportmodule.forest-tool archive/snapshotCLI subcommands and theChainExportDiffRPC method now import the export logic from that shared module.This is a pure move with no behaviour change.
Reference issue to close (if applicable)
Closes #6096
Other information and links
Identified during review of #6074 (#6074 (comment)).
I kept the module under
crate::toolsince the export path still uses CLI-oriented helpers (progress bar, interactive overwrite prompt guarded byforce). Happy to move it deeper (e.g. undercrate::chain) if you'd prefer to fully separate it from the tooling layer.Change checklist
Outside contributions
Summary by CodeRabbit
Bug Fixes
Refactor
Tests