fix: preserve TotalDeposited lifetime value across TTL expiry - #500
Merged
overprodigy merged 17 commits intoSep 2, 2026
Conversation
|
@Andreas2410 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR fixes the silent reset of
TotalDeposited(account)in the investment vault after the single persistent-entry TTL expires. The current contract only callsextend_ttlonce, which caps the entry's guaranteed lifetime at roughly518,400ledgers (~30 days). For an investor who deposits once and never deposits again,get_portfolioreads a missing entry and silently falls back tounwrap_or(0), destroying the documented “lifetime deposited” semantics.The fix extends the TTL window to cover the vault's intended lifetime and also renews the TTL whenever
get_portfolioreads the total-deposited entry. A new regression test advances the simulated ledger past the previous expiration point and verifies the value is preserved instead of resetting to zero.Related Issue
Changes
🗄️ Storage / TTL handling
investment_vault/src/lib.rs17280, 518400TTL extension with named constants and increases the extension from518,400ledgers to5,184,000ledgers (~300 days), covering the vault's intended lifetime while keeping entries archived only after a significantly longer inactivity window.get_portfolio(lines 808-812) when readingTotalDeposited, so any active portfolio read also renews the entry and prevents expiry in live operational paths.🧪 Regression test
investment_vault/src/test.rstest_total_deposited_survives_ttl_expiry.518,400-ledger TTL, then callsget_portfolioand assertstotal_depositedretains the original deposited amount instead of0.Verification Results
5,184,000ledgers (~300 days) and renewed on everyget_portfolioreadtest_total_deposited_survives_ttl_expiryadvances past the old518,400-ledger point and verifies the original deposit remainsCloses #316