Skip to content

fix: preserve TotalDeposited lifetime value across TTL expiry - #500

Merged
overprodigy merged 17 commits into
Heliobond:mainfrom
Andreas2410:fix/issue-316-totaldeposited-lifetime-analytics-entry-can
Sep 2, 2026
Merged

fix: preserve TotalDeposited lifetime value across TTL expiry#500
overprodigy merged 17 commits into
Heliobond:mainfrom
Andreas2410:fix/issue-316-totaldeposited-lifetime-analytics-entry-can

Conversation

@Andreas2410

@Andreas2410 Andreas2410 commented Aug 31, 2026

Copy link
Copy Markdown

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 calls extend_ttl once, which caps the entry's guaranteed lifetime at roughly 518,400 ledgers (~30 days). For an investor who deposits once and never deposits again, get_portfolio reads a missing entry and silently falls back to unwrap_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_portfolio reads 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

  • [MODIFY] investment_vault/src/lib.rs
    • Replaces the hard-coded 17280, 518400 TTL extension with named constants and increases the extension from 518,400 ledgers to 5,184,000 ledgers (~300 days), covering the vault's intended lifetime while keeping entries archived only after a significantly longer inactivity window.
    • Adds the same persistent-storage TTL bump in get_portfolio (lines 808-812) when reading TotalDeposited, so any active portfolio read also renews the entry and prevents expiry in live operational paths.

🧪 Regression test

  • [ADD] investment_vault/src/test.rs
    • Adds test_total_deposited_survives_ttl_expiry.
    • Simulates an investor deposit, advances the ledger past the previous 518,400-ledger TTL, then calls get_portfolio and asserts total_deposited retains the original deposited amount instead of 0.

Verification Results

cargo test -p investment_vault test_total_deposited_survives_ttl_expiry
✅ 1 passed

cargo test -p investment_vault
✅ all tests passed
Acceptance Criteria Status
TotalDeposited survives investor inactivity for the vault's intended lifetime ✅ TTL extended to 5,184,000 ledgers (~300 days) and renewed on every get_portfolio read
A test simulates ledger advancement past the current TTL and checks the value is preserved test_total_deposited_survives_ttl_expiry advances past the old 518,400-ledger point and verifies the original deposit remains

Closes #316

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Andreas2410 Andreas2410 changed the title fix: preserve TotalDeposited lifetime analytics across storage TTL fix: preserve TotalDeposited lifetime analytics past 30-day TTL Aug 31, 2026
@Andreas2410 Andreas2410 changed the title fix: preserve TotalDeposited lifetime analytics past 30-day TTL fix: preserve TotalDeposited lifetime value across TTL expiry Aug 31, 2026
@overprodigy
overprodigy merged commit 2e24bff into Heliobond:main Sep 2, 2026
1 of 7 checks passed
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.

TotalDeposited lifetime-analytics entry can silently reset to zero after ~30 days of investor inactivity

2 participants