Skip to content

πŸ”΄ No TTL management for token bookkeeping β€” state can be archived and the factory has no rent strategyΒ #1011

Description

@Ejirowebfi

Area: Smart contract Β· lib.rs (extend_token_ttl, all storage writes)

Description

extend_token_ttl(env, _token_address, _index) ignores both of its arguments and merely extends
the instance TTL β€” a misleading no-op wrapper. The entire factory relies on a single instance-storage
TTL that is only extended when someone happens to call a state-writing function. If the factory sits
idle longer than the TTL window (MAX_TTL = 535_000 ledgers β‰ˆ 31 days), the instance entry β€”
containing all token records, metadata pointers, creator lists, and the admin/fee configuration β€” is
archived. Reads start failing (StateNotFound / missing-entry traps) and every user's token becomes
invisible to the app until someone performs a state restoration, a flow neither the contract, the
scripts, nor the frontend implements or documents. On mainnet, "the app went dark because nobody made
a transaction for a month" is a critical operational failure. This issue is the TTL/archival half of
the storage redesign in Issue 3.

Tasks

  • After the persistent-storage migration (Issue 3), implement real per-key TTL extension: extend a
    token's TokenInfo/TokenIndex/Metadata/owner/supply keys whenever that token is touched.
  • Delete or fix the argument-ignoring extend_token_ttl so its behavior matches its name.
  • Add a public extend_ttls(keys)-style maintenance entrypoint (or document use of the ledger
    RestoreFootprint/ExtendFootprintTTL operations) so anyone can keep entries alive
    permissionlessly.
  • Add an operational runbook (docs/): monitoring entry TTLs, restoring archived entries, and the
    expected rent budget; wire a scheduled CI job or cron doc for TTL keep-alive on mainnet.
  • Add tests that advance the ledger past TTL boundaries and verify (a) touched entries survive,
    (b) restoration of archived entries works.

Acceptance criteria

  • Every persistent entry a user's token depends on gets its TTL extended on access, proven by
    ledger-advancing tests.
  • An archived-entry recovery procedure exists, is documented, and is exercised by a test.
  • No function signature advertises per-token TTL behavior it does not implement.

Issue 7 of 20 from the codebase audit tracked in ISSUES.md.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26auditFrom the ISSUES.md codebase auditseverity: criticalFunds/consensus/permanent-brick risk

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions