substrate-api-client icon indicating copy to clipboard operation
substrate-api-client copied to clipboard

Test/Example for WebAssembly

Open Niederb opened this issue 9 months ago • 3 comments

It would be nice to have an example that works with WebAssembly. We should also have some tests that run a WebAssembly executable. Some of the existing examples might actually work but it would still be nice to document this.

  • Find/Write an example that works with wasm
    • Run this example with a wasm runtime
  • Documentation
    • What does work with WebAssembly
    • Differences between wasm-unknown-unknown and wasm-wasip1
    • Differences no_std and wasm

Niederb avatar Apr 25 '24 11:04 Niederb

Using the kitchensink_runtime seems very problematic. As soon as it is included the wasm module cannot be instantiated anymore 👎

Error: failed to run main module `target/wasm32-unknown-unknown/release/examples/wasm_example.wasm`

Caused by:
    0: failed to instantiate "target/wasm32-unknown-unknown/release/examples/wasm_example.wasm"
    1: unknown import: `env::ext_trie_blake2_256_ordered_root_version_2` has not been defined

Niederb avatar Jun 10 '24 13:06 Niederb

@Niederb What's your suggestion on how we should continue with this? Should we try to fix this in the kitchensink_runtime (with the goal to do a PR there?) or create an example with a different runtime? Or just pause this issue and try again in the future?

masapr avatar Jun 11 '24 07:06 masapr

I already worked quite a bit on the test infrastructure. At least a very minimal example should be possible and I think having something running with WebAssembly would already be useful.

Niederb avatar Jun 11 '24 08:06 Niederb