Repository navigation
feat(voting): record and retry failed vault releases (closes #314) - #319
Open
Ranjeet2063 wants to merge 1 commit into
Open
Ranjeet2063 wants to merge 1 commit into
Ranjeet2063 wants to merge 1 commit into
Conversation
…tocol#314) - Record failed vault releases in instance storage (PendingRelease(task_id) and AllPendingReleases) - Add permissionless retry_vault_release entrypoint that clears pending record on success - Reject retrying tasks with no pending release with ContractError::NoPendingRelease - Prevent double releases on repeated retries - Clean up pending release record and compact index if a task is purged - Expose public get_pending_releases query entrypoint - Add comprehensive unit test suite covering all Acceptance Criteria
Author
|
Hello @maintainers, Just a quick note that all local unit and integration tests are passing cleanly across the test suite ( |
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.
Description
Closes #314
Resolves fund-stranding for tasks that resolve successfully but whose vault release fails. Previously,
try_release_vault_fundsswallowed vault failures by emitting an event, but because the task was markedis_done = true, the release block guarded by!t.is_donecould never execute again, stranding contributor payouts permanently on-chain.This PR introduces:
DataKey::PendingRelease(task_id)andDataKey::AllPendingReleases.retry_vault_release(task_id)entrypoint guarded against reentrancy and paused states, which attempts the release again, clears the pending record on success, and prevents double-releasing.get_pending_releases()to query all outstanding unreleased task IDs without replaying past events.purge_task.Key Changes
1. Storage Layout (
src/contracts/storage_layout.rs,src/storage.rs)DataKey::PendingRelease(u64)namespace key andDataKey::AllPendingReleasesindex key.has_pending_release(env, task_id) -> boolget_pending_releases(env) -> Vec<u64>set_pending_release(env, task_id)(appends toAllPendingReleasesif not already tracked)remove_pending_release(env, task_id)(removes key and compactsAllPendingReleases)2. Error Definition & Gas Accounting (
src/types.rs,src/gas.rs)ContractError::NoPendingRelease = 43.Operation::RetryVaultRelease = 30and registered calibrated gas estimateCOST_RETRY_VAULT_RELEASE = 3_000_000.3. Voting & Recovery Implementation (
src/contracts/voting.rs,src/contracts/logic.rs)try_release_vault_funds: OnErr(_), recordsstorage::set_pending_release(env, task_id)while maintaining non-reverting resolution fault isolation.retry_vault_release(env, task_id):has_pending_release; returnsErr(ContractError::NoPendingRelease)if not pending.VaultClient::try_release_funds.vault_okevent, releases reentrancy lock.vault_errevent, releases reentrancy lock, and returnsErr(ContractError::EscrowUnavailable).4. Entrypoint Surface (
src/contracts/proxy_entry/entry_tasks.rs)pub fn retry_vault_release(env: Env, task_id: u64) -> Result<(), ContractError>.pub fn get_pending_releases(env: Env) -> Vec<u64>.5. Task Purge Compaction (
src/task.rs)purge_task: cleans up any pending release storage and index entries for terminal tasks.6. Test Suite (
tests/vault_release_retry.rs)test_task_resolves_and_records_pending_release_when_vault_fails: Task resolves even if vault fails, and task is recorded inget_pending_releases().test_successful_vault_release_does_not_create_pending_release: Happy path releases directly without creating pending record.test_retry_after_vault_recovers_releases_funds_and_clears_record: Vault recovery enables successful retry which clears the pending record.test_retry_for_task_with_no_pending_release_is_rejected: Non-pending tasks reject retry withNoPendingRelease.test_retrying_twice_does_not_double_release: Second retry attempt rejects withNoPendingRelease.test_retry_fails_when_vault_still_unhealthy_preserves_record: Unhealthy vault failure preserves pending record.test_purging_task_cleans_up_pending_release: Task purging clears pending release state.test_retry_vault_release_paused_rejected: Paused contract rejects retry.test_batch_voting_records_pending_release_on_failure: Batch voting correctly records multiple failed releases.Acceptance Criteria Checklist