Repository navigation
feat(escrow): explicit storage TTL management - #1764
Merged
mikewheeleer merged 2 commits intoOct 25, 2026
Merged
Conversation
Contributor
|
hey @OkeA-dev 👋 this PR scans clean and CI is green, but it now has merge conflicts with |
# Conflicts: # README.md # contracts/escrow/src/lib.rs # contracts/escrow/src/test.rs
Contributor
|
well done — thanks for this! |
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
Implements explicit storage TTL management for the escrow contract so live state is never left to archive while the protocol is in use.
Closes #1710
Changes
bump_instanceis now called from every public mutating entry point:deposit_funds,release_milestone,open_dispute,resolve_dispute,cancel_contract,issue_reputation,void_rating, plusinitialize,set_pausedandcreate_contractwhich already did it. This keeps the instance (holdingAdmin,Paused,NextId) alive during normal use.extend_escrow_ttl(id)— permissionless; extends the escrow entry and itsRating(id)side key (when present) toPERSISTENT_TTL_EXTEND, and bumps the instance TTL. ReturnsContractNotFound (5)when the escrow does not exist.extend_reputation_ttl(freelancer)— permissionless; extendsReputation(freelancer)and the instance TTL. ReturnsReputationNotFound (20)when no reputation record exists.README.md: documented the new functions and added a Storage TTL policy section (thresholds, who pays, archival behaviour, errors).Security checklist
extend_ttlon existing keys andbump_instance; they perform noset/remove. The tests assert the escrow/reputation values are byte-for-byte identical before and after the call.env.mock_auths(&[])to prove no authorization is needed.ContractNotFound/ReputationNotFound) instead of creating empty entries.Acceptance evidence
TTL tests
contracts/escrow/src/test.rsusesenv.as_contract(..)withinstance().get_ttl()/persistent().get_ttl(&key):initialize_bumps_instance_ttlevery_mutating_entry_point_bumps_instance_ttl— coversset_paused,create_contract,deposit_funds,release_milestone,open_dispute,resolve_dispute,cancel_contract,issue_reputation,void_rating; each call is made after the instance is aged belowPERSISTENT_TTL_THRESHOLDand must leave TTL >= threshold.extend_escrow_ttl_raises_contract_rating_and_instance_ttlextend_reputation_ttl_raises_reputation_and_instance_ttlextend_escrow_ttl_missing_id_returns_contract_not_foundextend_reputation_ttl_missing_record_returns_reputation_not_foundgetters_do_not_extend_ttl— all getters leave instance/persistent TTL unchanged.extended_escrow_survives_past_unbumped_expiry— archival simulation.How the archival scenario is simulated
The test creates two identical escrows and ages the ledger until each has
PERSISTENT_TTL_THRESHOLD / 2ledgers left. It callsextend_escrow_ttlon one, then advancesremaining + 1ledgers. The un-bumped escrow (mainbehaviour) is now archived — the test host escalates archived storage access to a panic, which the test catches to prove the entry is unreachable; on the real network the call would not be admitted. The escrow kept alive byextend_escrow_ttl(this branch) is still readable and returns its data.Build / wasm size
38,481 bytes39,753 bytes+1,272 bytes(~3.3%), far below the 128 KB network limit.cargo clippy --all-targetsis clean. No existing test was deleted or weakened; existing tests are unchanged.Full
cargo testoutput