Skip to content

Settlement: cap get_all_developer_balances or paginate to bound gas for large maps #347

@greatest0fallt1me

Description

@greatest0fallt1me

Description

CalloraSettlement::get_all_developer_balances iterates the entire developer Map and its own docs warn that >100 entries can exhaust gas. A single unbounded admin view that can hit the transaction budget is a denial-of-service vector for operators. Add pagination (offset/limit) or a hard cap so the call cannot exceed Soroban resource limits.

Requirements and Context

  • Add get_developer_balances_page(caller, start, limit) with a documented max limit.
  • Keep the legacy full call but reject when entry count exceeds a safe threshold, pointing operators to the paginated API and off-chain indexing.
  • Document gas implications in docs/SETTLEMENT_IMPLEMENTATION.md.
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feature/settlement-paginated-balances
  2. Implement changes
    • contracts/settlement/src/lib.rs — paginated view + cap
    • docs/SETTLEMENT_IMPLEMENTATION.md — gas/pagination notes
  3. Test and commit
    • cargo test -p callora-settlement
    • Test pagination boundaries and over-cap rejection
    • Include test output and notes in the PR

Example commit message

feat: add paginated developer balance query to settlement

Acceptance Criteria

  • Paginated query with documented max limit
  • Over-threshold full query rejected with guidance
  • Pagination boundaries tested
  • Gas notes documented

Guidelines

  • .rs under contracts/settlement/src/, cargo test, /// docs, minimum 95% line coverage, no unwrap() in prod paths
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programauditSecurity audit/reviewenhancementNew feature or improvementsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions