Skip to content

feat(contracts): keep terminal campaign storage readable - #217

Open
shinzoxD wants to merge 1 commit into
Cylo-Traders:masterfrom
shinzoxD:fix/154-terminal-campaign-ttl
Open

feat(contracts): keep terminal campaign storage readable#217
shinzoxD wants to merge 1 commit into
Cylo-Traders:masterfrom
shinzoxD:fix/154-terminal-campaign-ttl

Conversation

@shinzoxD

Copy link
Copy Markdown

Summary

Once a campaign reaches a terminal state (Settled, Failed, Resolved), write paths stop calling extend_ttl on its persistent entries. After PERSISTENT_BUMP_AMOUNT (~90 days of ledgers) those keys archive and history becomes unreadable until a RestoreFootprintOp.

This adds a permissionless touch_campaign(campaign_id) on both contracts that only extends TTL (no other state change), so an indexer/keeper can cheaply keep settled history alive.

Public getters already return Option on master. Mutating paths that still require a live record now panic with an archival-aware message pointing at touch_campaign / RestoreFootprintOp.

Closes #154

Changes

ProductionEscrowContract

  • touch_campaign bumps Campaign and, when present, Dispute, Tranches, HarvestRecord, plus instance TTL
  • require_campaign / require_dispute replace opaque campaign/dispute-not-found panics
  • Documented TTL constants, terminal keys, cadence, and restore path in production_escrow/README.md

RegistryContract

  • touch_campaign bumps Campaign metadata, CampaignRecord, activity page-count and every activity page, plus instance TTL
  • require_campaign_record panic mentions restore / touch
  • New registry/README.md with the same TTL/archival ops notes

Contribution(id, investor) keys are per-investor and are not enumerated by touch_campaign (no on-chain investor index). Keep those alive via get_contribution for known investors, or restore them after archival.

TTL constants (both contracts)

Constant Value
PERSISTENT_LIFETIME_THRESHOLD DAY_IN_LEDGERS * 30 (518,400 ledgers, ~30 days)
PERSISTENT_BUMP_AMOUNT DAY_IN_LEDGERS * 90 (1,555,200 ledgers, ~90 days)

Suggested indexer cadence: call touch_campaign about every 30 days. extend_ttl is a no-op while remaining TTL is still above the 30-day threshold.

If an entry has already archived, restore it with RestoreFootprintOp first; touch_campaign cannot revive archived keys.

Tests

cd contracts
cargo test -p production_escrow --lib   # 81 passed (78 unit + 3 proptest)
cargo test -p registry --lib            # 47 passed

New coverage:

  • TTL actually extends after remaining life drops below the threshold
  • No stored state change
  • Related terminal keys (tranches / harvest / dispute / activity pages) are bumped
  • Missing campaign panics with the archival-aware message

Payout wallet: GBVHELLD2JE235Y2NGTDT3MWI3T65ON6SY4N6FBHYVDAQ5FZC2CP5QXH

Add permissionless touch_campaign on escrow and registry so an indexer
can extend TTL on terminal campaign entries without changing state.
Document archival, PERSISTENT_* constants, and RestoreFootprintOp in
both contract READMEs.

Closes Cylo-Traders#154
Copilot AI lite review requested due to automatic review settings August 24, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

[Contract] Terminal campaigns' storage entries stop being TTL-extended and can be archived, making settled history unreadable

3 participants