py-evm icon indicating copy to clipboard operation
py-evm copied to clipboard

Add ewasm support

Open lrettig opened this issue 7 years ago • 3 comments

Tie together the software packages (py-evm, juno, pywasm) and test detecting WASM code and passing data and receiving data. One stEWASMtests test (useGas) is passing so data is flowing in both directions.

For now the nastiness lives mostly in another package called Juno (which is the Latin name of Hera, which is the EVMC "glue code" in C++). One of the things @poemm and I have been discussing is whether this "glue" code belongs in py-evm or not.

@poemm's pywebassembly lives at https://github.com/poemm/pywebassembly.

Cute Animal Picture

put a cute animal picture link inside the parentheses

lrettig avatar Jun 18 '18 19:06 lrettig

This seems like a good place to dump some brief thoughts.

  1. The code quality of the python ewasm interpreter is pretty poor. Acceptable for a POC, will require lots of work for much beyond that.
  2. In this model, the computation object no longer contains accurate information about what happened during computation. This is going to be problematic in many places and is something we will need to explore fixing. Losing this information is not something I'm inclined to accept lightly as it is very valuable information.
  3. Very cool to see how easy this was to glue together, though I expect (as stated in my previous two points) that real integration may be significantly more complex.

pipermerriam avatar Jun 19 '18 15:06 pipermerriam

In this model, the computation object no longer contains accurate information about what happened during computation. This is going to be problematic in many places and is something we will need to explore fixing. Losing this information is not something I'm inclined to accept lightly as it is very valuable information.

Completely agree. I wouldn't even call this hacky thing a "model." Agree this is important to maintain if possible.

lrettig avatar Jun 20 '18 14:06 lrettig

Dear @pipermerriam ,

Thank you for your message. My responses follow.

  1. I sincerely apologize for not explaining the motivations behind the way in which PyWebAssembly was written. PyWebAssembly follows the Wasm Spec document closely, referencing where each function was defined. This is useful for the following reasons. i) The Spec document can be used as a user's manual. ii) PyWebAssembly can be audited alongside the Spec document. iii) When Wasm 1.1 is released, PyWebAssembly can be updated alongside the Spec document. iv) PyWebAssembly does not introduce invariants or design decisions that are not in the Spec document. There are many subtleties in the 150 page Spec document, and invariants may be difficult to maintain, as I have learned. v) Implementing the Spec document has allowed me to find errors and submit fixes to the Spec document, and I have more fixes coming. PyWebAssembly is also structured for my personal economy-of-thought as it is being developed and studied for errors. I do not know any better than to follow the Spec document, but I have a lot to learn, and I am eager to improve myself. In any case, PyWebAssembly was brought to your attention because it is 100% finished for your purposes, modulo tracing which is to-be-done, and some tests which are not applicable to your application. This is not to speak of aesthetics.

  2. Tracing Wasm execution is possible at the granularity of opcodes. When testing, I step through execution of each opcode, printing the operand stack and other info. I am open to your suggestions on how to implement tracing in a way which meets your parameters and specifications.

  3. Lane is skilled at quickly gluing code together. Full integration may be complex because Wasm has different structure and properties than EVM, and it may be difficult to honor the invariants and designs which you have specified for EVM. Because of this complexity and resulting difficulty, I am willing to offer assistance in your project, although I do not wish to hinder your progress, nor do I wish to create any feelings of obligation.

I wish you only the best success.

Sincerely, @poemm

poemm avatar Jun 22 '18 01:06 poemm