-
Notifications
You must be signed in to change notification settings - Fork 784
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
Refactor evm and prepare for ewasm integration #424
Conversation
Signed-off-by: Sina Mahmoodi <[email protected]>
Signed-off-by: Sina Mahmoodi <[email protected]>
Signed-off-by: Sina Mahmoodi <[email protected]>
Signed-off-by: Sina Mahmoodi <[email protected]>
Signed-off-by: Sina Mahmoodi <[email protected]>
Speechless. But...ahm... Cool. 🙂 Really important that you take in the opfns.js file with renaming (currently shown as deleted) for later review. |
Sorry, I should have first created an issue to discuss before suddenly creating a big PR 😓 I can close it right away if you don't think its a good idea... Yeah, I'm not sure why github is not showing the diff (and thinks |
No, that's ok, go ahead. Seems to be really targeted on what we want to achieve on the road to ewasm. 😀 |
cool! One issue with ewasm integration is async vs sync around the EEI and js host functions (https://github.com/ewasm/design/blob/master/interface_questions.md#ewasm-interface-methods-synchronous-vs-asynchronous). What's your preferred workaround for that? |
btw, I think another fix for the sync vs async issue would be to rewrite merkle-patricia-tree so that its fully synchronous (no callbacks/async). |
That was one of the original ideas, but seemed even more tedious than doing a wrapper. |
I think that's what the guys from Rainblock have done in their fork? |
Nice, didn't know about rainblock: https://github.com/RainBlock/merkle-patricia-tree |
wow that's great. |
I don't really have a satisfactory workaround in mind 😅 I was thinking of just using some easy (but not so elegant and performant) mechanism at the beginning for turning the async funcs into sync ones, like deasync, and then iterate on that. Rainblock's sync trie is definitely an interesting idea! Do you think it'd be possible to use coroutines to switch between the wasm module and the environment interface? E.g. wrap the wasm module and the functions it imports ( |
Here's an example for using deasync. Update: Doesn't work in browser (when using browserify). |
Thanks for pointing this out Casey, it sent me down a fascinating rabbit hole (through which I learned a lot)! Here's my current thinking on this:
After that, ideally wasm-js-api would support async imports but that seems farther away. In the meanwhile (and here I'm only repeating what this doc says):
However all I've said are based on my incomplete understanding. I'd love to hear from @axic and @cdetrio if this "plan" makes sense, or what approach you'd prefer. |
Your assessment is correct, for precompiles only there none of the async issues come into play.
I personally would avoid any workarounds like SAB, so this is out of scope for me.
This is the approach I think is the best for now. It also works with our hope to do some kind of stateless client prototype, where all the touched accounts have to be supplied prior to execution and in that case everything can be preloaded.
I feel this approach would only work with a fresh prototype, as you've mentioned it would be a material change in current ethereumjs-vm. Also before changing ethereumjs-vm I would prefer the speed change to be evaluated, whether it is for the better or the worse. |
@s1na please rebase |
@s1na Can we close this here? |
Work in progress:
lib/vm
opFns
instead ofrunState
object for most casesMemory
class and use it inmemLoad
andmemStore
Memory
's sizeStack
classopFns
, e.g. whether operation is allowed in current hardfork, or gas price of operations which are specific to HFopFns
all sync and delegate async fetching of data either torunCode
or toEEI