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

Commit 0bae4c6

Browse files
authored
Merge pull request #201 from lrettig/cpp-implementation
Cpp implementation
2 parents 2bdcb3b + a4fc405 commit 0bae4c6

File tree

13 files changed

+2630
-21
lines changed

13 files changed

+2630
-21
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ set(CMAKE_CXX_EXTENSIONS Off)
99

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

12+
include(HunterGate)
13+
HunterGate(
14+
URL "https://github.com/ruslo/hunter/archive/v0.20.24.tar.gz"
15+
SHA1 "3e2037a462bcf2ec3440f60298d933e74ffd4df3"
16+
)
17+
1218
project(evm2wasm)
1319

1420
include(ProjectBinaryen)

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ $ bin/evm2wasm.js -e `evm_bytecode_file` -o `wasm_output_file` --wast --charge-p
3636
* To lint run `npm run lint`
3737
* And make sure you test with `npm test` and `npm run vmTests` which runs the offical Ethereum test suite
3838

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

42-
The core logic of the evm2wasm compiler is in `index.js`, which iterates the input EMV bytecode and generates
42+
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
4343
a Webassembly output by invoking each of the above generated Webassembly functions and concatenating them into the output.
4444

45+
To build the C++ frontend:
46+
```
47+
$ mkdir build
48+
$ cd build
49+
$ cmake ..
50+
$ make
51+
```
52+
4553
# API
4654
[./docs/](./docs/index.md)
4755

circle.yml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,32 @@ defaults:
2727
2828
build-hera: &build-hera
2929
run:
30-
name: "build hera"
30+
name: "Build hera"
3131
working_directory: ~
3232
command: |
3333
git clone https://github.com/ewasm/hera
3434
cd hera
35-
git reset 817d85bb4f09d24f11ddfc67bcc548032f708cfc --hard
35+
git reset ef3c17f3d4fec8abb6d2901bc363a7461fa1a9d9 --hard
3636
git submodule update --init --recursive
3737
cmake -DBUILD_SHARED_LIBS=ON .
3838
make -j8
3939
mv ~/evm2wasm/hera/src/libhera.so ~/libhera.so
4040
41+
build-hera-cpp: &build-hera-cpp
42+
run:
43+
name: "Build hera (with builtin evm2wasm)"
44+
working_directory: ~
45+
command: |
46+
git clone https://github.com/ewasm/hera
47+
cd hera
48+
git reset ef3c17f3d4fec8abb6d2901bc363a7461fa1a9d9 --hard
49+
git submodule update --init --recursive
50+
rm -rf evm2wasm
51+
ln -s /home/builder/evm2wasm evm2wasm
52+
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=evm2wasm/cmake/toolchains/cxx11-pic.cmake .
53+
make -j8
54+
mv ~/evm2wasm/hera/src/libhera.so ~/libhera.so
55+
4156
vm-tests: &vm-tests
4257
run:
4358
name: "Run ethereum VM tests"
@@ -76,6 +91,22 @@ defaults:
7691
testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.js=true
7792
echo "ran the state tests."
7893
94+
state-tests: &state-tests-cpp
95+
run:
96+
name: "Run Ethereum state tests"
97+
working_directory: ~/build
98+
command: |
99+
echo 'export PATH=~/evm2wasm/bin:$PATH' >> $BASH_ENV
100+
source $BASH_ENV
101+
echo "running testeth command..."
102+
testeth -t GeneralStateTests/stExample -- --testpath ~/tests --singlenet "Byzantium" --singletest "add11" --vm ~/libhera.so --evmc evm2wasm.cpp=true
103+
#testeth -t GeneralStateTests/stStackTests -- --testpath ~/tests --singlenet "Byzantium" --vm ~/libhera.so --evmc evm2wasm.cpp=true
104+
testeth -t GeneralStateTests/stBadOpcode -- --testpath ~/tests --singlenet "Byzantium" --vm ~/libhera.so --evmc evm2wasm.cpp=true
105+
testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcall_00" --vm ~/libhera.so --evmc evm2wasm.cpp=true
106+
testeth -t GeneralStateTests/stCallCodes -- --testpath ~/tests --singlenet "Byzantium" --singletest "callcallcode_01" --vm ~/libhera.so --evmc evm2wasm.cpp=true
107+
testeth -t GeneralStateTests/stMemoryTest -- --testpath ~/tests --singlenet "Byzantium" --singletest "memReturn" --vm ~/libhera.so --evmc evm2wasm.cpp=true
108+
echo "ran the state tests."
109+
79110
cli-tests: &cli-tests
80111
run:
81112
name: "Basic CLI validation"
@@ -84,7 +115,7 @@ defaults:
84115
bin/evm2wasm.js 600160020200 --trace
85116
build/tools/evm2wasm/evm2wasm <(echo "600160020200")
86117
87-
state-test-steps: &state-test-steps
118+
js-state-test-steps: &js-state-test-steps
88119
- checkout
89120
- *npm-install
90121
- *lint
@@ -99,17 +130,39 @@ defaults:
99130
# - *store-hera
100131
- *state-tests
101132

133+
cpp-state-test-steps: &cpp-state-test-steps
134+
- checkout
135+
- *npm-install
136+
- *lint
137+
- *validate-build
138+
- *clone-tests
139+
#- *build-cpp
140+
#- *cli-tests # weird chars mess up the console
141+
#- *vm-tests # vm-tests temporarily disabled until ewasm-kernel is fixed
142+
# - *print-cpp-hera-version
143+
- *install-cpp-ethereum
144+
- *build-hera-cpp
145+
# - *store-hera
146+
- *state-tests-cpp
147+
102148
version: 2
103149
jobs:
104150
# to run this using local circleci tool, rename Ewasm-Tests to `build` then do `circleci build -c circle.yml`
105-
build:
151+
build-js:
152+
working_directory: ~/evm2wasm
153+
docker:
154+
- image: cdetrio/nodejs-cpp-build-env
155+
steps: *js-state-test-steps
156+
157+
build-cpp:
106158
working_directory: ~/evm2wasm
107159
docker:
108160
- image: cdetrio/nodejs-cpp-build-env
109-
steps: *state-test-steps
161+
steps: *cpp-state-test-steps
110162

111163
workflows:
112164
version: 2
113165
evm2wasm-build:
114166
jobs:
115-
- build
167+
- build-js
168+
- build-cpp

0 commit comments

Comments
 (0)