Stream: wasmtime

Topic: keyvalue component demo


view this post on Zulip Mossaka (Joe) (Dec 15 2022 at 18:49):

Hey there! I want to share a simple key-value interface and a wasm component demo using the latest "component-model" feature from wasmtime, thewit-bindgen tool and wasm-tools. I did this primarily for my own learning and keeping track of the progress on wasm component tool-chains. I thought it would be beneficial for the community to see an example of running something similar to real-world scenario that involves in a in-memory keyvalue store.

Check it out here https://github.com/Mossaka/keyvalue-component-model-demo!

A demo repo that shows how to use the latest component model feature in wasmtime to implement a key-value capability defined in a WIT file. - GitHub - Mossaka/keyvalue-component-model-demo: A demo ...

view this post on Zulip Alex Crichton (Dec 15 2022 at 20:44):

That all looks pretty good to me! I'm curious though if you found this flag to be necessary or if it's copied from elsewhere?

A demo repo that shows how to use the latest component model feature in wasmtime to implement a key-value capability defined in a WIT file. - keyvalue-component-model-demo/build.rs at 00448e1c37e2f...

view this post on Zulip Alex Crichton (Dec 15 2022 at 20:45):

You might also be interested in getting the wasi_snapshot_preview1.wasm from here and seeing how that works out. That will require copying some *.wit into your repo though, but in theory you can slim down the wit to just what your one module needs rather than implementing all of preview2

Commits 272151a: Implement fd_renumber. (#21) (Dan Gohman) #21

view this post on Zulip Mossaka (Joe) (Dec 16 2022 at 19:01):

I'm curious though if you found this flag to be necessary or if it's copied from elsewhere?

It is copied from wit-bindgen https://github.com/bytecodealliance/wit-bindgen/blob/main/crates/test-helpers/macros/build.rs#L136

Thanks for providing the link to "wasi_snapshot_preview1.wasm"!

A language binding generator for WebAssembly interface types - wit-bindgen/build.rs at main · bytecodealliance/wit-bindgen

view this post on Zulip Mossaka (Joe) (Dec 19 2022 at 20:22):

Hey! Do you have any insights into this error? The wasi_snapshot_preview1.wasm was built from preview2-prototyping repo.

wasm-tools component new ./guest/target/wasm32-wasi/debug/guest.wasm --adapt ../preview2-prototyping/target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.wasm

Error: failed to encode a component from module

Caused by:
    0: failed to reduce input adapter module to its minimal size
    1: locally-defined memories are not allowed define a local memory

view this post on Zulip Mossaka (Joe) (Dec 19 2022 at 21:23):

Nevermind, once I updated wasm-tools to the latest version from the main branch. This problem went away.

However, I still have the same issue with using wit-component as a crate.

view this post on Zulip Mossaka (Joe) (Dec 19 2022 at 21:23):

Updated the repo to use wasi_snapshot_preview1.wasm from the preview2-prototyping repo! https://github.com/Mossaka/keyvalue-component-model-demo

A demo repo that shows how to use the latest component model feature in wasmtime to implement a key-value capability defined in a WIT file. - GitHub - Mossaka/keyvalue-component-model-demo: A demo ...

Last updated: Oct 23 2024 at 20:03 UTC