From 156746518364522e539ec059f3578105112d3fbe Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 26 Mar 2018 23:23:52 +0100 Subject: [PATCH 1/8] Remove spare line in evm2wasm.js --- bin/evm2wasm.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/evm2wasm.js b/bin/evm2wasm.js index 019ab571..073c08a4 100755 --- a/bin/evm2wasm.js +++ b/bin/evm2wasm.js @@ -7,8 +7,6 @@ const fs = require('fs') // convert evm bytecode to WASM or WAST function convert (bytecode, wast) { return new Promise((resolve, reject) => { - outputFile = argv.o ? argv.o : undefined - if (!bytecode) { resolve(Buffer.from('')) } From 5938b0173a0c3cf125df40c606835bf8f115cc99 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 26 Mar 2018 23:26:16 +0100 Subject: [PATCH 2/8] Change options handling for better readability in CLI --- bin/evm2wasm.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/evm2wasm.js b/bin/evm2wasm.js index 073c08a4..5b403f9c 100755 --- a/bin/evm2wasm.js +++ b/bin/evm2wasm.js @@ -5,15 +5,15 @@ const argv = require('minimist')(process.argv.slice(2)) const fs = require('fs') // convert evm bytecode to WASM or WAST -function convert (bytecode, wast) { +function convert (bytecode, opts) { return new Promise((resolve, reject) => { if (!bytecode) { resolve(Buffer.from('')) } - if (wast) { + if (opts.wast) { let output = evm2wasm.evm2wast(bytecode, { - stackTrace: trace, + stackTrace: opts.trace, tempName: 'temp', inlineOps: true, wabt: false @@ -21,7 +21,7 @@ function convert (bytecode, wast) { resolve(output) } else { evm2wasm.evm2wasm(bytecode, { - stackTrace: trace, + stackTrace: opts.trace, tempName: 'temp', inlineOps: true, wabt: false @@ -46,28 +46,28 @@ function storeOrPrintResult (output, outputFile) { } } -let outputFile = argv.o ? argv.o : undefined -let wast = argv.wast !== undefined +const outputFile = argv.o ? argv.o : undefined +const wast = argv.wast !== undefined const trace = argv.trace !== undefined -let file = argv.e ? argv.e : undefined +const inputFile = argv.e ? argv.e : undefined let bytecode try { - if (!file) { + if (!inputFile) { if (argv._.length > 0) { bytecode = argv._[0] } else { throw new Error('must provide evm bytecode file or supply bytecode as a non-named argument') } } else { - bytecode = fs.readFileSync(file).toString() + bytecode = fs.readFileSync(inputFile).toString() } // always consider input EVM as a hex string and translate that into binary for the next stage bytecode = Buffer.from(bytecode, 'hex') - convert(bytecode, wast).then((result) => { + convert(bytecode, { wast: wast, trace: trace }).then((result) => { storeOrPrintResult(result, outputFile) }).catch((err) => { throw err From a1caeb0912fc5c7b9276aee962a1634836fb72c2 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 26 Mar 2018 23:26:52 +0100 Subject: [PATCH 3/8] Fix travis for evm2wasm.js --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 626308cf..7697bab5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ before_install: script: - | if [ $LANG = js ]; then - bin/evm2wasm.js 0x600160020200 trace + ./bin/evm2wasm.js 600160020200 --trace npm run $TEST_SUITE fi From 303b320b7f82f00c8b7fc79956c75abacf659735 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 26 Mar 2018 23:32:19 +0100 Subject: [PATCH 4/8] Fix resolve in convert to stop execution --- bin/evm2wasm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/evm2wasm.js b/bin/evm2wasm.js index 5b403f9c..d7a5a26f 100755 --- a/bin/evm2wasm.js +++ b/bin/evm2wasm.js @@ -8,7 +8,7 @@ const fs = require('fs') function convert (bytecode, opts) { return new Promise((resolve, reject) => { if (!bytecode) { - resolve(Buffer.from('')) + return resolve(Buffer.from('')) } if (opts.wast) { From f8bdaa2bb38ce057fa50b73102ab80ff3c0672be Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 27 Mar 2018 01:21:30 +0000 Subject: [PATCH 5/8] Always use `set -e` in circleci This should be the default, but go figure --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7697bab5..71d5fc18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,8 +35,9 @@ matrix: - LANG=cpp before_install: - - git submodule update --init - | + set -e + git submodule update --init if [ $LANG = js ]; then ./tools/wabt/scripts/travis-before-install.sh cd ./tools/wabt/ && make @@ -47,12 +48,12 @@ before_install: script: - | + set -e if [ $LANG = js ]; then ./bin/evm2wasm.js 600160020200 --trace npm run $TEST_SUITE fi - - | if [ $LANG = cpp ]; then mkdir build && cd build cmake .. From 742bdf61b5e12928e7e619bb946b83c9d9dd45a3 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 27 Mar 2018 03:04:18 +0100 Subject: [PATCH 6/8] Run wabt build in a subshell on circleci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 71d5fc18..8c503e72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ before_install: git submodule update --init if [ $LANG = js ]; then ./tools/wabt/scripts/travis-before-install.sh - cd ./tools/wabt/ && make + (cd ./tools/wabt/ && make) npm install npm run validateBuild From 74e10569fdbcebca28e28f53379c1fa41a5ac585 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 27 Mar 2018 02:31:41 +0000 Subject: [PATCH 7/8] Install eslint as dependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 865daa1d..39ee6bdf 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "transcompiler" ], "dependencies": { + "eslint": "^4.19.1", "ethereumjs-block": "^1.2.2", "ethereumjs-util": "^5.1.5", "ewasm-kernel": "git+https://github.com/ewasm/ewasm-kernel.git#async-pojo", From e81136ae2f98997eabdfd334c4f6f82475bf9615 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 27 Mar 2018 10:48:39 +0100 Subject: [PATCH 8/8] Ensure that arguments to evm2wasm.js are treated as string --- bin/evm2wasm.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/evm2wasm.js b/bin/evm2wasm.js index d7a5a26f..80c1a756 100755 --- a/bin/evm2wasm.js +++ b/bin/evm2wasm.js @@ -56,7 +56,8 @@ let bytecode try { if (!inputFile) { if (argv._.length > 0) { - bytecode = argv._[0] + // ensure it is a string even it was passed as a number + bytecode = argv._[0].toString() } else { throw new Error('must provide evm bytecode file or supply bytecode as a non-named argument') }