Feat/add rate limiting and input validation - #151
Merged
manoahLinks merged 3 commits intoMar 29, 2026
Merged
Conversation
|
@EA10-lite 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.
Pull Request
Description
Add input validation and rate limiting on EventManager contract entrypoints to limit storage bloat and abusive patterns (spam events, oversized strings, runaway ticket batches, unrealistic prices/schedules).
Fixes #99
Type of Change
Please delete options that are not relevant.
Changes Made
theme,event_type, and tier names must be non-empty and within a max byte length (200); failures returnInvalidStringInput.TicketPriceOutOfRange);purchase_ticketsquantity capped per transaction (500,PurchaseQuantityTooLarge).end_date > start_date > ledgertime on create; max event duration (~366 days) and max how far start may be in the future (~5 years) viaEventScheduleOutOfRange/ existing date errors.update_eventapplies the same span/future-start rules only when the effective start is still in the future so in-progress events can extendend_datesensibly.TooManyTicketTiers).OrganizerOpenEventCount— max 50 open events per organizer (TooManyOrganizerEvents). Count increments on successful create and decrements oncancel_eventandwithdraw_funds.OrganizerLastCreateTs+ 120s cooldown between creates only while the organizer still has at least one open event (EventCreationRateLimited), so canceling/withdrawing all events allows an immediate replacement create.DataKey/Errorvariants used by waitlist, escrow balance, and withdraw paths; added no-optry_promote_from_waitlistforwithdraw_funds.#[cfg(test)] mod testwired; tests usecreate_event_with_tiers/ correctpurchase_ticketsarity; fixed corruptedtest_withdraw_funds_double_withdrawal; added tests for empty theme, rate limit, post-cancel recreate, and over-limit purchase quantity. Integration test bumps ledger time between two creates for the same organizer; importLedgertestutils forset_timestamp.Testing
Please describe the tests that you ran to verify your changes:
cargo test -p event_manager(32 unit tests)cargo build -p event_manager --target wasm32-unknown-unknown --releaseChecklist
Screenshots (if applicable)
Add screenshots to help explain your changes.
N/A (contract-only changes)
Additional Notes
Errordiscriminants should be regenerated after deploy.integration_tests) still require built WASM artifacts undertarget/wasm32-unknown-unknown/release/forcontractimport!; this is unchanged from the existing workflow.