-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Add ratelimit sanity check (SC-1164) #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis PR enhances rate-limit validation in the test harness by introducing context-aware checks. A new internal helper function validates rate-limit data values (maxAmount and slope) for each rate-limit id, while the existing key verification function is updated to invoke this validation during checks. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/test-harness/SparkLiquidityLayerTests.sol (3)
366-390: Context‑aware rate‑limit key check wiring looks correctPassing
ctxinto_checkRateLimitKeyshere keeps the existing key‑coverage semantics while enabling value sanity checks viactx.rateLimits. Since_checkRateLimitKeyscurrently only usesctx.rateLimits, reusing the same pre‑executionctxfor both calls is safe; if you later extend it to depend on the controller, consider re‑fetchingctxwithisPostExecution: truefor the second call to make that intent explicit.
2791-2818: Domain E2E runner correctly updated to pass context into key checksThe
_runSLLE2ETestsForDomainflow now validates rate‑limit values for all integrations pre‑ and post‑execution using the domain’sctx.rateLimits, which is exactly what the new helper requires. As with the Ethereum test, if_checkRateLimitKeysever starts depending on controller state, it may be worth calling it with the post‑executionctxyou compute later in this function for clarity.
3602-3612: Rate‑limit magnitude sanity check is reasonable; consider named constants/comments
_checkRateLimitValueenforces thatmaxAmountandslopeare either 0,type(uint256).max, or ≤ ~1e10in 18‑dec units, which is a sensible upper bound to catch obvious misconfigurations (e.g., missing scaling). The logic is straightforward and side‑effect‑free.For readability and future tuning, it would help to:
- Extract the
1e10and1e18values into named constants (e.g.,MAX_NORMALIZED_RATE_LIMITandDECIMALS) or- Add a short comment indicating this is “~10B units at 18 decimals” so the intent is clear at call sites.
Functionally, this is solid as‑is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/test-harness/SparkLiquidityLayerTests.sol(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (1)
src/test-harness/SparkLiquidityLayerTests.sol (1)
3564-3599: New_checkRateLimitKeysbehavior preserves coverage and adds value sanityPulling
SparkLiquidityLayerContextinto_checkRateLimitKeysand invoking_checkRateLimitValuefor each non‑zeroentryId/entryId2/exitId/exitId2gives you per‑id sanity checking on top of the existing “every key must be covered and removed” invariant. Therequireon non‑empty integrations and the finalassertTrue(rateLimitKeys.length == 0)keep the original safety properties intact, with_removestill guaranteeing that every integration id appears inrateLimitKeys.
Summary by CodeRabbit