-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decompress wasm runtime before validating #4182
Decompress wasm runtime before validating #4182
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Originally tried zstandard-wasm and @hpcc-js/wasm and the decompression seems to fail to work correctly. The decompressed file is always much larger than expected and fails to validate. It seems both of those packages don't support "streaming decompression". Finally used @oneidentity/zstd-js and that works correctly, but the package is ~67Mb. Only |
const prefix = wasm.slice(0, 8) | ||
const isCompressed = Buffer.compare(prefix, ZSTD_PREFIX) === 0 | ||
if (isCompressed) { | ||
const { ZstdStream } = await ZstdInit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is not he best place to import or load the library, but I'm not an expert in React so perhaps it can be refactored by someone else, or suggest how/where to place initializing of the library and how to pass it down to this component.
Was also looking for a way to "unload" the library from memory (as I have seem some other wasm libraries do) but couldn't find it in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost forgot about this! You're right it makes sense to move this lib out of the main bundle.
I chose to move it to a web worker in this commit (because it's already a common pattern in Pioneer) however I'm not sure where did the library actually went:
The main bundle lost the correct size, but I couldn't find any bundles which significantly grew. Maybe the lib was already a dependency in that chunk.
@mnaamani thank you for the WASM validation logic 🙏 I would have struggled with this ! |
Fixes #4122
Effect on bundle size, increased by ~600KB
New bundle size:
Old bundle size:
There is a separate issue with actually submitting the proposal, the "Create Proposal" button is not enabled.