Skip to content

fix: log Rand errors#7082

Merged
LesnyRumcajs merged 2 commits into
mainfrom
hm/inpect-rand-errors
May 20, 2026
Merged

fix: log Rand errors#7082
LesnyRumcajs merged 2 commits into
mainfrom
hm/inpect-rand-errors

Conversation

@hanabi1224
Copy link
Copy Markdown
Contributor

@hanabi1224 hanabi1224 commented May 20, 2026

Summary of changes

Changes introduced in this pull request:

  • log Rand errors as they are not propagated in fvm
  • disable tipset lookup cache in forest-dev state compute to ensure snapshot completeness

Original bug:

> forest-dev state compute --chain mainnet --epoch 6029534 --export-db-to mainnet_6029534.forest.car.zst
epoch: 6029534, state_root: bafy2bzaceagedjhikhjsi2ruwbjmy2gspszqcua5ct5j2o2e6ar7zxsyr5fzk, receipt_root: bafy2bzacebtnqz5kit2i22ggb6aq6u2cyqmsnkvnezudyytlbymqptlqc44xq, db_snapshot_size: 4.4 MiB

> forest-dev state replay-compute --chain mainnet mainnet_6029534.forest.car.zst
Error: state root mismatch, state_root: bafy2bzacebf5ytfseptikwcm2shtzwe6saunt4umytwk3ehl6bkgehhvirpei, expected_state_root: bafy2bzaceagedjhikhjsi2ruwbjmy2gspszqcua5ct5j2o2e6ar7zxsyr5fzk

With the fix:

> forest-dev state compute --chain mainnet --epoch 6029534 --export-db-to mainnet_6029534.forest.car.zst
epoch: 6029534, state_root: bafy2bzaceagedjhikhjsi2ruwbjmy2gspszqcua5ct5j2o2e6ar7zxsyr5fzk, receipt_root: bafy2bzacebtnqz5kit2i22ggb6aq6u2cyqmsnkvnezudyytlbymqptlqc44xq, db_snapshot_size: 11.4 MiB

> forest-dev state replay-compute --chain mainnet mainnet_6029534.forest.car.zst
2026-05-20T06:42:01.712496Z  INFO forest::state_manager::utils::state_compute: epoch: 6029534, state_root: bafy2bzaceagedjhikhjsi2ruwbjmy2gspszqcua5ct5j2o2e6ar7zxsyr5fzk, receipt_root: bafy2bzacebtnqz5kit2i22ggb6aq6u2cyqmsnkvnezudyytlbymqptlqc44xq, took 5s 986ms 689us 922ns.

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.

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 environment variable option to disable tipset lookup table cache for development and testing scenarios.
  • Improvements

    • Enhanced error logging for chain randomness operations with contextual information including request details and chain state.
  • Documentation

    • Updated environment variable reference guide with new configuration option and usage details.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

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: c465617b-2876-4387-88de-85b6b4398ead

📥 Commits

Reviewing files that changed from the base of the PR and between 7d19be2 and 8b732a2.

📒 Files selected for processing (4)
  • docs/docs/users/reference/env_variables.md
  • src/chain/store/index.rs
  • src/dev/subcommands/state_cmd.rs
  • src/state_manager/chain_rand.rs

Walkthrough

This PR adds a toggleable environment flag FOREST_TIPSET_LOOKUP_TABLE_DISABLED to conditionally disable tipset lookup-table cache traversal in chain store operations, documents the flag, integrates it into cache-disabling utilities, and adds error-side logging to chain randomness methods.

Changes

Tipset Cache Control and Observability Improvements

Layer / File(s) Summary
Tipset lookup table disable feature
docs/docs/users/reference/env_variables.md, src/chain/store/index.rs, src/dev/subcommands/state_cmd.rs
Environment variable FOREST_TIPSET_LOOKUP_TABLE_DISABLED is documented, then checked in ChainIndex::tipset_by_height to skip checkpoint-based lookup-table resolution when the flag is set. The flag is also set by disable_tipset_cache() alongside FOREST_TIPSET_CACHE_DISABLED to disable both caches together.
Error logging for randomness generation
src/state_manager/chain_rand.rs
ChainRand's get_chain_randomness and get_beacon_randomness trait methods now call their v2/v3 implementations and attach inspect_err handlers that emit tracing::warn! logs with the requested round, tipset context, and error details.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • ChainSafe/forest#6705: Both PRs touch the environment-flag surface for tipset caching—chore: update env variables #6705 documents FOREST_TIPSET_CACHE_DISABLED, while the main PR adds/uses FOREST_TIPSET_LOOKUP_TABLE_DISABLED and extends disable_tipset_cache() to disable that cache alongside FOREST_TIPSET_CACHE_DISABLED.

Suggested reviewers

  • LesnyRumcajs
  • sudo-shashank
🚥 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 'fix: log Rand errors' accurately summarizes the main change in the PR—adding error logging for Rand trait methods in chain_rand.rs, which is the primary technical change across the files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 hm/inpect-rand-errors
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/inpect-rand-errors

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

@hanabi1224 hanabi1224 marked this pull request as ready for review May 20, 2026 06:56
@hanabi1224 hanabi1224 requested a review from a team as a code owner May 20, 2026 06:56
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and sudo-shashank and removed request for a team May 20, 2026 06:56
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.21%. Comparing base (7d19be2) to head (8b732a2).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/state_manager/chain_rand.rs 0.00% 8 Missing and 2 partials ⚠️
src/dev/subcommands/state_cmd.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/chain/store/index.rs 89.62% <100.00%> (ø)
src/dev/subcommands/state_cmd.rs 0.00% <0.00%> (ø)
src/state_manager/chain_rand.rs 65.64% <0.00%> (-5.90%) ⬇️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d19be2...8b732a2. 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 added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit 57f4c47 May 20, 2026
50 checks passed
@LesnyRumcajs LesnyRumcajs deleted the hm/inpect-rand-errors branch May 20, 2026 08:37
Sign up for free to 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