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

Can the rune VM be used in a lightweight webassembly module? #692

Closed
sanity opened this issue Apr 19, 2024 · 2 comments
Closed

Can the rune VM be used in a lightweight webassembly module? #692

sanity opened this issue Apr 19, 2024 · 2 comments

Comments

@sanity
Copy link

sanity commented Apr 19, 2024

I'm working on Freenet, a large-scale platform for distributed computation.

Freenet relies on lightweight webassembly modules called contracts which we currently compile from Rust, these need to be small so we use ![no_std] and minimize dependencies.

The problem is that Rust has a significant learning curve, and so I was wondering whether we could use Rune to allow the easy creation of Freenet contracts - which (in Rust) implement the ContractInterface trait.

I found #662 so it appears that Rune can work with WebAssembly, but it wasn't clear to me what the code example was doing - so I thought I'd ask directly:

Can the Rune VM be used in a lightweight wasm module (with no_std) to provide a Rune implementation of the ContractInterface trait?

@sanity sanity closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2024
@udoprog
Copy link
Collaborator

udoprog commented Apr 20, 2024

Hi,

I would say no, from what I can intuit of your definition of "lightweight". But it really depends.

Since Rune will always be a virtual machine running on top of webassembly in contrast to Rust, which targets webassembly (code written in Rust directly becomes webassembly instructions) it will never have that low of an overhead. I.e. Rune won't take your scripts and convert them into native webassembly modules.

Rune also requires the use of an allocator. The memory for the virtual machine is allocated explicitly through the system allocator.

I found #662 so it appears that Rune can work with WebAssembly, but it wasn't clear to me what the code example was doing - so I thought I'd ask directly:

The code example linked in 662 is a webassembly module which defines a function that takes a string. This string is then compiled as a unit for the rune virtual machine which is compiled for webassembly to execute.

@sanity
Copy link
Author

sanity commented May 5, 2024

Thank you for the reply.

I understand that the Rune VM running on the wasm VM will not be as lightweight as Rust code compiled to wasm directly - my question is more whether the Rune compiler and VM can run on webassembly. I think it can based on the example I found.

Thanks again.

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

No branches or pull requests

2 participants