All Projects → ewasm → Evm2wasm

ewasm / Evm2wasm

Licence: mpl-2.0
[ORPHANED] Transcompiles EVM code to eWASM

Projects that are alternatives of or similar to Evm2wasm

Bytecoder
Rich Domain Model for JVM Bytecode and Framework to interpret and transpile it.
Stars: ✭ 401 (+317.71%)
Mutual labels:  compiler, transpiler, webassembly
Viper
[WIP] A Pythonesque language with a design that focuses on efficiency and expressiveness. Compiles to WebAssembly
Stars: ✭ 23 (-76.04%)
Mutual labels:  compiler, webassembly
Design
Ewasm Design Overview and Specification
Stars: ✭ 827 (+761.46%)
Mutual labels:  ethereum, webassembly
Ette
EVM-based Blockchain Indexer, with historical data query & real-time notification support 😎
Stars: ✭ 37 (-61.46%)
Mutual labels:  ethereum, evm
J2cl
Java to Closure JavaScript transpiler
Stars: ✭ 773 (+705.21%)
Mutual labels:  compiler, transpiler
Typescripttolua
Typescript to lua transpiler. https://typescripttolua.github.io/
Stars: ✭ 783 (+715.63%)
Mutual labels:  compiler, transpiler
Burrow
https://wiki.hyperledger.org/display/burrow
Stars: ✭ 851 (+786.46%)
Mutual labels:  ethereum, evm
Echidna
Ethereum smart contract fuzzer
Stars: ✭ 571 (+494.79%)
Mutual labels:  ethereum, evm
Elchemy
Write Elixir code using statically-typed Elm-like syntax (compatible with Elm tooling)
Stars: ✭ 1,080 (+1025%)
Mutual labels:  compiler, transpiler
Py Evm
A Python implementation of the Ethereum Virtual Machine
Stars: ✭ 1,122 (+1068.75%)
Mutual labels:  ethereum, evm
Jsweet
A Java to JavaScript transpiler.
Stars: ✭ 1,167 (+1115.63%)
Mutual labels:  compiler, transpiler
Ssvm
SSVM is a high performance, extensible, and hardware optimized WebAssembly Virtual Machine for cloud, AI, and blockchain applications.
Stars: ✭ 751 (+682.29%)
Mutual labels:  ethereum, webassembly
Ring
Innovative and practical general-purpose multi-paradigm language
Stars: ✭ 716 (+645.83%)
Mutual labels:  compiler, webassembly
Ethereumjs Monorepo
Monorepo for the Ethereum VM TypeScript Implementation
Stars: ✭ 813 (+746.88%)
Mutual labels:  ethereum, evm
Intellij Solidity
Solidity plugin for IntelliJ
Stars: ✭ 646 (+572.92%)
Mutual labels:  ethereum, evm
Ruby To Solidity
(Secure) Ruby to Solidity (Source-to-Source) Cross-Compiler Cheat Sheet / White Paper
Stars: ✭ 7 (-92.71%)
Mutual labels:  ethereum, evm
Wasm Forth
A Forth implementation compiling to WebAssembly.
Stars: ✭ 92 (-4.17%)
Mutual labels:  compiler, webassembly
Capstone
Capstone disassembly/disassembler framework: Core (Arm, Arm64, BPF, EVM, M68K, M680X, MOS65xx, Mips, PPC, RISCV, Sparc, SystemZ, TMS320C64x, Web Assembly, X86, X86_64, XCore) + bindings.
Stars: ✭ 5,374 (+5497.92%)
Mutual labels:  ethereum, webassembly
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+489.58%)
Mutual labels:  compiler, webassembly
Remix
This has been moved to https://github.com/ethereum/remix-project
Stars: ✭ 1,063 (+1007.29%)
Mutual labels:  ethereum, evm

Note: this project is not actively maintained. See RuneVM and yevm for replacement candidates.

SYNOPSIS

CircleCI js-standard-style

EVM (Ethereum VM 1.0) to eWASM transcompiler. Here is a online frontend.

INSTALL

Clone the repository and run npm install

USE

There is a commandline tool to transcompile EVM input:

Transcompile EVM to WASM

$ bin/evm2wasm.js -e `evm_bytecode_file` -o `wasm_output_file`

Transcompile EVM to WAST

$ bin/evm2wasm.js -e `evm_bytecode_file` -o `wasm_output_file` --wast

Transcompile EVM to WAST with embedded EVM trace statements for each transpiled EVM opcode

$ bin/evm2wasm.js -e `evm_bytecode_file` -o `wasm_output_file` --wast --trace

Transcompile EVM to WAST with gas metering per transpiled EVM opcode (not per branch segment)

$ bin/evm2wasm.js -e `evm_bytecode_file` -o `wasm_output_file` --wast --charge-per-op

DEVELOP

  • After any changes to .wast file, npm run build needs to be run to compile the files into a .json file
  • To rebuild the documentation run npm run build:docs
  • To lint run npm run lint
  • And make sure you test with npm test and npm run vmTests which runs the offical Ethereum test suite

The above build command will invoke wasm/generateInterface.js which generates wasm/wast.json and include/wast.h containing a Webassembly function corresponding to each EVM opcode.

The core logic of the evm2wasm compiler is in index.js (Javascript frontend) or libs/evm2wasm/evm2wasm.cpp (C++ fronetend), which iterates the input EMV bytecode and generates a Webassembly output by invoking each of the above generated Webassembly functions and concatenating them into the output.

To build the C++ frontend:

$ mkdir build
$ cd build
$ cmake ..
$ make

API

./docs/

TECHNICAL NOTES

EVM is stack based and offers access to memory, storage and state via special instructions.
Here we replicate the stack layout in WebAssembly (WASM) and implement each operation working on this stack.

OPCODES

Every opcode (bar some special instructions) receives the current stack pointer ($sp) as i32 and must return the adjusted stack pointer.

STACK LAYOUT

The stack grows from memory location 0, where 256 bit values are stored linearly in LSB byteorder.
The $sp points to the starting position of the top stack entry (and not the next free stack position). If the stack is empty, it is set to -32.

MEMORY LAYOUT

The resulting (after transpilation) contract memory layout is currently as follows:

.---------------------------------------------------
| Reserved space for the stack (32768 bytes)
| - each stack entry is 256 bits
| - the stack is limited to 1024 entries
+---------------------------------------------------
| Word count (4 bytes)
| (Number of 256 bit words stored in memory)
+---------------------------------------------------
| Previous memory cost in word count (4 bytes)
| (The cost charged for the last memory allocation)
+---------------------------------------------------
| Scratch space (32 bytes)
+---------------------------------------------------
| Reserved space for the Keccak-256 context (1024 bytes)
+---------------------------------------------------
| "EVM 1.0" contract memory starts here ("unlimited" in size)
`---------------------------------------------------

METERING

The generated eWASM contract contains gas metering. It is assumed evm2wasm will become a deployed trusted contract, which returns eWASM code that does not need to be run through the gas injector contract.

LICENSE

MPL-2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].