Skip to content

feat(events): remove per-event participant caps, add paginated list getters - #104

Merged
0xdevcollins merged 1 commit into
boundlessfi:testnetfrom
Celengwu:Feat/remove-per-event-cap
Jul 28, 2026
Merged

feat(events): remove per-event participant caps, add paginated list getters#104
0xdevcollins merged 1 commit into
boundlessfi:testnetfrom
Celengwu:Feat/remove-per-event-cap

Conversation

@Celengwu

@Celengwu Celengwu commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Closes #103

Summary

Removes the 5,000-entry caps on applicants, contributors, and submissions. Participant storage is per-entry (one ledger entry per participant, paid by the participant's own transaction), and no state-changing path iterates the full set in one transaction, so the caps prevented no failure mode. They did, however, let an attacker fill all slots with throwaway wallets and lock real participants out. Events now support unlimited participants.

Changes

  • Drop the cap checks and cap params from append_applicant, append_contributor, and append_submission; the only remaining guard is checked_add on the u32 counter (old error codes reused on overflow, none renumbered)
  • Delete MAX_APPLICANTS_PER_EVENT, MAX_CONTRIBUTORS_PER_EVENT, MAX_SUBMISSIONS_PER_EVENT
  • Keep MAX_WINNERS_PER_SELECT (50) and MAX_REFUNDS_PER_BATCH (25) unchanged; these batching limits are what make unbounded sets safe
  • Clamp get_applicants / get_contributors / get_winners to the first 100 entries (VIEW_PAGE_LIMIT) and add get_applicants_page / get_contributors_page / get_winners_page(event_id, start, limit) for reading beyond that
  • Tests: apply/submit past the former cap succeeds, counter overflow reverts, pagination edge cases (start past end, limit 0, oversized limit clamps)

Notes

  • No existing entrypoint signatures or error codes changed; three new read-only entrypoints added
  • Full participant lists remain the indexer's job off-chain; clients reading more than 100 entries should use the _page variants
  • 225 tests pass, fmt clean, wasm builds at 56.9 KB (under the 64 KB ceiling)

Summary by CodeRabbit

  • New Features
    • Added pagination for applicant, winner, and contributor lists.
    • Added safeguards to limit individual page requests for reliable viewing.
  • Improvements
    • Events can now support more applicants, contributors, and submissions without the previous per-event caps.
    • Existing list views return the first page, with additional pages available on demand.
  • Bug Fixes
    • Added protection against counter overflow when participant or submission counts reach their maximum.

…submissions; implement pagination for applicant and contributor retrieval
@almanax-ai

almanax-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Quota reached

Your plan allows 300 CI/CD file units per month. You've used 299 and this scan would add 7 more (total: 306).

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Per-event applicant, contributor, and submission caps are removed in favor of u32 overflow checks. Applicant, winner, and contributor getters now support bounded pagination, with tests covering former-cap and pagination behavior.

Changes

Participant capacity and pagination

Layer / File(s) Summary
Storage overflow guards and page windows
contracts/events/src/errors.rs, contracts/events/src/storage.rs
Append operations no longer enforce per-event caps; counters reject only u32 overflow, and snapshots read (start, limit) windows.
Entry points and paged view wiring
contracts/events/src/bounty.rs, contracts/events/src/event_ops.rs, contracts/events/src/lib.rs
State-changing callers use cap-free append APIs, while public getters expose bounded applicant, winner, and contributor pages.
Capacity and pagination regression coverage
contracts/events/src/tests/*
Tests cover writes beyond former caps, counter overflow, and pagination edge cases.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant ContractGetters
  participant EventOps
  participant EventStorage
  Caller->>ContractGetters: get_applicants_page(event_id, start, limit)
  ContractGetters->>EventOps: get_applicants_page(event_id, start, limit)
  EventOps->>EventStorage: applicants_snapshot(event_id, start, bounded_limit)
  EventStorage-->>EventOps: applicant page
  EventOps-->>ContractGetters: page result
  ContractGetters-->>Caller: Vec<Address>
Loading

Possibly related PRs

Suggested reviewers: 0xdevcollins

Poem

I’m a bunny with pages to hop,
No 5,000-wall makes me stop.
Counters leap wide, overflow stays barred,
Each little view is neatly bounded and starred.
Applicants, winners, contributors too—
Paginated trails for the review crew.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: removing participant caps and adding paginated getters.
Linked Issues check ✅ Passed The changes match issue #103 by removing the caps, preserving overflow guards, and adding paginated list accessors.
Out of Scope Changes check ✅ Passed No clearly unrelated code changes appear in the summarized diff; the edits stay focused on caps, pagination, and tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
contracts/events/src/storage.rs (1)

678-688: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add contributor partition/overflow coverage.

contributors_snapshot and get_contributors_page now mirror the applicant/submission pagination behavior, but contributor-specific tests only cover normal top-up/de-dup/cancel paths. Add coverage for the contributor set: duplicate contribution rejoin, overflow around u32::MAX returning TooManyContributors, and out-of-bounds pagination clamping.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/events/src/storage.rs` around lines 678 - 688, Extend the
contributor-specific test coverage around contributors_snapshot and
get_contributors_page to verify duplicate contribution rejoin behavior,
contributor-count overflow near u32::MAX returns TooManyContributors, and
pagination starting beyond the available range clamps safely without returning
entries or panicking. Reuse the existing applicant/submission pagination and
overflow test patterns, adapting them to the contributor set.
🧹 Nitpick comments (1)
contracts/events/src/errors.rs (1)

53-61: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Reused TooManyContributors error code conflates two unrelated overflow conditions. Both append_contributor's contributor-counter overflow and append_submission's submission-counter overflow return the same Error::TooManyContributors, so callers/monitoring cannot distinguish which counter actually overflowed. The enum comment itself notes only 48 of 50 contracterror variants are used, so a dedicated variant is feasible without hitting the XDR cap.

  • contracts/events/src/errors.rs#L53-L61: add a distinct TooManySubmissions variant (e.g. discriminant 92, since 91 is already the highest used) instead of documenting TooManyContributors as dual-purpose.
  • contracts/events/src/storage.rs#L463-L481: change append_submission's checked_add(1).ok_or(Error::TooManyContributors) to return the new dedicated variant.
♻️ Proposed fix
--- a/contracts/events/src/errors.rs
@@
     TooManyContributors = 61,
+
+    // Distinct from TooManyContributors: signals append_submission's own
+    // u32 counter overflow rather than the contributor counter's.
+    TooManySubmissions = 92,
--- a/contracts/events/src/storage.rs
@@
-    let next = cur.checked_add(1).ok_or(Error::TooManyContributors)?;
+    let next = cur.checked_add(1).ok_or(Error::TooManySubmissions)?;

Note: adding a new variant also requires updating hackathon_pillar.rs's submit_at_counter_overflow_reverts assertion from Error::TooManyContributors to the new variant.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/events/src/errors.rs` around lines 53 - 61, Add a dedicated
TooManySubmissions error variant with discriminant 92 in the error enum, keeping
TooManyContributors limited to contributor-counter overflow and updating its
comments. In contracts/events/src/storage.rs lines 463-481, change
append_submission’s checked_add overflow mapping to Error::TooManySubmissions;
also update hackathon_pillar.rs’s submit_at_counter_overflow_reverts assertion
to expect the new variant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@contracts/events/src/storage.rs`:
- Around line 678-688: Extend the contributor-specific test coverage around
contributors_snapshot and get_contributors_page to verify duplicate contribution
rejoin behavior, contributor-count overflow near u32::MAX returns
TooManyContributors, and pagination starting beyond the available range clamps
safely without returning entries or panicking. Reuse the existing
applicant/submission pagination and overflow test patterns, adapting them to the
contributor set.

---

Nitpick comments:
In `@contracts/events/src/errors.rs`:
- Around line 53-61: Add a dedicated TooManySubmissions error variant with
discriminant 92 in the error enum, keeping TooManyContributors limited to
contributor-counter overflow and updating its comments. In
contracts/events/src/storage.rs lines 463-481, change append_submission’s
checked_add overflow mapping to Error::TooManySubmissions; also update
hackathon_pillar.rs’s submit_at_counter_overflow_reverts assertion to expect the
new variant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a535a1bd-f333-4de5-9736-8525051c9ca5

📥 Commits

Reviewing files that changed from the base of the PR and between 9bdb45b and 27a78c0.

📒 Files selected for processing (7)
  • contracts/events/src/bounty.rs
  • contracts/events/src/errors.rs
  • contracts/events/src/event_ops.rs
  • contracts/events/src/lib.rs
  • contracts/events/src/storage.rs
  • contracts/events/src/tests/bounty_pillar.rs
  • contracts/events/src/tests/hackathon_pillar.rs

@0xdevcollins
0xdevcollins merged commit b1a8a75 into boundlessfi:testnet Jul 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove per-event participant caps; support unlimited applicants/contributors/submissions

2 participants