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

feat(gate)!: wasmtime support #669

Merged
merged 16 commits into from
Apr 21, 2024
Merged

feat(gate)!: wasmtime support #669

merged 16 commits into from
Apr 21, 2024

Conversation

michael-0acf4
Copy link
Contributor

@michael-0acf4 michael-0acf4 commented Apr 9, 2024

Motivation and context

Enable support for wit and facilitate readiness for the upcoming specs.

Migration notes

#[wasmedge_bindgen] are replaced by wit bindings.

In the old version we were restricted to#[wasmedge_bindgen], which was only available in Rust and unique to WasmEdge.

#[wasmedge_bindgen]
fn add(a: u32, b: u32) -> u32 {
   a + b
}

In the new implementation, wasm modules written in any language that uses the wit interface are now natively supported within typegate.

// wit/example.wit
package example:host;
world host {
  export add: func(a: u32, b: u32) -> u32;
}

An implementation (eg. in Rust) may look like this..

// src/lib.rs
wit_bindgen::generate!({ world: "host" });
struct MyLib;
impl Guest for MyLib {
    fn add(a: u32, b: u32) -> u32 {
        a + b
    }
}
export!(MyLib);

Checklist

  • The change come with new or modified tests
  • Hard-to-understand functions have explanatory comments
  • End-user documentation is updated to reflect the change

Copy link

linear bot commented Apr 9, 2024

@michael-0acf4 michael-0acf4 changed the title feat(wasm): wasmtime support feat(gate): wasmtime support Apr 12, 2024
@michael-0acf4 michael-0acf4 changed the title feat(gate): wasmtime support feat(gate)!: wasmtime support Apr 12, 2024
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 39.84375% with 77 lines in your changes are missing coverage. Please review.

Project coverage is 73.85%. Comparing base (be4a4ed) to head (8eabc6b).

Files Patch % Lines
typegate/src/runtimes/wasm.ts 1.28% 76 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #669      +/-   ##
==========================================
- Coverage   73.94%   73.85%   -0.10%     
==========================================
  Files         114      114              
  Lines       12950    13003      +53     
  Branches     1358     1358              
==========================================
+ Hits         9576     9603      +27     
- Misses       3352     3377      +25     
- Partials       22       23       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@zifeo zifeo left a comment

Choose a reason for hiding this comment

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

Can you add an example in the migration description?

typegate/tests/runtimes/wasm/wasm_test.ts Show resolved Hide resolved
Copy link
Member

@zifeo zifeo left a comment

Choose a reason for hiding this comment

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

lgtm, waiting on another review with that large PR :)

Yohe-Am
Yohe-Am previously approved these changes Apr 21, 2024
@Yohe-Am Yohe-Am force-pushed the met-447-gate-wasmtime-support branch from 929c5d3 to 3c43717 Compare April 21, 2024 05:05
@destifo destifo merged commit 7b8c794 into main Apr 21, 2024
11 checks passed
@destifo destifo deleted the met-447-gate-wasmtime-support branch April 21, 2024 08:10
Yohe-Am added a commit that referenced this pull request Apr 21, 2024
#### Motivation and context

Enable support for
[wit](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md)
and facilitate readiness for the upcoming specs.

#### Migration notes
`#[wasmedge_bindgen]` are replaced by wit bindings.

In the old version we were restricted to`#[wasmedge_bindgen]`, which was
only available in Rust and unique to WasmEdge.
```rust
#[wasmedge_bindgen]
fn add(a: u32, b: u32) -> u32 {
   a + b
}
```

In the new implementation, wasm modules written in any language that
uses the `wit` interface are now natively supported within `typegate`.
```wit
// wit/example.wit
package example:host;
world host {
  export add: func(a: u32, b: u32) -> u32;
}
```
An implementation (eg. in Rust) may look like this..
```rust
// src/lib.rs
wit_bindgen::generate!({ world: "host" });
struct MyLib;
impl Guest for MyLib {
    fn add(a: u32, b: u32) -> u32 {
        a + b
    }
}
export!(MyLib);
```

### Checklist

- [x] The change come with new or modified tests
- [x] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

---------

Co-authored-by: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com>
Yohe-Am added a commit that referenced this pull request Apr 30, 2024
- Finalizes the host side of the `wit_wire` implementation started in
#687 .
- Fixes a few issues with the `mdk_rust` generator.

#### Motivation and context

The code generator was already in place but we the typegate had no
support for the `wit_wire` interface used by the rust mdk. This PR adds
that.

The two week delay is mainly due to the base work required in #669 and
related PRs.

#### Migration notes

_No breaking changes on user._

### Checklist

- [x] The change come with new or modified tests
- [x] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change
Yohe-Am pushed a commit that referenced this pull request May 7, 2024
fix: cherry-pick

feat(wasm): wit component support

test(wasm): error propagation

refactor(wasm): all remaining wasmedge -> wasm

fix(wasm): bad conversion

feat(wasm): nested object output

test(wasm): tuple deserialize

test(wasm): update binding test value

feat(wasm): nested wit input support

feat(wasm): handle enum input, fix object bug

feat(wasm): reject on extra fields

fix(wasm): typos and minor cleanups

fix(tests.yml): disable cache deno dir for now

fix: version lock

fix: lockfile

refactor: rename all wasmedge ref. to wasm

refactor(gate): wasi 0.2 pyrt

refactor: rename to `pyrt_wit_wire`

fix: pre-commit issue

wip: try ci fix

feat: add pyrt bin inline

refactor: `python_wasi` -> `python`

wip: import module support

fix: rebase bugs

feat(metagen): `mdk_rs` finalization (#673)

- Finalizes the host side of the `wit_wire` implementation started in
- Fixes a few issues with the `mdk_rust` generator.

The code generator was already in place but we the typegate had no
support for the `wit_wire` interface used by the rust mdk. This PR adds
that.

The two week delay is mainly due to the base work required in #669 and
related PRs.

_No breaking changes on user._

- [x] The change come with new or modified tests
- [x] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

feat: Enable batch prisma queries in the typegate runtime (#682)

Enable batch prisma queries (and transaction) in the typegate runtime

Console

[MET-381](https://linear.app/metatypedev/issue/MET-381/console-collections)

<!-- Explain HOW users should update their code when required -->

- [x] The change come with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

---------

Co-authored-by: Teo Stocco <teo@zifeo.com>
Co-authored-by: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com>

fix: update poetry lockfile

fix: CI issues

fix: minor bugs

fix: ci breakage

wip: try fix
Yohe-Am pushed a commit that referenced this pull request May 23, 2024
fix: cherry-pick

feat(wasm): wit component support

test(wasm): error propagation

refactor(wasm): all remaining wasmedge -> wasm

fix(wasm): bad conversion

feat(wasm): nested object output

test(wasm): tuple deserialize

test(wasm): update binding test value

feat(wasm): nested wit input support

feat(wasm): handle enum input, fix object bug

feat(wasm): reject on extra fields

fix(wasm): typos and minor cleanups

fix(tests.yml): disable cache deno dir for now

fix: version lock

fix: lockfile

refactor: rename all wasmedge ref. to wasm

refactor(gate): wasi 0.2 pyrt

refactor: rename to `pyrt_wit_wire`

fix: pre-commit issue

wip: try ci fix

feat: add pyrt bin inline

refactor: `python_wasi` -> `python`

wip: import module support

fix: rebase bugs

feat(metagen): `mdk_rs` finalization (#673)

- Finalizes the host side of the `wit_wire` implementation started in
- Fixes a few issues with the `mdk_rust` generator.

The code generator was already in place but we the typegate had no
support for the `wit_wire` interface used by the rust mdk. This PR adds
that.

The two week delay is mainly due to the base work required in #669 and
related PRs.

_No breaking changes on user._

- [x] The change come with new or modified tests
- [x] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

feat: Enable batch prisma queries in the typegate runtime (#682)

Enable batch prisma queries (and transaction) in the typegate runtime

Console

[MET-381](https://linear.app/metatypedev/issue/MET-381/console-collections)

<!-- Explain HOW users should update their code when required -->

- [x] The change come with new or modified tests
- [ ] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

---------

Co-authored-by: Teo Stocco <teo@zifeo.com>
Co-authored-by: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com>

fix: update poetry lockfile

fix: CI issues

fix: minor bugs

fix: ci breakage

wip: try fix
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.

4 participants