Skip to content

Task/centralize storage ttl#566

Merged
greatest0fallt1me merged 2 commits into
Predictify-org:masterfrom
Agbasimere:task/centralize-storage-ttl
May 27, 2026
Merged

Task/centralize storage ttl#566
greatest0fallt1me merged 2 commits into
Predictify-org:masterfrom
Agbasimere:task/centralize-storage-ttl

Conversation

@Agbasimere
Copy link
Copy Markdown
Contributor

Summary

Closes #542

This centralizes persistent-storage TTL policy in storage.rs so TTL behavior is auditable, consistent across write paths, and easier to tune if Stellar rent parameters change.

What changed

  • added TTL tier fields to StorageConfig
    • balance_ttl_ledgers
    • market_ttl_ledgers
    • event_ttl_ledgers
    • archive_ttl_ledgers
  • introduced shared storage helpers for persistent writes and TTL refreshes
  • replaced raw inline TTL literals in persistent write paths
  • applied centralized TTL handling to:
    • balances
    • compressed market and market-reference writes
    • event writes
    • creator counter writes
    • archive/migration/config writes
  • documented TTL tiers and approximated wall-clock durations in docs/contracts/STORAGE_LAYOUT.md

TTL tiers

  • Balance: 535,680 ledgers, about 31 days
  • Market: 6,307,200 ledgers, about 365 days
  • Event: 1,555,200 ledgers, about 90 days
  • Archive: 6,307,200 ledgers, about 365 days

Why

Previously, storage.rs mixed TTL policy into individual write paths, including hardcoded values like 535680. That made archival behavior harder to reason about and easy to drift over time.

Now:

  • TTL policy is defined in one place
  • persistent writes refresh TTL consistently
  • the runtime helper caps requested TTLs to the live Soroban maximum TTL
  • tests cover refresh behavior when entries are rewritten near expiry

Files changed

  • contracts/predictify-hybrid/src/storage.rs
  • docs/contracts/STORAGE_LAYOUT.md

Tests

cargo test -p predictify-hybrid -- storage --test-threads=1
cargo test -p predictify-hybrid --lib -- --test-threads=1

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 26, 2026

@Agbasimere Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit a1573c8 into Predictify-org:master May 27, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract hardcoded persistent-storage TTL bump values into a centralized StorageConfig in storage.rs

2 participants