Skip to content
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

Make vm serializable #33

Merged
merged 4 commits into from
Sep 26, 2022
Merged

Make vm serializable #33

merged 4 commits into from
Sep 26, 2022

Conversation

lukedawilson
Copy link
Contributor

No description provided.

@lukedawilson lukedawilson self-assigned this Sep 23, 2022
@lukedawilson lukedawilson marked this pull request as ready for review September 23, 2022 12:34
@@ -30,6 +30,7 @@
"downlevelIteration": true,
"outDir": "dist",
"rootDir": "src",
"skipLibCheck": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See https://www.typescriptlang.org/tsconfig#skipLibCheck for details.

Rather than doing a full check of all d.ts files, TypeScript will type check the code you specifically refer to in your app’s source code.

Otherwise, we get these two errors due to webpack:

node_modules/@types/eslint/index.d.ts:451:42 - error TS2724: '"/Users/lukewilson/git/terra/cosmwasm-vm-js/node_modules/@types/estree/index"' has no exported member named 'ChainExpression'. Did you mean 'Expression'?

451         ChainExpression?: ((node: ESTree.ChainExpression & NodeParentExtension) => void) | undefined;
                                             ~~~~~~~~~~~~~~~

node_modules/@types/eslint/index.d.ts:474:43 - error TS2694: Namespace '"/Users/lukewilson/git/terra/cosmwasm-vm-js/node_modules/@types/estree/index"' has no exported member 'ImportExpression'.

474         ImportExpression?: ((node: ESTree.ImportExpression & NodeParentExtension) => void) | undefined;


constructor(backend: IBackend) {
this.backend = backend;
this.bech32 = bech32;
this.eddsa = new eddsa('ed25519');
Copy link
Contributor Author

@lukedawilson lukedawilson Sep 23, 2022

Choose a reason for hiding this comment

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

eddsa is not serialisable, but nor does it (seem to) hold any (mutable) state - its methods appear to be pure functions.

export * from './memory';
export * from './backend';
export * from './instance';
export * from './environment';

global.eddsa = () => global._eddsa || (global._eddsa = new eddsa('ed25519'));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to store this globally (and lazy-initialise it) because constructing it each time is slow - on my year-old macbook, about 500ms.

@lukedawilson lukedawilson merged commit 6ccf7ff into main Sep 26, 2022
@lukedawilson lukedawilson deleted the feat/serializable branch September 26, 2022 09:40
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.

2 participants