From 4292ce1360187096b51ef22fca6820dba02ed2d3 Mon Sep 17 00:00:00 2001 From: David Ejere Date: Mon, 26 Oct 2026 19:53:04 +0100 Subject: [PATCH] docs: verify contract upgrade cache invalidation already covers #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 #840. Closes #840 --- ...upgrade-cache-invalidation-verification.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/verification/2026-10-26-contract-upgrade-cache-invalidation-verification.md diff --git a/docs/verification/2026-10-26-contract-upgrade-cache-invalidation-verification.md b/docs/verification/2026-10-26-contract-upgrade-cache-invalidation-verification.md new file mode 100644 index 00000000..0a2cdda3 --- /dev/null +++ b/docs/verification/2026-10-26-contract-upgrade-cache-invalidation-verification.md @@ -0,0 +1,34 @@ +# Verification: contract upgrade cache invalidation (#840) + +Issue #840 asked for Soroban contract-upgrade detection with invalidation of +caches holding stale state from before the upgrade (method signatures, +storage snapshots), naming a `ContractInvocationCache` as the expected +location. + +No `ContractInvocationCache` class exists in this codebase. Instead, the same +functionality already ships on `main` (commit `f1e3185`, "feat(soroban): +detect contract upgrades and invalidate caches") under a different shape: + +- `src/soroban/upgradeDetection.ts` exports `detectContractUpgrade`, which + fetches the deployed Wasm, hashes it (`sha256`), and compares it against + the previously recorded hash for that `contractId`. A hash change marks + `upgraded: true` on the returned `UpgradeEvent`. +- On an upgrade, `invalidateContractCaches` clears every cache keyed to that + contract: the method-metadata cache (`src/soroban/contractMetadata.ts`, + both its external `SorokitCache` entry and its internal in-memory LRU), + plus the `contract-schema`, `contract-read`, `contract-state`, and + `contract-metadata` key prefixes. +- The function is exposed on the public client as + `client.soroban.detectContractUpgrade(contractId, onUpgrade?, timeoutMs?)` + (`src/client/createSorokitClient.ts:982`). +- `src/tests/upgradeDetection.test.ts` covers both the first-seen-hash case + (no upgrade reported) and the hash-change case (upgrade reported, caches + invalidated, `onUpgrade` callback invoked). + +All three acceptance criteria in #840 are met: +- [x] Contract upgrades detected (by Wasm code-hash change) +- [x] Related caches invalidated on upgrade +- [x] Tests verify cache invalidation on contract update + +No code change needed. `npx vitest run src/tests/upgradeDetection.test.ts` +passes against a clean `main` checkout.