Skip to content

feat: FOREST_PATH env variable#7200

Merged
LesnyRumcajs merged 2 commits into
mainfrom
forest-path-env-var
Jun 22, 2026
Merged

feat: FOREST_PATH env variable#7200
LesnyRumcajs merged 2 commits into
mainfrom
forest-path-env-var

Conversation

@LesnyRumcajs

@LesnyRumcajs LesnyRumcajs commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary of changes

Changes introduced in this pull request:

  • exposes FOREST_PATH env variable to specify the DATA_DIR.
  • honor this path across our binaries

Reference issue to close (if applicable)

Closes #6008

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.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added FOREST_PATH environment variable to override the Forest data directory, taking precedence over config and defaults.
    • The daemon now logs the resolved data directory path on startup.
    • RPC admin token resolution honors the FOREST_PATH override.
  • Documentation
    • Updated the environment variables reference guide formatting.
    • Added a changelog entry documenting FOREST_PATH.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a3c72e5b-96b0-4cd1-b656-ae253cb501c6

📥 Commits

Reviewing files that changed from the base of the PR and between 37d8d93 and b8b5644.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • src/daemon/mod.rs
  • src/tool/offline_server/server.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs
  • src/tool/subcommands/api_cmd/test_snapshot.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)
✅ Files skipped from review due to trivial changes (2)
  • src/daemon/mod.rs
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/tool/offline_server/server.rs
  • src/tool/subcommands/api_cmd/test_snapshot.rs
  • src/tool/subcommands/api_cmd/api_compare_tests.rs

Walkthrough

Introduces FOREST_PATH as an environment variable to override the Forest data directory (precedence: env > config > default). The config-loading path in cli_shared is updated to apply this override, new helper functions default_data_dir() and default_token_path() are exposed, and all proofs-cache and RPC-token call sites are updated. Shell test scripts rename the existing FOREST_PATH daemon-binary variable to FOREST_DAEMON_PATH to avoid collision. Daemon startup now logs the resolved data directory.

Changes

FOREST_PATH data directory override

Layer / File(s) Summary
Core env var constant, config override, and helper functions
src/cli_shared/mod.rs, src/cli_shared/cli/client.rs
Defines FOREST_DATA_DIR_ENV ("FOREST_PATH") and RPC_TOKEN_FILENAME constants; read_config overwrites config.client.data_dir from the env var when set and non-empty; adds default_data_dir() and default_token_path() helpers and serial unit tests for env precedence and empty-value fallback.
RPC client token path resolution
src/rpc/client.rs
Client::default_or_from_env now calls cli_shared::default_token_path() for the default token path, inheriting FOREST_PATH awareness; adds a test that writes a token file into a FOREST_PATH-pointed temp directory and verifies it is loaded.
Proofs cache dir callsites
src/dev/subcommands/mod.rs, src/tool/offline_server/server.rs, src/tool/subcommands/api_cmd/api_compare_tests.rs, src/tool/subcommands/api_cmd/test_snapshot.rs, src/tool/subcommands/snapshot_cmd.rs
Replaces Config::default().client.data_dir with cli_shared::default_data_dir() in all maybe_set_proofs_parameter_cache_dir_env call sites so the proofs cache directory also honors FOREST_PATH; removes unused Config imports.
Daemon startup logging and integration test
src/daemon/mod.rs, tests/config.rs
Adds an info! log of config.client.data_dir in startup_init; adds an integration test asserting that setting FOREST_PATH to a non-existent path causes the daemon to create that directory.
Shell script variable rename
scripts/tests/harness.sh, scripts/tests/butterflynet_check.sh, scripts/tests/calibnet_*.sh
Renames the exported daemon-binary variable from FOREST_PATH to FOREST_DAEMON_PATH in harness.sh and updates all daemon launch invocations across all test scripts to use the new name, freeing FOREST_PATH for the new env var meaning.
Changelog and env var docs
CHANGELOG.md, docs/docs/users/reference/env_variables.md
Adds a changelog entry for FOREST_PATH and updates markdown formatting of the environment variables reference table.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ChainSafe/forest#6372: Both PRs touch the FIL_PROOFS_PARAMETER_CACHE environment setup; the retrieved PR updates params-caching in CI while this PR changes how the source path for that setup is derived via default_data_dir().

Suggested reviewers

  • akaladarshi
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing the FOREST_PATH environment variable feature.
Linked Issues check ✅ Passed All completion criteria from issue #6008 are met: FOREST_PATH env variable is implemented and honored across binaries, test scripts are updated, and documentation is added.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the FOREST_PATH environment variable feature with proper precedence and documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch forest-path-env-var
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch forest-path-env-var

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

@LesnyRumcajs LesnyRumcajs added the RPC requires calibnet RPC checks to run on CI label Jun 19, 2026
@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review June 19, 2026 11:12
@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner June 19, 2026 11:12
@LesnyRumcajs LesnyRumcajs requested review from akaladarshi and hanabi1224 and removed request for a team June 19, 2026 11:12
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.87755% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.42%. Comparing base (8c8e717) to head (b8b5644).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/daemon/mod.rs 0.00% 0 Missing and 1 partial ⚠️
src/tool/offline_server/server.rs 0.00% 1 Missing ⚠️
src/tool/subcommands/snapshot_cmd.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/cli_shared/cli/client.rs 100.00% <100.00%> (ø)
src/cli_shared/mod.rs 97.29% <100.00%> (+1.94%) ⬆️
src/dev/subcommands/mod.rs 73.52% <100.00%> (ø)
src/rpc/client.rs 56.48% <100.00%> (+3.34%) ⬆️
src/tool/subcommands/api_cmd/test_snapshot.rs 82.09% <100.00%> (ø)
src/daemon/mod.rs 24.70% <0.00%> (-0.04%) ⬇️
src/tool/offline_server/server.rs 27.23% <0.00%> (ø)
src/tool/subcommands/snapshot_cmd.rs 0.00% <0.00%> (ø)

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c8e717...b8b5644. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/cli_shared/mod.rs
hanabi1224
hanabi1224 previously approved these changes Jun 22, 2026
@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue Jun 22, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 22, 2026
@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue Jun 22, 2026
Merged via the queue into main with commit f9febda Jun 22, 2026
44 checks passed
@LesnyRumcajs LesnyRumcajs deleted the forest-path-env-var branch June 22, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customize Forest data directory via env variable

2 participants