Skip to content

fix: improve lookback tipset check error message#7327

Open
hanabi1224 wants to merge 1 commit into
mainfrom
hm/strict-lookback-check
Open

fix: improve lookback tipset check error message#7327
hanabi1224 wants to merge 1 commit into
mainfrom
hm/strict-lookback-check

Conversation

@hanabi1224

@hanabi1224 hanabi1224 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Ports the error message improvement from https://github.com/filecoin-project/lotus/pull/13680/changes#diff-b62548166087e88f8ca2c5613b67b4a44fc090cf65311824d3efbcd1e87182c9R185

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.

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

  • Bug Fixes
    • Improved handling of lookback height calculations when the requested round would go past the current chain height.
    • For newer network versions, the system now returns a clear error instead of falling back to an unexpected result.
    • Preserved the previous fallback behavior for older network versions and genesis cases.

@coderabbitai

coderabbitai Bot commented Jul 9, 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: 60c619e5-8c44-4bc0-a3b1-0f6d3860a437

📥 Commits

Reviewing files that changed from the base of the PR and between cb9c72b and b940820.

📒 Files selected for processing (2)
  • src/chain/store/chain_store.rs
  • src/chain/store/errors.rs
🔗 Linked repositories identified

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

  • filecoin-project/lotus (manual)

Walkthrough

This PR modifies ChainStore::get_lookback_tipset_for_round_blocking to restrict the previous unconditional fallback (recomputing state root against the heaviest tipset) to network versions ≤ V3 or genesis epoch. A new Error::LookbackHeightOverflow variant is added and returned for other cases.

Changes

Lookback overflow error handling

Layer / File(s) Summary
New error variant and type import
src/chain/store/errors.rs
Adds crate::prelude::* import, switches NullRound to prelude ChainEpoch, and adds LookbackHeightOverflow { lookback_height, base_height } variant with formatted error message.
Guarded lookback fallback logic
src/chain/store/chain_store.rs
Restricts the state-root recomputation fallback to network version ≤ V3 or genesis epoch; returns Error::LookbackHeightOverflow otherwise when lookback height exceeds the heaviest tipset epoch.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • ChainSafe/forest#7289: Both PRs modify ChainStore::get_lookback_tipset_for_round_blocking, changing its tipset lookup/error behavior.
  • ChainSafe/forest#7290: Both PRs modify the same function, adjusting the fallback branch logic around genesis/overflow handling.

Suggested reviewers: LesnyRumcajs, 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 clearly matches the main change: stricter lookback tipset handling with an improved error message.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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/strict-lookback-check
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/strict-lookback-check

Warning

Review ran into problems

🔥 Problems

Linked repositories: Couldn't analyze filecoin-project/lotus - clone failed: Clone operation failed: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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

@hanabi1224 hanabi1224 marked this pull request as ready for review July 9, 2026 06:46
@hanabi1224 hanabi1224 requested a review from a team as a code owner July 9, 2026 06:46
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and akaladarshi and removed request for a team July 9, 2026 06:46
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.31%. Comparing base (b2b29fa) to head (b940820).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/chain/store/chain_store.rs 0.00% 17 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/chain/store/errors.rs 12.50% <ø> (ø)
src/chain/store/chain_store.rs 69.92% <0.00%> (-0.71%) ⬇️

... and 10 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 cb9c72b...b940820. 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.


// More null blocks than lookback
// More null blocks than our lookback
if lbr >= heaviest_tipset.epoch() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hanabi1224 I think adding a small unit test for this change will be helpful

nit: You can use the guard-first shape here, but that just my personal preference, you can leave or take it.

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.

2 participants