Skip to content

feat: FOREST_PATH env variable#7200

Open
LesnyRumcajs wants to merge 1 commit into
mainfrom
forest-path-env-var
Open

feat: FOREST_PATH env variable#7200
LesnyRumcajs wants to merge 1 commit 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. Takes precedence over config file settings and defaults.
    • Data directory path is now logged when the daemon starts.
  • Documentation

    • Updated environment variables reference guide with formatting improvements.
    • Added changelog entry documenting the FOREST_PATH environment variable.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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.
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#5836: The new api test-stateful subcommand constructs its RPC client via rpc::Client::default_or_from_env(None), which this PR updates to use default_token_path() and honor FOREST_PATH.
  • 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

  • hanabi1224
  • akaladarshi
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: introducing the FOREST_PATH environment variable feature for customizing the Forest data directory.
Linked Issues check ✅ Passed The PR fully addresses issue #6008: implements FOREST_PATH env variable with proper precedence (env > config > defaults), updates test scripts to use FOREST_DAEMON_PATH, updates documentation, and ensures consistency across forest binaries.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing FOREST_PATH functionality and updating test scripts accordingly; no unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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 (ead4de9) to head (37d8d93).
⚠️ Report is 1 commits behind head on main.
✅ 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 13 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 ead4de9...37d8d93. 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.

@LesnyRumcajs LesnyRumcajs enabled auto-merge June 19, 2026 11:34
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

1 participant