Skip to content

Add storage-rent budget pre-flight check on create_market to prevent under-funded archives #634

Description

@greatest0fallt1me

Description

create_market does not pre-flight check that the caller has paid sufficient rent for the persistent-tier keys it will allocate. Add a pre-flight estimate and reject if insufficient.

Requirements and Context

  • Compute rent estimate from StorageConfig constants and number of keys allocated
  • Compare to env.storage().instance().get_ttl() headroom
  • Reject with Error::InsufficientStorageRent
  • 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 feat/create-market-rent-preflight
  2. Implement changes
    • contracts/predictify-hybrid/src/markets.rs
    • contracts/predictify-hybrid/src/storage.rs
    • contracts/predictify-hybrid/src/err.rs
  3. Test and commit
    • cargo test -p predictify-hybrid market_creation_validation_tests -- --nocapture
    • Cover edge cases: ample headroom, just-enough, insufficient
    • Include test output and notes in the PR

Example commit message

feat: pre-flight storage-rent check in create_market

Acceptance Criteria

  • Rejection on insufficient rent
  • Estimate formula documented
  • No unwrap() introduced
  • Tests cover boundary

Guidelines

  • Avoid double-counting persistent-key bumps
  • Minimum 95% coverage
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions