feat(ttl): state-specific TTL thresholds for escrow contracts - #1384
Open
ogbemercyada-sketch wants to merge 2 commits into
Open
feat(ttl): state-specific TTL thresholds for escrow contracts#1384ogbemercyada-sketch wants to merge 2 commits into
ogbemercyada-sketch wants to merge 2 commits into
Conversation
Active obligations can silently disappear when persistent entries are not extended as the lifecycle progresses. This implements a tiered TTL policy that matches contract lifetime to actual lifecycle state: Active (Created/PartiallyFunded/Funded): 60 d, bump threshold 15 d Disputed: 75 d, bump threshold 20 d Closed (Completed/Cancelled/Refunded): 30 d, bump threshold 7 d Changes: - ttl.rs: add ACTIVE/DISPUTED/CLOSED _CONTRACT_TTL_LEDGERS and _BUMP_THRESHOLD constants; add ttl_for_status(status)->(threshold, extend_to), extend_contract_ttl_for_status, extend_milestone_ttl_for_status, extend_contract_and_milestones_ttl_for_status helpers; update module doc. - create_contract.rs: use extend_contract_and_milestones_ttl_for_status with ContractStatus::Created so new records receive 60-day windows. - deposit.rs: use state-aware TTL bump after Funded/PartiallyFunded transition instead of flat extend_contract_ttl. - lib.rs: replace flat extend_contract_ttl calls at cancel_contract, release_milestone (single+batch), raise_dispute, resolve_dispute, and refund_unreleased_milestones with state-aware counterparts. - test/ttl_lifecycle.rs: full edge-case coverage for new_record, active_record, disputed_record, near_expiry, expired_record, TTL constant ordering, and ttl_for_status correctness. - test/mod.rs: register ttl_lifecycle module. Security note: TTL is bumped only on meaningful writes (state transitions, deposits, releases, refunds, cancellations, dispute operations). Read-only entrypoints do not bump TTL, preventing indefinite TTL extension via reads. Closes Talenttrust#1348
|
@ogbemercyada-sketch 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! 🚀 |
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.
Active obligations can silently disappear when persistent entries are not extended as the lifecycle progresses. This implements a tiered TTL policy that matches contract lifetime to actual lifecycle state:
Active (Created/PartiallyFunded/Funded): 60 d, bump threshold 15 d
Disputed: 75 d, bump threshold 20 d
Closed (Completed/Cancelled/Refunded): 30 d, bump threshold 7 d
Changes:
Security note: TTL is bumped only on meaningful writes (state transitions, deposits, releases, refunds, cancellations, dispute operations). Read-only entrypoints do not bump TTL, preventing indefinite TTL extension via reads.
Closes #1348