Skip to content

feat(storage): add TTL/rent-bumping logic for contract storage (Closes #1923)#2079

Open
Carlys17 wants to merge 2 commits into
EarnQuestOne:mainfrom
Carlys17:feat/ttl-rent-bumping-1923
Open

feat(storage): add TTL/rent-bumping logic for contract storage (Closes #1923)#2079
Carlys17 wants to merge 2 commits into
EarnQuestOne:mainfrom
Carlys17:feat/ttl-rent-bumping-1923

Conversation

@Carlys17

Copy link
Copy Markdown

Summary

Implements explicit TTL/rent-bumping management for all contract storage (issue #1923).

This contract stores ALL state via env.storage().instance(). Since instance storage is a single logical entry, a single instance-TTL bump keeps every key alive together. We now bump the instance TTL at the start of every state-mutating entrypoint.

Changes

  • src/ttl.rs (new): TTL helpers + constants (DEFAULT_TTL_THRESHOLD = ~30 days, DEFAULT_TTL_EXTEND_TO = ~120 days)
  • src/lib.rs: bump_instance_ttl() called at start of each write entrypoint
  • SNAPSHOT_MANAGEMENT.md: documents the TTL model
  • tests/test_storage.rs: 7 new tests covering extension and contract flows
  • gas_baselines.json: updated (TTL extension adds ~10-40% gas per write, expected)

Acceptance Criteria

  • Storage entries have explicit, tested TTL management
  • Tests simulate TTL extension scenarios
  • Documentation matches implementation

Test Plan

  • cargo fmt passes
  • cargo test passes (all 400+ tests green)
  • Gas regression test updated and passing

Closes #1923

@Carlys17
Carlys17 requested a review from RUKAYAT-CODER as a code owner July 23, 2026 12:50
@RUKAYAT-CODER

RUKAYAT-CODER commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Hi well done on the job done so far!
Kindly resolve econflict

- Remove unused imports (StellarAssetClient, TokenClient, LedgerInfo)
- Prefix unused params in extend_entry_ttl with underscores
- Use const assertions for compile-time constant checks
- Replace len() >= 0 with !is_empty() for usize comparison
- Remove empty line after doc attribute in initialize()
- Align test_snapshots with main
@Carlys17
Carlys17 force-pushed the feat/ttl-rent-bumping-1923 branch from 0e0f309 to 7045eea Compare July 23, 2026 14:47
@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
Kindly fix the workflow to pass

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.

Add TTL/rent-bumping logic for contract storage entries

2 participants