fix(staleness): use subtraction to avoid overflow for large timeout values#171
fix(staleness): use subtraction to avoid overflow for large timeout values#171thedavidmeister wants to merge 2 commits into
Conversation
…alues Closes #102 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The subtraction-based staleness check changes the compiled bytecode. Regenerated via script/BuildPointers.sol. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
block.timestamp > timestamp + timeoutoverflows whentimeoutis neartype(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
type(int224).maxwhich avoids the old overflow, so behavior is unchanged for those inputs)Closes #102
🤖 Generated with Claude Code