Repository navigation
fix(contract): bound withStateRestore retries and handle re-archival - #631
Merged
nonsobethel0-dev merged 2 commits intoSep 23, 2026
Conversation
Replace the unguarded second run() with a bounded restore/retry loop (maxRestores, default 1). If state is archived again after a restore, surface a ContractError with the original error in details instead of leaking a raw StateArchivedError. Restore is injectable for testing.
Verify successful retry after restore, ContractError on re-archival, maxRestores cap, and that a failed restore is not retried.
|
@Smoothjane 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! 🚀 |
❌ Deploy Preview for boisterous-sunshine-dd4c4c failed.
|
nonsobethel0-dev
merged commit Sep 23, 2026
ea6a8a6
into
Parashield-Protocol:main
0 of 4 checks passed
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.
Problem
withStateRestoreinsrc/lib/contract.tscaught aStateArchivedError, restored the footprint, and then calledrun()a second time outside anytry:If the entries were archived again before the retry finished (a race under load), the second
StateArchivedErrorescaped with no handling. Callers (invokeBuyPolicy,invokeSubmitClaim,DepositModal,WithdrawModal) then got a raw archival error carrying a stalerestoreXdr, and there was no explicit limit on how many restore rounds could happen.Changes
src/lib/contract.tsStateRestoreOptionsargument:maxRestores(default 1, the same number of restores as before): the most restore rounds, and so the most extra signature prompts, the user will see.restore: the restore implementation, defaulting torestoreArchivedState. It is injectable so the retry logic can be unit-tested without a live RPC.ContractError: "Contract data was archived again after being restored. Please try again in a moment." The lastStateArchivedErroris kept indetailsfor debugging, andtoUserMessagealready logsdetailswithout showing it to the user.src/lib/__tests__/contract.test.tsNew
withStateRestore() retry limit (#536)suite:ContractError, not aStateArchivedError, with the original error indetails;maxRestores: 2caps the restores at exactly 2 (3 runs);Verification
npx vitest run src/lib/__tests__/contract.test.ts: 33/33 pass.tsc --noEmitreports no errors in the touched files.Closes [security] withStateRestore retries once but does not limit retry depth #536
Closes [perf] Policies page fetches all policies client-side, no server-side pagination #537
Closes [bug] ConnectWalletPrompt shows stale stored address after wallet disconnect #538
Closes [bug] Dashboard recent claims table missing mobile layout #539