Skip to content

Contracts: Add storage pruning function to reclaim rent fees from expired data #451

Description

@joelpeace48-cell

Summary

On Soroban, storage that is not bumped expires and its rent fees are forfeited. The contract accumulates stale participant records, expired credits, and old nonces that bloat instance/persistent storage and increase minimum balance requirements. A pruning function cleans up expired data.

Acceptance Criteria

  • Add prune_expired_participants(env, max_entries: u32) — removes participant records where TTL has passed (batch to avoid gas limits, max_entries cap per call)
  • Add prune_used_nonces(env, admin, max_entries: u32) — removes nonce records older than 10,000 ledgers
  • Both functions callable by anyone (no auth required — they only delete expired/stale data)
  • Return the number of entries pruned
  • Emit pruned event with count
  • Add storage_stats(env) -> (participant_count, nonce_count, expired_estimate) view for monitoring
  • Add unit tests: prune empty (no-op), prune with expired entries, max_entries cap respected

References

  • contracts/campaign/src/lib.rs — participant storage
  • contracts/rewards/src/lib.rs — nonce storage

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions