-
Notifications
You must be signed in to change notification settings - Fork 3
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
Provide host functions for loading Wasm modules and calling to/from them #11
Conversation
In the next commit I'm planning to associate child runtimes with an identifier, to permit calls from the EE back into smart contracts. That requires RootRuntime to own a Vec<ChildRuntime> (or similar.) Using a reference would make that impossible.
Root runtimes can now load a Wasm module into a numbered "slot", instead of having to load and execute them at the same time as before. This arrangement permits calls from the root runtime back into the child runtimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamWilsn this is really awesome, you crushed it. I'm sure we'll continue to tweak and experiment with this, but I'm going to go ahead and merge this and release an updated crate because I'm opening up a new repo to play with the code execution functions. 😄
Feedback follows, all off the top of my head. Feel no obligation to respond, just want to give you some feedback to be aware of as you consider designs.
|
Thanks for the feedback @poemm!
Creating a new abstraction layer was exactly my intent. Sharing address space and host functions between EEs and child environments seems like a recipe for disaster. Other than creating a new interpreter, I didn't find any existing ways to isolate modules to the extent I wanted, though I didn't actually search that deeply.
While I'm not even close to certain about
I took a quick look into tables after submitting this PR! They seem like a much better implementation: no strings, standardized, etc. There's currently a limit of one table per module, right?
Metering is particularly difficult for child modules, but I think that applies to any implementation, not just this one.
I like the Harvard architecture as well, especially for EEs & smart contracts. Polymorphic code scares me a little. If we want to be super fancy, something like shared anonymous
100% agree! I took the most conservative approach in this PR, with basically no functionality exposed to the child code. This gives the EE the most freedom to define what child code is allowed to do. If my understanding is correct, this is similar to the If the child code should be allowed to do so, the EE can expose functions. I believe this is an efficiency vs. flexibility trade off. In this implementation, there's more Wasm executing, but it gives a lot freedom.
I'm not sure I understand. What other components of the system have intermodule communication?
You're absolutely correct. I'm new to the Ethereum space. I have no idea what is common in smart contracts today, or what will be common in the future. I went for maximum flexibility, but maybe something more restrictive is good enough. |
This is kinda how I'm thinking of doing the "execute Wasm function" we've been discussing.
I've created a second runtime and resolver that won't have access to the same host functions as the "root" runtime.
Feedback very welcome!
New Host Functions
To call into a child module:
To call back into the root module:
To get the most recent argument in both:
To copy a value to the caller:
Future Work
I haven't thought about how unloading a module will work, so there's no way to do that currently.