-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decompress wasm runtime before validating (#4182)
* decompress wasm runtime before validating * use @oneidentity/zstd-js/decompress * better comments for maybeDecompressRuntimeBlob() * Add a AddNewProposalModal Runtime Upgrade test * Remove unnecessary exports * Forward the test `runtime-upgrade-input` id * Fix the runtime file validation * Fix `react-hook-form` type inference error * Small refactors * Pass the runtime bytes through the react context * Fix the validation hook * Revert "Fix `react-hook-form` type inference error" This reverts commit 92eef39. * Forward the runtime file without the extra context * Fix AddNewProposalModal tests * Fix types on node.js < 18 * Generate the file array buffer only once * Add a loader under the file drop zone * Move `maybeDecompressRuntimeBlob` in a web worker * Push runtime upgrade proposal down the list * Move the loader to the `FileDropzone` component --------- Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
- Loading branch information
Showing
18 changed files
with
283 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import { merkleRootFromBinary, hashFile } from '..' | ||
import { merkleRootFromBinary, hashFile, maybeDecompressRuntimeBlob } from '..' | ||
|
||
export type WorkerRequestType = 'HASH_FILE' | 'MERKLE_ROOT' | ||
export type WorkerRequestType = 'HASH_FILE' | 'MERKLE_ROOT' | 'DECOMPRESS_RUNTIME' | ||
export type WorkerRequest = { | ||
type: WorkerRequestType | ||
id: string | ||
file: Blob | ||
file: Blob | ArrayBuffer | ||
} | ||
|
||
export type WorkerResponse = { | ||
type: WorkerRequestType | ||
id: string | ||
value: string | ||
value: any | ||
error?: boolean | ||
} | ||
|
||
export const compute = async (type: WorkerRequestType, file: Blob): Promise<string> => { | ||
export async function compute(type: WorkerRequestType, file: Blob | ArrayBuffer): Promise<any> { | ||
switch (type) { | ||
case 'HASH_FILE': | ||
return await hashFile(file) | ||
return await hashFile(file as Blob) | ||
case 'MERKLE_ROOT': | ||
return await merkleRootFromBinary(file) | ||
return await merkleRootFromBinary(file as Blob) | ||
case 'DECOMPRESS_RUNTIME': | ||
return await maybeDecompressRuntimeBlob(file as ArrayBuffer) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { memoize } from 'lodash' | ||
|
||
export const asArrayBuffer = memoize((file?: File) => file?.arrayBuffer() ?? new ArrayBuffer(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
f3c728f
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.
Successfully deployed to the following URLs:
pioneer-2-storybook – ./
pioneer-2-storybook-joystream.vercel.app
pioneer-2-storybook.vercel.app
pioneer-2-storybook-git-dev-joystream.vercel.app
f3c728f
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.
Successfully deployed to the following URLs:
pioneer-2 – ./
pioneer-2-git-dev-joystream.vercel.app
pioneer-2.vercel.app
pioneer-2-joystream.vercel.app