Skip to content

fix(staleness): use subtraction to avoid overflow for large timeout values#171

Open
thedavidmeister wants to merge 2 commits into
mainfrom
issue-102-staleness-overflow
Open

fix(staleness): use subtraction to avoid overflow for large timeout values#171
thedavidmeister wants to merge 2 commits into
mainfrom
issue-102-staleness-overflow

Conversation

@thedavidmeister

Copy link
Copy Markdown
Collaborator

Summary

block.timestamp > timestamp + timeout overflows when timeout is near type(uint256).max, causing a checked-arithmetic Panic instead of a clean pass. A very-large timeout semantically means "never stale," but the overflow makes the check revert instead.

Fixed in both stale-price checks:

  • src/lib/lts/LibFtsoV2LTS.sol: ftsoV2LTSGetFeed (timestamp is uint64, promoted to uint256)
  • src/lib/price/LibFtsoCurrentPriceUsd.sol: ftsoCurrentPriceUsd (both uint256)

Replacement: block.timestamp > timestamp && block.timestamp - timestamp > timeout — subtraction avoids the addition overflow entirely. The first guard (block.timestamp > timestamp) is always true for real feed data and makes the unsigned subtraction safe.

Test plan

  • Existing staleness fuzz tests still pass (they bound timeout to type(int224).max which avoids the old overflow, so behavior is unchanged for those inputs)
  • CI rainix-sol-test passes

Closes #102

🤖 Generated with Claude Code

…alues

Closes #102

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@thedavidmeister, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 9 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 51cce43e-67b2-4d0d-8956-4046afe7a070

📥 Commits

Reviewing files that changed from the base of the PR and between cb20d03 and aadcf61.

⛔ Files ignored due to path filters (1)
  • src/generated/FlareFtsoWords.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (2)
  • src/lib/lts/LibFtsoV2LTS.sol
  • src/lib/price/LibFtsoCurrentPriceUsd.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-102-staleness-overflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

The subtraction-based staleness check changes the compiled bytecode.
Regenerated via script/BuildPointers.sol.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

[F51] [LOW] Staleness check can panic-revert (overflow) instead of a clean error for large timeout

1 participant