Skip to content

docs: verify contract upgrade cache invalidation already covers #840 - #891

Merged
Just-Bamford merged 1 commit into
Sorokit:mainfrom
davedumto:fix/840-cache-invalidation
Oct 27, 2026
Merged

Just-Bamford merged 1 commit into
Sorokit:mainfrom
davedumto:fix/840-cache-invalidation

Conversation

@davedumto

Copy link
Copy Markdown
Contributor

Summary

Investigated #840 (ContractInvocationCache does not handle Soroban contract upgrades). No code change needed, this is already fully implemented on main.

closes #840

Details

  • src/soroban/upgradeDetection.ts's detectContractUpgrade fetches the deployed Wasm, hashes it, and compares against the previously recorded hash for that contract ID (shipped in commit f1e3185).
  • On a hash change, invalidateContractCaches clears every cache keyed to that contract: method metadata (both the external SorokitCache entry and the internal in-memory LRU in contractMetadata.ts), plus the contract-schema, contract-read, and contract-state key prefixes.
  • Exposed publicly as client.soroban.detectContractUpgrade(contractId, onUpgrade?, timeoutMs?).
  • src/tests/upgradeDetection.test.ts already covers both the first-seen-hash case and the hash-change/invalidation case.

All three acceptance criteria in #840 are met: upgrade detection by code-hash change, cache invalidation on upgrade, and test coverage.

The issue names a ContractInvocationCache class specifically, no such class exists, the same behavior is implemented via prefix-based invalidation against the generic SorokitCache interface instead. Functionally equivalent and already covers the acceptance criteria.

Validation

  • npx vitest run src/tests/upgradeDetection.test.ts passes on a clean checkout.
  • No files outside docs/ touched.

…it#840

detectContractUpgrade (src/soroban/upgradeDetection.ts) already detects
Soroban contract upgrades by Wasm code-hash change and invalidates every
contract-scoped cache (method metadata, schema, read, state) on upgrade,
with test coverage in src/tests/upgradeDetection.test.ts. No code change
needed for Sorokit#840.

Closes Sorokit#840
@Just-Bamford
Just-Bamford merged commit edb9279 into Sorokit:main Oct 27, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ContractInvocationCache does not handle Soroban contract upgrades — returns stale contract state after upgrade

2 participants