Skip to content

Marketplace persistent Listing entries are never TTL-extended and will be archived by Soroban ledger #356

Description

@Mac-5

Description

In Soroban, entries in persistent() storage expire after their TTL (time-to-live) elapses. Once archived, the entry is pruned from the ledger and reads return None — identical to the entry never having existed.

contracts/marketplace/src/lib.rs stores Listing structs in persistent storage:

env.storage()
    .persistent()
    .set(&DataKey::Listing(invoice_id), &listing);

However, no call to extend_ttl is made anywhere in the contract — not in list_invoice, fund_invoice, or cancel_listing. This means every listing will eventually expire and be archived by the ledger.

When that happens, get_listing returns KoraError::ListingNotFound for a listing that was created and never explicitly removed. Investors lose visibility into their positions, and the funded_amount history is irrecoverably gone.

Contrast this with the treasury contract, which correctly calls extend_ttl on persistent entries after updates.

Fix

Extend the TTL of a listing entry on every write (create, fund, cancel):

const LISTING_TTL_THRESHOLD: u32 = 535_680;  // ~31 days
const LISTING_TTL_BUMP: u32 = 535_680;

// After each .set():
env.storage().persistent().extend_ttl(
    &DataKey::Listing(invoice_id),
    LISTING_TTL_THRESHOLD,
    LISTING_TTL_BUMP,
);

Also extend TTL in get_listing to reset the clock on read-only access for long-lived listings.

Acceptance Criteria

  • list_invoice, fund_invoice, and cancel_listing all call extend_ttl after writing.
  • TTL constants are defined and documented.
  • Existing tests updated to verify listings remain accessible after expected ledger time.

Complexity: Low (75 points)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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