Skip to content

Add a max investor count guard per invoice to prevent unbounded settlement iteration cost #409

Description

@Chucks1093

Summary

The settlement function iterates over all investor positions to distribute returns. An unbounded investor count could exhaust the Soroban transaction budget. A maximum investor count per invoice enforced in the invest function would cap the settlement cost within safe limits.

Scope

  • Add set_max_investors(count: u32) admin function to configure the cap (default 500)
  • Track the investor count per invoice in a persistent counter keyed by invoice_id
  • In invest, panic with MaxInvestorsReached if adding a new investor would exceed the cap
  • Increment the counter only for first-time investors on a given invoice
  • Emit a max_investors_updated event when the cap is changed

Acceptance Criteria

  • First investment from a new wallet increments the investor counter
  • Subsequent investments from the same wallet do not increment the counter
  • New investor on a full invoice panics with MaxInvestorsReached
  • Non-admin set_max_investors panics with Unauthorized
  • max_investors_updated event emitted on change

ETA: 24 hours


Coordinate on Telegram

Activity

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions