Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Cpp implementation #201

Merged
merged 28 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
aecb5e6
Added dependency on Hunter and fmtlib.
esteve Mar 14, 2018
e044387
Add opcode list to C++
lrettig Mar 14, 2018
8efea5c
Implement the basic logic in C++
esteve Mar 14, 2018
19e0e02
Generate C++ header in generateInterface.js
axic May 26, 2018
716edba
Explicitly specify tuple type signature when building std::tuple from…
jwasinger Apr 22, 2018
0f3edf0
Convert C++ code to deal with vector<uint8_t> and not a string
jwasinger Apr 28, 2018
a5adf50
Apply changes from evm2wasm#263 to cpp implementation
jwasinger May 28, 2018
e36b7d8
Correctly build depmap recursively in C++
jwasinger May 28, 2018
beed04a
Apply changes from evm2wasm#200 to cpp implementation
axic May 28, 2018
e460905
Apply changes from evm2wasm#265 to cpp implementation
axic May 28, 2018
db5a644
Apply changes from evm2wasm#233 to cpp implementation
axic May 28, 2018
9a27cac
Apply changes from evm2wasm#204 to cpp implementation
axic May 28, 2018
3043641
Run tests with C++ implementation too
axic May 29, 2018
a13de10
Circle CI: Enforce PIC in Hera build
chfast May 29, 2018
f11740d
Apply changes from evm2wasm#245 to cpp implementation
jwasinger May 29, 2018
fcead25
Update old GNU-style field designator
axic Jul 26, 2018
1d29f4e
Update README with C++ specific information
axic Jul 26, 2018
e2a03b8
Use hera ef3c17f in circleci
axic Jul 27, 2018
c1b5060
Apply changes from evm2wasm#277 to cpp implementation
axic Jul 29, 2018
9af9372
Apply changes from evm2wasm#301 to cpp implementation
axic Jul 29, 2018
0e5524f
Fix stack check typo in cpp implementation
axic Jul 29, 2018
0617c18
Turn on chargePerOp by default in cpp implementation to match the JS …
axic Jul 29, 2018
415a575
Output push statement with signed numbers in C++ to match JS output
axic Jul 29, 2018
d29026d
Fix useGas value typo in cpp implementation
axic Jul 29, 2018
4391371
Disallow stStackTests as it surfaces a binaryen vs. wabt disagreement
axic Jul 30, 2018
dc7a9a3
Update to binaryen 1.38.9
axic Jul 30, 2018
5881af0
Apply changes from evm2wasm#305 to cpp implementation
axic Aug 2, 2018
a4fc405
Regenerate interfaces
axic Jul 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ set(CMAKE_CXX_EXTENSIONS Off)

add_compile_options(-Wall -Wextra -Wconversion -Wno-sign-conversion -Wno-unknown-pragmas)

include(HunterGate)
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.20.24.tar.gz"
SHA1 "3e2037a462bcf2ec3440f60298d933e74ffd4df3"
)

project(evm2wasm)

include(ProjectBinaryen)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,20 @@ $ bin/evm2wasm.js -e `evm_bytecode_file` -o `wasm_output_file` --wast --charge-p
* 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` containing a
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`, which iterates the input EMV bytecode and generates
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/](./docs/index.md)

Expand Down
65 changes: 59 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,32 @@ defaults:

build-hera: &build-hera
run:
name: "build hera"
name: "Build hera"
working_directory: ~
command: |
git clone https://github.com/ewasm/hera
cd hera
git reset 817d85bb4f09d24f11ddfc67bcc548032f708cfc --hard
git reset ef3c17f3d4fec8abb6d2901bc363a7461fa1a9d9 --hard
git submodule update --init --recursive
cmake -DBUILD_SHARED_LIBS=ON .
make -j8
mv ~/evm2wasm/hera/src/libhera.so ~/libhera.so

build-hera-cpp: &build-hera-cpp
run:
name: "Build hera (with builtin evm2wasm)"
working_directory: ~
command: |
git clone https://github.com/ewasm/hera
cd hera
git reset ef3c17f3d4fec8abb6d2901bc363a7461fa1a9d9 --hard
git submodule update --init --recursive
rm -rf evm2wasm
ln -s /home/builder/evm2wasm evm2wasm
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=evm2wasm/cmake/toolchains/cxx11-pic.cmake .
make -j8
mv ~/evm2wasm/hera/src/libhera.so ~/libhera.so

vm-tests: &vm-tests
run:
name: "Run ethereum VM tests"
Expand Down Expand Up @@ -76,6 +91,22 @@ defaults:
testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.js=true
echo "ran the state tests."

state-tests: &state-tests-cpp
run:
name: "Run Ethereum state tests"
working_directory: ~/build
command: |
echo 'export PATH=~/evm2wasm/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
echo "running testeth command..."
testeth -t GeneralStateTests/stExample -- --testpath ~/tests --singlenet "Byzantium" --singletest "add11" --vm ~/libhera.so --evmc evm2wasm.cpp=true
#testeth -t GeneralStateTests/stStackTests -- --testpath ~/tests --singlenet "Byzantium" --vm ~/libhera.so --evmc evm2wasm.cpp=true
testeth -t GeneralStateTests/stBadOpcode -- --testpath ~/tests --singlenet "Byzantium" --vm ~/libhera.so --evmc evm2wasm.cpp=true
testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcall_00" --vm ~/libhera.so --evmc evm2wasm.cpp=true
testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcallcode_01" --vm ~/libhera.so --evmc evm2wasm.cpp=true
testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.cpp=true
echo "ran the state tests."

cli-tests: &cli-tests
run:
name: "Basic CLI validation"
Expand All @@ -84,7 +115,7 @@ defaults:
bin/evm2wasm.js 600160020200 --trace
build/tools/evm2wasm/evm2wasm <(echo "600160020200")

state-test-steps: &state-test-steps
js-state-test-steps: &js-state-test-steps
- checkout
- *npm-install
- *lint
Expand All @@ -99,17 +130,39 @@ defaults:
# - *store-hera
- *state-tests

cpp-state-test-steps: &cpp-state-test-steps
- checkout
- *npm-install
- *lint
- *validate-build
- *clone-tests
#- *build-cpp
#- *cli-tests # weird chars mess up the console
#- *vm-tests # vm-tests temporarily disabled until ewasm-kernel is fixed
# - *print-cpp-hera-version
- *install-cpp-ethereum
- *build-hera-cpp
# - *store-hera
- *state-tests-cpp

version: 2
jobs:
# to run this using local circleci tool, rename Ewasm-Tests to `build` then do `circleci build -c circle.yml`
build:
build-js:
working_directory: ~/evm2wasm
docker:
- image: cdetrio/nodejs-cpp-build-env
steps: *js-state-test-steps

build-cpp:
working_directory: ~/evm2wasm
docker:
- image: cdetrio/nodejs-cpp-build-env
steps: *state-test-steps
steps: *cpp-state-test-steps

workflows:
version: 2
evm2wasm-build:
jobs:
- build
- build-js
- build-cpp
Loading