Skip to content

fix(sdk-lib-mpc): lazy-load wasm-mps to fix browser DSG#9132

Open
Marzooqa wants to merge 1 commit into
masterfrom
marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require
Open

fix(sdk-lib-mpc): lazy-load wasm-mps to fix browser DSG#9132
Marzooqa wants to merge 1 commit into
masterfrom
marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require

Conversation

@Marzooqa

Copy link
Copy Markdown
Contributor

Static top-level import compiled to synchronous require() in CJS, causing fs.readFileSync at module init — unavailable in browser. DSG failed with: Cannot read properties of undefined (reading '__wbindgen_add_to_stack_pointer')

Similar to the lazy-load pattern from DKG fix:

  • Browser: await import('@bitgo/wasm-mps/web') + webWasm.default()
  • Node: await import('@bitgo/wasm-mps')
  • initDsg() and restoreSession() made async
  • eddsaMPCv2.ts call sites updated to await initDsg()
  • Tests updated accordingly

WCI-866

@linear-code

linear-code Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

WCI-866

@Marzooqa Marzooqa force-pushed the marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require branch 2 times, most recently from f64215a to 1e9904e Compare June 29, 2026 11:52
@Marzooqa Marzooqa marked this pull request as ready for review June 29, 2026 12:23
@Marzooqa Marzooqa requested review from a team as code owners June 29, 2026 12:23
Comment thread modules/sdk-core/test/unit/bitgo/utils/tss/eddsa/verifyMpsDerivation.ts Outdated
Comment thread modules/sdk-lib-mpc/src/tss/eddsa-mps/dsg.ts
@Marzooqa Marzooqa force-pushed the marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require branch from 1e9904e to e7bdb1c Compare June 29, 2026 14:43
vibhavgo
vibhavgo previously approved these changes Jun 29, 2026

@danielpeng1 danielpeng1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; only small comments

Also since asyncifying is technically a breaking change should we explicitly note that callers must now await these methods (via merge commit message, which updates CHANGELOG.mds for respective modules)?

Comment thread modules/sdk-lib-mpc/src/tss/eddsa-mps/dsg.ts
Comment thread modules/sdk-lib-mpc/src/tss/eddsa-mps/dsg.ts Outdated
Static top-level import compiled to synchronous require() in CJS,
causing fs.readFileSync at module init — unavailable in browser.
DSG failed with: Cannot read properties of undefined
(reading '__wbindgen_add_to_stack_pointer')

Mirrors the lazy-load pattern from WCI-244 (DKG fix):
- Browser: await import('@bitgo/wasm-mps/web') + webWasm.default()
- Node: await import('@bitgo/wasm-mps')
- initDsg() and restoreSession() made async
- eddsaMPCv2.ts call sites updated to await initDsg()
- Tests updated accordingly

WCI-866

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Marzooqa Marzooqa force-pushed the marzooqakather498/wci-866-fix-browser-wasm-loading-in-eddsa-mpcv2-dsg-sync-require branch from e7bdb1c to 8e65cb9 Compare June 30, 2026 08:15
@Marzooqa Marzooqa requested a review from danielpeng1 June 30, 2026 09:24

@pranavjain97 pranavjain97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, one small thing

if (
typeof window !== 'undefined' &&
/* checks for electron processes */
!window.process &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't an Electron renderer where window.process is set take the browser wasm path here? !window.process is false so the type check never runs.

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.

4 participants