fix: rate limiting, filter/sort allowlists, overflow bounds, and bench CI gates - #395
Open
DanielCharis1 wants to merge 1 commit into
Open
Conversation
…h CI gates Resolves the four Stellar Wave issues assigned to DanielCharis1: - UnityChainxx#295: rate-limit auth, wallet, and token-validation flows. The RateLimiterModule is now global, the guard emits standard 429 retry metadata (Retry-After + X-RateLimit-* headers, retryAfterSeconds in the body), supports account/wallet-aware keys, and lockout behavior is covered by new service + guard tests. - UnityChainxx#277: reject arbitrary sortBy/sortOrder values in puzzle-review via runtime allowlists mapping public keys to known columns (the old code interpolated raw query strings into the ORDER BY clause). - UnityChainxx#265: explicit checked arithmetic for question ids, per-level indices, attempts, and last_question_index, failing with a defined ArithmeticOverflow error; min/max and overflow boundary tests added. - UnityChainxx#281: wire the previously-unincluded bench/test modules into the contract crate (the CI bench step was producing empty output), fix the duplicated nested bench test, and enforce documented resource-budget baselines (onchain/bench-baselines.json) via a CI check step. Also fixes the stale onchain/Cargo.lock (broke --locked builds) and the un-wired NFT test that referenced undefined bindings. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@DanielCharis1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the four Stellar Wave issues assigned to @DanielCharis1: rate limiting for auth/wallet flows (#295), filtering & sorting allowlists (#277), overflow/boundary behavior for onchain arithmetic (#265), and resource-budget regression thresholds in contract CI (#281).
Changes
#295 — Rate limiting for authentication & wallet verification
RateLimiterModuleis now@Globaland registered inAppModule, so the guard/decorator work anywhere.RateLimitGuardemits standard retry metadata on 429:Retry-After+X-RateLimit-*headers andretryAfterSecondsin the error body.keyGenerator(login keys by email, wallet verification keys by address) while still throttling anonymous traffic by IP.POST /auth/register,POST /auth/login,POST /auth/validate-token,POST /wallet/link, andPOST/GET /wallet/verify-signature.#277 — Filtering & sorting allowlists
puzzle-reviewspreviously interpolated rawsortBy/sortOrderquery strings into the SQLORDER BY(queryBuilder.orderBy(\review.${sortBy}`)). Runtime allowlists now map public keys (createdAt/rating/helpfulCount,ASC/DESC`) to known columns and reject anything else with a 400, enforced in both the controller and the service.#265 — Overflow & boundary behavior (onchain)
question_id, per-level indices,attempts,last_question_index, and the old-level index decrement) and fails with a definedError::ArithmeticOverflow(Replace hardcoded JWT secret fallback"your-secret-key"with a startup-time assert #12) instead of wrapping.#281 — Resource-budget regression thresholds in contract CI
bench.rs/test.rswere never declared as modules inlib.rs, so the CI bench step ran zero tests and uploaded empty output. They are now wired in (#[cfg(test)] mod test; mod bench;).AttemptTooSoonledger issue in the bench loop.onchain/bench-baselines.jsondocuments the budget baselines;scripts/check-bench-budgets.pyparses the bench output and fails the job on any metric exceeding its baseline (or when no measurements appear at all). Wired intobuild.ymlafter the bench step.Additional fixes required to make
cargo test --workspace --lockedgreenonchain/Cargo.lockwas stale (missing the receiver's dev-deps) and broke all--lockedbuilds; regenerated.stellar_huntstest suite for the soroban-sdk 22 APIs (register_contractreturnsAddress,MockAuthborrow semantics) and the brokenstellar_hunts_nfttest_double_mint_rejectedthat referenced undefined bindings.cargo fmtacross the onchain workspace so the fmt gate passes.Testing
cargo test --workspace --locked— all 27 tests pass (23 game contract + 4 NFT); bench measurements (CPU 185k / mem 29k / avg 17k) are well under the documented baselines andcheck-bench-budgets.pyexits 0.jeston the touched areas — 25 tests pass (rate-limiter service + guard, wallet, puzzle-review allowlists). Backendtscshows no new errors in changed files (pre-existing repo errors remain, matching the advisory CI note).cargo fmt --all -- --checkpasses.Related Issues
Closes #295, closes #281, closes #277, closes #265