Skip to content

feat: SDK hardening integration (sign-callback recovery + apply-after-submit)#268

Open
WiktorStarczewski wants to merge 4 commits into
mainfrom
wiktor/thin-189-sdk-only
Open

feat: SDK hardening integration (sign-callback recovery + apply-after-submit)#268
WiktorStarczewski wants to merge 4 commits into
mainfrom
wiktor/thin-189-sdk-only

Conversation

@WiktorStarczewski
Copy link
Copy Markdown
Collaborator

Summary

Thinned-down replacement for #189. Contains only the SDK-hardening improvements that are backed by external SDK PRs (miden-client / web-sdk) — the MidenClient singleton unification is dropped entirely, and the client singleton is left untouched.

Supersedes #189.

What's included

  1. Typed sign-callback failure recovery — when the wallet gets locked mid-transaction the sign callback throws; the failure is recovered via the SDK's lastAuthError() and the tx is left Queued for retry after unlock instead of marked Failed (which previously caused note loss).
  2. ApplyTransactionAfterSubmitFailed handling — a tx that submits on-chain but fails the local apply step is marked Completed (not Failed) via the SDK's errorCode dispatch, so the user sees "Transaction sent" rather than a confusing failure for a tx that IS on chain. InputNoteAlreadyConsumedOnChain is cancelled.
  3. Transaction-stage progress UI — a stage field (syncing / sending / confirming / delivering) drives per-stage labels in the progress modal during the spinner window.
  4. Stress-suite transport-failure perturbation (STRESS_TRANSPORT_FAIL_PROB) — end-to-end coverage of the SDK's durable relay outbox (fix(rust): durable NTL relay for Client::send_private_note miden-client#2127).

The per-tx sign callback is wired through the existing getMidenClient(options) path; the error classification (buildSignCallbackError + lastAuthError() recovery) all degrades gracefully if the SDK methods aren't present.

What's dropped vs #189

  • The entire MidenClient singleton unificationkeystore-bridge.ts, keystore-wiring.ts, Vault.encryptKeystoreEntry(), the two-instance→one-singleton collapse, the getMidenClient() signature change, and the adapter/main.ts wiring. miden-client.ts, vault.ts, miden-client-interface.ts, and the intercom adapters are unchanged from base.
  • Item 3 (waitForIdle() in Actions.lock()), which was backed by the draft/exploratory miden-client#2057 — switching lock() to a runtime-guarded waitForIdle() would no-op (regressing the existing withWasmClientLock drain) until #2057 lands, so lock() is left as-is.

Verification

  • Full unit suite: 1662/1662 pass
  • tsc --noEmit: clean
  • eslint: clean on changed files

Diff: 26 files, +1216 / −70 (vs #189's 44 files, +1867 / −577).

Note: like #189, this branch is based on the pre-#189 merge-base and is stale vs current main (~52 commits) — rebasing onto main is a separate step.

…-submit)

Thinned from the original #189 to contain only the improvements backed by
outside SDK PRs, dropping the MidenClient singleton unification entirely:

- Typed sign-callback failure recovery: a sign callback that fails because the
  wallet locked mid-tx is recovered via the SDK's lastAuthError(); the tx is
  left Queued for retry after unlock instead of marked Failed
  (miden-client#2058).
- ApplyTransactionAfterSubmitFailed / errorCode dispatch: a tx that submits
  on-chain but fails to apply locally is marked Completed, not Failed
  (miden-client#2059, #2060). InputNoteAlreadyConsumedOnChain is cancelled.
- Transaction-stage progress UI (syncing/sending/confirming/delivering) and
  the stress suite's transport-failure perturbation for the SDK relay outbox
  (miden-client#2127).

Dropped vs #189: the singleton unification (keystore-bridge/keystore-wiring,
Vault.encryptKeystoreEntry, two-instance->one collapse) and item 3
(waitForIdle in lock(), backed by draft #2057). The sign-callback is wired
through the existing getMidenClient(options) path; the client singleton is
untouched.
# Conflicts:
#	playwright/e2e/stress/stress-driver.ts
#	playwright/e2e/stress/stress.spec.ts
#	src/components/TransactionProgressModal.tsx
#	src/lib/miden/activity/transactions.ts
#	src/screens/generating-transaction/GeneratingTransaction.tsx
… gate

Export buildSignCallbackError and readLastAuthReason and add branch-coverage
tests for the SDK-hardening error recovery: reason classification, all four
lastAuthError reasons + invalid/throw, the locked->leave-Queued path, and the
wrapped sign callback's success/failure paths. Lifts global branch coverage
back over 95% (the new error-recovery code had introduced uncovered branches).
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