Skip to content

fix(staleness): guard priceTimestamp+timeout overflow; treat as stale - #179

Closed
thedavidmeister wants to merge 3 commits into
mainfrom
issue-105-staleness-overflow
Closed

fix(staleness): guard priceTimestamp+timeout overflow; treat as stale#179
thedavidmeister wants to merge 3 commits into
mainfrom
issue-105-staleness-overflow

Conversation

@thedavidmeister

Copy link
Copy Markdown
Collaborator

Summary

  • LibFtsoCurrentPriceUsd.ftsoCurrentPriceUsd: wrap the priceTimestamp + timeout addition in unchecked with an overflow guard — if the sum wraps below priceTimestamp, treat it as stale instead of panicking with Panic(0x11).
  • testRunStaleTimestampOverflow: fuzz test covering the new path, bounding priceTimestamp so priceTimestamp + timeout always overflows and asserting StalePrice (not a panic).

Test plan

  • testRunStaleTimestampOverflow passes (was previously impossible to reach the StalePrice path because checked arithmetic would panic first).
  • Existing testRunStale and testRunStaleBoundaryNotStale still pass.
  • CI green.

Closes #105

🤖 Generated with Claude Code

@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 9 minutes and 33 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: 64a2cd14-21ec-40d5-82e9-c3d00aaaac97

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • src/generated/FlareFtsoWords.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (2)
  • src/lib/price/LibFtsoCurrentPriceUsd.sol
  • test/src/lib/op/LibOpFtsoCurrentPriceUsd.t.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-105-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.

thedavidmeister and others added 2 commits June 23, 2026 11:02
…tempt]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…low fix [3b-attempt]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thedavidmeister thedavidmeister added the ai:ready AI vetter: passes review, ready for human decision label Jul 6, 2026
@thedavidmeister

thedavidmeister commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 ai:vetter
Reviewed 29ff19a: ready — Correct overflow guard: unchecked block with deadline<priceTimestamp detection treats overflow as st
cost 415 — unchecked overflow guard in staleness check plus fuzz test

@thedavidmeister

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #125 (kept). #125 fixes the same overflow via subtraction (block.timestamp > ts && block.timestamp - ts > timeout) across BOTH LibFtsoCurrentPriceUsd.sol (#105) and LibFtsoV2LTS.sol (#102), treating a large timeout or a future/large priceTimestamp as "never stale" (staleness is only about being too old). This PR reverts StalePrice on overflow — which mislabels a large timeout (a valid "never stale" config per #102) as stale. Keeping the single #125.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ready AI vetter: passes review, ready for human decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[F54] [LOW] Stale-price boundary not exercised at uint256 overflow of priceTimestamp + timeout

1 participant