polyphene / holium-rs-sdk

MIT License
1 stars 0 forks source link

Feature/revamp host interaction #5

Closed tchataigner closed 2 years ago

tchataigner commented 2 years ago

What It Does πŸ”Ž

Pull request that changes the way we integrate with an host to send and receive data from a guest wasm module. We leverage pointers on the linear memory of the module.

The objective was to have an integration as light as possible that could be easily integrated on any runtime and allowing for easier updates in the future.

Lets consider a case where we have a transformation named exported and its generated glue code function named wrapped_exported.

From a compiled Wasm stand point, all of our wrapping function that we export to the host will have a signature as such: fn wrapped_exported(ret_ptr: u32, input_payload_ptr: u32, input_payload_len: u32)

In ret_ptr the Wasm bytecode will store a structure that will store the pointer and length of the return value (a 2 elem tuple of u32) of the exported function.

To make sure that memory is properly handled we also added a function called __hbindgen_mem_alloc that will allocate memory space for each data payload passed from the host to the guest and for the returned structure.

Documentation Updates πŸ“˜

N/A

How To Test βœ”οΈ

cargo test

Linked Issues 🎫

No tickets linked to this specific development

Related Pull Requests πŸ”€

tchataigner commented 2 years ago

Okay, the problem for different environment seems to come from the recent release of trybuild. For now I fixed the version of the crate to 1.0.42 where it should work the same on Linux and Windows !

tchataigner commented 2 years ago

After looking trhough the trybuild crate it seems that the desired workflow was correctly implemented between 1.0.43 and 1.0.49. But this commit in the 1.0.50 seems to have broken the desired flow. An issue is currently opened on the repo so I will bump the version to 1.0.49 and create a ticket to unfreeze dep when the issue is closed.

This path replacement seems to be a big subject in the crate. If not changes seems to come in the following weeks I will open an issue on their repo and maybe open a PR.