-
Notifications
You must be signed in to change notification settings - Fork 182
fix: improve export status output and CI #6221
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
WalkthroughThe PR makes the Changes
Sequence DiagramsequenceDiagram
participant Start as Snapshot Export
participant Util as ExportStatus<br/>(ipld/util)
participant RPC as ForestChainExportStatus<br/>(rpc/methods)
participant API as ApiExportStatus<br/>(rpc/types)
participant CLI as snapshot_cmd<br/>(cli/subcommands)
Start->>Util: start_export()
Util->>Util: start_time = Some(Utc::now())
Note over Util,API: Export progresses...
RPC->>Util: Query ExportStatus
Util-->>RPC: start_time: Option<DateTime>
RPC->>RPC: Calculate progress<br/>Round to 2 decimals
RPC->>API: Convert to ApiExportStatus
API-->>API: start_time remains Option
CLI->>API: Poll export-status
API-->>CLI: ApiExportStatus
CLI->>CLI: elapsed = start_time<br/>.unwrap_or_default()
CLI->>CLI: Update progress bar
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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 (1)
src/cli/subcommands/snapshot_cmd.rs (1)
220-224: Consider defaulting to current time for better UX.The code correctly handles the optional
start_time, but usingunwrap_or_default()would compute elapsed time from Unix epoch (1970-01-01) ifstart_timeisNone, resulting in a very large duration (~50+ years). While this scenario is unlikely in practice (the wait block is only entered whenexportingis true, andstart_timeis set atomically with it), consider usingunwrap_or_else(|| Utc::now())for more sensible fallback behavior:let elapsed = chrono::Utc::now() - .signed_duration_since(result.start_time.unwrap_or_default()) + .signed_duration_since(result.start_time.unwrap_or_else(|| chrono::Utc::now())) .to_std() .unwrap_or(Duration::ZERO);This would show ~0 elapsed time rather than 50+ years if the field is unexpectedly
None.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
scripts/tests/calibnet_export_check.sh(1 hunks)src/cli/subcommands/snapshot_cmd.rs(1 hunks)src/ipld/util.rs(2 hunks)src/rpc/methods/chain.rs(1 hunks)src/rpc/types/mod.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: LesnyRumcajs
Repo: ChainSafe/forest PR: 5907
File: src/rpc/methods/state.rs:523-570
Timestamp: 2025-08-06T15:44:33.467Z
Learning: LesnyRumcajs prefers to rely on BufWriter's Drop implementation for automatic flushing rather than explicit flush() calls in Forest codebase.
📚 Learning: 2025-08-25T13:35:24.230Z
Learnt from: hanabi1224
Repo: ChainSafe/forest PR: 5969
File: src/tool/subcommands/snapshot_cmd.rs:412-412
Timestamp: 2025-08-25T13:35:24.230Z
Learning: In src/tool/subcommands/snapshot_cmd.rs, the +1 in `last_epoch = ts.epoch() - epochs as i64 + 1` fixes an off-by-1 bug where specifying --check-stateroots=N would validate N+1 epochs instead of N epochs, causing out-of-bounds errors when the snapshot contains only N recent state roots.
Applied to files:
src/cli/subcommands/snapshot_cmd.rs
📚 Learning: 2025-10-17T14:24:47.046Z
Learnt from: hanabi1224
Repo: ChainSafe/forest PR: 6167
File: src/tool/subcommands/state_compute_cmd.rs:89-91
Timestamp: 2025-10-17T14:24:47.046Z
Learning: In `src/tool/subcommands/state_compute_cmd.rs`, when using `ReadOpsTrackingStore` to generate minimal snapshots, `HEAD_KEY` should be written to `db.tracker` (not `db` itself) before calling `export_forest_car()`, because the export reads from the tracker MemoryDB which accumulates only the accessed data during computation.
Applied to files:
src/cli/subcommands/snapshot_cmd.rs
📚 Learning: 2025-08-08T12:10:45.218Z
Learnt from: hanabi1224
Repo: ChainSafe/forest PR: 5867
File: src/ipld/util.rs:553-558
Timestamp: 2025-08-08T12:10:45.218Z
Learning: Forest project targets Rust stable >=1.89; features stabilized in 1.88 like let-chains are acceptable in this codebase.
Applied to files:
src/rpc/methods/chain.rs
📚 Learning: 2025-08-28T12:52:46.927Z
Learnt from: LesnyRumcajs
Repo: ChainSafe/forest PR: 6011
File: src/cli/main.rs:18-25
Timestamp: 2025-08-28T12:52:46.927Z
Learning: In Forest CLI (src/cli/main.rs), the early RPC network check before Cli::parse_from() does not block help/version commands because clap processes these internally before reaching the RPC call. LesnyRumcajs confirmed this implementation works correctly and that RPC call failures are acceptable in this context.
Applied to files:
src/rpc/methods/chain.rs
⏰ 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). (7)
- GitHub Check: tests
- GitHub Check: Build Ubuntu
- GitHub Check: Build forest binaries on Linux AMD64
- GitHub Check: tests-release
- GitHub Check: Build MacOS
- GitHub Check: cargo-publish-dry-run
- GitHub Check: All lint checks
🔇 Additional comments (5)
scripts/tests/calibnet_export_check.sh (1)
14-14: LGTM: Increased retry tolerance for CI stability.Tripling the retry limit from 10 to 30 provides better tolerance for slower CI environments or startup delays, improving test reliability.
src/rpc/types/mod.rs (1)
571-571: LGTM: Necessary API change to fix Unix epoch display issue.Making
start_timeoptional correctly addresses the issue where a rebooted node with no prior export would show Unix epoch (genesis) time. Consumers should handleNoneappropriately.src/ipld/util.rs (2)
29-29: LGTM: Consistent with API change.Making the field optional allows
Defaultinitialization to set it toNone, preventing display of Unix epoch time before the first export.
49-49: LGTM: Correct initialization.Setting
start_timetoSome(Utc::now())when export starts ensures the field is populated for active exports.src/rpc/methods/chain.rs (1)
526-527: LGTM: Clean progress rounding to two decimal places.The rounding formula correctly limits progress values to two decimal places (e.g.,
0.31instead of0.31231231353452), improving output readability as per PR objectives.
Summary of changes
Changes introduced in this pull request:
forest-cli snapshot export-status --format jsonon a rebooted node (where no prior export has taken place)0.31231231353452is weird; let's keep only to two decimal placeson a fresh node it's now:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Summary by CodeRabbit