Skip to content

fix(extension): unblock local proving via sdk re-entrancy + sync-mgr classification#247

Open
WiktorStarczewski wants to merge 1 commit into
mainfrom
wiktor/investigate-local-prove-stuck
Open

fix(extension): unblock local proving via sdk re-entrancy + sync-mgr classification#247
WiktorStarczewski wants to merge 1 commit into
mainfrom
wiktor/investigate-local-prove-stuck

Conversation

@WiktorStarczewski
Copy link
Copy Markdown
Collaborator

Web SDK PR: #152

Summary

Three independent wallet-side fixes that, together with the linked web-sdk#152, unblock local proving on Chrome MV3 and stop the misleading "cannot reach the miden node" banner from firing during honest long proves.

  1. SDK fix consumption — bumps @miden-sdk/miden-sdk to 0.14.10 via the linked-PR pipeline. The SDK fix is the load-bearing change: _withInnerWebClient was deadlocking the moment its callback called back into a proxied wasm method on the same client (inner.getInputNote(...), inner.executeTransaction(...), etc.). All wallet usage of proveLocallyViaOffscreen for consumes and sends hung indefinitely. With the SDK fix, the offscreen-doc MT-WASM prove path actually completes.
  2. SyncManager classification (src/lib/miden/back/sync-manager.ts) — the 5 s SYNC_TIMEOUT_MS now bounds the RPC call alone, not the lock acquisition. Lock-contention during an in-flight prove queues patiently behind it (the prove yields the wasm-client mutex during the offscreen step via yieldWasmClientLock); only an actual unresponsive RPC trips the timeout. Three consecutive timeouts still open the circuit breaker, but they only fire when the network is really sick — not when the wallet is just busy proving.
  3. Harness fixes — the test infrastructure changes that let CI catch this class of regression:
    • playwright/e2e/helpers/miden-cli.ts: add --locked to cargo install miden-client-cli. The published 0.14.8 crate ships a Cargo.lock pinning miden-assembly = 0.22.1, the same version the wallet's bundled SDK uses. Without --locked, cargo re-resolved to miden-assembly@0.22.3 which silently shifts BasicFungibleFaucet MAST procedure roots (see miden-vm#3144). The wallet then fails to recognize CLI-deployed faucets and renders their tokens as "Unknown", which any test selector filtering by token symbol can't match.
    • WalletPage.setDelegateProofEnabled(enabled) added to the WalletPage interface and all three impls (Chrome, iOS, Android). Just flips localStorage['delegate_proof_setting_key']; the wallet reads that synchronously per render so the next form interaction picks it up.
    • playwright/e2e/stress/stress.spec.ts: optional STRESS_LOCAL_PROVING=true env var that flips both stress wallets to local proving after creation. Lets you run the existing stress suite end-to-end against the local-prove pipeline.
    • playwright/e2e/tests/send-public-local-prove.spec.ts: focused regression spec — single send/claim with local proving forced. Smaller scope than the full stress, fast to run for targeted CI gating.
    • src/lib/miden/sdk/miden-client-interface.ts: keeps the per-step prove-timing markers I added to localize the deadlock (between executeTransaction / proveViaOffscreen / submitProvenTransaction / applyTransaction). +20 LoC of recordProveTiming calls; gated on MIDEN_E2E_TEST=true so production users see nothing.

How they fit

The SDK deadlock (#152) is what makes local proving impossible. Once unblocked, the next user-visible failure mode is the false "node unreachable" banner — that's #2 here. Together, local proving works AND looks healthy to the user.

The harness changes (#3) are independent of either fix's correctness — they just let CI exercise the path that was previously broken without anyone noticing.

Empirical verification

With this PR's harness changes + web-sdk#152's SDK fix linked in, ran the 5-tx stress against testnet with STRESS_LOCAL_PROVING=true:

Pre-fix: every consume hung at inner.getInputNote; zero sends completed; 5-minute Playwright timeout.

Post-fix:

  • 5 of 5 sends completed end-to-end through the offscreen-doc prove pipeline
  • [mt-offscreen-prove] tx_completed prove_ms=… fires for every op
  • Send latencies: min 10.8 s, p50 15.7 s, p95 17.7 s (10–18 s/send = ~8 s pure prove + execute + submit + apply RPC overhead)
  • Zero SyncManager false-positives during prove — banner stays clear

(Remaining stress harness failures trace to the conservation-check accounting drift and the getByText('TST') selector vs "Unknown" tile rendering — pre-existing, downstream of miden-vm#3144, unrelated to anything here. The --locked change in this PR closes the harness-side variant by pinning the CLI's transitive miden-assembly to the same version the wallet SDK bundles.)

Verification done locally

  • yarn lint — clean
  • yarn format — clean
  • npx tsc --noEmit — clean
  • yarn test — 1865/1865 pass
  • yarn build — succeeds

Test plan

  • Wait for linked-web-sdk-pr-ready status (web-sdk#152 merge + release)
  • CI green on this branch
  • Manual: enable Settings → General → Local proving, send a tx → completes in ~10 s (was: hang forever)
  • Manual: same flow with delegated proving → unchanged (no regression on the delegate path)
  • Stress harness rerun on testnet with STRESS_LOCAL_PROVING=true after merge

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.

1 participant