fix(stellar): fix #58 storage rent audit and persistent migration - #83
Conversation
|
@fhayvy 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! 🚀 |
|
Conflicts in git fetch origin
git rebase origin/develop
git push --force-with-lease
|
|
@truthixify kindly merge now conflict resolved |
|
Clean merge. Persistent-storage migration for stealth-registry, stealth-sender, and wraith-names is exactly the storage-rent fix we needed. STORAGE_RENT.md is a great writeup. Thanks @fhayvy. |
Closes #58
PR Description
Soroban contract instances have strict storage capacity limits (64 KB for the entire instance). In the previous implementation of our contracts, user registration data, names, and reverse-lookup mappings in
stealth-registryandwraith-nameswere stored directly ininstancestorage. Under higher user volumes, this design leads to rapid contract bloat, leading to instances exceeding limits and rendering contracts permanently un-upgradable or unusable. Furthermore, lack of active time-to-live (TTL) management meant that these vital entries risk accidental expiration and archival, necessitating expensive and complex restoration processes.This PR conducts a comprehensive storage rent audit and performing architectural migrations.
Solutions & Improvements
Migration to Persistent Storage:
instancestorage topersistentstorage.stealth-registryandwraith-namescontracts to completely eliminate user data storage on instances, keeping only minimal operational variables in instances if any, thus avoiding the 64 KB limit entirely.Conditional Active TTL Management:
extend_ttlhost functions.TTL_THRESHOLDto17,280ledgers (~1 day) andTTL_EXTEND_TOto518,400ledgers (~30 days).Audit Documentation:
stellar/STORAGE_RENT.md. This contains complete storage write enumerations (tier, creator, renewal responsibilities), cost models calculated across three scale tiers (10k, 100k, and 1M entries) using current mainnet fees, and strategic recommendations for Soroban state management.Enhanced Test Coverage:
stealth-sendercovering initialization, token integration, transfer triggers, and TTL extension assertions.Why It Matters
These improvements resolve the issue by ensuring state sustainability at scale. With this architecture, the contracts can support millions of concurrent users without hitting memory limits, and the active names/registries will remain permanently live via permissionless read/write extensions.
Changed
The following files were modified:
stellar/stealth-registry/src/lib.rs: Migrated all registry mapping storage operations frominstancetopersistentstorage and integrated conditional TTL extension checks on registrations and lookups.stellar/wraith-names/src/lib.rs: Swapped instance storage for persistent storage for all name registrations and reverse lookups, and implementedextend_ttlshelper to manage data keys and contract instance lifecycles.stellar/stealth-sender/src/lib.rs: Added contract testing covering initialization, batch sends, and fast-forward ledger simulation verifying proactive TTL extensions on the sender contract instance.stellar/STORAGE_RENT.md: Created the audit report including contract storage write enumerations, cost formulas, and recommendations.Testing
Unit and integration tests were executed successfully within the
stellarworkspace to verify the persistence migration and correct TTL bumping behaviour.