feat(contracts): keep terminal campaign storage readable - #217
Open
shinzoxD wants to merge 1 commit into
Open
Conversation
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
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.
Summary
Once a campaign reaches a terminal state (
Settled,Failed,Resolved), write paths stop callingextend_ttlon its persistent entries. AfterPERSISTENT_BUMP_AMOUNT(~90 days of ledgers) those keys archive and history becomes unreadable until aRestoreFootprintOp.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
Optionon master. Mutating paths that still require a live record now panic with an archival-aware message pointing attouch_campaign/RestoreFootprintOp.Closes #154
Changes
ProductionEscrowContract
touch_campaignbumpsCampaignand, when present,Dispute,Tranches,HarvestRecord, plus instance TTLrequire_campaign/require_disputereplace opaque campaign/dispute-not-found panicsproduction_escrow/README.mdRegistryContract
touch_campaignbumpsCampaignmetadata,CampaignRecord, activity page-count and every activity page, plus instance TTLrequire_campaign_recordpanic mentions restore / touchregistry/README.mdwith the same TTL/archival ops notesContribution(id, investor)keys are per-investor and are not enumerated bytouch_campaign(no on-chain investor index). Keep those alive viaget_contributionfor known investors, or restore them after archival.TTL constants (both contracts)
PERSISTENT_LIFETIME_THRESHOLDDAY_IN_LEDGERS * 30(518,400 ledgers, ~30 days)PERSISTENT_BUMP_AMOUNTDAY_IN_LEDGERS * 90(1,555,200 ledgers, ~90 days)Suggested indexer cadence: call
touch_campaignabout every 30 days.extend_ttlis a no-op while remaining TTL is still above the 30-day threshold.If an entry has already archived, restore it with
RestoreFootprintOpfirst;touch_campaigncannot revive archived keys.Tests
New coverage:
Payout wallet:
GBVHELLD2JE235Y2NGTDT3MWI3T65ON6SY4N6FBHYVDAQ5FZC2CP5QXH