Skip to content

Fix unbounded receipt minting by adding MAX_USER_RECEIPTS cap - #953

Open
Peolite001 wants to merge 8 commits into
FinChippay:mainfrom
Peolite001:fix/receipt-cap
Open

Fix unbounded receipt minting by adding MAX_USER_RECEIPTS cap#953
Peolite001 wants to merge 8 commits into
FinChippay:mainfrom
Peolite001:fix/receipt-cap

Conversation

@Peolite001

@Peolite001 Peolite001 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR bounds the number of receipts a single account can mint by introducing a MAX_USER_RECEIPTS cap. This prevents individual accounts from bloating the contract's storage footprint and slowing down the TTL sweep.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / chore
  • Smart contract change

Related issue

Closes #884

Changes

  • Defined a MAX_USER_RECEIPTS constant set to 1,000 in contracts/finchippay-contract/src/lib.rs.
  • Updated the mint_receipt function to enforce the cap and panic with "User receipt limit reached" if the limit is exceeded.
  • Added documentation for the new receipt cap in contracts/finchippay-contract/README.md under the "Bounded inputs" section.
  • Added boundary tests (test_mint_receipt_cap and test_mint_receipt_cap_exceeded) to verify that minting works up to the limit and cleanly reverts when the cap is crossed.

Testing

  • Tested locally on Testnet
  • Added/updated unit tests
  • Manually tested UI flow

Screenshots (if UI change)

N/A

Checklist

  • My code follows the project style
  • I've updated docs if needed
  • No console errors or warnings
  • I've rebased on latest main

@github-actions github-actions Bot added the needs-review PR ready for Greptile AI code review label Aug 27, 2026
@github-actions

Copy link
Copy Markdown

🤖 Greptile AI Code Review

Greptile will automatically review this PR (6 file(s) changed).

Review gates:

  • ✅ CodeQL Security Scan
  • ✅ Custom rules (.greptile/config.json)
  • ✅ Architecture guidelines (.greptile/rules.md)

To manually trigger a re-review, comment @greptileai on this PR.
To skip review, add the skip-review label.

@Topmatrixmor2014

Copy link
Copy Markdown
Contributor

resolve conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review PR ready for Greptile AI code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#103 — Has No Per-Payer Cap: Receipt Counters Grow Unbounded

2 participants