Skip to content

fix: load actor bundles in forest-tool archive diff - #6060

Merged
hanabi1224 merged 3 commits into
mainfrom
hm/load-actor-bundles-in-archive-diff
Sep 15, 2025
Merged

fix: load actor bundles in forest-tool archive diff#6060
hanabi1224 merged 3 commits into
mainfrom
hm/load-actor-bundles-in-archive-diff

Conversation

@hanabi1224

@hanabi1224hanabi1224 commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Summary of changes

This PR tries a avoid actor missing error in forest-tool archive diff for scenarios like testing an upcoming state migration at a dummy epoch

e.g. to test GoldenWeek upgrade at 5283321

forest-tool archive diff lite_2000_5283323.forest.car.zst --epoch 5283322
➜ car_db /usr/bin/time -v forest-tool archive diff lite_2000_5283323.forest.car.zst --epoch 5283322
2025-09-10T10:17:47.472769Z INFO forest::daemon::bundle: Loading actor bundle from /home/me/actors/actor_bundles.car.zst set by FOREST_ACTOR_BUNDLE_PATH environment variable
2025-09-10T10:17:47.947674Z INFO forest::state_migration: Running GoldenWeek migration at epoch 5283321
2025-09-10T10:17:49.254209Z INFO forest::state_migration::common::state_migration: Processed 100000 actors
2025-09-10T10:17:50.323175Z INFO forest::state_migration::common::state_migration: Processed 200000 actors
2025-09-10T10:17:51.446184Z INFO forest::state_migration::common::state_migration: Processed 300000 actors
2025-09-10T10:17:52.520946Z INFO forest::state_migration::common::state_migration: Processed 400000 actors
2025-09-10T10:17:53.704433Z INFO forest::state_migration::common::state_migration: Processed 500000 actors
2025-09-10T10:17:54.911640Z INFO forest::state_migration::common::state_migration: Processed 600000 actors
2025-09-10T10:17:55.976611Z INFO forest::state_migration::common::state_migration: Processed 700000 actors
2025-09-10T10:17:54.519621Z INFO forest::state_migration::common::state_migration: Processed 800000 actors
2025-09-10T10:17:55.539588Z INFO forest::state_migration::common::state_migration: Processed 900000 actors
2025-09-10T10:17:56.935732Z INFO forest::state_migration::common::state_migration: Processed 1000000 actors
2025-09-10T10:17:57.903098Z INFO forest::state_migration::common::state_migration: Processed 1100000 actors
2025-09-10T10:17:58.900165Z INFO forest::state_migration::common::state_migration: Processed 1200000 actors
2025-09-10T10:17:59.940613Z INFO forest::state_migration::common::state_migration: Processed 1300000 actors
2025-09-10T10:18:01.018348Z INFO forest::state_migration::common::state_migration: Processed 1400000 actors
2025-09-10T10:18:02.062080Z INFO forest::state_migration::common::state_migration: Processed 1500000 actors
2025-09-10T10:18:03.109623Z INFO forest::state_migration::common::state_migration: Processed 1600000 actors
2025-09-10T10:18:04.183351Z INFO forest::state_migration::common::state_migration: Processed 1700000 actors
2025-09-10T10:18:05.235338Z INFO forest::state_migration::common::state_migration: Processed 1800000 actors
2025-09-10T10:18:07.366890Z INFO forest::state_migration::common::state_migration: Processed 1900000 actors
2025-09-10T10:18:08.323431Z INFO forest::state_migration::common::state_migration: Processed 2000000 actors
2025-09-10T10:18:09.289872Z INFO forest::state_migration::common::state_migration: Processed 2100000 actors
2025-09-10T10:18:10.230454Z INFO forest::state_migration::common::state_migration: Processed 2200000 actors
2025-09-10T10:18:11.377019Z INFO forest::state_migration::common::state_migration: Processed 2300000 actors
2025-09-10T10:18:12.552257Z INFO forest::state_migration::common::state_migration: Processed 2400000 actors
2025-09-10T10:18:13.520343Z INFO forest::state_migration::common::state_migration: Processed 2500000 actors
2025-09-10T10:18:14.475935Z INFO forest::state_migration::common::state_migration: Processed 2600000 actors
2025-09-10T10:18:15.481166Z INFO forest::state_migration::common::state_migration: Processed 2700000 actors
2025-09-10T10:18:16.500452Z INFO forest::state_migration::common::state_migration: Processed 2800000 actors
2025-09-10T10:18:17.610435Z INFO forest::state_migration::common::state_migration: Processed 2900000 actors
2025-09-10T10:18:18.798944Z INFO forest::state_migration::common::state_migration: Processed 3000000 actors
2025-09-10T10:18:20.082152Z INFO forest::state_migration::common::state_migration: Processed 3100000 actors
2025-09-10T10:18:21.410108Z INFO forest::state_migration::common::state_migration: Processed 3200000 actors
2025-09-10T10:18:22.788861Z INFO forest::state_migration::common::state_migration: Processed 3300000 actors
2025-09-10T10:18:24.154132Z INFO forest::state_migration::common::state_migration: Processed 3400000 actors
2025-09-10T10:18:25.576967Z INFO forest::state_migration::common::state_migration: Processed 3500000 actors
2025-09-10T10:18:24.313490Z INFO forest::state_migration::common::state_migration: Processed 3600000 actors
2025-09-10T10:18:24.833343Z INFO forest::state_migration::common::state_migration: Processing deferred migrations
2025-09-10T10:18:25.481911Z INFO forest::state_migration::common::state_migration: Processed 3642797 deferred migrations
Error: State post migration at height GoldenWeek must not match. Previous state: bafy2bzacediqw3uxsoi7cdhimxc6nelw7lb2f3xrienzpmf5fj2caay7nofpi, new state: bafy2bzacediqw3uxsoi7cdhimxc6nelw7lb2f3xrienzpmf5fj2caay7nofpi, new state actors: bafy2bzaceaqmuntz5qkanjuhqcrkjy6w3chyepvf5zav5htxvdkgnbgtnd3ks. Took 58s 285ms 299us 938ns.
Stack backtrace:
0: <unknown>
Command exited with non-zero status 1
Command being timed: "forest-tool archive diff lite_2000_5283323.forest.car.zst --epoch 5283322"
User time (seconds): 58.89
System time (seconds): 54.62
Percent of CPU this job got: 205%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:55.23
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 12005556
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 29408
Minor (reclaiming a frame) page faults: 2455915
Voluntary context switches: 4644766
Involuntary context switches: 211
Swaps: 0
File system inputs: 4732664
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 1

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.

Summary by CodeRabbit

  • Bug Fixes

    • Preloads required actor data for the detected network before running tipset diffs, preventing sporadic failures and inconsistent archive diff results.
  • Performance

    • Slightly faster and more reliable initial diff computation due to upfront resource loading.

@coderabbitai

coderabbitaiBot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

An asynchronous preload of actor bundles was added in the archive subcommand’s tipset diff path. After deriving the network from genesis, the code now calls load_actor_bundles(&store, &network).await? before proceeding with timestamp extraction and diff logic. Only one file was changed; no public APIs were modified.

Changes

Cohort / File(s)Summary
Archive command: preload actor bundles
src/tool/subcommands/archive_cmd.rs
Added import for load_actor_bundles and invoked it after determining network to asynchronously preload actor bundles via load_actor_bundles(&store, &network).await?; error propagates with ?. No public signatures changed.

Sequence Diagram(s)

sequenceDiagram
autonumber
participant CLI as CLI
participant Archive as show_tipset_diff
participant Store as Blockstore
participant Bundles as load_actor_bundles
CLI->>Archive: run tipset diff
Archive->>Store: compute genesis / derive network
Archive->>Bundles: load_actor_bundles(store, network) (async)
alt success
Bundles-->>Archive: Ok
Archive->>Archive: proceed to extract timestamps & diff
Archive-->>CLI: output diff
else error
Bundles-->>Archive: Err
Archive-->>CLI: propagate error
end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • LesnyRumcajs
  • akaladarshi

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title Check✅ PassedThe title clearly and concisely describes the primary change—enabling actor bundle loading in the forest-tool archive diff command—using a standard conventional commit prefix without adding unnecessary detail or noise.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"mode: "warning"instructions: | Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ 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/load-actor-bundles-in-archive-diff

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

@hanabi1224
hanabi1224 marked this pull request as ready for review September 10, 2025 11:01
@hanabi1224
hanabi1224 requested a review from a team as a code ownerSeptember 10, 2025 11:01
@hanabi1224
hanabi1224 requested review from LesnyRumcajs and akaladarshi and removed request for a teamSeptember 10, 2025 11:01

@coderabbitaicoderabbitaiBot 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: 0

🧹 Nitpick comments (1)
src/tool/subcommands/archive_cmd.rs (1)

785-790: Add failure context to bundle loading for easier diagnosis.
Wrap the await with anyhow::Context so users see which network/path failed.

- load_actor_bundles(&store, &network).await?;+ load_actor_bundles(&store, &network)+ .await+ .with_context(|| format!("failed to load actor bundles for network {network}"))?;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4411a and c1acee9.

📒 Files selected for processing (1)
  • src/tool/subcommands/archive_cmd.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 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.
🧬 Code graph analysis (1)
src/tool/subcommands/archive_cmd.rs (1)
src/daemon/bundle.rs (1)
  • load_actor_bundles (22-39)
⏰ 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: tests-release
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Build Ubuntu
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build MacOS
  • GitHub Check: All lint checks
🔇 Additional comments (2)
src/tool/subcommands/archive_cmd.rs (2)

36-36: LGTM: import is appropriate and scoped to Diff path.


785-790: Verify PersistentStore implementation and loader idempotency

  • Confirm the concrete store type (e.g. ManyCar) implements PersistentStore with writable put semantics so load_actor_bundles can succeed at compile- and run-time.
  • Ensure load_actor_bundles short-circuits when bundles already exist (idempotent/offline-safe).

@LesnyRumcajs

Copy link
Copy Markdown
Member

@akaladarshi

@hanabi1224
hanabi1224 added this pull request to the merge queueSep 15, 2025
Merged via the queue into main with commit 5b61c18Sep 15, 2025
39 checks passed
@hanabi1224
hanabi1224 deleted the hm/load-actor-bundles-in-archive-diff branch September 15, 2025 10:35
Sign up for freeto 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.

3 participants

@hanabi1224@LesnyRumcajs@akaladarshi