├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── benchmark_results_data ├── cpuinfo.txt ├── evm_benchmarks.csv ├── geth_precompile_benchmarks.csv ├── native_benchmarks.csv ├── parity_precompile_benchmarks.csv ├── scout_bignum_benchmarks.csv └── standalone_wasm_results.csv ├── charts └── generate-charts.py ├── circle.yml ├── evm ├── cita-vm │ └── Dockerfile ├── evmone-evm384 │ └── Dockerfile ├── evmone │ └── Dockerfile ├── evmraceresults │ ├── evm_benchmarks.csv │ ├── evm_benchmarks_cita-vm.csv │ ├── evm_benchmarks_evmone.csv │ ├── evm_benchmarks_geth.csv │ ├── evm_benchmarks_parity.csv │ ├── geth_precompile_benchmarks.csv │ └── parity_precompile_benchmarks.csv ├── geth │ └── Dockerfile ├── input_data │ ├── evmcode │ │ ├── blake2b.hex │ │ ├── blake2b.sol │ │ ├── blake2b_huff.hex │ │ ├── blake2b_huff.huff │ │ ├── blake2b_shift.hex │ │ ├── blake2b_shift.sol │ │ ├── bn128_mul_weierstrudel.hex │ │ ├── bn128_mul_weierstrudel.sol │ │ ├── bn256g2mul.hex │ │ ├── bn256g2mul.sol │ │ ├── mul256.hex │ │ ├── mul256.sol │ │ ├── sha1.hex │ │ ├── sha1.sol │ │ ├── sha1_shift.hex │ │ └── sha1_shift.sol │ └── input_vectors │ │ ├── blake2b-inputs.json │ │ ├── blake2b_huff-inputs.json │ │ ├── bn128_mul_weierstrudel-inputs.json │ │ ├── bn256g2mul-inputs.json │ │ ├── mul256-inputs.json │ │ └── sha1-inputs.json ├── parity │ └── Dockerfile └── scripts │ ├── bench_evm384.py │ ├── benchevm.py │ ├── benchgethprecompiles.py │ ├── benchparityprecompiles.py │ ├── merge.py │ ├── nanodurationpy.py │ └── run_bench.sh ├── images ├── bignums-bls12-pairings-fizzy-vs-wabt-exec-startup-time.png ├── bignums-bls12-pairings-host-func-variations-exec-startup-time.png ├── bignums-bls12-pairings-host-func-variations-total-time.png ├── bignums-bls12-pairings-rust-vs-wasm-exec-startup-time.png ├── bignums-bls12-pairings-rust-vs-wasm-total-time.png ├── bignums-bls12-pairings-wabt-vs-native-exec-startup-time.png ├── bignums-bls12-synth-loop-fizzy-vs-wabt-exec-startup-time.png ├── bignums-rollup-rs-bn128-pairings-all-combos.png ├── bignums-rollup-rs-bn128-pairings-superops.png ├── bignums-rollup-rs-bn128-pairings-wabt-with-bignums.png ├── bignums-rollup-rs-bn128-pairings-with-vs-without-bignums.png ├── bignums-websnark-bn128-pairings-fasthost.png ├── bignums-websnark-bn128-pairings-fastmont.png ├── bignums-websnark-bn128-pairings-startup-and-execution.png ├── bignums-websnark-bn128-pairings-superops.png ├── bignums-websnark-bn128-pairings-v8-with-bignums.png ├── bignums-zkrollup-rust-vs-websnark-bn128-pairings.png ├── evm-vs-wasm-blake2b-huff-rust.png ├── evm-vs-wasm-blake2b-huff-sol-rust.png ├── evm-vs-wasm-blake2b-sol-huff.png ├── evm-vs-wasm-blake2b-sol-rust.png ├── evm-vs-wasm-bn128mul-huff-rust.png ├── evm-vs-wasm-mul256-sol-rust.png ├── evm384-bls12-pairings-synth-loop-rust-wasm.png ├── evm384-bls12-synth-loop-vs-native-rust.png ├── evm384-bls12-synth-loop-vs-pairings.png ├── evm384-bls12-synth-loop-wasm.png ├── evm384-synth-loop-v1-v2-v3.png ├── evm384-wasm-native-pairings-and-synth-loop.png ├── evm384-wasm-native-pairings-vs-adjusted-synth-loop.png ├── evm384-wasm-pairings-vs-synth-loop.png ├── scout-biturbo-token-all-engines.png ├── scout-biturbo-token-compilers-vs-interpreters.png ├── scout-daiquiri-all-engines.png ├── scout-daiquiri-v8-vs-wabt.png ├── scout-ecpairing-zkrollup-rust-wasm-bn128-two-pairings-all-engines.png ├── scout-ecpairing-zkrollup-rust-wasm-bn128-two-pairings-v8.png ├── scout-ecpairing-zkrollup-websnark-bn128-two-pairings-all-engines.png ├── scout-ecpairing-zkrollup-websnark-bn128-two-pairings-v8.png ├── scout-ecrecover-websnark-secp256k1-verify-72-sigs-all-engines.png ├── scout-ecrecover-websnark-secp256k1-verify-72-sigs-wabt-vs-v8.png ├── standalone-blake2b-8415-bytes-compilers.png ├── standalone-bls12-381-aggreg-128-pubkeys-verify-sig-compilers-vs-native.png ├── standalone-jitbomb-guido-fuzzer-find-1-log-scale.png ├── standalone-jitbomb-guido-fuzzer-find-1.png ├── standalone-jitbomb-guido-fuzzer-find-2-log-scale.png ├── standalone-rust-bn128-pairings-compiler-vs-native.png ├── standalone-wabt-all-precompiles.png ├── standalone-wabt-vs-v8-liftoff-speedup.png ├── standalone-wasm-interp-bn128-pairings.png ├── standalone-wasmi-all-precompiles.png ├── wasm-interp-blake2b-exec.png ├── wasm-interp-blake2b-fast.png ├── wasm-interp-blake2b-life-wagon-v8.png ├── wasm-interp-blake2b.png ├── wasm-interp-bls12.png ├── wasm-interp-bn128-add.png ├── wasm-interp-modexp.png ├── websnark-vs-native-bn128-two-pairings-v8.png ├── websnark-vs-rust-wasm-native-zkrollup-bn128-pairings.png └── websnark-vs-rust-wasm-zkrollup-bn128-pairings.png ├── requirements.txt ├── scout-engines ├── Dockerfile ├── nanodurationpy.py ├── run_benchmarks.sh └── scout_bignum_bench.py └── wasm-engines ├── bench_wasm_and_native.sh ├── benchmeteredstandalone.sh ├── benchnativerust_prepwasm.py ├── build_engines.sh ├── docker ├── asmble.Dockerfile ├── bench-build-base.Dockerfile ├── fizzy.Dockerfile ├── life.Dockerfile ├── llvm-10.Dockerfile ├── ssvm.Dockerfile ├── vanilla-wabt.Dockerfile ├── wabt.Dockerfile ├── wagon.Dockerfile ├── wamr.Dockerfile ├── wasm-engines-bench.Dockerfile ├── wasm3.Dockerfile ├── wasmi.Dockerfile ├── wasmtime.Dockerfile └── wavm.Dockerfile ├── fizzy.sh ├── fluence_bencher ├── VMDescriptor.py ├── WasmVMBencher.py ├── __init__.py └── settings.py ├── inputvectors ├── blake2b-inputs.json ├── bls12-381-inputs.json ├── bn128_add-inputs.json ├── bn128_mul-inputs.json ├── bn128_pairing-inputs.json ├── ecrecover-inputs.json ├── ed25519-inputs.json ├── keccak256-inputs.json ├── modexp-inputs.json ├── mul256-inputs.json ├── sha1-inputs.json └── sha256-inputs.json ├── main.py ├── nanodurationpy.py ├── node-timer.js ├── run_benchmarks.sh ├── rust-code ├── .cargo │ └── config ├── blake2b │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── bls12-381 │ ├── Cargo.toml │ ├── crate-override │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── bn128_add │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── bn128_mul │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── bn128_pairing │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── ed25519 │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── modexp │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs ├── mul256 │ ├── Cargo.toml │ └── src │ │ ├── bench.rs │ │ ├── lib.rs │ │ └── main.rs └── sha1 │ ├── Cargo.toml │ └── src │ ├── bench.rs │ ├── lib.rs │ └── main.rs ├── wamr_aot.sh └── wasmfiles ├── blake2b-2805-bytes.wasm ├── blake2b-5610-bytes.wasm ├── blake2b-8415-bytes.wasm ├── ecpairing.wasm ├── guido-fuzzer-find-1.wasm ├── guido-fuzzer-find-2-norotates.wasm └── guido-fuzzer-find-2.wasm /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/Cargo.lock 3 | .ipynb_checkpoints 4 | **/__pycache__ 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build_docker_images benchmark generate_charts 2 | 3 | build_evm_engines: 4 | cd evm/geth && docker build . -t ewasm/geth-bench:1 5 | cd evm/parity && docker build . -t ewasm/parity-bench:1 6 | cd evm/evmone && docker build . -t ewasm/evmone-bench:1 7 | cd evm/cita-vm && docker build . -t ewasm/cita-vm-bench:1 8 | cd evm/evmone-evm384 && docker build . -t ewasm/evmone-evm384-bench:1 9 | 10 | build_wasm_engines: 11 | cd wasm-engines && ./build_engines.sh 12 | 13 | build_scout_engines: 14 | cd scout-engines && docker build . -t ewasm/scout-engines:1 15 | 16 | build_docker_images: build_evm_engines build_wasm_engines build_scout_engines 17 | 18 | benchmark_evm_engines: 19 | cd evm && \ 20 | ./scripts/run_bench.sh 21 | 22 | benchmark_scout_engines: 23 | cd scout-engines && \ 24 | ./run_benchmarks.sh && \ 25 | cp benchmarks_results_data/scout_bignum_benchmarks.csv ../benchmark_results_data/ 26 | 27 | benchmark_wasm_engines: 28 | cd wasm-engines && \ 29 | ./run_benchmarks.sh && \ 30 | cp benchmark_results_data/standalone_wasm_results.csv ../benchmark_results_data/ && \ 31 | cp benchmark_results/data/native_results.csv ../benchmark_results_data/ 32 | 33 | benchmark: benchmark_scout_engines benchmark_wasm_engines benchmark_evm_engines benchmark_evm_precompiles 34 | 35 | generate_charts: 36 | cd charts && \ 37 | python3 generate-charts.py 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | This repository contains instructions for benchmarking evm implementations, ewasm contracts and standalone wasm modules. Directory descriptions follow. 4 | 5 | ``` 6 | evm/ - contains benchmarks for different evm implementations (geth, parity, cita-vm, evmone) 7 | ewasm/ - contains benchmarks and tests for ewasm contracts in ewasm engines. 8 | wasm/ - contains benchmarks for wasm modules in standalone wasm engines. 9 | wasm-engines/ - contains benchmarks for wasm modules comparing wasm engines. 10 | ``` 11 | 12 | ## EVM 13 | 14 | Directory `/evm` contains a list of the current benchmarked evm implementations: 15 | 16 | ``` 17 | evm/ 18 | cita-vm/ 19 | evmone/ 20 | geth/ 21 | parity/ 22 | ``` 23 | 24 | Build each one of the evm implementations: 25 | 26 | ```shell 27 | $ make build_evm_engines 28 | ``` 29 | 30 | Run EVM benchmarks: 31 | 32 | ```shell 33 | $ make benchmark_evm_engines 34 | ``` 35 | 36 | The previous command will create a new directory `evmraceresults`, containing the following files: 37 | 38 | ``` 39 | evm_benchmarks.csv - consolidated benchmarks 40 | evm_benchmarks_evmone.csv - evmone benchmarks 41 | evm_benchmarks_parity.csv - parity benchmarks 42 | evm_benchmarks_geth.csv - geth benchmarks 43 | evm_benchmarks_cita-vm.csv - cita vm benchmarks 44 | ``` 45 | 46 | Run precompiles benchmarks: 47 | 48 | - Geth: 49 | 50 | ```shell 51 | $ cd evm 52 | $ ./scripts/run_precompiles_bench.py geth 53 | ``` 54 | 55 | - Parity 56 | ```shell 57 | $ cd evm 58 | $ ./scripts/run_precompiles_bench.py parity 59 | ``` 60 | 61 | ### Wasm Engines Benchmarks 62 | 63 | Build the docker image: 64 | 65 | ```shell 66 | $ make build_wasm_engines 67 | ``` 68 | 69 | Build the wasm binaries and execute benchmarks: 70 | 71 | ```shell 72 | $ cd wasm-engines && ./run_benchmarks.sh 73 | ``` 74 | 75 | ### Scout Benchmarks 76 | 77 | Build the docker image: 78 | 79 | ```shell 80 | $ make build_scout_engines 81 | ``` 82 | 83 | Run benchmarks 84 | 85 | ```shell 86 | make benchmark_scout_engines 87 | ``` 88 | 89 | ## Generate charts 90 | 91 | Install python deps for plotting benchmark graphs: 92 | 93 | ```shell 94 | $ pip install -r requirements.txt 95 | $ make generate_charts 96 | ``` 97 | 98 | ## EVM engine versions 99 | 100 | - cita-vm: v0.1.3 (May 2019) 101 | - evmone: v0.5.0 (Jun 2020) 102 | - geth: v1.9.14 (+ go 1.11) (May 2020) 103 | - parity/openethereum: v2.5.1 (May 2019) 104 | 105 | ## WebAssembly engine versions 106 | 107 | - asmble: v0.4.2-fl (+ openjdk-8-jre) (Oct 2018) 108 | - fizzy: v0.3.0 (Jul 2020) 109 | - life: d05763d1 (Feb 2019) 110 | - ssvm: v0.6.0 (Jun 2020) 111 | - v8 (node.js): v12.18.2 (Jun 2020) 112 | - modified/optimised wabt: 04fe0c41 (closest to v1.0.9) (Mar 2019) 113 | - "vanilla" wabt: v1.0.17 (Jun 2020) 114 | - wagon: v0.4.0 (Mar 2019) 115 | - wamr: WAMR-02-18-2020 (Feb 2020) 116 | - wasm3: v0.4.7 (Apr 2020) 117 | - wasmi: v0.4.4 (Mar 2019) 118 | - wasmtime: fb7c1b77 (closest to v0.31.0) (Feb 2019) 119 | - wavm: d3607084 (closest to nightly-2019-08-28) (Aug 2019) 120 | -------------------------------------------------------------------------------- /benchmark_results_data/cpuinfo.txt: -------------------------------------------------------------------------------- 1 | model name : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 2 | cpu MHz : 700.093 3 | model name : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 4 | cpu MHz : 700.037 5 | model name : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 6 | cpu MHz : 700.055 7 | model name : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 8 | cpu MHz : 700.125 9 | -------------------------------------------------------------------------------- /benchmark_results_data/evm_benchmarks.csv: -------------------------------------------------------------------------------- 1 | engine, test_name, total_time, gas_used 2 | engine,test_name,total_time,gas_used 3 | evmone,sha1-10808-bits-shiftopt,0.000793345,759785 4 | evmone,sha1-21896-bits-shiftopt,0.001545941,1484254 5 | evmone,sha1-42488-bits-shiftopt,0.002976448,2898473 6 | evmone,bn256g2mul-0xAshish,0.001172171,455757 7 | evmone,blake2b-8415-bytes-shiftopt,0.01365291,12043105 8 | evmone,blake2b-5610-bytes-shiftopt,0.0089686,7434820 9 | evmone,blake2b-2805-bytes-shiftopt,0.004342448,3423526 10 | evmone,mul256-gcolvin-drag-race,0.007159219,5610277 11 | evmone,bn128_mul_weierstrudel-cdetrio2,0.000328392,47165 12 | evmone,bn128_mul_weierstrudel-chfast1,0.000172408,23449 13 | evmone,bn128_mul_weierstrudel-chfast2,0.000280519,39337 14 | evmone,bn128_mul_weierstrudel-chfast3,0.000332211,47291 15 | evmone,bn128_mul_weierstrudel-cdetrio6,0.000327677,47561 16 | evmone,bn128_mul_weierstrudel-cdetrio7,0.000333883,47165 17 | evmone,bn128_mul_weierstrudel-cdetrio11,0.000333957,47561 18 | evmone,bn128_mul_weierstrudel-cdetrio12,0.000329381,47165 19 | evmone,blake2b_huff-8415-bytes,0.001049435,879920 20 | evmone,blake2b_huff-5610-bytes,0.000702116,586839 21 | evmone,blake2b_huff-2805-bytes,0.000379592,293755 22 | evmone,blake2b-8415-bytes,0.016695173,12351815 23 | evmone,blake2b-5610-bytes,0.011085657,7640669 24 | evmone,blake2b-2805-bytes,0.005462505,3526514 25 | evmone,sha1-10808-bits,0.001527905,790156 26 | evmone,sha1-21896-bits,0.003110602,1543605 27 | evmone,sha1-42488-bits,0.005649394,3014404 28 | engine,test_name,total_time,gas_used 29 | parity-evm,sha1-10808-bits-shiftopt,0.018641107,759785 30 | parity-evm,sha1-21896-bits-shiftopt,0.034963908,1484254 31 | parity-evm,sha1-42488-bits-shiftopt,0.069549043,2898473 32 | parity-evm,bn256g2mul-0xAshish,0.016423093,455757 33 | parity-evm,blake2b-8415-bytes-shiftopt,0.253661906,12043105 34 | parity-evm,blake2b-5610-bytes-shiftopt,0.167942964,7434820 35 | parity-evm,blake2b-2805-bytes-shiftopt,0.075225324,3423526 36 | parity-evm,mul256-gcolvin-drag-race,0.102674566,5610277 37 | parity-evm,bn128_mul_weierstrudel-cdetrio2,0.003550443,47165 38 | parity-evm,bn128_mul_weierstrudel-chfast1,0.001629055,23449 39 | parity-evm,bn128_mul_weierstrudel-chfast2,0.002895177,39337 40 | parity-evm,bn128_mul_weierstrudel-chfast3,0.003433942,47291 41 | parity-evm,bn128_mul_weierstrudel-cdetrio6,0.003911592,47561 42 | parity-evm,bn128_mul_weierstrudel-cdetrio7,0.004013359,47165 43 | parity-evm,bn128_mul_weierstrudel-cdetrio11,0.003586314,47561 44 | parity-evm,bn128_mul_weierstrudel-cdetrio12,0.003398176,47165 45 | parity-evm,blake2b_huff-8415-bytes,0.020829242,879920 46 | parity-evm,blake2b_huff-5610-bytes,0.013631459,586839 47 | parity-evm,blake2b_huff-2805-bytes,0.007137712,293755 48 | parity-evm,blake2b-8415-bytes,0.254601369,12351815 49 | parity-evm,blake2b-5610-bytes,0.183427886,7640669 50 | parity-evm,blake2b-2805-bytes,0.084697691,3526514 51 | parity-evm,sha1-10808-bits,0.051473938,790156 52 | parity-evm,sha1-21896-bits,0.098100583,1543605 53 | parity-evm,sha1-42488-bits,0.186598441,3014404 54 | engine,test_name,total_time,gas_used 55 | geth-evm,sha1-10808-bits-shiftopt,0.01092,759785 56 | geth-evm,sha1-21896-bits-shiftopt,0.021413,1484254 57 | geth-evm,sha1-42488-bits-shiftopt,0.041112,2898473 58 | geth-evm,bn256g2mul-0xAshish,0.007847,455757 59 | geth-evm,blake2b-8415-bytes-shiftopt,0.122643,12043105 60 | geth-evm,blake2b-5610-bytes-shiftopt,0.083966,7434820 61 | geth-evm,blake2b-2805-bytes-shiftopt,0.042208,3423526 62 | geth-evm,mul256-gcolvin-drag-race,0.125658,5610277 63 | geth-evm,bn128_mul_weierstrudel-cdetrio2,0.001712,47165 64 | geth-evm,bn128_mul_weierstrudel-chfast1,0.000809,23449 65 | geth-evm,bn128_mul_weierstrudel-chfast2,0.001332,39337 66 | geth-evm,bn128_mul_weierstrudel-chfast3,0.001577,47291 67 | geth-evm,bn128_mul_weierstrudel-cdetrio6,0.001578,47561 68 | geth-evm,bn128_mul_weierstrudel-cdetrio7,0.001611,47165 69 | geth-evm,bn128_mul_weierstrudel-cdetrio11,0.001589,47561 70 | geth-evm,bn128_mul_weierstrudel-cdetrio12,0.001534,47165 71 | geth-evm,blake2b_huff-8415-bytes,0.01598,879920 72 | geth-evm,blake2b_huff-5610-bytes,0.010693,586839 73 | geth-evm,blake2b_huff-2805-bytes,0.00528,293755 74 | geth-evm,blake2b-8415-bytes,0.138907,12351815 75 | geth-evm,blake2b-5610-bytes,0.089215,7640669 76 | geth-evm,blake2b-2805-bytes,0.04446,3526514 77 | geth-evm,sha1-10808-bits,0.012774,790156 78 | geth-evm,sha1-21896-bits,0.02663,1543605 79 | geth-evm,sha1-42488-bits,0.050663,3014404 80 | engine,test_name,total_time,gas_used 81 | cita-evm,sha1-10808-bits-shiftopt,0.010150599,873117 82 | cita-evm,sha1-21896-bits-shiftopt,0.02101219,1691062 83 | cita-evm,sha1-42488-bits-shiftopt,0.0409114,3280257 84 | cita-evm,bn256g2mul-0xAshish,0.038344502,486053 85 | cita-evm,blake2b-8415-bytes-shiftopt,0.19389169,12635513 86 | cita-evm,blake2b-5610-bytes-shiftopt,0.133938707,7837276 87 | cita-evm,blake2b-2805-bytes-shiftopt,0.063182734,3635902 88 | cita-evm,mul256-gcolvin-drag-race,0.038346168,5635901 89 | cita-evm,bn128_mul_weierstrudel-cdetrio2,0.014218677,74437 90 | cita-evm,bn128_mul_weierstrudel-chfast1,0.006561293,49441 91 | cita-evm,bn128_mul_weierstrudel-chfast2,0.012221963,66865 92 | cita-evm,bn128_mul_weierstrudel-chfast3,0.014412372,74819 93 | cita-evm,bn128_mul_weierstrudel-cdetrio6,0.014749287,75089 94 | cita-evm,bn128_mul_weierstrudel-cdetrio7,0.014841591,74501 95 | cita-evm,bn128_mul_weierstrudel-cdetrio11,0.015013243,75089 96 | cita-evm,bn128_mul_weierstrudel-cdetrio12,0.01447287,74501 97 | cita-evm,blake2b_huff-8415-bytes,0.012121245,1471220 98 | cita-evm,blake2b_huff-5610-bytes,0.008219742,988103 99 | cita-evm,blake2b_huff-2805-bytes,0.004319099,504983 100 | cita-evm,blake2b-8415-bytes,0.23522132,12944223 101 | cita-evm,blake2b-5610-bytes,0.156721206,8043125 102 | cita-evm,blake2b-2805-bytes,0.078461201,3738890 103 | cita-evm,sha1-10808-bits,0.043154085,903488 104 | cita-evm,sha1-21896-bits,0.084976683,1750413 105 | cita-evm,sha1-42488-bits,0.166074513,3396188 106 | engine,test_name,total_time,gas_used 107 | evmone384,evm384-synth-loop-v1,0.020664,12569235 108 | evmone384,evm384-synth-loop-v2,0.013845,5851179 109 | evmone384,evm384-synth-loop-v3,0.010952,5534906 110 | -------------------------------------------------------------------------------- /benchmark_results_data/geth_precompile_benchmarks.csv: -------------------------------------------------------------------------------- 1 | test_name,gas,time 2 | PrecompiledEcrecover/,3000,0.000200384 3 | PrecompiledSha256/128,108,7.81e-07 4 | PrecompiledRipeMD/128,1080,1.849e-06 5 | PrecompiledIdentity/128,27,2.2e-08 6 | PrecompiledModExp/eip_example1,13056,4.4222e-05 7 | PrecompiledModExp/eip_example2,13056,8.827e-06 8 | PrecompiledModExp/nagydani-1-square,204,2.32e-06 9 | PrecompiledModExp/nagydani-1-qube,204,3.123e-06 10 | PrecompiledModExp/nagydani-1-pow0x10001,3276,1.7161e-05 11 | PrecompiledModExp/nagydani-2-square,665,3.838e-06 12 | PrecompiledModExp/nagydani-2-qube,665,5.932e-06 13 | PrecompiledModExp/nagydani-2-pow0x10001,10649,3.5287e-05 14 | PrecompiledModExp/nagydani-3-square,1894,7.22e-06 15 | PrecompiledModExp/nagydani-3-qube,1894,1.2765e-05 16 | PrecompiledModExp/nagydani-3-pow0x10001,30310,8.4558e-05 17 | PrecompiledModExp/nagydani-4-square,5580,1.6841e-05 18 | PrecompiledModExp/nagydani-4-qube,5580,3.6225e-05 19 | PrecompiledModExp/nagydani-4-pow0x10001,89292,0.000240298 20 | PrecompiledModExp/nagydani-5-square,17868,4.8404e-05 21 | PrecompiledModExp/nagydani-5-qube,17868,0.000106421 22 | PrecompiledModExp/nagydani-5-pow0x10001,285900,0.000737485 23 | PrecompiledBn256Add/chfast1,150,1.6961e-05 24 | PrecompiledBn256Add/chfast2,150,1.6861e-05 25 | PrecompiledBn256Add/cdetrio1,150,1.229e-06 26 | PrecompiledBn256Add/cdetrio2,150,1.271e-06 27 | PrecompiledBn256Add/cdetrio3,150,1.28e-06 28 | PrecompiledBn256Add/cdetrio4,150,1.293e-06 29 | PrecompiledBn256Add/cdetrio5,150,1.225e-06 30 | PrecompiledBn256Add/cdetrio6,150,1.601e-06 31 | PrecompiledBn256Add/cdetrio7,150,1.603e-06 32 | PrecompiledBn256Add/cdetrio8,150,1.645e-06 33 | PrecompiledBn256Add/cdetrio9,150,1.6e-06 34 | PrecompiledBn256Add/cdetrio10,150,1.597e-06 35 | PrecompiledBn256Add/cdetrio11,150,1.6847e-05 36 | PrecompiledBn256Add/cdetrio12,150,1.6846e-05 37 | PrecompiledBn256Add/cdetrio13,150,1.6962e-05 38 | PrecompiledBn256Add/cdetrio14,150,2.449e-06 39 | PrecompiledBn256ScalarMul/chfast1,6000,0.000116761 40 | PrecompiledBn256ScalarMul/chfast2,6000,0.000126191 41 | PrecompiledBn256ScalarMul/chfast3,6000,0.000121596 42 | PrecompiledBn256ScalarMul/cdetrio1,6000,0.000129348 43 | PrecompiledBn256ScalarMul/cdetrio6,6000,0.000129531 44 | PrecompiledBn256ScalarMul/cdetrio11,6000,0.000129713 45 | PrecompiledBn256Pairing/jeff1,113000,0.003976009 46 | PrecompiledBn256Pairing/jeff2,113000,0.003986492 47 | PrecompiledBn256Pairing/jeff3,113000,0.003978427 48 | PrecompiledBn256Pairing/jeff4,147000,0.005381218 49 | PrecompiledBn256Pairing/jeff5,147000,0.005373975 50 | PrecompiledBn256Pairing/jeff6,113000,0.00400313 51 | PrecompiledBn256Pairing/empty_data,45000,0.001284861 52 | PrecompiledBn256Pairing/one_point,79000,0.002618891 53 | PrecompiledBn256Pairing/two_point_match_2,113000,0.003997496 54 | PrecompiledBn256Pairing/two_point_match_3,113000,0.003990785 55 | PrecompiledBn256Pairing/two_point_match_4,113000,0.004017242 56 | PrecompiledBn256Pairing/ten_point_match_1,385000,0.014724648 57 | PrecompiledBn256Pairing/ten_point_match_2,385000,0.014672495 58 | PrecompiledBn256Pairing/ten_point_match_3,113000,0.004083614 59 | PrecompiledBn256Pairing/two_point_match_rollup_input,113000,0.00399292 60 | PrecompiledBlake2F/vector_4,0,1.49e-07 61 | PrecompiledBlake2F/vector_5,12,2.96e-07 62 | PrecompiledBlake2F/vector_6,12,3.03e-07 63 | PrecompiledBlake2F/vector_7,1,1.57e-07 64 | PrecompiledBlake2F/vector_8,8000000,0.095992815 65 | -------------------------------------------------------------------------------- /benchmark_results_data/parity_precompile_benchmarks.csv: -------------------------------------------------------------------------------- 1 | test_name,gas,time 2 | ecrecover,0,0.00015013 3 | sha256,0,7.25e-07 4 | ripemd,0,9.74e-07 5 | identity,0,1.53e-07 6 | modexp_eip_example1,0,0.00054534 7 | modexp_eip_example2,0,3.12e-07 8 | modexp_nagydani_1_square,0,5.706e-06 9 | modexp_nagydani_1_qube,0,1.0016e-05 10 | modexp_nagydani_1_pow0x10001,0,6.7877e-05 11 | modexp_nagydani_2_square,0,1.1177e-05 12 | modexp_nagydani_2_qube,0,1.9979e-05 13 | modexp_nagydani_2_pow0x10001,0,0.00015054 14 | modexp_nagydani_3_square,0,2.6989e-05 15 | modexp_nagydani_3_qube,0,5.0913e-05 16 | modexp_nagydani_3_pow0x10001,0,0.00040831 17 | modexp_nagydani_4_square,0,7.7673e-05 18 | modexp_nagydani_4_qube,0,0.00014908 19 | modexp_nagydani_4_pow0x10001,0,0.0012234 20 | modexp_nagydani_5_square,0,0.00025164 21 | modexp_nagydani_5_qube,0,0.00049946 22 | modexp_nagydani_5_pow0x10001,0,0.0041383 23 | alt_bn128_add_chfast1,0,8.987e-06 24 | alt_bn128_add_chfast2,0,9.357e-06 25 | alt_bn128_add_cdetrio1,0,2.82e-07 26 | alt_bn128_add_cdetrio2,0,2.89e-07 27 | alt_bn128_add_cdetrio3,0,2.97e-07 28 | alt_bn128_add_cdetrio4,0,2.89e-07 29 | alt_bn128_add_cdetrio5,0,2.82e-07 30 | alt_bn128_add_cdetrio6,0,7.42e-07 31 | alt_bn128_add_cdetrio7,0,7.5e-07 32 | alt_bn128_add_cdetrio8,0,7.5e-07 33 | alt_bn128_add_cdetrio9,0,7.39e-07 34 | alt_bn128_add_cdetrio10,0,7.41e-07 35 | alt_bn128_add_cdetrio11,0,1.1131e-05 36 | alt_bn128_add_cdetrio12,0,1.1138e-05 37 | alt_bn128_add_cdetrio13,0,9.094e-06 38 | alt_bn128_add_cdetrio14,0,1.754e-06 39 | alt_bn128_mul_chfast1,0,7.2523e-05 40 | alt_bn128_mul_chfast2,0,0.00016211 41 | alt_bn128_mul_chfast3,0,0.00028644 42 | alt_bn128_mul_cdetrio1,0,0.00031897 43 | alt_bn128_mul_cdetrio6,0,0.00032078 44 | alt_bn128_mul_cdetrio11,0,0.00031935 45 | alt_bn128_pairing_jeff1,0,0.0095591 46 | alt_bn128_pairing_jeff2,0,0.0095191 47 | alt_bn128_pairing_jeff3,0,0.009539 48 | alt_bn128_pairing_jeff4,0,0.014247 49 | alt_bn128_pairing_jeff5,0,0.014241 50 | alt_bn128_pairing_jeff6,0,0.0094086 51 | alt_bn128_pairing_empty_data,0,4.6e-08 52 | alt_bn128_pairing_one_point,0,0.004737 53 | alt_bn128_pairing_two_point_match_2,0,0.0094152 54 | alt_bn128_pairing_two_point_match_3,0,0.0094791 55 | alt_bn128_pairing_two_point_match_4,0,0.0095071 56 | alt_bn128_pairing_ten_point_match_1,0,0.047233 57 | alt_bn128_pairing_ten_point_match_2,0,0.047514 58 | alt_bn128_pairing_ten_point_match_3,0,0.009523 59 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | charts: 5 | docker: 6 | - image: circleci/python:3.8.2 7 | 8 | jobs: 9 | rebuild-charts: 10 | executor: charts 11 | steps: 12 | - checkout 13 | - run: 14 | name: Install dependencies 15 | command: | 16 | sudo pip3 install -r requirements.txt 17 | - run: 18 | name: Rebuild notebook 19 | command: | 20 | rm -rf images/* 21 | make generate_charts 22 | # Ensures the generated images are matching 23 | git diff --color --exit-code 24 | 25 | workflows: 26 | version: 2 27 | 28 | charts: 29 | jobs: 30 | - rebuild-charts 31 | -------------------------------------------------------------------------------- /evm/cita-vm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (cita-vm)" 7 | 8 | RUN pip3 install durationpy jinja2 pandas 9 | 10 | # install cita-vm 11 | RUN git clone --single-branch --branch v0.1.3-benchmarking https://github.com/ewasm-benchmarking/cita-vm 12 | RUN cd cita-vm/evmbin && cargo build --release 13 | -------------------------------------------------------------------------------- /evm/evmone-evm384/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (evmone-evm384)" 7 | 8 | RUN pip3 install durationpy pandas 9 | 10 | # install evmone (need CXXFLAGS=-w or the build fails) 11 | WORKDIR /root 12 | RUN git clone --recursive --single-branch --branch v0.5.0-evm384-v1 https://github.com/ethereum/evmone.git evmone-evm384-v1 13 | RUN cd evmone-evm384-v1 && mkdir build && \ 14 | cd build && CXXFLAGS="-w" cmake .. -DEVMONE_TESTING=ON && make -j4 15 | 16 | RUN git clone --recursive --single-branch --branch v0.5.0-evm384-v2 https://github.com/ethereum/evmone.git evmone-evm384-v2 17 | RUN cd evmone-evm384-v2 && mkdir build && \ 18 | cd build && CXXFLAGS="-w" cmake .. -DEVMONE_TESTING=ON && make -j4 19 | 20 | # evmone branch with mem check disabled 21 | RUN git clone --recursive --single-branch https://github.com/ethereum/evmone -b v0.5.0-evm384-v2-unsafe evmone-evm384-v2-unsafe 22 | RUN cd evmone-evm384-v2-unsafe && mkdir build && \ 23 | cd build && CXXFLAGS="-w" cmake .. -DEVMONE_TESTING=ON && make -j4 24 | 25 | # fetch evm384 f6m_mul synthetic loop repo 26 | RUN git clone --single-branch --branch v0.0.1 https://github.com/ewasm/evm384_f6m_mul.git 27 | 28 | # branch that pre-allocates a page of memory to remain safe (because mem check is disabled) 29 | RUN git clone --single-branch --branch mem-check-disable https://github.com/ewasm/evm384_f6m_mul.git mem-check-disable-evm384_f6m_mul 30 | 31 | WORKDIR / 32 | CMD /bin/bash 33 | -------------------------------------------------------------------------------- /evm/evmone/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (evmone)" 7 | 8 | RUN pip3 install durationpy jinja2 pandas 9 | 10 | # install evmone 11 | WORKDIR /root 12 | RUN git clone --recursive --single-branch --branch v0.5.0 https://github.com/ethereum/evmone 13 | RUN cd evmone && mkdir build 14 | RUN cd evmone/build && cmake .. -DEVMONE_TESTING=ON 15 | RUN cd evmone/build && make -j4 16 | 17 | WORKDIR / 18 | CMD /bin/bash 19 | -------------------------------------------------------------------------------- /evm/evmraceresults/evm_benchmarks.csv: -------------------------------------------------------------------------------- 1 | engine, test_name, total_time, gas_used 2 | evmone,blake2b-8415-bytes-shiftopt,0.054213,1204310 3 | parity-evm,blake2b-8415-bytes-shiftopt,0.316956977,12043105 4 | geth-evm,blake2b-8415-bytes-shiftopt,0.189711069,12043105 5 | cita-evm,blake2b-8415-bytes-shiftopt,0.248893572,12635513 6 | evmone,blake2b-5610-bytes-shiftopt,0.035875,743482 7 | parity-evm,blake2b-5610-bytes-shiftopt,0.20601357,7434820 8 | geth-evm,blake2b-5610-bytes-shiftopt,0.113561772,7434820 9 | cita-evm,blake2b-5610-bytes-shiftopt,0.163724593,7837276 10 | evmone,blake2b-2805-bytes-shiftopt,0.019119,342353 11 | parity-evm,blake2b-2805-bytes-shiftopt,0.116225032,3423526 12 | geth-evm,blake2b-2805-bytes-shiftopt,0.051484922,3423526 13 | cita-evm,blake2b-2805-bytes-shiftopt,0.086552189,3635902 14 | evmone,sha1-10808-bits,0.005104,79015 15 | parity-evm,sha1-10808-bits,0.056514386,790156 16 | geth-evm,sha1-10808-bits,0.017261686,790156 17 | cita-evm,sha1-10808-bits,0.050898555,903488 18 | evmone,sha1-21896-bits,0.009742,154361 19 | parity-evm,sha1-21896-bits,0.11256767,1543605 20 | geth-evm,sha1-21896-bits,0.042415729,1543605 21 | cita-evm,sha1-21896-bits,0.099558211,1750413 22 | evmone,sha1-42488-bits,0.018686,301440 23 | parity-evm,sha1-42488-bits,0.234752859,3014404 24 | geth-evm,sha1-42488-bits,0.080625691,3014404 25 | cita-evm,sha1-42488-bits,0.19651497,3396188 26 | evmone,mul256-gcolvin-drag-race,0.019177,561028 27 | parity-evm,mul256-gcolvin-drag-race,0.138243573,5610277 28 | geth-evm,mul256-gcolvin-drag-race,0.227623711,5610277 29 | cita-evm,mul256-gcolvin-drag-race,0.091606691,5635901 30 | evmone,sha1-10808-bits-shiftopt,0.003893,75978 31 | parity-evm,sha1-10808-bits-shiftopt,0.027183214,759785 32 | geth-evm,sha1-10808-bits-shiftopt,0.015148921,759785 33 | cita-evm,sha1-10808-bits-shiftopt,0.016494862,873117 34 | evmone,sha1-21896-bits-shiftopt,0.007088,148425 35 | parity-evm,sha1-21896-bits-shiftopt,0.049224914,1484254 36 | geth-evm,sha1-21896-bits-shiftopt,0.029567276,1484254 37 | cita-evm,sha1-21896-bits-shiftopt,0.031189288,1691062 38 | evmone,sha1-42488-bits-shiftopt,0.01481,289847 39 | parity-evm,sha1-42488-bits-shiftopt,0.092339599,2898473 40 | geth-evm,sha1-42488-bits-shiftopt,0.056787827,2898473 41 | cita-evm,sha1-42488-bits-shiftopt,0.060134451,3280257 42 | evmone,blake2b-8415-bytes,0.064587,1235180 43 | parity-evm,blake2b-8415-bytes,0.330776013,12351815 44 | geth-evm,blake2b-8415-bytes,0.171602651,12351815 45 | cita-evm,blake2b-8415-bytes,0.300924486,12944223 46 | evmone,blake2b-5610-bytes,0.040648,764067 47 | parity-evm,blake2b-5610-bytes,0.225545786,7640669 48 | geth-evm,blake2b-5610-bytes,0.115226858,7640669 49 | cita-evm,blake2b-5610-bytes,0.202168585,8043125 50 | evmone,blake2b-2805-bytes,0.02082,352651 51 | parity-evm,blake2b-2805-bytes,0.11554926,3526514 52 | geth-evm,blake2b-2805-bytes,0.061277222,3526514 53 | cita-evm,blake2b-2805-bytes,0.09909084,3738890 54 | evmone,bn128_mul_weierstrudel-cdetrio2,0.000583,4716 55 | parity-evm,bn128_mul_weierstrudel-cdetrio2,0.004230255,47165 56 | geth-evm,bn128_mul_weierstrudel-cdetrio2,0.002396169,47165 57 | cita-evm,bn128_mul_weierstrudel-cdetrio2,0.015893918,74437 58 | evmone,bn128_mul_weierstrudel-chfast1,0.000323,2344 59 | parity-evm,bn128_mul_weierstrudel-chfast1,0.001940616,23449 60 | geth-evm,bn128_mul_weierstrudel-chfast1,0.001052022,23449 61 | cita-evm,bn128_mul_weierstrudel-chfast1,0.00683698,49441 62 | evmone,bn128_mul_weierstrudel-chfast2,0.000524,3933 63 | parity-evm,bn128_mul_weierstrudel-chfast2,0.004237918,39337 64 | geth-evm,bn128_mul_weierstrudel-chfast2,0.0015577,39337 65 | cita-evm,bn128_mul_weierstrudel-chfast2,0.012899205,66865 66 | evmone,bn128_mul_weierstrudel-chfast3,0.000575,4729 67 | parity-evm,bn128_mul_weierstrudel-chfast3,0.004908508,47291 68 | geth-evm,bn128_mul_weierstrudel-chfast3,0.001949494,47291 69 | cita-evm,bn128_mul_weierstrudel-chfast3,0.015247729,74819 70 | evmone,bn128_mul_weierstrudel-cdetrio6,0.000563,4756 71 | parity-evm,bn128_mul_weierstrudel-cdetrio6,0.004730309,47561 72 | geth-evm,bn128_mul_weierstrudel-cdetrio6,0.002096795,47561 73 | cita-evm,bn128_mul_weierstrudel-cdetrio6,0.015227745,75089 74 | evmone,bn128_mul_weierstrudel-cdetrio7,0.000565,4716 75 | parity-evm,bn128_mul_weierstrudel-cdetrio7,0.004429321,47165 76 | geth-evm,bn128_mul_weierstrudel-cdetrio7,0.002273449,47165 77 | cita-evm,bn128_mul_weierstrudel-cdetrio7,0.01517853,74501 78 | evmone,bn128_mul_weierstrudel-cdetrio11,0.000573,4756 79 | parity-evm,bn128_mul_weierstrudel-cdetrio11,0.00441621,47561 80 | geth-evm,bn128_mul_weierstrudel-cdetrio11,0.002106279,47561 81 | cita-evm,bn128_mul_weierstrudel-cdetrio11,0.015374415,75089 82 | evmone,bn128_mul_weierstrudel-cdetrio12,0.00055,4716 83 | parity-evm,bn128_mul_weierstrudel-cdetrio12,0.004522368,47165 84 | geth-evm,bn128_mul_weierstrudel-cdetrio12,0.002398648,47165 85 | cita-evm,bn128_mul_weierstrudel-cdetrio12,0.015857303,74501 86 | evmone,bn256g2mul-0xAshish,0.003202,45575 87 | parity-evm,bn256g2mul-0xAshish,0.021008241,455757 88 | geth-evm,bn256g2mul-0xAshish,0.010119752,455757 89 | cita-evm,bn256g2mul-0xAshish,0.044238243,486053 90 | evmone,blake2b_huff-8415-bytes,0.004483,87992 91 | parity-evm,blake2b_huff-8415-bytes,0.029408588,879920 92 | geth-evm,blake2b_huff-8415-bytes,0.019343657,879920 93 | cita-evm,blake2b_huff-8415-bytes,0.02115236,1471220 94 | evmone,blake2b_huff-5610-bytes,0.002793,58683 95 | parity-evm,blake2b_huff-5610-bytes,0.021109934,586839 96 | geth-evm,blake2b_huff-5610-bytes,0.014393628,586839 97 | cita-evm,blake2b_huff-5610-bytes,0.013129701,988103 98 | evmone,blake2b_huff-2805-bytes,0.001571,29375 99 | parity-evm,blake2b_huff-2805-bytes,0.012020942,293755 100 | geth-evm,blake2b_huff-2805-bytes,0.007442814,293755 101 | cita-evm,blake2b_huff-2805-bytes,0.006572538,504983 102 | -------------------------------------------------------------------------------- /evm/evmraceresults/evm_benchmarks_cita-vm.csv: -------------------------------------------------------------------------------- 1 | engine,test_name,total_time,gas_used 2 | cita-evm,blake2b-8415-bytes-shiftopt,0.248893572,12635513 3 | cita-evm,blake2b-5610-bytes-shiftopt,0.163724593,7837276 4 | cita-evm,blake2b-2805-bytes-shiftopt,0.086552189,3635902 5 | cita-evm,sha1-10808-bits,0.050898555,903488 6 | cita-evm,sha1-21896-bits,0.099558211,1750413 7 | cita-evm,sha1-42488-bits,0.19651497,3396188 8 | cita-evm,mul256-gcolvin-drag-race,0.091606691,5635901 9 | cita-evm,sha1-10808-bits-shiftopt,0.016494862,873117 10 | cita-evm,sha1-21896-bits-shiftopt,0.031189288,1691062 11 | cita-evm,sha1-42488-bits-shiftopt,0.060134451,3280257 12 | cita-evm,blake2b-8415-bytes,0.300924486,12944223 13 | cita-evm,blake2b-5610-bytes,0.202168585,8043125 14 | cita-evm,blake2b-2805-bytes,0.09909084,3738890 15 | cita-evm,bn128_mul_weierstrudel-cdetrio2,0.015893918,74437 16 | cita-evm,bn128_mul_weierstrudel-chfast1,0.00683698,49441 17 | cita-evm,bn128_mul_weierstrudel-chfast2,0.012899205,66865 18 | cita-evm,bn128_mul_weierstrudel-chfast3,0.015247729,74819 19 | cita-evm,bn128_mul_weierstrudel-cdetrio6,0.015227745,75089 20 | cita-evm,bn128_mul_weierstrudel-cdetrio7,0.01517853,74501 21 | cita-evm,bn128_mul_weierstrudel-cdetrio11,0.015374415,75089 22 | cita-evm,bn128_mul_weierstrudel-cdetrio12,0.015857303,74501 23 | cita-evm,bn256g2mul-0xAshish,0.044238243,486053 24 | cita-evm,blake2b_huff-8415-bytes,0.02115236,1471220 25 | cita-evm,blake2b_huff-5610-bytes,0.013129701,988103 26 | cita-evm,blake2b_huff-2805-bytes,0.006572538,504983 27 | -------------------------------------------------------------------------------- /evm/evmraceresults/evm_benchmarks_evmone.csv: -------------------------------------------------------------------------------- 1 | engine,test_name,total_time,gas_used 2 | evmone,blake2b-8415-bytes-shiftopt,0.054213,12.0431M 3 | evmone,blake2b-5610-bytes-shiftopt,0.035875,7.43482M 4 | evmone,blake2b-2805-bytes-shiftopt,0.019119,3.42353M 5 | evmone,sha1-10808-bits,0.005104,790.156k 6 | evmone,sha1-21896-bits,0.009742,1.54361M 7 | evmone,sha1-42488-bits,0.018686,3.0144M 8 | evmone,mul256-gcolvin-drag-race,0.019177,5.61028M 9 | evmone,sha1-10808-bits-shiftopt,0.003893,759.785k 10 | evmone,sha1-21896-bits-shiftopt,0.007088,1.48425M 11 | evmone,sha1-42488-bits-shiftopt,0.01481,2.89847M 12 | evmone,blake2b-8415-bytes,0.064587,12.3518M 13 | evmone,blake2b-5610-bytes,0.040648,7.64067M 14 | evmone,blake2b-2805-bytes,0.02082,3.52651M 15 | evmone,bn128_mul_weierstrudel-cdetrio2,0.000583,47.165k 16 | evmone,bn128_mul_weierstrudel-chfast1,0.000323,23.449k 17 | evmone,bn128_mul_weierstrudel-chfast2,0.000524,39.337k 18 | evmone,bn128_mul_weierstrudel-chfast3,0.000575,47.291k 19 | evmone,bn128_mul_weierstrudel-cdetrio6,0.000563,47.561k 20 | evmone,bn128_mul_weierstrudel-cdetrio7,0.000565,47.165k 21 | evmone,bn128_mul_weierstrudel-cdetrio11,0.000573,47.561k 22 | evmone,bn128_mul_weierstrudel-cdetrio12,0.00055,47.165k 23 | evmone,bn256g2mul-0xAshish,0.003202,455.757k 24 | evmone,blake2b_huff-8415-bytes,0.004483,879.92k 25 | evmone,blake2b_huff-5610-bytes,0.002793,586.839k 26 | evmone,blake2b_huff-2805-bytes,0.001571,293.755k 27 | -------------------------------------------------------------------------------- /evm/evmraceresults/evm_benchmarks_geth.csv: -------------------------------------------------------------------------------- 1 | engine,test_name,total_time,gas_used 2 | geth-evm,blake2b-8415-bytes-shiftopt,0.189711069,12043105 3 | geth-evm,blake2b-5610-bytes-shiftopt,0.113561772,7434820 4 | geth-evm,blake2b-2805-bytes-shiftopt,0.051484922,3423526 5 | geth-evm,sha1-10808-bits,0.017261686,790156 6 | geth-evm,sha1-21896-bits,0.042415729,1543605 7 | geth-evm,sha1-42488-bits,0.080625691,3014404 8 | geth-evm,mul256-gcolvin-drag-race,0.227623711,5610277 9 | geth-evm,sha1-10808-bits-shiftopt,0.015148921,759785 10 | geth-evm,sha1-21896-bits-shiftopt,0.029567276,1484254 11 | geth-evm,sha1-42488-bits-shiftopt,0.056787827,2898473 12 | geth-evm,blake2b-8415-bytes,0.171602651,12351815 13 | geth-evm,blake2b-5610-bytes,0.115226858,7640669 14 | geth-evm,blake2b-2805-bytes,0.061277222,3526514 15 | geth-evm,bn128_mul_weierstrudel-cdetrio2,0.002396169,47165 16 | geth-evm,bn128_mul_weierstrudel-chfast1,0.001052022,23449 17 | geth-evm,bn128_mul_weierstrudel-chfast2,0.0015577,39337 18 | geth-evm,bn128_mul_weierstrudel-chfast3,0.001949494,47291 19 | geth-evm,bn128_mul_weierstrudel-cdetrio6,0.002096795,47561 20 | geth-evm,bn128_mul_weierstrudel-cdetrio7,0.002273449,47165 21 | geth-evm,bn128_mul_weierstrudel-cdetrio11,0.002106279,47561 22 | geth-evm,bn128_mul_weierstrudel-cdetrio12,0.002398648,47165 23 | geth-evm,bn256g2mul-0xAshish,0.010119752,455757 24 | geth-evm,blake2b_huff-8415-bytes,0.019343657,879920 25 | geth-evm,blake2b_huff-5610-bytes,0.014393628,586839 26 | geth-evm,blake2b_huff-2805-bytes,0.007442814,293755 27 | -------------------------------------------------------------------------------- /evm/evmraceresults/evm_benchmarks_parity.csv: -------------------------------------------------------------------------------- 1 | engine,test_name,total_time,gas_used 2 | parity-evm,blake2b-8415-bytes-shiftopt,0.316956977,12043105 3 | parity-evm,blake2b-5610-bytes-shiftopt,0.20601357,7434820 4 | parity-evm,blake2b-2805-bytes-shiftopt,0.116225032,3423526 5 | parity-evm,sha1-10808-bits,0.056514386,790156 6 | parity-evm,sha1-21896-bits,0.11256767,1543605 7 | parity-evm,sha1-42488-bits,0.234752859,3014404 8 | parity-evm,mul256-gcolvin-drag-race,0.138243573,5610277 9 | parity-evm,sha1-10808-bits-shiftopt,0.027183214,759785 10 | parity-evm,sha1-21896-bits-shiftopt,0.049224914,1484254 11 | parity-evm,sha1-42488-bits-shiftopt,0.092339599,2898473 12 | parity-evm,blake2b-8415-bytes,0.330776013,12351815 13 | parity-evm,blake2b-5610-bytes,0.225545786,7640669 14 | parity-evm,blake2b-2805-bytes,0.11554926,3526514 15 | parity-evm,bn128_mul_weierstrudel-cdetrio2,0.004230255,47165 16 | parity-evm,bn128_mul_weierstrudel-chfast1,0.001940616,23449 17 | parity-evm,bn128_mul_weierstrudel-chfast2,0.004237918,39337 18 | parity-evm,bn128_mul_weierstrudel-chfast3,0.004908508,47291 19 | parity-evm,bn128_mul_weierstrudel-cdetrio6,0.004730309,47561 20 | parity-evm,bn128_mul_weierstrudel-cdetrio7,0.004429321,47165 21 | parity-evm,bn128_mul_weierstrudel-cdetrio11,0.00441621,47561 22 | parity-evm,bn128_mul_weierstrudel-cdetrio12,0.004522368,47165 23 | parity-evm,bn256g2mul-0xAshish,0.021008241,455757 24 | parity-evm,blake2b_huff-8415-bytes,0.029408588,879920 25 | parity-evm,blake2b_huff-5610-bytes,0.021109934,586839 26 | parity-evm,blake2b_huff-2805-bytes,0.012020942,293755 27 | -------------------------------------------------------------------------------- /evm/evmraceresults/geth_precompile_benchmarks.csv: -------------------------------------------------------------------------------- 1 | test_name,gas,time 2 | PrecompiledEcrecover/,3000,0.000171278 3 | PrecompiledSha256/128,108,6.75e-07 4 | PrecompiledRipeMD/128,1080,1.601e-06 5 | PrecompiledIdentity/128,27,2.6e-08 6 | PrecompiledModExp/eip_example1,13056,3.8813e-05 7 | PrecompiledModExp/eip_example2,13056,7.627e-06 8 | PrecompiledModExp/nagydani-1-square,204,2.214e-06 9 | PrecompiledModExp/nagydani-1-qube,204,2.97e-06 10 | PrecompiledModExp/nagydani-1-pow0x10001,3276,1.6031e-05 11 | PrecompiledModExp/nagydani-2-square,665,3.647e-06 12 | PrecompiledModExp/nagydani-2-qube,665,5.475e-06 13 | PrecompiledModExp/nagydani-2-pow0x10001,10649,3.2472e-05 14 | PrecompiledModExp/nagydani-3-square,1894,6.62e-06 15 | PrecompiledModExp/nagydani-3-qube,1894,1.1542e-05 16 | PrecompiledModExp/nagydani-3-pow0x10001,30310,7.658e-05 17 | PrecompiledModExp/nagydani-4-square,5580,1.4711e-05 18 | PrecompiledModExp/nagydani-4-qube,5580,3.1939e-05 19 | PrecompiledModExp/nagydani-4-pow0x10001,89292,0.000206473 20 | PrecompiledModExp/nagydani-5-square,17868,3.8787e-05 21 | PrecompiledModExp/nagydani-5-qube,17868,8.9211e-05 22 | PrecompiledModExp/nagydani-5-pow0x10001,285900,0.00059206 23 | PrecompiledBn256Add/chfast1,150,1.4771e-05 24 | PrecompiledBn256Add/chfast2,150,1.4826e-05 25 | PrecompiledBn256Add/cdetrio1,150,1.141e-06 26 | PrecompiledBn256Add/cdetrio2,150,1.181e-06 27 | PrecompiledBn256Add/cdetrio3,150,1.199e-06 28 | PrecompiledBn256Add/cdetrio4,150,1.23e-06 29 | PrecompiledBn256Add/cdetrio5,150,1.148e-06 30 | PrecompiledBn256Add/cdetrio6,150,1.457e-06 31 | PrecompiledBn256Add/cdetrio7,150,1.466e-06 32 | PrecompiledBn256Add/cdetrio8,150,1.505e-06 33 | PrecompiledBn256Add/cdetrio9,150,1.465e-06 34 | PrecompiledBn256Add/cdetrio10,150,1.47e-06 35 | PrecompiledBn256Add/cdetrio11,150,1.4803e-05 36 | PrecompiledBn256Add/cdetrio12,150,1.4868e-05 37 | PrecompiledBn256Add/cdetrio13,150,1.4774e-05 38 | PrecompiledBn256Add/cdetrio14,150,2.239e-06 39 | PrecompiledBn256ScalarMul/chfast1,6000,0.000101592 40 | PrecompiledBn256ScalarMul/chfast2,6000,0.00011012 41 | PrecompiledBn256ScalarMul/chfast3,6000,0.000106361 42 | PrecompiledBn256ScalarMul/cdetrio1,6000,0.000113095 43 | PrecompiledBn256ScalarMul/cdetrio6,6000,0.000112832 44 | PrecompiledBn256ScalarMul/cdetrio11,6000,0.00011279 45 | PrecompiledBn256Pairing/jeff1,113000,0.003480264 46 | PrecompiledBn256Pairing/jeff2,113000,0.003481122 47 | PrecompiledBn256Pairing/jeff3,113000,0.003488338 48 | PrecompiledBn256Pairing/jeff4,147000,0.004651568 49 | PrecompiledBn256Pairing/jeff5,147000,0.004655143 50 | PrecompiledBn256Pairing/jeff6,113000,0.003486339 51 | PrecompiledBn256Pairing/empty_data,45000,0.001126386 52 | PrecompiledBn256Pairing/one_point,79000,0.002307792 53 | PrecompiledBn256Pairing/two_point_match_2,113000,0.003479592 54 | PrecompiledBn256Pairing/two_point_match_3,113000,0.003481145 55 | PrecompiledBn256Pairing/two_point_match_4,113000,0.003477909 56 | PrecompiledBn256Pairing/ten_point_match_1,385000,0.012912267 57 | PrecompiledBn256Pairing/ten_point_match_2,385000,0.012909478 58 | PrecompiledBn256Pairing/ten_point_match_3,113000,0.003482344 59 | PrecompiledBlake2F/vector_4,0,1.29e-07 60 | PrecompiledBlake2F/vector_5,12,2.74e-07 61 | PrecompiledBlake2F/vector_6,12,2.73e-07 62 | PrecompiledBlake2F/vector_7,1,1.39e-07 63 | PrecompiledBlake2F/vector_8,8000000,0.095974459 64 | -------------------------------------------------------------------------------- /evm/evmraceresults/parity_precompile_benchmarks.csv: -------------------------------------------------------------------------------- 1 | test_name,gas,time 2 | ecrecover,0,0.00013848 3 | sha256,0,7.05e-07 4 | ripemd,0,9.28e-07 5 | identity,0,3.78e-07 6 | modexp_eip_example1,0,0.0005437 7 | modexp_eip_example2,0,3.85e-07 8 | modexp_nagydani_1_square,0,5.881e-06 9 | modexp_nagydani_1_qube,0,9.766e-06 10 | modexp_nagydani_1_pow0x10001,0,6.3111e-05 11 | modexp_nagydani_2_square,0,1.0642e-05 12 | modexp_nagydani_2_qube,0,1.8653e-05 13 | modexp_nagydani_2_pow0x10001,0,0.00013454 14 | modexp_nagydani_3_square,0,2.5708e-05 15 | modexp_nagydani_3_qube,0,4.7968e-05 16 | modexp_nagydani_3_pow0x10001,0,0.00036653 17 | modexp_nagydani_4_square,0,6.8661e-05 18 | modexp_nagydani_4_qube,0,0.00013305 19 | modexp_nagydani_4_pow0x10001,0,0.0010832 20 | modexp_nagydani_5_square,0,0.00023079 21 | modexp_nagydani_5_qube,0,0.00044885 22 | modexp_nagydani_5_pow0x10001,0,0.0037508 23 | alt_bn128_add_chfast1,0,7.61e-06 24 | alt_bn128_add_chfast2,0,7.809e-06 25 | alt_bn128_add_cdetrio1,0,3.63e-07 26 | alt_bn128_add_cdetrio2,0,3.62e-07 27 | alt_bn128_add_cdetrio3,0,3.79e-07 28 | alt_bn128_add_cdetrio4,0,3.58e-07 29 | alt_bn128_add_cdetrio5,0,3.63e-07 30 | alt_bn128_add_cdetrio6,0,7.55e-07 31 | alt_bn128_add_cdetrio7,0,7.55e-07 32 | alt_bn128_add_cdetrio8,0,7.51e-07 33 | alt_bn128_add_cdetrio9,0,7.49e-07 34 | alt_bn128_add_cdetrio10,0,7.52e-07 35 | alt_bn128_add_cdetrio11,0,9.262e-06 36 | alt_bn128_add_cdetrio12,0,9.281e-06 37 | alt_bn128_add_cdetrio13,0,7.786e-06 38 | alt_bn128_add_cdetrio14,0,1.627e-06 39 | alt_bn128_mul_chfast1,0,6.2935e-05 40 | alt_bn128_mul_chfast2,0,0.00013844 41 | alt_bn128_mul_chfast3,0,0.000246 42 | alt_bn128_mul_cdetrio1,0,0.00028039 43 | alt_bn128_mul_cdetrio6,0,0.00028197 44 | alt_bn128_mul_cdetrio11,0,0.00027971 45 | alt_bn128_pairing_jeff1,0,0.0085643 46 | alt_bn128_pairing_jeff2,0,0.0085483 47 | alt_bn128_pairing_jeff3,0,0.0085401 48 | alt_bn128_pairing_jeff4,0,0.012831 49 | alt_bn128_pairing_jeff5,0,0.012804 50 | alt_bn128_pairing_jeff6,0,0.0085382 51 | alt_bn128_pairing_empty_data,0,9.8e-08 52 | alt_bn128_pairing_one_point,0,0.0042805 53 | alt_bn128_pairing_two_point_match_2,0,0.0085503 54 | alt_bn128_pairing_two_point_match_3,0,0.0085525 55 | alt_bn128_pairing_two_point_match_4,0,0.0085571 56 | alt_bn128_pairing_ten_point_match_1,0,0.042631 57 | alt_bn128_pairing_ten_point_match_2,0,0.042682 58 | alt_bn128_pairing_ten_point_match_3,0,0.0086894 59 | -------------------------------------------------------------------------------- /evm/geth/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (geth)" 7 | 8 | # install python modules needed for benchmarking script 9 | RUN pip3 install durationpy jinja2 pandas 10 | 11 | # install geth 12 | RUN go get -u -v github.com/ewasm-benchmarking/go-ethereum 13 | RUN cd /root/go/src/github.com/ewasm-benchmarking/go-ethereum && git checkout origin/v1.9.14-benchmarking -b v1.9.14-benchmarking && make all 14 | RUN ln -s /root/go/src/github.com/ewasm-benchmarking/go-ethereum /go-ethereum 15 | 16 | WORKDIR / 17 | RUN mkdir -p /evmraceresults 18 | RUN mkdir /evmrace 19 | 20 | CMD /bin/bash 21 | -------------------------------------------------------------------------------- /evm/input_data/evmcode/bn256g2mul.hex: -------------------------------------------------------------------------------- 1 | 6080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166355a3e90f811461005b57806361a931ec14610082578063b73ab75d146100d5575b600080fd5b34801561006757600080fd5b506100706100f9565b60408051918252519081900360200190f35b34801561008e57600080fd5b506100af60043560243560443560643560843560a43560c43560e43561010b565b604080519485526020850193909352838301919091526060830152519081900360800190f35b3480156100e157600080fd5b506100af60043560243560443560643560843561025c565b600080516020610a5183398151915290565b600080600080610119610a31565b8c15801561012557508b155b801561012f57508a155b8015610139575089155b15610189578815801561014a575087155b8015610154575086155b801561015e575085155b151561017857610170898989896102ec565b151561017857fe5b88888888945094509450945061024c565b88158015610195575087155b801561019f575086155b80156101a9575085155b156101d3576101ba8d8d8d8d6102ec565b15156101c257fe5b8c8c8c8c945094509450945061024c565b6101df8d8d8d8d6102ec565b15156101e757fe5b6101f3898989896102ec565b15156101fb57fe5b6102138d8d8d8d600160008f8f8f8f600160006103a1565b90506102438160005b602090810291909101519083015160408401516060850151608086015160a087015161062a565b94509450945094505b5098509850985098945050505050565b600080600080600061026c610a31565b600191508915801561027c575088155b8015610286575087155b8015610290575086155b156102a6576001995060019750600091506102ba565b6102b28a8a8a8a6102ec565b15156102ba57fe5b6102ca8b8b8b8b8b876000610674565b90506102d781600061021c565b929e919d509b50909950975050505050505050565b6000806000806000610300878789896106f0565b9094509250610311898981816106f0565b909250905061032282828b8b6106f0565b909250905061033384848484610761565b909450925061038384847f2b149d40ceb8aaae81be18991be06ac3b5b4c5e559dbefa33267e6dc24a138e57e9713b03af0fed4cd2cafadeed8fdf4a74fa084e52d1852e4a2bd0685c315d2610761565b909450925083158015610394575082155b9998505050505050505050565b6103a9610a31565b881580156103b5575087155b156103f7578686868686868660005b60a0890192909252608088019290925260608701929092526040860192909252602085810193909352909102015261061a565b82158015610403575081155b15610416578c8c8c8c8c8c8660006103c4565b61042285858b8b6106f0565b90955093506104338b8b85856106f0565b6060830152604082015261044987878b8b6106f0565b909750955061045a8d8d85856106f0565b60a08301526080820181905287148015610477575060a081015186145b156104bc576040810151851480156104925750606081015184145b156104ad576104a58d8d8d8d8d8d6107a3565b8660006103c4565b600160008181808086816103c4565b6104c8898985856106f0565b90935091506104e8858583600260200201518460035b6020020151610761565b909d509b50610502878783600460200201518460056104de565b909b5099506105138b8b81816106f0565b9099509750610533898983600460200201518460055b60200201516106f0565b909550935061054489898d8d6106f0565b9099509750610555898985856106f0565b60a0830152608082015261056b8d8d81816106f0565b909750955061057c878785856106f0565b909750955061058d87878b8b610761565b909750955061059e85856002610912565b90935091506105af87878585610761565b90975095506105c08b8b89896106f0565b602083015281526105d385858989610761565b909b5099506105e48d8d8d8d6106f0565b909b5099506105fe89898360026020020151846003610529565b909d509b5061060f8b8b8f8f610761565b606083015260408201525b9c9b505050505050505050505050565b60008060008060008061063d8888610945565b909250905061064e8c8c84846106f0565b909650945061065f8a8a84846106f0565b969d959c509a50949850929650505050505050565b61067c610a31565b87156106e55760018816156106bd578051602082015160408301516060840151608085015160a08601516106ba9594939291908d8d8d8d8d8d6103a1565b90505b6106cb8787878787876107a3565b949b5092995090975095509350915060028804975061067c565b979650505050505050565b60008061072e600080516020610a51833981519152858809600080516020610a51833981519152858809600080516020610a518339815191526109c8565b600080516020610a5183398151915280868809600080516020610a51833981519152868a09089150915094509492505050565b60008061077d8685600080516020610a518339815191526109c8565b6107968685600080516020610a518339815191526109c8565b9150915094509492505050565b6000806000806000806107b88c8c6003610912565b90965094506107c986868e8e6106f0565b90965094506107da8a8a8a8a6106f0565b90985096506107eb8c8c8c8c6106f0565b90945092506107fc84848a8a6106f0565b909450925061080d868681816106f0565b909c509a5061081e84846008610912565b909250905061082f8c8c8484610761565b909c509a50610840888881816106f0565b909250905061085184846004610912565b909450925061086284848e8e610761565b9094509250610873848488886106f0565b90945092506108848a8a6008610912565b909650945061089586868c8c6106f0565b90965094506108a6868684846106f0565b90965094506108b784848888610761565b90945092506108c88c8c6002610912565b90965094506108d986868a8a6106f0565b90965094506108ea888884846106f0565b90925090506108fb82826008610912565b809250819350505096509650965096509650969050565b600080600080516020610a51833981519152838609600080516020610a5183398151915284860991509150935093915050565b60008080610986600080516020610a5183398151915280878809600080516020610a5183398151915287880908600080516020610a518339815191526109e1565b9050600080516020610a51833981519152818609600080516020610a51833981519152828609600080516020610a518339815191520392509250509250929050565b6000818015156109d457fe5b8383038508949350505050565b600060018284835b8115610a275781838115156109fa57fe5b04905083610a158688801515610a0c57fe5b878509896109c8565b909550935090918183029003906109e9565b5050505092915050565b60c0604051908101604052806006906020820280388339509192915050560030644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47a165627a7a72305820620737530e8412ec891697b2147d92da793c0a9fafb0006e11b02478ee3c42f80029 -------------------------------------------------------------------------------- /evm/input_data/evmcode/mul256.hex: -------------------------------------------------------------------------------- 1 | 60806040526004361061003a577c0100000000000000000000000000000000000000000000000000000000600035046326bceb59811461003f575b600080fd5b34801561004b57600080fd5b5061006f6004803603604081101561006257600080fd5b5080359060200135610081565b60408051918252519081900360200190f35b6000805b6127108110156101195792820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820282028202820292600101610085565b50919291505056fea165627a7a72305820f177a28bdd911c3050e8385c430286abe9e0aca6388127eee00bd13961acba6a0029 -------------------------------------------------------------------------------- /evm/input_data/evmcode/mul256.sol: -------------------------------------------------------------------------------- 1 | /* 2 | based on https://github.com/gcolvin/evm-drag-race/blob/550e4e85f4db9c1485d01498d8033ef91c55cd78/mul256.asm 3 | 4 | remix input format: "0x802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9", "0xa1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57" 5 | 6 | calldata: 0x26bceb59802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9a1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57 7 | 8 | compiled with soljson-v0.5.1+commit.c8a2cb62.js 9 | */ 10 | 11 | 12 | pragma solidity ^0.5.1; 13 | 14 | contract MUL256 { 15 | 16 | function mul256(uint256 x, uint256 y) public pure returns(bytes32 ret) { 17 | assembly { 18 | 19 | //let x := 0x802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9 20 | //let y := 0xa1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57 21 | 22 | for { let i := 0 } lt(i, 10000) { i := add(i, 1) } { 23 | x := mul(y, mul(y, mul(y, mul(y, x)))) 24 | x := mul(y, mul(y, mul(y, mul(y, x)))) 25 | 26 | x := mul(y, mul(y, mul(y, mul(y, x)))) 27 | x := mul(y, mul(y, mul(y, mul(y, x)))) 28 | 29 | x := mul(y, mul(y, mul(y, mul(y, x)))) 30 | x := mul(y, mul(y, mul(y, mul(y, x)))) 31 | 32 | x := mul(y, mul(y, mul(y, mul(y, x)))) 33 | x := mul(y, mul(y, mul(y, mul(y, x)))) 34 | 35 | x := mul(y, mul(y, mul(y, mul(y, x)))) 36 | x := mul(y, mul(y, mul(y, mul(y, x)))) 37 | 38 | x := mul(y, mul(y, mul(y, mul(y, x)))) 39 | x := mul(y, mul(y, mul(y, mul(y, x)))) 40 | 41 | x := mul(y, mul(y, mul(y, mul(y, x)))) 42 | x := mul(y, mul(y, mul(y, mul(y, x)))) 43 | 44 | x := mul(y, mul(y, mul(y, mul(y, x)))) 45 | x := mul(y, mul(y, mul(y, mul(y, x)))) 46 | } 47 | 48 | ret := x 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /evm/input_data/evmcode/sha1.hex: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b5060043610610047577c010000000000000000000000000000000000000000000000000000000060003504631605782b811461004c575b600080fd5b6100f26004803603602081101561006257600080fd5b81019060208101813564010000000081111561007d57600080fd5b82018360208201111561008f57600080fd5b803590602001918460018302840111640100000000831117156100b157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610114945050505050565b604080516bffffffffffffffffffffffff199092168252519081900360200190f35b60006040518251602084019350604067ffffffffffffffc0600183011601600982820310600181146101455761014c565b6040820191505b50776745230100efcdab890098badcfe001032547600c3d2e1f061019f565b600083831015610198575080820151928290039260208410156101985760001960208590036101000a0119165b9392505050565b60005b82811015610565576101b584828961016b565b85526101c584602083018961016b565b6020860152604081850310600181146101dd576101e6565b60808286038701535b50604083038114600181146101fa57610208565b602086018051600887021790525b5060405b608081101561029057858101603f19810151603719820151601f19830151600b198401516002911891909218189081027ffffffffefffffffefffffffefffffffefffffffefffffffefffffffefffffffe1663800000009091047c010000000100000001000000010000000100000001000000010000000116179052600c0161020c565b5060805b61014081101561031957858101607f19810151606f19820151603f198301516017198401516004911891909218189081027ffffffffcfffffffcfffffffcfffffffcfffffffcfffffffcfffffffcfffffffc1663400000009091047c030000000300000003000000030000000300000003000000030000000316179052601801610294565b508160008060005b605081101561053b57601481048015610351576001811461038d57600281146103c757600381146104065761043c565b6501000000000085046a0100000000000000000000860481186f01000000000000000000000000000000870416189350635a827999925061043c565b6501000000000085046f0100000000000000000000000000000086046a0100000000000000000000870418189350636ed9eba1925061043c565b6a010000000000000000000085046f010000000000000000000000000000008604818117650100000000008804169116179350638f1bbcdc925061043c565b6501000000000085046f0100000000000000000000000000000086046a010000000000000000000087041818935063ca62c1d692505b50601f770800000000000000000000000000000000000000000000008504168063ffffffe073080000000000000000000000000000000000000087041617905080840190508063ffffffff86160190508083019050807c0100000000000000000000000000000000000000000000000000000000600484028c0151040190507401000000000000000000000000000000000000000081026501000000000086041794506a0100000000000000000000633fffffff6a040000000000000000000087041663c00000006604000000000000880416170277ffffffff00ffffffff000000000000ffffffff00ffffffff861617945050600181019050610321565b5050509190910177ffffffff00ffffffff00ffffffff00ffffffff00ffffffff16906040016101a2565b506c0100000000000000000000000063ffffffff821667ffffffff000000006101008404166bffffffff0000000000000000620100008504166fffffffff000000000000000000000000630100000086041673ffffffff00000000000000000000000000000000640100000000870416171717170294505050505091905056fea165627a7a723058209b8907beefa8788cefc9b87aab1aa045aa08b0534449e5e0664be20e54e004fc0029 -------------------------------------------------------------------------------- /evm/input_data/evmcode/sha1.sol: -------------------------------------------------------------------------------- 1 | // derived from https://github.com/ensdomains/solsha1/blob/master/contracts/SHA1.sol 2 | // deployed ENS code at: https://etherscan.io/address/0x4e89a683dade995736457bde623e75f5840c2d34#code 3 | 4 | // compiled with solc version:0.5.4+commit.9549d8ff.Emscripten.clang with optimizer enabled 5 | 6 | 7 | /* 8 | var definition = `[{"constant":true,"inputs":[{"name":"data","type":"bytes"}],"name":"sha1","outputs":[{"name":"ret","type":"bytes20"}],"payable":false,"stateMutability":"pure","type":"function"}]`; 9 | */ 10 | 11 | /* 12 | 13 | // sha1 test vectors from https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/secure-hashing#shavs 14 | // FIPS 180-4 "SHA Test Vectors for Hashing Byte-Oriented Messages" 15 | 16 | input := common.Hex2Bytes("{{input}}") 17 | // contract returns padded bytes "a94d7bf363f32a5a5b6e9f71b2edaa3f2ae31a61000000000000000000000000" 18 | expected := "{{expected}}000000000000000000000000" 19 | 20 | calldata, err := abi.Pack("sha1", input) 21 | 22 | */ 23 | 24 | 25 | pragma solidity ^0.5.1; 26 | 27 | contract SHA1 { 28 | 29 | function sha1(bytes memory data) public pure returns(bytes20 ret) { 30 | assembly { 31 | // Get a safe scratch location 32 | let scratch := mload(0x40) 33 | 34 | // Get the data length, and point data at the first byte 35 | let len := mload(data) 36 | data := add(data, 32) 37 | 38 | // Find the length after padding 39 | let totallen := add(and(add(len, 1), 0xFFFFFFFFFFFFFFC0), 64) 40 | switch lt(sub(totallen, len), 9) 41 | case 1 { totallen := add(totallen, 64) } 42 | 43 | let h := 0x6745230100EFCDAB890098BADCFE001032547600C3D2E1F0 44 | 45 | function readword(ptr, off, count) -> result { 46 | result := 0 47 | if lt(off, count) { 48 | result := mload(add(ptr, off)) 49 | count := sub(count, off) 50 | if lt(count, 32) { 51 | let mask := not(sub(exp(256, sub(32, count)), 1)) 52 | result := and(result, mask) 53 | } 54 | } 55 | } 56 | 57 | for { let i := 0 } lt(i, totallen) { i := add(i, 64) } { 58 | mstore(scratch, readword(data, i, len)) 59 | mstore(add(scratch, 32), readword(data, add(i, 32), len)) 60 | 61 | // If we loaded the last byte, store the terminator byte 62 | switch lt(sub(len, i), 64) 63 | case 1 { mstore8(add(scratch, sub(len, i)), 0x80) } 64 | 65 | // If this is the last block, store the length 66 | switch eq(i, sub(totallen, 64)) 67 | case 1 { mstore(add(scratch, 32), or(mload(add(scratch, 32)), shl(3, len))) } 68 | 69 | // Expand the 16 32-bit words into 80 70 | for { let j := 64 } lt(j, 128) { j := add(j, 12) } { 71 | let temp := xor(xor(mload(add(scratch, sub(j, 12))), mload(add(scratch, sub(j, 32)))), xor(mload(add(scratch, sub(j, 56))), mload(add(scratch, sub(j, 64))))) 72 | temp := or(and(shl(1, temp), 0xFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFE), and(shr(31, temp), 0x0000000100000001000000010000000100000001000000010000000100000001)) 73 | mstore(add(scratch, j), temp) 74 | } 75 | for { let j := 128 } lt(j, 320) { j := add(j, 24) } { 76 | let temp := xor(xor(mload(add(scratch, sub(j, 24))), mload(add(scratch, sub(j, 64)))), xor(mload(add(scratch, sub(j, 112))), mload(add(scratch, sub(j, 128))))) 77 | temp := or(and(shl(2, temp), 0xFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFC), and(shr(30, temp), 0x0000000300000003000000030000000300000003000000030000000300000003)) 78 | mstore(add(scratch, j), temp) 79 | } 80 | 81 | let x := h 82 | let f := 0 83 | let k := 0 84 | for { let j := 0 } lt(j, 80) { j := add(j, 1) } { 85 | switch div(j, 20) 86 | case 0 { 87 | // f = d xor (b and (c xor d)) 88 | f := xor(shr(80, x), shr(40, x)) 89 | f := and(shr(120, x), f) 90 | f := xor(shr(40, x), f) 91 | k := 0x5A827999 92 | } 93 | case 1{ 94 | // f = b xor c xor d 95 | f := xor(shr(120, x), shr(80, x)) 96 | f := xor(shr(40, x), f) 97 | k := 0x6ED9EBA1 98 | } 99 | case 2 { 100 | // f = (b and c) or (d and (b or c)) 101 | f := or(shr(120, x), shr(80, x)) 102 | f := and(shr(40, x), f) 103 | f := or(and(shr(120, x), shr(80, x)), f) 104 | k := 0x8F1BBCDC 105 | } 106 | case 3 { 107 | // f = b xor c xor d 108 | f := xor(shr(120, x), shr(80, x)) 109 | f := xor(shr(40, x), f) 110 | k := 0xCA62C1D6 111 | } 112 | // temp = (a leftrotate 5) + f + e + k + w[i] 113 | let temp := and(shr(187, x), 0x1F) 114 | temp := or(and(shr(155, x), 0xFFFFFFE0), temp) 115 | temp := add(f, temp) 116 | temp := add(and(x, 0xFFFFFFFF), temp) 117 | temp := add(k, temp) 118 | temp := add(shr(224, mload(add(scratch, shl(2, j)))), temp) 119 | //x := or(div(x, 0x10000000000), mul(temp, 0x10000000000000000000000000000000000000000)) 120 | x := or(shr(40, x), shl(160, temp)) 121 | x := or(and(x, 0xFFFFFFFF00FFFFFFFF000000000000FFFFFFFF00FFFFFFFF), shl(80, or(and(shr(50, x), 0xC0000000), and(shr(82, x), 0x3FFFFFFF)))) 122 | } 123 | 124 | h := and(add(h, x), 0xFFFFFFFF00FFFFFFFF00FFFFFFFF00FFFFFFFF00FFFFFFFF) 125 | } 126 | ret := shl(96, or(or(or(or(and(shr(32, h), 0xFFFFFFFF00000000000000000000000000000000), and(shr(24, h), 0xFFFFFFFF000000000000000000000000)), and(shr(16, h), 0xFFFFFFFF0000000000000000)), and(shr(8, h), 0xFFFFFFFF00000000)), and(h, 0xFFFFFFFF))) 127 | } 128 | 129 | } 130 | } 131 | 132 | -------------------------------------------------------------------------------- /evm/input_data/evmcode/sha1_shift.hex: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b506004361061002b5760003560e01c80631605782b14610030575b600080fd5b6100d66004803603602081101561004657600080fd5b81019060208101813564010000000081111561006157600080fd5b82018360208201111561007357600080fd5b8035906020019184600183028401116401000000008311171561009557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506100f8945050505050565b604080516bffffffffffffffffffffffff199092168252519081900360200190f35b60006040518251602084019350604067ffffffffffffffc06001830116016009828203106001811461012957610130565b6040820191505b50776745230100efcdab890098badcfe001032547600c3d2e1f0610183565b60008383101561017c5750808201519282900392602084101561017c5760001960208590036101000a0119165b9392505050565b60005b8281101561045c5761019984828961014f565b85526101a984602083018961014f565b6020860152604081850310600181146101c1576101ca565b60808286038701535b50604083038114600181146101de576101ee565b8460031b60208701511760208701525b5060405b608081101561027157858101603f19810151603719820151601f19830151600b1984015118911818600181901b7ffffffffefffffffefffffffefffffffefffffffefffffffefffffffefffffffe16601f9190911c7c010000000100000001000000010000000100000001000000010000000116179052600c016101f2565b5060805b6101408110156102f557858101607f19810151606f19820151603f1983015160171984015118911818600281901b7ffffffffcfffffffcfffffffcfffffffcfffffffcfffffffcfffffffcfffffffc16601e9190911c7c030000000300000003000000030000000300000003000000030000000316179052601801610275565b508160008060005b60508110156104325760148104801561032d576001811461034e576002811461036d5760038114610391576103ac565b602885901c605086901c8118607887901c16189350635a82799992506103ac565b8460501c8560781c189350838560281c189350636ed9eba192506103ac565b605085901c607886901c818117602888901c169116179350638f1bbcdc92506103ac565b8460501c8560781c189350838560281c18935063ca62c1d692505b50601f8460bb1c168063ffffffe086609b1c1617905080840190508063ffffffff86160190508083019050808260021b8b015160e01c0190508060a01b8560281c179450633fffffff8560521c1663c00000008660321c161760501b77ffffffff00ffffffff000000000000ffffffff00ffffffff8616179450506001810190506102fd565b5050509190910177ffffffff00ffffffff00ffffffff00ffffffff00ffffffff1690604001610186565b5063ffffffff811667ffffffff000000008260081c166bffffffff00000000000000008360101c166fffffffff0000000000000000000000008460181c1673ffffffff000000000000000000000000000000008560201c161717171760601b94505050505091905056fea165627a7a72305820227af8b272b9b0e3d345f580ebcde55f50e3e8b7ecafabffcadb92e55e4de68e0029 -------------------------------------------------------------------------------- /evm/input_data/evmcode/sha1_shift.sol: -------------------------------------------------------------------------------- 1 | 2 | // derived from https://github.com/ensdomains/solsha1/blob/master/contracts/SHA1.sol 3 | // compiled with solc version:0.5.4+commit.9549d8ff.Emscripten.clang with optimizer enabled 4 | // hand optimized to replace div and mul with shr and shl 5 | 6 | /* 7 | var definition = `[{"constant":true,"inputs":[{"name":"data","type":"bytes"}],"name":"sha1","outputs":[{"name":"ret","type":"bytes20"}],"payable":false,"stateMutability":"pure","type":"function"}]`; 8 | 9 | // sha1 test vectors from https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/secure-hashing#shavs 10 | // FIPS 180-4 "SHA Test Vectors for Hashing Byte-Oriented Messages" 11 | 12 | input := common.Hex2Bytes("{{input}}") 13 | // contract returns padded bytes "a94d7bf363f32a5a5b6e9f71b2edaa3f2ae31a61000000000000000000000000" 14 | expected := "{{expected}}000000000000000000000000" 15 | 16 | calldata, err := abi.Pack("sha1", input) 17 | */ 18 | 19 | 20 | 21 | pragma solidity ^0.5.1; 22 | 23 | contract SHA1 { 24 | 25 | function sha1(bytes memory data) public pure returns(bytes20 ret) { 26 | assembly { 27 | // Get a safe scratch location 28 | let scratch := mload(0x40) 29 | 30 | // Get the data length, and point data at the first byte 31 | let len := mload(data) 32 | data := add(data, 32) 33 | 34 | // Find the length after padding 35 | let totallen := add(and(add(len, 1), 0xFFFFFFFFFFFFFFC0), 64) 36 | switch lt(sub(totallen, len), 9) 37 | case 1 { totallen := add(totallen, 64) } 38 | 39 | let h := 0x6745230100EFCDAB890098BADCFE001032547600C3D2E1F0 40 | 41 | function readword(ptr, off, count) -> result { 42 | result := 0 43 | if lt(off, count) { 44 | result := mload(add(ptr, off)) 45 | count := sub(count, off) 46 | if lt(count, 32) { 47 | let mask := not(sub(exp(256, sub(32, count)), 1)) 48 | result := and(result, mask) 49 | } 50 | } 51 | } 52 | 53 | for { let i := 0 } lt(i, totallen) { i := add(i, 64) } { 54 | mstore(scratch, readword(data, i, len)) 55 | mstore(add(scratch, 32), readword(data, add(i, 32), len)) 56 | 57 | // If we loaded the last byte, store the terminator byte 58 | switch lt(sub(len, i), 64) 59 | case 1 { mstore8(add(scratch, sub(len, i)), 0x80) } 60 | 61 | // If this is the last block, store the length 62 | switch eq(i, sub(totallen, 64)) 63 | case 1 { mstore(add(scratch, 32), or(mload(add(scratch, 32)), shl(3, len))) } 64 | 65 | // Expand the 16 32-bit words into 80 66 | for { let j := 64 } lt(j, 128) { j := add(j, 12) } { 67 | let temp := xor(xor(mload(add(scratch, sub(j, 12))), mload(add(scratch, sub(j, 32)))), xor(mload(add(scratch, sub(j, 56))), mload(add(scratch, sub(j, 64))))) 68 | temp := or(and(shl(1, temp), 0xFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFEFFFFFFFE), and(shr(31, temp), 0x0000000100000001000000010000000100000001000000010000000100000001)) 69 | mstore(add(scratch, j), temp) 70 | } 71 | for { let j := 128 } lt(j, 320) { j := add(j, 24) } { 72 | let temp := xor(xor(mload(add(scratch, sub(j, 24))), mload(add(scratch, sub(j, 64)))), xor(mload(add(scratch, sub(j, 112))), mload(add(scratch, sub(j, 128))))) 73 | temp := or(and(shl(2, temp), 0xFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFCFFFFFFFC), and(shr(30, temp), 0x0000000300000003000000030000000300000003000000030000000300000003)) 74 | mstore(add(scratch, j), temp) 75 | } 76 | 77 | let x := h 78 | let f := 0 79 | let k := 0 80 | for { let j := 0 } lt(j, 80) { j := add(j, 1) } { 81 | switch div(j, 20) 82 | case 0 { 83 | // f = d xor (b and (c xor d)) 84 | f := xor(shr(80, x), shr(40, x)) 85 | f := and(shr(120, x), f) 86 | f := xor(shr(40, x), f) 87 | k := 0x5A827999 88 | } 89 | case 1{ 90 | // f = b xor c xor d 91 | f := xor(shr(120, x), shr(80, x)) 92 | f := xor(shr(40, x), f) 93 | k := 0x6ED9EBA1 94 | } 95 | case 2 { 96 | // f = (b and c) or (d and (b or c)) 97 | f := or(shr(120, x), shr(80, x)) 98 | f := and(shr(40, x), f) 99 | f := or(and(shr(120, x), shr(80, x)), f) 100 | k := 0x8F1BBCDC 101 | } 102 | case 3 { 103 | // f = b xor c xor d 104 | f := xor(shr(120, x), shr(80, x)) 105 | f := xor(shr(40, x), f) 106 | k := 0xCA62C1D6 107 | } 108 | // temp = (a leftrotate 5) + f + e + k + w[i] 109 | let temp := and(shr(187, x), 0x1F) 110 | temp := or(and(shr(155, x), 0xFFFFFFE0), temp) 111 | temp := add(f, temp) 112 | temp := add(and(x, 0xFFFFFFFF), temp) 113 | temp := add(k, temp) 114 | temp := add(shr(224, mload(add(scratch, shl(2, j)))), temp) 115 | //x := or(div(x, 0x10000000000), mul(temp, 0x10000000000000000000000000000000000000000)) 116 | x := or(shr(40, x), shl(160, temp)) 117 | x := or(and(x, 0xFFFFFFFF00FFFFFFFF000000000000FFFFFFFF00FFFFFFFF), shl(80, or(and(shr(50, x), 0xC0000000), and(shr(82, x), 0x3FFFFFFF)))) 118 | } 119 | 120 | h := and(add(h, x), 0xFFFFFFFF00FFFFFFFF00FFFFFFFF00FFFFFFFF00FFFFFFFF) 121 | } 122 | ret := shl(96, or(or(or(or(and(shr(32, h), 0xFFFFFFFF00000000000000000000000000000000), and(shr(24, h), 0xFFFFFFFF000000000000000000000000)), and(shr(16, h), 0xFFFFFFFF0000000000000000)), and(shr(8, h), 0xFFFFFFFF00000000)), and(h, 0xFFFFFFFF))) 123 | } 124 | 125 | } 126 | } 127 | 128 | -------------------------------------------------------------------------------- /evm/input_data/input_vectors/bn128_mul_weierstrudel-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "bn128_mul_weierstrudel-cdetrio2", 4 | "input": "1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000", 5 | "expected": "0fd77bc20ccc92d0b4ffacb61e424d6b6fd72a6d151d8b509219520cc1864bb5288d1f482955e8c54e25edd0b042165f5956080040012c123f212f4f3ae89af53006aa526e2b86b15d1dee9c860a14ae854c204a849c93ba61b05837bf52bbd9" 6 | }, 7 | { 8 | "name": "bn128_mul_weierstrudel-chfast1", 9 | "input": "2bd3e6d0f3b142924f5ca7b49ce5b9d54c4703d7ae5648e61d02268b1a0a9fb721611ce0a6af85915e2f1d70300909ce2e49dfad4a4619c8390cae66cefdb20400000000000000000000000000000000000000000000000011138ce750fa15c2", 10 | "expected": "0bf7bceb8008937f680acf513b071028920555ec741a23c7a1ce94012f480e7e25fe6f425ede8643777d99a16875d2edba1f6af0deedfc87adaa94a88223c16028a6344a52a5a9006001bb0ac953540b251334d4aae7c815e84bda7ad1586c31" 11 | }, 12 | { 13 | "name": "bn128_mul_weierstrudel-chfast2", 14 | "input": "070a8d6a982153cae4be29d434e8faef8a47b274a053f5a4ee2a6c9c13c31e5c031b8ce914eba3a9ffb989f9cdd5b0f01943074bf4f0f315690ec3cec6981afc30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46", 15 | "expected": "2991087fdb407821505a609daef81e7d239d790f56920a737ec29f738028aaa11ff2f37464ad918f0333c99ca9d890de452c4486b4b925c808378b8c320d4c1c10bd0b249179a59d7201a7408e6931de0e1687bd016e68b6aa78ec7f5bbfc8ba" 16 | }, 17 | { 18 | "name": "bn128_mul_weierstrudel-chfast3", 19 | "input": "025a6f4181d2b4ea8b724290ffb40156eb0adb514c688556eb79cdea0752c2bb2eff3f31dea215f1eb86023a133a996eb6300b44da664d64251d05381bb8a02e183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea3", 20 | "expected": "1d0afc9bb1059a0aed80b1e494b673e195cc81c9f61d27c2be1b4d2e219d85e410777acd638132946872de4d6d25f38bdae622ccd5eba13e8727e77c53b0e0ec2c9dcdd26f57f433e4b379cc52dc328cb8e8fb106d21c9539e0a643719ea00ee" 21 | }, 22 | { 23 | "name": "bn128_mul_weierstrudel-cdetrio6", 24 | "input": "17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 25 | "expected": "062f82903b8ff1ea92fd79524b3f74a2f9828d919bd74363e9284df1584c29fa005b670c42ef50487eb89c815ffb4dd7063306efd7b010ce8e969a4e85ed6853065ee72dbfa35c88cc6dc9399c260df4b30e8a653c41db751f2907084ac0cdba" 26 | }, 27 | { 28 | "name": "bn128_mul_weierstrudel-cdetrio7", 29 | "input": "17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000", 30 | "expected": "26c8162046eafa5f18a0356fcb3ffb80ced491ef21c7d27f5585cf7d3ca0e1bb15776559e47782083c416c2d862db615a52532733bdc0ddfce7cb21d77ada21e25902c0c8fb910640a519990e377404b3bc56319ba61c65d3e5c4928f99c418d" 31 | }, 32 | { 33 | "name": "bn128_mul_weierstrudel-cdetrio11", 34 | "input": "039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 35 | "expected": "0e9c28772a2a79561257f998c9c31e9b47bb592d54b6936bc00066453f50b27816c1cda062bd6cc07463ba71ff1d299223dd1bb9a6ac5cfe1d57a19c87a229e029a4b5947ed4dca6df8349674078a9b3ea3d06b4373d9d7a50866f3de054285d" 36 | }, 37 | { 38 | "name": "bn128_mul_weierstrudel-cdetrio12", 39 | "input": "039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d9830644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000", 40 | "expected": "15b96faea1d3c641392c406d56c4c2437773189efe5f7ba558f96f5a1ed2abcf27e78562e10de3bf1614ff439e00aecfd4a6c724fc4ef939d06c662d88792f9d2dcb8ebd521d0d7a3db329695e2ba0dd0a7bade2e9fa1200ad7c913c5d0bb0cf" 41 | } 42 | ] -------------------------------------------------------------------------------- /evm/input_data/input_vectors/bn256g2mul-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "bn256g2mul-0xAshish", 4 | "input": "b73ab75d00000000000000000000000000000000000000000000000000000002dddefa191800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c212c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b", 5 | "expected": "23997083c2c4409869ee3546806a544c8c16bc46cc88598c4e1c853eb81d45b01142585a23028cbe57783f890d1a2f6837049fce43c9b3b5e8e14c40a43c617a215a23c8a96e1ca11d52cf6e2d6ada4ed01ee7e09b06dbc7f3315e7e6e73b9190edac9f3a977530e28d4a385e614bcb7a8f9c3c3cb65707c1b90b5ea86174512" 6 | } 7 | ] -------------------------------------------------------------------------------- /evm/input_data/input_vectors/mul256-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "mul256-gcolvin-drag-race", 4 | "input": "26bceb59802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9a1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57", 5 | "expected": "80baf8d183a4163e36b5076c8ac089871d90f3c75ee88f4a0204ca9ec2833da9" 6 | } 7 | ] -------------------------------------------------------------------------------- /evm/parity/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (parity)" 7 | 8 | # deps required to build full parity for native precompile benchmarks 9 | RUN apt-get update && \ 10 | apt-get install -y libudev-dev 11 | 12 | # install python modules needed for benchmarking script 13 | RUN pip3 install durationpy jinja2 pandas 14 | 15 | RUN rustup default nightly-2019-01-15 16 | 17 | WORKDIR / 18 | 19 | # install parity-evm 20 | RUN git clone --recursive --single-branch --branch v2.5.1-benchmarking https://github.com/ewasm-benchmarking/openethereum parity 21 | RUN cd parity/evmbin && cargo build --release 22 | 23 | CMD /bin/bash 24 | -------------------------------------------------------------------------------- /evm/scripts/bench_evm384.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import re 4 | import subprocess 5 | import nanodurationpy as durationpy 6 | import csv 7 | import time 8 | import datetime 9 | import os 10 | import shutil 11 | import shlex 12 | import json 13 | 14 | # output paths should be mounted docker volumes 15 | RESULT_CSV_OUTPUT_PATH = "/evmraceresults" 16 | 17 | RESULT_CSV_FILENAME = "evm_benchmarks_evmone384.csv" 18 | 19 | EVMONE_BENCH_INFOS = [ 20 | { 21 | "command": "/root/evmone-evm384-v1/build/bin/evmone-bench --benchmark_format=json --benchmark_color=false --benchmark_min_time=5 /root/evm384_f6m_mul/build/v1-f6m_mul_bench.bin 00 74229fc665e6c3f4401905c1a454ea57c8931739d05a074fd60400f19684d680a9e1305c25f13613dcc6cdd6e6e57d0800000000000000000000000000000000", 22 | "bench_name": "evm384-synth-loop-v1" 23 | }, 24 | { 25 | "command": "/root/evmone-evm384-v2/build/bin/evmone-bench --benchmark_format=json --benchmark_color=false --benchmark_min_time=5 /root/evm384_f6m_mul/build/v2-f6m_mul_bench.bin 00 74229fc665e6c3f4401905c1a454ea57c8931739d05a074fd60400f19684d680a9e1305c25f13613dcc6cdd6e6e57d0800000000000000000000000000000000", 26 | "bench_name": "evm384-synth-loop-v2" 27 | }, 28 | { 29 | "command": "/root/evmone-evm384-v2-unsafe/build/bin/evmone-bench --benchmark_format=json --benchmark_color=false --benchmark_min_time=5 /root/mem-check-disable-evm384_f6m_mul/build/v2-f6m_mul_bench.bin 00 74229fc665e6c3f4401905c1a454ea57c8931739d05a074fd60400f19684d680a9e1305c25f13613dcc6cdd6e6e57d0800000000000000000000000000000000", 30 | "bench_name": "evm384-synth-loop-v3" 31 | } 32 | ] 33 | 34 | 35 | """ 36 | root@472ab2fd1fc1:~/evm384_f6m_mul# /root/evmone-evm384-v2/build/bin/evmone-bench ~/evm384_f6m_mul/build/v2-f6m_mul_bench.bin "00" "74229fc665e6c3f4401905c1a454ea57c8931739d05a074fd60400f19684d680a9e1305c25f13613dcc6cdd6e6e57d0800000000000000000000000000000000" 37 | Benchmarking evmone 38 | 39 | 2020-06-18 20:52:56 40 | Running /root/evmone-evm384-v2/build/bin/evmone-bench 41 | Run on (4 X 2294.68 MHz CPU s) 42 | CPU Caches: 43 | L1 Data 32K (x2) 44 | L1 Instruction 32K (x2) 45 | L2 Unified 256K (x2) 46 | L3 Unified 51200K (x2) 47 | ------------------------------------------------------------------------------------------------------- 48 | Benchmark Time CPU Iterations UserCounters... 49 | ------------------------------------------------------------------------------------------------------- 50 | /root/evm384_f6m_mul/build/v2-f6m_mul_bench.bin 18156 us 18156 us 39 gas_rate=322.266M/s gas_used=5.85118M 51 | """ 52 | 53 | 54 | def do_evmone_bench(evmone_bench_cmd): 55 | evmone_cmd = shlex.split(evmone_bench_cmd) 56 | print("running evmone benchmark...\n{}".format(evmone_bench_cmd)) 57 | 58 | stdoutlines = [] 59 | with subprocess.Popen(evmone_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) as p: 60 | for line in p.stdout: # b'\n'-separated lines 61 | print(line, end='') 62 | stdoutlines.append(line) # pass bytes as is 63 | p.wait() 64 | 65 | json_result = json.loads("".join(stdoutlines[2:])) 66 | benchmarks = json_result['benchmarks'] 67 | benchmark_results = benchmarks[0] 68 | gasused = int(benchmark_results['gas_used']) 69 | total_time = str(benchmark_results['real_time']) + benchmark_results['time_unit'] 70 | time = durationpy.from_str(total_time) 71 | return {'gas_used': gasused, 'time': time.total_seconds()} 72 | 73 | 74 | def saveResults(precompile_benchmarks): 75 | # move existing csv file to backup-datetime-folder 76 | ts = time.time() 77 | date_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 78 | ts_folder_name = "backup-{}-{}".format(date_str, round(ts)) 79 | dest_backup_path = os.path.join(RESULT_CSV_OUTPUT_PATH, ts_folder_name) 80 | result_file = "{}/{}".format(RESULT_CSV_OUTPUT_PATH, RESULT_CSV_FILENAME) 81 | 82 | # back up existing result csv file 83 | if os.path.isfile(result_file): 84 | os.makedirs(dest_backup_path) 85 | shutil.move(result_file, dest_backup_path) 86 | print("existing {} moved to {}".format(RESULT_CSV_FILENAME, dest_backup_path)) 87 | 88 | with open(result_file, 'w', newline='') as bench_result_file: 89 | fieldnames = ['engine', 'test_name', 'total_time', 'gas_used'] 90 | writer = csv.DictWriter(bench_result_file, fieldnames=fieldnames) 91 | writer.writeheader() 92 | for test_result in precompile_benchmarks: 93 | writer.writerow({"engine": test_result['engine'], "test_name" : test_result['bench_name'], "gas_used" : test_result['gas_used'], "total_time" : test_result['time']}) 94 | 95 | 96 | 97 | def main(): 98 | all_bench_resuls = [] 99 | for evmone_bench_info in EVMONE_BENCH_INFOS: 100 | evmone_cmd = evmone_bench_info['command'] 101 | bench_result = do_evmone_bench(evmone_cmd) 102 | bench_result['bench_name'] = evmone_bench_info['bench_name'] 103 | bench_result['engine'] = "evmone384" 104 | all_bench_resuls.append(bench_result) 105 | 106 | saveResults(all_bench_resuls) 107 | 108 | 109 | if __name__ == "__main__": 110 | main() 111 | -------------------------------------------------------------------------------- /evm/scripts/benchgethprecompiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import re 4 | import subprocess 5 | import nanodurationpy as durationpy 6 | import csv 7 | import time 8 | import datetime 9 | import os 10 | import shutil 11 | import shlex 12 | 13 | # output paths should be mounted docker volumes 14 | RESULT_CSV_OUTPUT_PATH = "/benchmark_results_data" 15 | 16 | RESULT_CSV_FILENAME = "geth_precompile_benchmarks.csv" 17 | 18 | GO_PRECOMPILE_BENCH_CMD = "go test -timeout 900s -bench BenchmarkPrecompiled -benchtime 10s" 19 | GO_DIR = "/go-ethereum/core/vm/" 20 | 21 | 22 | """ 23 | $ go test -bench BenchmarkPrecompiled -benchtime 5s 24 | goos: linux 25 | goarch: amd64 26 | pkg: github.com/ethereum/go-ethereum/core/vm 27 | BenchmarkPrecompiledEcrecover/-Gas=3000-2 50000 159077 ns/op 28 | BenchmarkPrecompiledSha256/128-Gas=108-2 10000000 639 ns/op 29 | BenchmarkPrecompiledRipeMD/128-Gas=1080-2 3000000 2030 ns/op 30 | BenchmarkPrecompiledIdentity/128-Gas=27-2 500000000 17.2 ns/op 31 | BenchmarkPrecompiledModExp/eip_example1-Gas=13056-2 200000 34735 ns/op 32 | BenchmarkPrecompiledModExp/eip_example2-Gas=13056-2 1000000 7713 ns/op 33 | BenchmarkPrecompiledModExp/nagydani-1-square-Gas=204-2 3000000 2590 ns/op 34 | BenchmarkPrecompiledModExp/nagydani-1-qube-Gas=204-2 2000000 3357 ns/op 35 | BenchmarkPrecompiledModExp/nagydani-1-pow0x10001-Gas=3276-2 500000 13991 ns/op 36 | BenchmarkPrecompiledModExp/nagydani-2-square-Gas=665-2 2000000 4215 ns/op 37 | BenchmarkPrecompiledModExp/nagydani-2-qube-Gas=665-2 1000000 6248 ns/op 38 | BenchmarkPrecompiledModExp/nagydani-2-pow0x10001-Gas=10649-2 200000 31272 ns/op 39 | BenchmarkPrecompiledModExp/nagydani-3-square-Gas=1894-2 1000000 7558 ns/op 40 | BenchmarkPrecompiledModExp/nagydani-3-qube-Gas=1894-2 500000 12706 ns/op 41 | BenchmarkPrecompiledModExp/nagydani-3-pow0x10001-Gas=30310-2 100000 78718 ns/op 42 | BenchmarkPrecompiledModExp/nagydani-4-square-Gas=5580-2 500000 18090 ns/op 43 | BenchmarkPrecompiledModExp/nagydani-4-qube-Gas=5580-2 200000 36116 ns/op 44 | BenchmarkPrecompiledModExp/nagydani-4-pow0x10001-Gas=89292-2 30000 207740 ns/op 45 | BenchmarkPrecompiledModExp/nagydani-5-square-Gas=17868-2 200000 45934 ns/op 46 | BenchmarkPrecompiledModExp/nagydani-5-qube-Gas=17868-2 100000 99434 ns/op 47 | BenchmarkPrecompiledModExp/nagydani-5-pow0x10001-Gas=285900-2 10000 659933 ns/op 48 | BenchmarkPrecompiledBn256Add/chfast1-Gas=500-2 500000 14068 ns/op 49 | BenchmarkPrecompiledBn256Add/chfast2-Gas=500-2 500000 14136 ns/op 50 | BenchmarkPrecompiledBn256Add/cdetrio1-Gas=500-2 10000000 1032 ns/op 51 | BenchmarkPrecompiledBn256Add/cdetrio2-Gas=500-2 10000000 1110 ns/op 52 | BenchmarkPrecompiledBn256Add/cdetrio3-Gas=500-2 5000000 1189 ns/op 53 | BenchmarkPrecompiledBn256Add/cdetrio4-Gas=500-2 10000000 1135 ns/op 54 | BenchmarkPrecompiledBn256Add/cdetrio5-Gas=500-2 10000000 1199 ns/op 55 | BenchmarkPrecompiledBn256Add/cdetrio6-Gas=500-2 5000000 1417 ns/op 56 | BenchmarkPrecompiledBn256Add/cdetrio7-Gas=500-2 5000000 1495 ns/op 57 | BenchmarkPrecompiledBn256Add/cdetrio8-Gas=500-2 5000000 1552 ns/op 58 | BenchmarkPrecompiledBn256Add/cdetrio9-Gas=500-2 5000000 1611 ns/op 59 | BenchmarkPrecompiledBn256Add/cdetrio10-Gas=500-2 5000000 1440 ns/op 60 | BenchmarkPrecompiledBn256Add/cdetrio11-Gas=500-2 500000 14456 ns/op 61 | BenchmarkPrecompiledBn256Add/cdetrio12-Gas=500-2 500000 14485 ns/op 62 | BenchmarkPrecompiledBn256Add/cdetrio13-Gas=500-2 500000 14315 ns/op 63 | BenchmarkPrecompiledBn256Add/cdetrio14-Gas=500-2 3000000 2164 ns/op 64 | BenchmarkPrecompiledBn256ScalarMul/chfast1-Gas=40000-2 100000 97875 ns/op 65 | BenchmarkPrecompiledBn256ScalarMul/chfast2-Gas=40000-2 100000 105280 ns/op 66 | BenchmarkPrecompiledBn256ScalarMul/chfast3-Gas=40000-2 100000 101911 ns/op 67 | BenchmarkPrecompiledBn256ScalarMul/cdetrio1-Gas=40000-2 100000 108458 ns/op 68 | BenchmarkPrecompiledBn256ScalarMul/cdetrio6-Gas=40000-2 100000 107855 ns/op 69 | BenchmarkPrecompiledBn256ScalarMul/cdetrio11-Gas=40000-2 100000 108114 ns/op 70 | BenchmarkPrecompiledBn256Pairing/jeff1-Gas=260000-2 2000 3259099 ns/op 71 | BenchmarkPrecompiledBn256Pairing/jeff2-Gas=260000-2 2000 3203017 ns/op 72 | BenchmarkPrecompiledBn256Pairing/jeff3-Gas=260000-2 2000 3230769 ns/op 73 | BenchmarkPrecompiledBn256Pairing/jeff4-Gas=340000-2 2000 4320089 ns/op 74 | BenchmarkPrecompiledBn256Pairing/jeff5-Gas=340000-2 2000 4314707 ns/op 75 | BenchmarkPrecompiledBn256Pairing/jeff6-Gas=260000-2 2000 3250827 ns/op 76 | BenchmarkPrecompiledBn256Pairing/empty_data-Gas=100000-2 10000 1027267 ns/op 77 | BenchmarkPrecompiledBn256Pairing/one_point-Gas=180000-2 3000 2130905 ns/op 78 | BenchmarkPrecompiledBn256Pairing/two_point_match_2-Gas=260000-2 2000 3183844 ns/op 79 | BenchmarkPrecompiledBn256Pairing/two_point_match_3-Gas=260000-2 2000 3181564 ns/op 80 | BenchmarkPrecompiledBn256Pairing/two_point_match_4-Gas=260000-2 2000 3222494 ns/op 81 | BenchmarkPrecompiledBn256Pairing/ten_point_match_1-Gas=900000-2 1000 11762181 ns/op 82 | BenchmarkPrecompiledBn256Pairing/ten_point_match_2-Gas=900000-2 1000 11861035 ns/op 83 | BenchmarkPrecompiledBn256Pairing/ten_point_match_3-Gas=260000-2 2000 3186670 ns/op 84 | PASS 85 | ok github.com/ethereum/go-ethereum/core/vm 510.099s 86 | """ 87 | 88 | def do_go_precompile_bench(): 89 | go_cmd = shlex.split(GO_PRECOMPILE_BENCH_CMD) 90 | print("running go precompile benchmarks...\n{}".format(GO_PRECOMPILE_BENCH_CMD)) 91 | 92 | raw_stdoutlines = [] 93 | with subprocess.Popen(go_cmd, cwd=GO_DIR, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) as p: 94 | for line in p.stdout: # b'\n'-separated lines 95 | print(line, end='') 96 | raw_stdoutlines.append(line) # pass bytes as is 97 | p.wait() 98 | 99 | #stdoutlines = [line.decode('utf8') for line in raw_stdoutlines] 100 | # line.decode('utf8') crashes python. AttributeError: 'str' object has no attribute 'decode' 101 | print("process done. got stdout:", raw_stdoutlines) 102 | return raw_stdoutlines 103 | 104 | # parsing code from https://github.com/ethereum/benchmarking/blob/master/constantinople/scripts/postprocess_geth_v2.py 105 | def parse_go_bench_output(stdoutlines): 106 | benchRegex = "Benchmark(Precompiled.*)-Gas=([\d]+)\S+\s+\d+\s+([\d\.]+) ns\/op" 107 | #opRegexp = re.compile("Benchmark(Op.*)\S+\s+\d+\s+([\d\.]+) ns\/op") 108 | 109 | bench_tests = [] 110 | for line in stdoutlines: 111 | match = re.search(benchRegex, line) 112 | if match: 113 | (name, gas, nanosecs) = (match.group(1), match.group(2), match.group(3)) 114 | bench_time = durationpy.from_str("{}ns".format(nanosecs)) 115 | bench_tests.append({'name': name, 'gas': gas, 'time': bench_time.total_seconds()}) 116 | 117 | return bench_tests 118 | 119 | 120 | def saveResults(precompile_benchmarks): 121 | # move existing csv file to backup-datetime-folder 122 | ts = time.time() 123 | date_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 124 | ts_folder_name = "backup-{}-{}".format(date_str, round(ts)) 125 | dest_backup_path = os.path.join(RESULT_CSV_OUTPUT_PATH, ts_folder_name) 126 | result_file = "{}/{}".format(RESULT_CSV_OUTPUT_PATH, RESULT_CSV_FILENAME) 127 | 128 | # back up existing result csv file 129 | if os.path.isfile(result_file): 130 | os.makedirs(dest_backup_path) 131 | shutil.move(result_file, dest_backup_path) 132 | print("existing {} moved to {}".format(RESULT_CSV_FILENAME, dest_backup_path)) 133 | 134 | with open(result_file, 'w', newline='') as bench_result_file: 135 | fieldnames = ['test_name', 'gas', 'time'] 136 | writer = csv.DictWriter(bench_result_file, fieldnames=fieldnames) 137 | writer.writeheader() 138 | for test_result in precompile_benchmarks: 139 | writer.writerow({"test_name" : test_result['name'], "gas" : test_result['gas'], "time" : test_result['time']}) 140 | 141 | def main(): 142 | bench_output = do_go_precompile_bench() 143 | bench_results = parse_go_bench_output(bench_output) 144 | print("got precompile benchmarks:", bench_results) 145 | 146 | # TODO: bench parity precompiles 147 | 148 | saveResults(bench_results) 149 | 150 | 151 | if __name__ == "__main__": 152 | main() 153 | -------------------------------------------------------------------------------- /evm/scripts/benchparityprecompiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import re 4 | import subprocess 5 | import nanodurationpy as durationpy 6 | import csv 7 | import time 8 | import datetime 9 | import os 10 | import shutil 11 | import shlex 12 | 13 | # output paths should be mounted docker volumes 14 | RESULT_CSV_OUTPUT_PATH = "/benchmark_results_data" 15 | 16 | RESULT_CSV_FILENAME = "parity_precompile_benchmarks.csv" 17 | 18 | PARITY_DIR = "/parity" 19 | 20 | PARITY_PRECOMPILE_BENCH_CMD = "cargo bench --package ethcore --color never" 21 | 22 | 23 | 24 | """ 25 | Benchmarking modexp_nagydani_4_square 26 | Benchmarking modexp_nagydani_4_square: Warming up for 3.0000 s 27 | Benchmarking modexp_nagydani_4_square: Collecting 100 samples in estimated 5.3360 s (71k iterations) 28 | Benchmarking modexp_nagydani_4_square: Analyzing 29 | modexp_nagydani_4_square 30 | time: [74.530 us 75.376 us 76.310 us] 31 | change: [-4.2962% -1.7062% +0.7488%] (p = 0.20 > 0.05) 32 | No change in performance detected. 33 | Found 7 outliers among 100 measurements (7.00%) 34 | 4 (4.00%) high mild 35 | 3 (3.00%) high severe 36 | 37 | Benchmarking modexp_nagydani_4_qube 38 | Benchmarking modexp_nagydani_4_qube: Warming up for 3.0000 s 39 | Benchmarking modexp_nagydani_4_qube: Collecting 100 samples in estimated 5.1062 s (35k iterations) 40 | Benchmarking modexp_nagydani_4_qube: Analyzing 41 | modexp_nagydani_4_qube time: [145.48 us 147.36 us 149.49 us] 42 | change: [-3.3057% -0.8724% +1.4027%] (p = 0.49 > 0.05) 43 | No change in performance detected. 44 | Found 1 outliers among 100 measurements (1.00%) 45 | 1 (1.00%) high mild 46 | 47 | Benchmarking modexp_nagydani_4_pow0x10001 48 | Benchmarking modexp_nagydani_4_pow0x10001: Warming up for 3.0000 s 49 | Benchmarking modexp_nagydani_4_pow0x10001: Collecting 100 samples in estimated 6.0989 s (5050 iterations) 50 | Benchmarking modexp_nagydani_4_pow0x10001: Analyzing 51 | modexp_nagydani_4_pow0x10001 52 | time: [1.2012 ms 1.2129 ms 1.2260 ms] 53 | change: [-0.8848% +0.7336% +2.5488%] (p = 0.41 > 0.05) 54 | No change in performance detected. 55 | Found 3 outliers among 100 measurements (3.00%) 56 | 2 (2.00%) high mild 57 | 1 (1.00%) high severe 58 | """ 59 | 60 | def parse_parity_bench_output(stdoutlines): 61 | nameRegex = "Benchmarking (\w+): Warming up for" 62 | timeRegex = "time:\s+\[[\d\.]+\s+\w+\s+([\d\.]+\s+\w+)" 63 | 64 | # first match test name 65 | # then match time, then append result and wait for next test name 66 | bench_tests = [] 67 | test_name = "" 68 | bench_time = None 69 | for line in stdoutlines: 70 | matchName = re.search(nameRegex, line) 71 | if matchName: 72 | test_name = matchName.group(1) 73 | bench_time = None 74 | 75 | matchTime = re.search(timeRegex, line) 76 | if matchTime: 77 | bench_time = matchTime.group(1) 78 | bench_time = bench_time.replace(" ", "") # "1.2129 ms" -> "1.2129ms" 79 | 80 | if bench_time is not None and test_name != "": 81 | bench_time = durationpy.from_str(bench_time) 82 | bench_tests.append({'name': test_name, 'gas': 0, 'time': bench_time.total_seconds()}) 83 | print("parsed test result:", bench_tests[-1]) 84 | bench_time = 0 85 | test_name = "" 86 | 87 | return bench_tests 88 | 89 | 90 | def do_parity_precompile_bench(): 91 | # TODO: running `cargo bench` for the first time generates a lot of compiler output. 92 | # should we do anything to handle that? 93 | parity_cmd = shlex.split(PARITY_PRECOMPILE_BENCH_CMD) 94 | print("running parity precompile benchmarks...\n{}".format(PARITY_PRECOMPILE_BENCH_CMD)) 95 | 96 | raw_stdoutlines = [] 97 | with subprocess.Popen(parity_cmd, cwd=PARITY_DIR, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True) as p: 98 | for line in p.stdout: # b'\n'-separated lines 99 | print(line, end='') 100 | raw_stdoutlines.append(line) # pass bytes as is 101 | p.wait() 102 | 103 | print("process done. got stdout:", raw_stdoutlines) 104 | return raw_stdoutlines 105 | 106 | 107 | def saveResults(precompile_benchmarks): 108 | result_file = os.path.join(RESULT_CSV_OUTPUT_PATH, RESULT_CSV_FILENAME) 109 | 110 | # back up existing result csv file 111 | if os.path.isfile(result_file): 112 | ts = time.time() 113 | date_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 114 | ts_folder_name = "backup-{}-{}".format(date_str, round(ts)) 115 | dest_backup_path = os.path.join(RESULT_CSV_OUTPUT_PATH, ts_folder_name) 116 | os.makedirs(dest_backup_path) 117 | shutil.move(result_file, dest_backup_path) 118 | print("existing {} moved to {}".format(RESULT_CSV_FILENAME, dest_backup_path)) 119 | 120 | with open(result_file, 'w', newline='') as bench_result_file: 121 | fieldnames = ['test_name', 'gas', 'time'] 122 | writer = csv.DictWriter(bench_result_file, fieldnames=fieldnames) 123 | writer.writeheader() 124 | for test_result in precompile_benchmarks: 125 | writer.writerow({"test_name" : test_result['name'], "gas" : test_result['gas'], "time" : test_result['time']}) 126 | 127 | 128 | def main(): 129 | bench_output = do_parity_precompile_bench() 130 | bench_results = parse_parity_bench_output(bench_output) 131 | print("got parity precompile benchmarks:", bench_results) 132 | 133 | ## TODO: bench parity precompiles 134 | 135 | saveResults(bench_results) 136 | 137 | 138 | if __name__ == "__main__": 139 | main() 140 | -------------------------------------------------------------------------------- /evm/scripts/merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import csv 4 | import os 5 | import time 6 | import datetime 7 | import shutil 8 | 9 | INDIVIDUAL_EVM_RESULTS_CSV_PATH = "/evmraceresults/" 10 | RESULT_CSV_OUTPUT_PATH = "/benchmark_results_data/" 11 | EVMS = ["evmone", "parity", "geth", "cita-vm", "evmone384"] 12 | RESULT_CSV_FILENAME = "evm_benchmarks.csv" 13 | RESULT_FILE = os.path.join(RESULT_CSV_OUTPUT_PATH, RESULT_CSV_FILENAME) 14 | 15 | # translate a string representing a numerical field like '1.8M' to '1800000' 16 | def format_evmone_benchmark(csv_line): 17 | fields = csv_line.split(',') 18 | gas_used = fields[-1] 19 | 20 | if gas_used[-1].lower() == 'k': 21 | gas_used = str(int(float(gas_used[:-1]) * 1000)) 22 | elif gas_used[-1].lower() == 'm': 23 | gas_used = str(int(float(gas_used[:-1]) * 1000000)) 24 | else: 25 | return csv_line 26 | 27 | return ','.join(fields[:-1] + [gas_used])[:-1] 28 | 29 | # merge benchmarks from multiple engines into one csv output 30 | def main(): 31 | merged_csv_contents = 'engine, test_name, total_time, gas_used\n' 32 | evm_results = [] 33 | 34 | for evm in EVMS: 35 | path = os.path.join(INDIVIDUAL_EVM_RESULTS_CSV_PATH, "evm_benchmarks_{}.csv".format(evm)) 36 | data_file = open(path, 'r') 37 | data = data_file.read().splitlines() 38 | data_file.close() 39 | evm_results.append(data) 40 | 41 | for e in range(0, len(EVMS)): 42 | for i in range(0, len(evm_results[e])): 43 | if EVMS[e] == 'evmone' or EVMS[e] == 'evmone384': 44 | merged_csv_contents += format_evmone_benchmark(evm_results[e][i]) + '\n' 45 | else: 46 | merged_csv_contents += evm_results[e][i] + '\n' 47 | 48 | 49 | # move existing csv file to backup-datetime-folder 50 | ts = time.time() 51 | date_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 52 | ts_folder_name = "backup-{}-{}".format(date_str, round(ts)) 53 | dest_backup_path = os.path.join(RESULT_CSV_OUTPUT_PATH, ts_folder_name) 54 | 55 | # back up existing result csv file 56 | if os.path.isfile(RESULT_FILE): 57 | os.makedirs(dest_backup_path) 58 | shutil.move(RESULT_FILE, dest_backup_path) 59 | print("existing {} moved to {}".format(RESULT_CSV_FILENAME, dest_backup_path)) 60 | 61 | with open(RESULT_FILE, 'w') as bench_result_file: 62 | bench_result_file.write(merged_csv_contents) 63 | 64 | print("saved evm results to:", RESULT_FILE) 65 | 66 | 67 | if __name__ == "__main__": 68 | main() 69 | -------------------------------------------------------------------------------- /evm/scripts/nanodurationpy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | 3 | # originally from https://github.com/icholy/durationpy/blob/master/durationpy/duration.py 4 | 5 | import re 6 | import datetime 7 | import pandas 8 | 9 | _nanosecond_size = 1 10 | _microsecond_size = 1000 * _nanosecond_size 11 | _millisecond_size = 1000 * _microsecond_size 12 | _second_size = 1000 * _millisecond_size 13 | _minute_size = 60 * _second_size 14 | _hour_size = 60 * _minute_size 15 | _day_size = 24 * _hour_size 16 | _week_size = 7 * _day_size 17 | _month_size = 30 * _day_size 18 | _year_size = 365 * _day_size 19 | 20 | units = { 21 | "ns": _nanosecond_size, 22 | "us": _microsecond_size, 23 | "µs": _microsecond_size, 24 | "μs": _microsecond_size, 25 | "ms": _millisecond_size, 26 | "s": _second_size, 27 | "m": _minute_size, 28 | "h": _hour_size, 29 | "d": _day_size, 30 | "w": _week_size, 31 | "mm": _month_size, 32 | "y": _year_size, 33 | } 34 | 35 | 36 | def from_str(duration): 37 | """Parse a duration string to a datetime.timedelta""" 38 | 39 | if duration in ("0", "+0", "-0"): 40 | return datetime.timedelta() 41 | 42 | pattern = re.compile('([\d\.]+)([a-zµμ]+)') 43 | total = 0 44 | sign = -1 if duration[0] == '-' else 1 45 | matches = pattern.findall(duration) 46 | 47 | if not len(matches): 48 | raise Exception("Invalid duration {}".format(duration)) 49 | 50 | for (value, unit) in matches: 51 | if unit not in units: 52 | raise Exception( 53 | "Unknown unit {} in duration {}".format(unit, duration)) 54 | try: 55 | total += float(value) * units[unit] 56 | except: 57 | raise Exception( 58 | "Invalid value {} in duration {}".format(value, duration)) 59 | 60 | #microseconds = total / _microsecond_size 61 | nanoseconds = int(total) 62 | return pandas.Timedelta(nanoseconds=sign * nanoseconds) 63 | -------------------------------------------------------------------------------- /evm/scripts/run_bench.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Run evmone benchmarks 6 | docker run --env PYTHONIOENCODING=UTF-8 -v $(pwd)/evmraceresults:/evmraceresults -v $(pwd)/scripts:/scripts -v $(pwd)/input_data:/input_data -it ewasm/evmone-bench:1 /usr/bin/python3 /scripts/benchevm.py evmone 7 | 8 | # Run Parity benchmarks 9 | docker run --env PYTHONIOENCODING=UTF-8 -v $(pwd)/evmraceresults:/evmraceresults -v $(pwd)/scripts:/scripts -v $(pwd)/input_data:/input_data -it ewasm/parity-bench:1 /usr/bin/python3 /scripts/benchevm.py parity 10 | 11 | # Run Geth benchmarks 12 | docker run --env PYTHONIOENCODING=UTF-8 -v $(pwd)/evmraceresults:/evmraceresults -v $(pwd)/scripts:/scripts -v $(pwd)/input_data:/input_data -it ewasm/geth-bench:1 /usr/bin/python3 /scripts/benchevm.py geth 13 | 14 | # Run cita-vm benchmarks 15 | docker run --env PYTHONIOENCODING=UTF-8 -v $(pwd)/evmraceresults:/evmraceresults -v $(pwd)/scripts:/scripts -v $(pwd)/input_data:/input_data -it ewasm/cita-vm-bench:1 /usr/bin/python3 /scripts/benchevm.py cita-vm 16 | 17 | # Run evmone384 benchmarks 18 | docker run --env PYTHONIOENCODING=UTF-8 -v $(pwd)/evmraceresults:/evmraceresults -v $(pwd)/scripts:/scripts -it ewasm/evmone-evm384-bench:1 /usr/bin/python3 /scripts/bench_evm384.py 19 | 20 | # Merge benchmarks 21 | # TODO: just use python for merging? the docker image is only used to run python. 22 | docker run --env PYTHONIOENCODING=UTF-8 -v $(pwd)/../benchmark_results_data:/benchmark_results_data -v $(pwd)/evmraceresults:/evmraceresults -v $(pwd)/scripts:/scripts -it ewasm/cita-vm-bench:1 /usr/bin/python3 /scripts/merge.py 23 | 24 | -------------------------------------------------------------------------------- /images/bignums-bls12-pairings-fizzy-vs-wabt-exec-startup-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-pairings-fizzy-vs-wabt-exec-startup-time.png -------------------------------------------------------------------------------- /images/bignums-bls12-pairings-host-func-variations-exec-startup-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-pairings-host-func-variations-exec-startup-time.png -------------------------------------------------------------------------------- /images/bignums-bls12-pairings-host-func-variations-total-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-pairings-host-func-variations-total-time.png -------------------------------------------------------------------------------- /images/bignums-bls12-pairings-rust-vs-wasm-exec-startup-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-pairings-rust-vs-wasm-exec-startup-time.png -------------------------------------------------------------------------------- /images/bignums-bls12-pairings-rust-vs-wasm-total-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-pairings-rust-vs-wasm-total-time.png -------------------------------------------------------------------------------- /images/bignums-bls12-pairings-wabt-vs-native-exec-startup-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-pairings-wabt-vs-native-exec-startup-time.png -------------------------------------------------------------------------------- /images/bignums-bls12-synth-loop-fizzy-vs-wabt-exec-startup-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-bls12-synth-loop-fizzy-vs-wabt-exec-startup-time.png -------------------------------------------------------------------------------- /images/bignums-rollup-rs-bn128-pairings-all-combos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-rollup-rs-bn128-pairings-all-combos.png -------------------------------------------------------------------------------- /images/bignums-rollup-rs-bn128-pairings-superops.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-rollup-rs-bn128-pairings-superops.png -------------------------------------------------------------------------------- /images/bignums-rollup-rs-bn128-pairings-wabt-with-bignums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-rollup-rs-bn128-pairings-wabt-with-bignums.png -------------------------------------------------------------------------------- /images/bignums-rollup-rs-bn128-pairings-with-vs-without-bignums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-rollup-rs-bn128-pairings-with-vs-without-bignums.png -------------------------------------------------------------------------------- /images/bignums-websnark-bn128-pairings-fasthost.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-websnark-bn128-pairings-fasthost.png -------------------------------------------------------------------------------- /images/bignums-websnark-bn128-pairings-fastmont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-websnark-bn128-pairings-fastmont.png -------------------------------------------------------------------------------- /images/bignums-websnark-bn128-pairings-startup-and-execution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-websnark-bn128-pairings-startup-and-execution.png -------------------------------------------------------------------------------- /images/bignums-websnark-bn128-pairings-superops.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-websnark-bn128-pairings-superops.png -------------------------------------------------------------------------------- /images/bignums-websnark-bn128-pairings-v8-with-bignums.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-websnark-bn128-pairings-v8-with-bignums.png -------------------------------------------------------------------------------- /images/bignums-zkrollup-rust-vs-websnark-bn128-pairings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/bignums-zkrollup-rust-vs-websnark-bn128-pairings.png -------------------------------------------------------------------------------- /images/evm-vs-wasm-blake2b-huff-rust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm-vs-wasm-blake2b-huff-rust.png -------------------------------------------------------------------------------- /images/evm-vs-wasm-blake2b-huff-sol-rust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm-vs-wasm-blake2b-huff-sol-rust.png -------------------------------------------------------------------------------- /images/evm-vs-wasm-blake2b-sol-huff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm-vs-wasm-blake2b-sol-huff.png -------------------------------------------------------------------------------- /images/evm-vs-wasm-blake2b-sol-rust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm-vs-wasm-blake2b-sol-rust.png -------------------------------------------------------------------------------- /images/evm-vs-wasm-bn128mul-huff-rust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm-vs-wasm-bn128mul-huff-rust.png -------------------------------------------------------------------------------- /images/evm-vs-wasm-mul256-sol-rust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm-vs-wasm-mul256-sol-rust.png -------------------------------------------------------------------------------- /images/evm384-bls12-pairings-synth-loop-rust-wasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-bls12-pairings-synth-loop-rust-wasm.png -------------------------------------------------------------------------------- /images/evm384-bls12-synth-loop-vs-native-rust.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-bls12-synth-loop-vs-native-rust.png -------------------------------------------------------------------------------- /images/evm384-bls12-synth-loop-vs-pairings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-bls12-synth-loop-vs-pairings.png -------------------------------------------------------------------------------- /images/evm384-bls12-synth-loop-wasm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-bls12-synth-loop-wasm.png -------------------------------------------------------------------------------- /images/evm384-synth-loop-v1-v2-v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-synth-loop-v1-v2-v3.png -------------------------------------------------------------------------------- /images/evm384-wasm-native-pairings-and-synth-loop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-wasm-native-pairings-and-synth-loop.png -------------------------------------------------------------------------------- /images/evm384-wasm-native-pairings-vs-adjusted-synth-loop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-wasm-native-pairings-vs-adjusted-synth-loop.png -------------------------------------------------------------------------------- /images/evm384-wasm-pairings-vs-synth-loop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/evm384-wasm-pairings-vs-synth-loop.png -------------------------------------------------------------------------------- /images/scout-biturbo-token-all-engines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-biturbo-token-all-engines.png -------------------------------------------------------------------------------- /images/scout-biturbo-token-compilers-vs-interpreters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-biturbo-token-compilers-vs-interpreters.png -------------------------------------------------------------------------------- /images/scout-daiquiri-all-engines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-daiquiri-all-engines.png -------------------------------------------------------------------------------- /images/scout-daiquiri-v8-vs-wabt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-daiquiri-v8-vs-wabt.png -------------------------------------------------------------------------------- /images/scout-ecpairing-zkrollup-rust-wasm-bn128-two-pairings-all-engines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-ecpairing-zkrollup-rust-wasm-bn128-two-pairings-all-engines.png -------------------------------------------------------------------------------- /images/scout-ecpairing-zkrollup-rust-wasm-bn128-two-pairings-v8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-ecpairing-zkrollup-rust-wasm-bn128-two-pairings-v8.png -------------------------------------------------------------------------------- /images/scout-ecpairing-zkrollup-websnark-bn128-two-pairings-all-engines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-ecpairing-zkrollup-websnark-bn128-two-pairings-all-engines.png -------------------------------------------------------------------------------- /images/scout-ecpairing-zkrollup-websnark-bn128-two-pairings-v8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-ecpairing-zkrollup-websnark-bn128-two-pairings-v8.png -------------------------------------------------------------------------------- /images/scout-ecrecover-websnark-secp256k1-verify-72-sigs-all-engines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-ecrecover-websnark-secp256k1-verify-72-sigs-all-engines.png -------------------------------------------------------------------------------- /images/scout-ecrecover-websnark-secp256k1-verify-72-sigs-wabt-vs-v8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/scout-ecrecover-websnark-secp256k1-verify-72-sigs-wabt-vs-v8.png -------------------------------------------------------------------------------- /images/standalone-blake2b-8415-bytes-compilers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-blake2b-8415-bytes-compilers.png -------------------------------------------------------------------------------- /images/standalone-bls12-381-aggreg-128-pubkeys-verify-sig-compilers-vs-native.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-bls12-381-aggreg-128-pubkeys-verify-sig-compilers-vs-native.png -------------------------------------------------------------------------------- /images/standalone-jitbomb-guido-fuzzer-find-1-log-scale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-jitbomb-guido-fuzzer-find-1-log-scale.png -------------------------------------------------------------------------------- /images/standalone-jitbomb-guido-fuzzer-find-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-jitbomb-guido-fuzzer-find-1.png -------------------------------------------------------------------------------- /images/standalone-jitbomb-guido-fuzzer-find-2-log-scale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-jitbomb-guido-fuzzer-find-2-log-scale.png -------------------------------------------------------------------------------- /images/standalone-rust-bn128-pairings-compiler-vs-native.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-rust-bn128-pairings-compiler-vs-native.png -------------------------------------------------------------------------------- /images/standalone-wabt-all-precompiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-wabt-all-precompiles.png -------------------------------------------------------------------------------- /images/standalone-wabt-vs-v8-liftoff-speedup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-wabt-vs-v8-liftoff-speedup.png -------------------------------------------------------------------------------- /images/standalone-wasm-interp-bn128-pairings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-wasm-interp-bn128-pairings.png -------------------------------------------------------------------------------- /images/standalone-wasmi-all-precompiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/standalone-wasmi-all-precompiles.png -------------------------------------------------------------------------------- /images/wasm-interp-blake2b-exec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-blake2b-exec.png -------------------------------------------------------------------------------- /images/wasm-interp-blake2b-fast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-blake2b-fast.png -------------------------------------------------------------------------------- /images/wasm-interp-blake2b-life-wagon-v8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-blake2b-life-wagon-v8.png -------------------------------------------------------------------------------- /images/wasm-interp-blake2b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-blake2b.png -------------------------------------------------------------------------------- /images/wasm-interp-bls12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-bls12.png -------------------------------------------------------------------------------- /images/wasm-interp-bn128-add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-bn128-add.png -------------------------------------------------------------------------------- /images/wasm-interp-modexp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/wasm-interp-modexp.png -------------------------------------------------------------------------------- /images/websnark-vs-native-bn128-two-pairings-v8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/websnark-vs-native-bn128-two-pairings-v8.png -------------------------------------------------------------------------------- /images/websnark-vs-rust-wasm-native-zkrollup-bn128-pairings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/websnark-vs-rust-wasm-native-zkrollup-bn128-pairings.png -------------------------------------------------------------------------------- /images/websnark-vs-rust-wasm-zkrollup-bn128-pairings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/images/websnark-vs-rust-wasm-zkrollup-bn128-pairings.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib==3.2.1 2 | pandas==1.0.3 3 | numpy==1.18.2 4 | durationpy==0.5 5 | adjusttext==0.7.3 6 | jupyter==1.0.0 7 | seaborn==0.10.1 8 | -------------------------------------------------------------------------------- /scout-engines/nanodurationpy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | 3 | # originally from https://github.com/icholy/durationpy/blob/master/durationpy/duration.py 4 | 5 | import re 6 | import datetime 7 | import pandas 8 | 9 | _nanosecond_size = 1 10 | _microsecond_size = 1000 * _nanosecond_size 11 | _millisecond_size = 1000 * _microsecond_size 12 | _second_size = 1000 * _millisecond_size 13 | _minute_size = 60 * _second_size 14 | _hour_size = 60 * _minute_size 15 | _day_size = 24 * _hour_size 16 | _week_size = 7 * _day_size 17 | _month_size = 30 * _day_size 18 | _year_size = 365 * _day_size 19 | 20 | units = { 21 | "ns": _nanosecond_size, 22 | "us": _microsecond_size, 23 | "µs": _microsecond_size, 24 | "μs": _microsecond_size, 25 | "ms": _millisecond_size, 26 | "s": _second_size, 27 | "m": _minute_size, 28 | "h": _hour_size, 29 | "d": _day_size, 30 | "w": _week_size, 31 | "mm": _month_size, 32 | "y": _year_size, 33 | } 34 | 35 | 36 | def from_str(duration): 37 | """Parse a duration string to a datetime.timedelta""" 38 | 39 | if duration in ("0", "+0", "-0"): 40 | return datetime.timedelta() 41 | 42 | pattern = re.compile('([\d\.]+)([a-zµμ]+)') 43 | total = 0 44 | sign = -1 if duration[0] == '-' else 1 45 | matches = pattern.findall(duration) 46 | 47 | if not len(matches): 48 | raise Exception("Invalid duration {}".format(duration)) 49 | 50 | for (value, unit) in matches: 51 | if unit not in units: 52 | raise Exception( 53 | "Unknown unit {} in duration {}".format(unit, duration)) 54 | try: 55 | total += float(value) * units[unit] 56 | except: 57 | raise Exception( 58 | "Invalid value {} in duration {}".format(value, duration)) 59 | 60 | #microseconds = total / _microsecond_size 61 | nanoseconds = int(total) 62 | return pandas.Timedelta(nanoseconds=sign * nanoseconds) 63 | -------------------------------------------------------------------------------- /scout-engines/run_benchmarks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker run --privileged \ 4 | -v $(pwd)/benchmark_results_data:/benchmark_results_data \ 5 | -v $(pwd)/nanodurationpy.py:/benchscript/nanodurationpy.py \ 6 | -v $(pwd)/scout_bignum_bench.py:/benchscript/scout_bignum_bench.py \ 7 | -it ewasm/scout-engines:1 python3 scout_bignum_bench.py 8 | -------------------------------------------------------------------------------- /wasm-engines/bench_wasm_and_native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # first compile standalone wasm files from rust code, and benchmark native rust 4 | # later, benchmark the standalone wasm files in all the wasm engines 5 | 6 | set -e 7 | 8 | # result output paths should be in mounted docker volumes 9 | CSV_NATIVE_RESULTS=/benchmark_results_data/native_benchmarks.csv 10 | CSV_WASM_RESULTS=/benchmark_results_data/standalone_wasm_results.csv 11 | 12 | # benchnativerust_prepwasm.py will use rust code templates and input vectors to 13 | # prepare standalone wasm files and native rust executables 14 | RUST_CODE_DIR=./rust-code 15 | INPUT_VECTORS_DIR=./inputvectors 16 | 17 | # benchnativerust_prepwasm.py will compile rust code to wasm and save them to WASM_FILE_DIR 18 | WASM_FILE_DIR=/wasmfiles 19 | 20 | # files in WASM_FILE_DIR will be minified, and outputted to WASM_MINIFIED_DIR 21 | # these files will be benchmarked in all the engines 22 | WASM_MINIFIED_DIR=/wasmfilesminified 23 | 24 | 25 | # save cpu info to a file, so we know what machine was used to run the benchmarks 26 | grep -E '^model name|^cpu MHz' /proc/cpuinfo > /benchmark_results_data/cpuinfo.txt 27 | 28 | 29 | # fill rust code templates with input vectors. compile rust code to wasm and native. benchmark native 30 | # wasm will be further processed and benchmarked later 31 | cd /benchprep 32 | python3.8 benchnativerust_prepwasm.py --wasmoutdir="${WASM_FILE_DIR}" --csvresults="${CSV_NATIVE_RESULTS}" --rustcodedir="${RUST_CODE_DIR}" --inputvectorsdir="${INPUT_VECTORS_DIR}" 33 | 34 | # furthur process wasm files by minifying them. 35 | 36 | echo "building sentinel-rs branch minify-tool..." 37 | # TODO: when wasm-chisel is ready, use it instead of sentinel-minify-tool 38 | cd /root 39 | rm -rf sentinel-minify-tool # delete old dir in case we are rerunning the script 40 | git clone --single-branch --branch minify-tool https://github.com/ewasm/sentinel-rs.git sentinel-minify-tool 41 | # .cargo/config sets default build target to wasm. we want to build x86 binary 42 | # and use the command line tool, so delete .cargo/config 43 | rm sentinel-minify-tool/.cargo/config 44 | cd sentinel-minify-tool/wasm-utils/cli 45 | cargo build --bin wasm-minify 46 | # built binary sentinel-rs/wasm-utils/target/debug/wasm-minify 47 | 48 | echo "minifying wasm files..." 49 | mkdir -p ${WASM_MINIFIED_DIR} 50 | cd "${WASM_FILE_DIR}" 51 | for filename in *.wasm 52 | do 53 | dest="${WASM_MINIFIED_DIR}/${filename}" 54 | /root/sentinel-minify-tool/wasm-utils/target/debug/wasm-minify "${filename}" "$dest" 55 | done 56 | 57 | echo "running benchmarks" 58 | cd /benchrunner 59 | python3.8 main.py --wasmdir="${WASM_MINIFIED_DIR}" --csvfile="${CSV_WASM_RESULTS}" 60 | chown -R 1000:1000 /benchrunner /benchprep /benchmark_results_data 61 | -------------------------------------------------------------------------------- /wasm-engines/benchmeteredstandalone.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | ## This is intended to benchmark standalone wasm files with injected metering 6 | # to measure the metering slowdown on wasm engines that aren't integrated into 7 | # ethereum clients. 8 | # Contrast with the `bench-ewasm` folder, which benches wasm files with injected 9 | # metering in wasm engines that are integrated into ethereum clients. 10 | 11 | # Standalone metering is always inline metering (obviously, because standalone 12 | # wasm files don't call any host functions, so they can't call a `useGas` host function). 13 | 14 | # first take dir of standalone wasm files, and inject standalone/inline metering on them 15 | 16 | #WASM_FILE_DIR=/wasmfiles 17 | 18 | WASM_FILE_DIR=/evmwasmfiles 19 | WASM_METERED_DIR=/evmwasmfilesmetered 20 | 21 | echo "building sentinel-rs branch inline-super-standalone..." 22 | cd /root 23 | git clone --single-branch --branch inline-super-standalone https://github.com/ewasm/sentinel-rs.git sentinel-inline-super-standalone 24 | # .cargo/config sets default build target to wasm 25 | rm sentinel-inline-super-standalone/.cargo/config 26 | cd sentinel-inline-super-standalone/wasm-utils/cli 27 | cargo build --bin wasm-gas 28 | # built binary sentinel-rs/wasm-utils/target/debug/wasm-gas 29 | 30 | echo "injecting metering into wasm files..." 31 | mkdir -p ${WASM_METERED_DIR} 32 | cd "${WASM_FILE_DIR}" 33 | for filename in *.wasm 34 | do 35 | dest="${WASM_METERED_DIR}/${filename}" 36 | /root/sentinel-inline-super-standalone/wasm-utils/target/debug/wasm-gas "${filename}" "$dest" 37 | done 38 | 39 | 40 | # python3.7 main.py --wasmdir="/evmwasmfilesmetered" --csvfile="/testresults/evmrace_wasm_results.csv" |& tee wasm-run1.log 41 | 42 | # "wagon,wabt,v8-liftoff,v8-turbofan,v8-interpreter,wasmtime,wavm,life-polymerase,life,wasmi,asmble" 43 | 44 | # only run interpreters 45 | # python3.7 main.py --wasmdir="/evmwasmfilesmetered" --csvfile="/testresults/evmrace_wasm_results.csv" --engines="wagon,wabt,life,wasmi,v8-interpreter" |& tee wasm-run2.log 46 | -------------------------------------------------------------------------------- /wasm-engines/benchnativerust_prepwasm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import jinja2, json, re 4 | from functools import reduce 5 | import subprocess 6 | import nanodurationpy as durationpy 7 | import csv 8 | import time 9 | import datetime 10 | import os 11 | import shutil 12 | import glob 13 | import argparse 14 | import sys 15 | 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument('--wasmoutdir', help='full path of dir containing wasm files') 18 | parser.add_argument('--csvresults', help='full path of csv result file') 19 | parser.add_argument('--rustcodedir', help='comma-separated list of engines to benchmark') 20 | parser.add_argument('--inputvectorsdir', help='comma-separated list of engines to benchmark') 21 | 22 | args = vars(parser.parse_args()) 23 | 24 | 25 | # how many times to run native exec 26 | RUST_BENCH_REPEATS = 50 27 | 28 | def get_rust_bytes(hex_str): 29 | tmp = map(''.join, zip(*[iter(hex_str)]*2)) 30 | tmp = map(lambda x: int(x, 16), tmp) 31 | tmp = map(lambda x: '{}u8'.format(x), tmp) 32 | tmp = reduce(lambda x, y: x+', '+y, tmp) 33 | return '[ '+tmp+' ]' 34 | 35 | def bench_rust_binary(rustdir, input_name, native_exec): 36 | print("running rust native {}...\n{}".format(input_name, native_exec)) 37 | bench_times = [] 38 | for i in range(1,RUST_BENCH_REPEATS): 39 | rust_process = subprocess.Popen(native_exec, cwd=rustdir, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) 40 | rust_process.wait(None) 41 | stdoutlines = [str(line, 'utf8') for line in rust_process.stdout] 42 | print(("").join(stdoutlines), end="") 43 | elapsedline = stdoutlines[0] 44 | elapsedmatch = re.search("Time elapsed in bench\(\) is: ([\w\.]+)", elapsedline) 45 | elapsed_time = durationpy.from_str(elapsedmatch[1]) 46 | bench_times.append(elapsed_time.total_seconds()) 47 | return bench_times 48 | 49 | def do_rust_bench(benchname, input, rust_code_dir, wasm_out_dir): 50 | #rustsrc = "{}/rust-code/src/bench.rs".format(os.path.abspath(benchname)) 51 | #rustsrc = "{}/rust-code".format(os.path.abspath(benchname)) 52 | rust_code_path = os.path.abspath(os.path.join(rust_code_dir, benchname)) 53 | #rustsrc = "{}/rust-code".format(os.path.abspath(benchname)) 54 | rustsrc = rust_code_path 55 | #rusttemplate = "{}/src/bench.rs".format(rustsrc) 56 | rusttemplate = os.path.join(rust_code_path, "src/bench.rs") 57 | 58 | if not os.path.exists(rustsrc): 59 | return False 60 | 61 | #filldir = os.path.abspath("{}/rust-code-filled".format(benchname)) 62 | filldir = os.path.abspath(os.path.join("./rust-code-filled/", benchname)) 63 | if os.path.exists(filldir): 64 | shutil.rmtree(filldir) 65 | shutil.copytree(rustsrc, filldir) 66 | 67 | template_args = {} 68 | for key in input.keys(): 69 | if key == "name": 70 | continue 71 | if key == "input": 72 | input_len = int(len(input['input']) / 2) 73 | input_str = "let input: [u8; {}] = {};".format(input_len, get_rust_bytes(input['input'])) 74 | template_args["input"] = input_str 75 | elif key == "expected": 76 | expected_len = int(len(input['expected']) / 2) 77 | expected_str = "let expected: [u8; {}] = {};".format(expected_len, get_rust_bytes(input['expected'])) 78 | template_args["expected"] = expected_str 79 | else: 80 | template_args[key] = input[key] 81 | 82 | # fill template if necessary 83 | if len(template_args.keys()) > 1: 84 | print("filling template for {}".format(input['name'])) 85 | with open(rusttemplate) as file_: 86 | template = jinja2.Template(file_.read()) 87 | filledrust = template.render(**template_args) 88 | 89 | #rustfileout = "{}/src/bench.rs".format(filldir) 90 | rustfileout = os.path.join(filldir, "src/bench.rs") 91 | with open(rustfileout, 'w') as outfile: 92 | outfile.write(filledrust) 93 | 94 | # compile rust code 95 | benchname_rust = benchname.replace("-", "_") 96 | rust_native_cmd = "cargo build --release --bin {}_native".format(benchname_rust) 97 | print("compiling rust native {}...\n{}".format(input['name'], rust_native_cmd)) 98 | rust_process = subprocess.Popen(rust_native_cmd, cwd=filldir, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) 99 | return_code = rust_process.wait(None) 100 | stdoutlines = [str(line, 'utf8') for line in rust_process.stdout] 101 | print(("").join(stdoutlines), end="") 102 | 103 | if return_code != 0: 104 | sys.exit(-1) 105 | 106 | # native binary is at ./target/release/sha1_native 107 | exec_path = "{}/target/release/{}_native".format(filldir, benchname_rust) 108 | exec_size = os.path.getsize(exec_path) 109 | 110 | # TODO: get rustc compile time 111 | # TODO: also build with optimization turned off 112 | 113 | # TODO: run wasm through wasm-gc 114 | rust_wasm_cmd = "cargo build --release --lib --target wasm32-unknown-unknown" 115 | print("compiling rust wasm {}...\n{}".format(input['name'], rust_wasm_cmd)) 116 | rust_process = subprocess.Popen(rust_wasm_cmd, cwd=filldir, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True) 117 | return_code = rust_process.wait(None) 118 | stdoutlines = [str(line, 'utf8') for line in rust_process.stdout] 119 | print(("").join(stdoutlines), end="") 120 | if return_code != 0: 121 | sys.exit(-1) 122 | # wasm is at ./target/wasm32-unknown-unkown/release/sha1_wasm.wasm 123 | wasmbin = "{}/target/wasm32-unknown-unknown/release/{}_wasm.wasm".format(filldir, benchname_rust) 124 | wasmdir = os.path.abspath(wasm_out_dir) 125 | wasmoutfile = os.path.join(wasmdir, "{}.wasm".format(input['name'])) 126 | if not os.path.exists(wasmdir): 127 | os.mkdir(wasmdir) 128 | shutil.copy(wasmbin, wasmoutfile) 129 | 130 | # TODO: get cargo build compiler time and report along with exec time. 131 | 132 | # run rust binary 133 | native_times = bench_rust_binary(filldir, input['name'], "./target/release/{}_native".format(benchname_rust)) 134 | return { 'bench_times': native_times, 'exec_size': exec_size } 135 | 136 | 137 | def saveResults(native_benchmarks, result_file): 138 | #result_file = os.path.join(RESULT_CSV_OUTPUT_PATH, RESULT_CSV_FILENAME) 139 | # move existing files to old-datetime-folder 140 | ts = time.time() 141 | date_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 142 | ts_folder_name = "{}-{}".format(date_str, round(ts)) 143 | result_path = os.path.dirname(result_file) 144 | dest_backup_path = os.path.join(result_path, ts_folder_name) 145 | os.makedirs(dest_backup_path) 146 | 147 | #for file in glob.glob(r"{}/*.csv".format(RESULT_CSV_OUTPUT_PATH)): 148 | # print("backing up existing {}".format(file)) 149 | # shutil.move(file, dest_backup_path) 150 | if os.path.isfile(result_file): 151 | print("backing up existing {}".format(result_file)) 152 | shutil.move(result_file, dest_backup_path) 153 | print("existing csv file backed up to {}".format(dest_backup_path)) 154 | 155 | with open(result_file, 'w', newline='') as bench_result_file: 156 | fieldnames = ['test_name', 'elapsed_times', 'native_file_size'] 157 | writer = csv.DictWriter(bench_result_file, fieldnames=fieldnames) 158 | writer.writeheader() 159 | for test_name, test_results in native_benchmarks.items(): 160 | bench_times = [str(t) for t in test_results['bench_times']] 161 | times_str = ", ".join(bench_times) 162 | writer.writerow({"test_name" : test_name, "elapsed_times" : times_str, "native_file_size" : test_results['exec_size']}) 163 | 164 | 165 | def main(): 166 | wasm_out_dir = args['wasmoutdir'] 167 | csv_file_path = args['csvresults'] 168 | rust_code_dir = args['rustcodedir'] 169 | input_vectors_dir = args['inputvectorsdir'] 170 | rustcodes = [dI for dI in os.listdir(rust_code_dir) if os.path.isdir(os.path.join(rust_code_dir,dI))] 171 | #benchdirs = [dI for dI in os.listdir('./') if os.path.isdir(os.path.join('./',dI))] 172 | native_benchmarks = {} 173 | for benchname in rustcodes: 174 | if benchname in ["__pycache__", ".cargo"]: 175 | continue 176 | print("start benching: ", benchname) 177 | 178 | #rust_code_path = os.path.join(RUST_CODES_DIR, benchname) 179 | 180 | ## TODO: move input vectors to their own "standalone" folder 181 | # use "ewasm" folder 182 | inputvecs_path = os.path.join(input_vectors_dir, "{}-inputs.json".format(benchname)) 183 | with open(inputvecs_path) as f: 184 | bench_inputs = json.load(f) 185 | 186 | for input in bench_inputs: 187 | print("bench input:", input['name']) 188 | native_input_times = do_rust_bench(benchname, input, rust_code_dir, wasm_out_dir) 189 | if native_input_times: 190 | native_benchmarks[input['name']] = native_input_times 191 | 192 | print("done with input:", input['name']) 193 | 194 | print("done benching: ", benchname) 195 | 196 | print("got native_benchmarks:", native_benchmarks) 197 | saveResults(native_benchmarks, csv_file_path) 198 | 199 | if __name__ == "__main__": 200 | main() 201 | -------------------------------------------------------------------------------- /wasm-engines/build_engines.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | set -e 4 | 5 | repo="ewasm" 6 | 7 | # build base images 8 | docker build -t $repo/bench-build-base:1 -f docker/bench-build-base.Dockerfile . 9 | docker build -t $repo/llvm-10:1 -f docker/llvm-10.Dockerfile . 10 | 11 | # build engines 12 | docker build -t $repo/fizzy:1 -f docker/fizzy.Dockerfile . 13 | docker build -t $repo/life:1 -f docker/life.Dockerfile . 14 | docker build -t $repo/ssvm:1 -f docker/ssvm.Dockerfile . 15 | docker build -t $repo/wabt:1 -f docker/wabt.Dockerfile . 16 | docker build -t $repo/wagon:1 -f docker/wagon.Dockerfile . 17 | docker build -t $repo/wamr:1 -f docker/wamr.Dockerfile . 18 | docker build -t $repo/wasm3:1 -f docker/wasm3.Dockerfile . 19 | docker build -t $repo/wasmi:1 -f docker/wasmi.Dockerfile . 20 | docker build -t $repo/wasmtime:1 -f docker/wasmtime.Dockerfile . 21 | docker build -t $repo/wavm:1 -f docker/wavm.Dockerfile . 22 | docker build -t $repo/asmble:1 -f docker/asmble.Dockerfile . 23 | docker build -t $repo/vanilla-wabt:1 -f docker/vanilla-wabt.Dockerfile . 24 | 25 | docker build -t $repo/wasm-engines-bench:1 -f docker/wasm-engines-bench.Dockerfile . 26 | -------------------------------------------------------------------------------- /wasm-engines/docker/asmble.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (asmble)" 7 | 8 | RUN apt update -y && apt-get install -y wget && \ 9 | wget https://github.com/ewasm-benchmarking/asmble/releases/download/0.4.2-fl-bench-times/asmble-0.4.2-fl-bench-times.tar && \ 10 | tar -xvf asmble-0.4.2-fl-bench-times.tar 11 | 12 | FROM ewasm/bench-build-base:1 13 | COPY --from=build /asmble /asmble 14 | -------------------------------------------------------------------------------- /wasm-engines/docker/bench-build-base.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Build environment for Ewasm benchmarking (base image)" 7 | 8 | ENV DEBIAN_FRONTEND=noninteractive 9 | 10 | RUN apt-get clean && \ 11 | apt-get update && \ 12 | apt-get install -y cmake software-properties-common git sudo build-essential wget curl nano python2.7 libc++-dev libc++abi-dev \ 13 | autoconf automake libtool llvm-6.0 make ninja-build unzip zlib1g-dev texinfo libssl-dev golang python3.8 python3-distutils python3-pip && \ 14 | curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.42.0 -y && . $HOME/.cargo/env && \ 15 | rustup target add wasm32-unknown-unknown 16 | 17 | RUN export GO111MODULE=on 18 | 19 | ENV PATH=/root/.cargo/bin:$PATH 20 | -------------------------------------------------------------------------------- /wasm-engines/docker/fizzy.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (fizzy)" 7 | 8 | # install fizzy 9 | RUN git clone https://github.com/wasmx/fizzy.git --single-branch --branch v0.3.0 && \ 10 | cd fizzy && mkdir build && cd build && cmake -DNATIVE=ON -DFIZZY_TESTING=ON .. && make -j4 11 | 12 | FROM ewasm/bench-build-base:1 13 | COPY --from=build /fizzy/build/bin/ /fizzy/build/bin 14 | -------------------------------------------------------------------------------- /wasm-engines/docker/life.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (life)" 7 | 8 | # install life 9 | RUN git clone --single-branch --branch bench-times https://github.com/ewasm-benchmarking/life && \ 10 | cd life && go mod vendor && go build 11 | 12 | FROM ewasm/bench-build-base:1 13 | COPY --from=build /life/life /life/life 14 | -------------------------------------------------------------------------------- /wasm-engines/docker/llvm-10.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Build environment for Ewasm benchmarking (llvm-10)" 7 | 8 | RUN echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main\ 9 | deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main" >> /etc/apt/sources.list && \ 10 | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - && apt update -y && apt install -y clang-10 lldb-10 lld-10 && \ 11 | ln -s /usr/bin/clang++-10 /usr/bin/clang++ && \ 12 | ln -s /usr/bin/clang-10 /usr/bin/clang 13 | 14 | ENV CC=clang 15 | ENV CXX=clang++ 16 | -------------------------------------------------------------------------------- /wasm-engines/docker/ssvm.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (ssvm)" 7 | 8 | RUN apt update -y && apt install -y libboost-all-dev && git clone https://github.com/ewasm-benchmarking/SSVM.git --single-branch --branch v0.6.0-benchmarking && \ 9 | cd SSVM && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DSSVM_DISABLE_AOT_RUNTIME=ON .. && make -j4 10 | 11 | FROM ewasm/bench-build-base:1 12 | COPY --from=build /SSVM/build/tools/ssvm/ssvm /SSVM/build/tools/ssvm/ssvm 13 | -------------------------------------------------------------------------------- /wasm-engines/docker/vanilla-wabt.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (vanilla-wabt)" 7 | 8 | RUN git clone --recursive --single-branch --branch v1.0.17-benchmarking https://github.com/ewasm-benchmarking/wabt.git vanilla-wabt && \ 9 | mkdir vanilla-wabt/build && cd vanilla-wabt/build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF .. && make -j4 10 | 11 | FROM ewasm/bench-build-base:1 12 | COPY --from=build /vanilla-wabt/build/wasm-interp /vanilla-wabt/build/wasm-interp 13 | -------------------------------------------------------------------------------- /wasm-engines/docker/wabt.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wabt)" 7 | 8 | RUN git clone --recursive --single-branch --branch bench-times https://github.com/ewasm-benchmarking/wabt.git && \ 9 | mkdir wabt/build && cd wabt/build && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF .. && make -j4 10 | 11 | FROM ewasm/bench-build-base:1 12 | COPY --from=build /wabt/build/wasm-interp /wabt/build/wasm-interp 13 | -------------------------------------------------------------------------------- /wasm-engines/docker/wagon.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wagon)" 7 | 8 | # install wagon 9 | RUN git clone --single-branch --branch v0.4.0-benchmarking https://github.com/ewasm-benchmarking/wagon && \ 10 | cd wagon/cmd/wasm-run && go build 11 | 12 | FROM ewasm/bench-build-base:1 13 | COPY --from=build /wagon/cmd/wasm-run/wasm-run /wagon/cmd/wasm-run/wasm-run 14 | -------------------------------------------------------------------------------- /wasm-engines/docker/wamr.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wamr)" 7 | 8 | ENV CC=/usr/bin/gcc 9 | ENV CXX=/usr/bin/g++ 10 | 11 | RUN git clone https://github.com/ewasm-benchmarking/wasm-micro-runtime.git --single-branch --branch wamr-02-18-2020-benchmarking && \ 12 | cd wasm-micro-runtime && \ 13 | ## Build LLVM 14 | cd product-mini/platforms/linux && \ 15 | ./build_llvm.sh 16 | 17 | ## Build JIT 18 | RUN cd wasm-micro-runtime/product-mini/platforms/linux && ./build_jit.sh && \ 19 | ## Build Interpreter 20 | mkdir build_interp && cd build_interp && cmake -DWAMR_BUILD_INTERP=1 .. -DCMAKE_BUILD_TYPE=Release .. && make -j4 && \ 21 | ## Build Compiler 22 | cd ../../../../wamr-compiler && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j4 23 | 24 | FROM ewasm/bench-build-base:1 25 | COPY --from=build /wasm-micro-runtime/product-mini/platforms/linux/build_interp/iwasm /wasm-micro-runtime/product-mini/platforms/linux/build_interp/iwasm 26 | COPY --from=build /wasm-micro-runtime/wamr-compiler/build/wamrc /wasm-micro-runtime/wamr-compiler/build/wamrc 27 | -------------------------------------------------------------------------------- /wasm-engines/docker/wasm-engines-bench.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/life:1 AS life 2 | FROM ewasm/wabt:1 AS wabt 3 | FROM ewasm/wasm3:1 AS wasm3 4 | FROM ewasm/ssvm:1 AS ssvm 5 | FROM ewasm/wasmtime:1 AS wasmtime 6 | FROM ewasm/wamr:1 AS wamr 7 | FROM ewasm/wagon:1 AS wagon 8 | FROM ewasm/wavm:1 AS wavm 9 | FROM ewasm/fizzy:1 AS fizzy 10 | FROM ewasm/asmble:1 AS asmble 11 | FROM ewasm/wasmi:1 AS wasmi 12 | FROM ewasm/vanilla-wabt:1 AS vanilla-wabt 13 | 14 | FROM ewasm/llvm-10:1 15 | 16 | LABEL maintainer="Ewasm Team" 17 | LABEL repo="https://github.com/ewasm/benchmarking" 18 | LABEL version="1" 19 | LABEL description="Benchmarking environment for Ewasm benchmarking" 20 | 21 | # install dependencies for standalone wasm prep 22 | RUN pip3 install jinja2 pandas click durationpy 23 | 24 | # install JRE for asmble 25 | RUN apt update -y && apt install -y openjdk-8-jre 26 | ENV JAVA_VER 8 27 | ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 28 | 29 | RUN mkdir /engines 30 | 31 | # install node for v8 benchmarks 32 | RUN curl -fsSLO --compressed https://nodejs.org/download/release/v12.18.2/node-v12.18.2-linux-x64.tar.gz && \ 33 | tar -xvf node-v12.18.2-linux-x64.tar.gz -C /usr/local/ --strip-components=1 --no-same-owner 34 | RUN mkdir /engines/node && ln -s /usr/local/bin/node /engines/node/node 35 | 36 | # wasm engine binaries 37 | COPY --from=wabt /wabt/build/wasm-interp /engines/wabt/wasm-interp 38 | COPY --from=vanilla-wabt /vanilla-wabt/build/wasm-interp /engines/vanilla-wabt/wasm-interp 39 | COPY --from=fizzy /fizzy/build/bin/fizzy-bench /engines/fizzy/fizzy-bench 40 | COPY --from=wasmi /wasmi/target/release/invoke /engines/wasmi/invoke 41 | COPY --from=wavm /wavm-build/ /engines/wavm 42 | RUN cd /engines/wavm/Lib && find . -name "*.so" -exec cp -prv '{}' '/usr/lib' ';' 43 | COPY --from=life /life/life /engines/life/life 44 | COPY --from=wasm3 /wasm3/build/wasm3 /engines/wasm3/wasm3 45 | COPY --from=wasmtime /wasmtime/target/release/wasmtime /engines/wasmtime/wasmtime 46 | COPY --from=ssvm /SSVM/build/tools/ssvm/ssvm /engines/ssvm/ssvm 47 | COPY --from=wamr /wasm-micro-runtime/product-mini/platforms/linux/build_interp/iwasm /engines/wamr/iwasm 48 | COPY --from=wamr /wasm-micro-runtime/wamr-compiler/build/wamrc /engines/wamr/wamrc 49 | COPY --from=asmble /asmble/ /engines/asmble/ 50 | COPY --from=wagon /wagon/cmd/wasm-run/wasm-run /engines/wagon/wasm-run 51 | 52 | RUN mkdir /benchmark_results_data 53 | 54 | # copy benchmarking scripts 55 | RUN mkdir /benchrunner 56 | 57 | # copy scripts to generate standalone wasm modules 58 | RUN mkdir /benchprep 59 | 60 | WORKDIR /benchprep 61 | 62 | CMD /bin/bash 63 | -------------------------------------------------------------------------------- /wasm-engines/docker/wasm3.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wasm3)" 7 | 8 | RUN git clone https://github.com/ewasm-benchmarking/wasm3.git --single-branch --branch v0.4.7-benchmarking && \ 9 | cd wasm3 && mkdir build && cd build && cmake -DBUILD_WASI=none -DCMAKE_BUILD_TYPE=Release .. && make -j4 10 | 11 | FROM ewasm/bench-build-base:1 12 | COPY --from=build /wasm3/build/wasm3 /wasm3/build/wasm3 13 | -------------------------------------------------------------------------------- /wasm-engines/docker/wasmi.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wasmi)" 7 | 8 | RUN git clone --single-branch --branch v0.4.4-benchmarking https://github.com/ewasm-benchmarking/wasmi.git --recursive && \ 9 | cd wasmi && cargo build --release 10 | 11 | FROM ewasm/bench-build-base:1 12 | COPY --from=build /wasmi/target/release/invoke /wasmi/target/release/invoke 13 | -------------------------------------------------------------------------------- /wasm-engines/docker/wasmtime.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/llvm-10:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wasmtime)" 7 | 8 | RUN git clone --single-branch --branch bench-times https://github.com/ewasm-benchmarking/wasmtime.git && \ 9 | cd wasmtime && cargo build --release 10 | 11 | FROM ewasm/bench-build-base:1 12 | COPY --from=build /wasmtime/target/release/wasmtime /wasmtime/target/release/wasmtime 13 | -------------------------------------------------------------------------------- /wasm-engines/docker/wavm.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ewasm/bench-build-base:1 AS build 2 | 3 | LABEL maintainer="Ewasm Team" 4 | LABEL repo="https://github.com/ewasm/benchmarking" 5 | LABEL version="1" 6 | LABEL description="Ewasm benchmarking (wavm)" 7 | 8 | # Use old gcc/g++ for wavm (needed by wavm) 9 | RUN apt install -y gcc-7 g++-7 && \ 10 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10 && \ 11 | update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 10 && \ 12 | # install wavm 13 | git clone --single-branch --branch bench-compile-time https://github.com/ewasm-benchmarking/WAVM && \ 14 | mkdir wavm-build && \ 15 | cd wavm-build && cmake -G Ninja ../WAVM -DCMAKE_BUILD_TYPE=Release -DWAVM_ENABLE_STATIC_LINKING=ON && \ 16 | ninja 17 | 18 | FROM ewasm/bench-build-base:1 19 | COPY --from=build /wavm-build /wavm-build 20 | -------------------------------------------------------------------------------- /wasm-engines/fizzy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # $1 = function name 6 | # $2 = wasm file 7 | 8 | # Create input file 9 | echo test > testcase.inputs # 1. Test name 10 | echo $1 >> testcase.inputs # 2. Function name 11 | echo $':\n' >> testcase.inputs # 3. Function signature 12 | echo $'\n' >> testcase.inputs # 4. Function parameters 13 | echo $'\n' >> testcase.inputs # 5. Initial Memory 14 | echo $'\n' >> testcase.inputs # 6. Expected result 15 | echo $'\n' >> testcase.inputs # 7. Expected memory 16 | 17 | # Copy wasm file 18 | cp $2 ./testcase.wasm 19 | 20 | /engines/fizzy/fizzy-bench --benchmark_filter=fizzy/* --benchmark_color=false ./ | sed 's/\([0-9][0-9]*\)\s\([nm]s\)/\1\2/g' 21 | 22 | rm -f testcase.inputs testcase.wasm 23 | -------------------------------------------------------------------------------- /wasm-engines/fluence_bencher/VMDescriptor.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2018 Fluence Labs Limited 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | 18 | class VMDescriptor: 19 | """Wasm VM descriptor that specifies how VM has to be launched. 20 | 21 | Attributes 22 | ---------- 23 | vm_relative_binary_path : str 24 | A relative path to VM binary in its main folder. 25 | vm_launch_cmd : str 26 | An format string with command for launch this vm with provided test. 27 | is_compiler_type : bool 28 | True, if vm is compiler-type (JIT, AOT, ...). 29 | 30 | """ 31 | def __init__(self, vm_binary_path="", vm_launch_cmd=""): 32 | self.vm_binary_path = vm_binary_path 33 | self.vm_launch_cmd = vm_launch_cmd 34 | -------------------------------------------------------------------------------- /wasm-engines/fluence_bencher/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/fluence_bencher/__init__.py -------------------------------------------------------------------------------- /wasm-engines/fluence_bencher/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2018 Fluence Labs Limited 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | from fluence_bencher.VMDescriptor import VMDescriptor 17 | 18 | # export function name that should be called from each Wasm module 19 | test_export_function_name = "main" 20 | 21 | """ 22 | Attributes 23 | ---------- 24 | vm_relative_binary_path : str 25 | A relative path to VM binary in its main folder. 26 | vm_launch_cmd : str 27 | An format string with command for launch this vm with provided test. 28 | 29 | VMDescriptor(vm_relative_binary_path="", vm_launch_cmd="") 30 | """ 31 | 32 | vm_descriptors = { 33 | "wagon" : VMDescriptor("/engines/wagon/wasm-run", "{wasm_file_path}"), 34 | "wabt" : VMDescriptor("/engines/wabt/wasm-interp", "{wasm_file_path} --run-all-exports"), 35 | "vanilla-wabt" : VMDescriptor("/engines/vanilla-wabt/wasm-interp", "{wasm_file_path} --run-all-exports"), 36 | "v8-liftoff" : VMDescriptor("/engines/node/node", "--liftoff --no-wasm-tier-up /engines/node/node-timer.js {wasm_file_path}"), 37 | "v8-turbofan" : VMDescriptor("/engines/node/node", "--no-liftoff /engines/node/node-timer.js {wasm_file_path}"), 38 | "v8-interpreter" : VMDescriptor("/engines/node/node", "--wasm-interpret-all --liftoff --no-wasm-tier-up /engines/node/node-timer.js {wasm_file_path}"), 39 | "wasmtime": VMDescriptor("/engines/wasmtime/wasmtime", "{wasm_file_path} --invoke=main"), 40 | "wavm" : VMDescriptor("/engines/wavm/bin/wavm-run", "{wasm_file_path} -f {function_name}"), 41 | "life-polymerase" : VMDescriptor("/engines/life/life", "-polymerase -entry {function_name} {wasm_file_path}"), 42 | "life" : VMDescriptor("/engines/life/life", "-entry {function_name} {wasm_file_path}"), 43 | "wasmi" : VMDescriptor("/engines/wasmi/invoke", "{wasm_file_path} {function_name}"), 44 | "asmble" : VMDescriptor("/engines/asmble/bin/asmble", "invoke -in {wasm_file_path} {function_name} -defmaxmempages 20000"), 45 | "wamr-interp" : VMDescriptor("/engines/wamr/iwasm", "-f {function_name} {wasm_file_path}"), 46 | "wamr-jit" : VMDescriptor("/engines/wamr/iwasm", "-f {function_name} {wasm_file_path}"), 47 | "wamr-aot" : VMDescriptor("/engines/wamr/wamr_aot.sh", "{function_name} {wasm_file_path}"), 48 | "wasm3" : VMDescriptor("/engines/wasm3/wasm3", "--func {function_name} {wasm_file_path}"), 49 | "fizzy" : VMDescriptor("/engines/fizzy/fizzy.sh", "{function_name} {wasm_file_path}"), 50 | "ssvm" : VMDescriptor("/engines/ssvm/ssvm", "{wasm_file_path} {function_name}"), 51 | 52 | # "wasmer" : VMDescriptor("/engines/wasmer/target/release/wasmer", "run {wasm_file_path}", True), 53 | # we have binaryen, but calling wasm-shell -e main is not working 54 | } 55 | -------------------------------------------------------------------------------- /wasm-engines/inputvectors/bn128_add-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "bn128_add-cdetrio11", 4 | "input": "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", 5 | "expected": "030644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd315ed738c0e0a7c92e7845f96b2ae9c0a68a6a449e3538fc7ff3ebf7a5a18a2c4" 6 | }, 7 | { 8 | "name": "bn128_add-cdetrio14", 9 | "input": "17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa92e83f8d734803fc370eba25ed1f6b8768bd6d83887b87165fc2434fe11a830cb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 10 | "expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" 11 | }, 12 | { 13 | "name": "bn128_add-cdetrio10", 14 | "input": "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 15 | "expected": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002" 16 | } 17 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/bn128_mul-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "bn128_mul-cdetrio11", 4 | "input": "039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d98ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 5 | "expected": "00a1a234d08efaa2616607e31eca1980128b00b415c845ff25bba3afcb81dc00242077290ed33906aeb8e42fd98c41bcb9057ba03421af3f2d08cfc441186024" 6 | }, 7 | { 8 | "name": "bn128_mul-chfast2", 9 | "input": "070a8d6a982153cae4be29d434e8faef8a47b274a053f5a4ee2a6c9c13c31e5c031b8ce914eba3a9ffb989f9cdd5b0f01943074bf4f0f315690ec3cec6981afc30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46", 10 | "expected": "025a6f4181d2b4ea8b724290ffb40156eb0adb514c688556eb79cdea0752c2bb2eff3f31dea215f1eb86023a133a996eb6300b44da664d64251d05381bb8a02e" 11 | }, 12 | { 13 | "name": "bn128_mul-chfast1", 14 | "input": "2bd3e6d0f3b142924f5ca7b49ce5b9d54c4703d7ae5648e61d02268b1a0a9fb721611ce0a6af85915e2f1d70300909ce2e49dfad4a4619c8390cae66cefdb20400000000000000000000000000000000000000000000000011138ce750fa15c2", 15 | "expected": "070a8d6a982153cae4be29d434e8faef8a47b274a053f5a4ee2a6c9c13c31e5c031b8ce914eba3a9ffb989f9cdd5b0f01943074bf4f0f315690ec3cec6981afc" 16 | }, 17 | { 18 | "name": "bn128_mul-chfast3", 19 | "input": "025a6f4181d2b4ea8b724290ffb40156eb0adb514c688556eb79cdea0752c2bb2eff3f31dea215f1eb86023a133a996eb6300b44da664d64251d05381bb8a02e183227397098d014dc2822db40c0ac2ecbc0b548b438e5469e10460b6c3e7ea3", 20 | "expected": "14789d0d4a730b354403b5fac948113739e276c23e0258d8596ee72f9cd9d3230af18a63153e0ec25ff9f2951dd3fa90ed0197bfef6e2a1a62b5095b9d2b4a27" 21 | }, 22 | { 23 | "name": "bn128_mul-cdetrio2", 24 | "input": "1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe31a2f3c951f6dadcc7ee9007dff81504b0fcd6d7cf59996efdc33d92bf7f9f8f630644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000", 25 | "expected": "1a87b0584ce92f4593d161480614f2989035225609f08058ccfa3d0f940febe3163511ddc1c3f25d396745388200081287b3fd1472d8339d5fecb2eae0830451" 26 | }, 27 | { 28 | "name": "bn128_mul-cdetrio6", 29 | "input": "17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 30 | "expected": "29e587aadd7c06722aabba753017c093f70ba7eb1f1c0104ec0564e7e3e21f6022b1143f6a41008e7755c71c3d00b6b915d386de21783ef590486d8afa8453b1" 31 | }, 32 | { 33 | "name": "bn128_mul-cdetrio7", 34 | "input": "17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa901e0559bacb160664764a357af8a9fe70baa9258e0b959273ffc5718c6d4cc7c30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000", 35 | "expected": "17c139df0efee0f766bc0204762b774362e4ded88953a39ce849a8a7fa163fa92e83f8d734803fc370eba25ed1f6b8768bd6d83887b87165fc2434fe11a830cb" 36 | }, 37 | { 38 | "name": "bn128_mul-cdetrio12", 39 | "input": "039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b869073a5ffcc6fc7a28c30723d6e58ce577356982d65b833a5a5c15bf9024b43d9830644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000", 40 | "expected": "039730ea8dff1254c0fee9c0ea777d29a9c710b7e616683f194f18c43b43b8692929ee761a352600f54921df9bf472e66217e7bb0cee9032e00acc86b3c8bfaf" 41 | } 42 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/bn128_pairing-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "bn128_pairing-ten_point_match_1", 4 | "input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d", 5 | "expected": "0000000000000000000000000000000000000000000000000000000000000001" 6 | }, 7 | { 8 | "name": "bn128_pairing-one_point", 9 | "input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa", 10 | "expected": "0000000000000000000000000000000000000000000000000000000000000000" 11 | }, 12 | { 13 | "name": "bn128_pairing-two_point_match_2", 14 | "input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d", 15 | "expected": "0000000000000000000000000000000000000000000000000000000000000001" 16 | } 17 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/ecrecover-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input": "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02", 4 | "expected": "000000000000000000000000ceaccac640adf55b2028469bd36ba501f28b699d", 5 | "name": "ecrecover-example" 6 | } 7 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/ed25519-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "ed25519-verify-ten-inputs" 4 | } 5 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/keccak256-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input": "6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071", 4 | "expected": "45d3b367a6904e6e8d502ee04999a7c27647f91fa845d456525fd352ae3d7371", 5 | "name": "keccak256-56byte" 6 | }, 7 | { 8 | "input": "6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f70716162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071", 9 | "expected": "1755e2691628ecd3f46550a13201b076d64df08146add18f18a1d74c13505e00", 10 | "name": "keccak256-560byte" 11 | } 12 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/modexp-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input": "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb503fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b", 4 | "expected": "4834a46ba565db27903b1c720c9d593e84e4cbd6ad2e64b31885d944f68cd801f92225a8961c952ddf2797fa4701b330c85c4b363798100b921a1a22a46a7fec", 5 | "name": "modexp-nagydani-1-qube" 6 | }, 7 | { 8 | "input": "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040e09ad9675465c53a109fac66a445c91b292d2bb2c5268addb30cd82f80fcb0033ff97c80a5fc6f39193ae969c6ede6710a6b7ac27078a06d90ef1c72e5c85fb502fc9e1f6beb81516545975218075ec2af118cd8798df6e08a147c60fd6095ac2bb02c2908cf4dd7c81f11c289e4bce98f3553768f392a80ce22bf5c4f4a248c6b", 9 | "expected": "60008f1614cc01dcfb6bfb09c625cf90b47d4468db81b5f8b7a39d42f332eab9b2da8f2d95311648a8f243f4bb13cfb3d8f7f2a3c014122ebb3ed41b02783adc", 10 | "name": "modexp-nagydani-1-square" 11 | }, 12 | { 13 | "input": "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002003fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", 14 | "expected": "0000000000000000000000000000000000000000000000000000000000000001", 15 | "name": "modexp-eip_example1" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /wasm-engines/inputvectors/mul256-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "mul256-gcolvin-drag-race", 4 | "input": "26bceb59802431afcbce1fc194c9eaa417b2fb67dc75a95db0bc7ec6b1c8af11df6a1da9a1f5aac137876480252e5dcac62c354ec0d42b76b0642b6181ed099849ea1d57", 5 | "expected": "80baf8d183a4163e36b5076c8ac089871d90f3c75ee88f4a0204ca9ec2833da9" 6 | } 7 | ] -------------------------------------------------------------------------------- /wasm-engines/inputvectors/sha256-inputs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "input": "38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e000000000000000000000000000000000000000000000000000000000000001b38d18acb67d25c8bb9942764b62f18e17054f66a817bd4295423adf9ed98873e789d1dd423d25f0772d2748d60f7e4b81bb14d086eba8e8e8efb6dcff8a4ae02", 4 | "expected": "811c7003375852fabd0d362e40e68607a12bdabae61a7d068fe5fdd1dbbf2a5d", 5 | "name": "sha256-128" 6 | } 7 | ] -------------------------------------------------------------------------------- /wasm-engines/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from fluence_bencher.WasmVMBencher import WasmVMBencher 4 | from fluence_bencher.settings import vm_descriptors 5 | 6 | import csv 7 | import logging 8 | import sys 9 | import os 10 | import time 11 | import datetime 12 | import shutil 13 | import argparse 14 | 15 | sys.stdout.reconfigure(encoding='utf-8') 16 | # sys.stdout.reconfigure requires python 3.7 17 | # if not using python 3.7, then you you need `PYTHONIOENCODING=UTF-8 python3 main.py` 18 | 19 | 20 | BLACKLIST = [] 21 | 22 | 23 | parser = argparse.ArgumentParser() 24 | parser.add_argument('--wasmdir', help='full path of dir containing wasm files') 25 | parser.add_argument('--csvfile', help='name of csv result file') 26 | parser.add_argument('--engines', help='comma-separated list of engines to benchmark') 27 | 28 | args = vars(parser.parse_args()) 29 | 30 | 31 | def getTestDescriptors(wasm_dir): 32 | test_descriptors = {} 33 | for filename in os.listdir(wasm_dir): 34 | if filename.endswith(".wasm") and filename not in BLACKLIST: 35 | test_name = filename[:-5] # file name without .wasm 36 | test_descriptors[test_name] = os.path.join(wasm_dir, filename) 37 | return test_descriptors 38 | 39 | 40 | def save_test_results(result_file, results): 41 | # move existing files to old-datetime-folder 42 | print(">>> result_file:") 43 | print(result_file) 44 | if os.path.isfile(result_file): 45 | print("backing up existing {}".format(result_file)) 46 | ts = time.time() 47 | date_str = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 48 | ts_folder_name = "{}-{}".format(date_str, round(ts)) 49 | out_dir = os.path.dirname(result_file) 50 | dest_backup_path = os.path.join(out_dir, ts_folder_name) 51 | os.makedirs(dest_backup_path) 52 | shutil.move(result_file, dest_backup_path) 53 | print("existing csv files backed up to {}".format(dest_backup_path)) 54 | 55 | # write header 56 | with open(result_file, 'w', newline='') as bench_result_file: 57 | fieldnames = ['engine', 'test_name', 'elapsed_time', 'compile_time', 'exec_time'] 58 | writer = csv.DictWriter(bench_result_file, fieldnames=fieldnames) 59 | writer.writeheader() 60 | 61 | # append results for each vm 62 | with open(result_file, 'a', newline='') as bench_result_file: 63 | fieldnames = ['engine', 'test_name', 'elapsed_time', 'compile_time', 'exec_time'] 64 | writer = csv.DictWriter(bench_result_file, fieldnames=fieldnames) 65 | for vm in results: 66 | for test_name, result_records in results[vm].items(): 67 | for record in result_records: 68 | writer.writerow({"engine": vm, "test_name" : test_name, "elapsed_time" : record.time, "compile_time" : record.compile_time, "exec_time" : record.exec_time}) 69 | 70 | 71 | def main(): 72 | logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(asctime)s %(message)s', 73 | datefmt='%m/%d/%Y %I:%M:%S %p') 74 | 75 | logger = logging.getLogger("wasm_bench_logger") 76 | 77 | wasm_dir = args['wasmdir'] 78 | csv_file_path = args['csvfile'] 79 | engines_to_run = args['engines'] 80 | # "wagon,wabt,v8-liftoff,v8-turbofan,v8-interpreter,wasmtime,wavm,life-polymerase,life,wasmi,asmble" 81 | vms_to_run = {} 82 | if engines_to_run is not None: 83 | for engine in engines_to_run.split(","): 84 | vms_to_run[engine] = vm_descriptors[engine] 85 | else: 86 | # run all engines 87 | vms_to_run = vm_descriptors 88 | 89 | print("vms_to_run:", vms_to_run) 90 | ## TODO: print version of each engine 91 | 92 | vm_bencher = WasmVMBencher() 93 | test_descriptors = getTestDescriptors(wasm_dir) 94 | test_results = vm_bencher.run_tests(test_descriptors, vms_to_run) 95 | print("test_results:") 96 | print(test_results) 97 | save_test_results(csv_file_path, test_results) 98 | 99 | 100 | if __name__ == '__main__': 101 | main() 102 | -------------------------------------------------------------------------------- /wasm-engines/nanodurationpy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: UTF-8 -*- 2 | 3 | # originally from https://github.com/icholy/durationpy/blob/master/durationpy/duration.py 4 | 5 | import re 6 | import datetime 7 | import pandas 8 | 9 | _nanosecond_size = 1 10 | _microsecond_size = 1000 * _nanosecond_size 11 | _millisecond_size = 1000 * _microsecond_size 12 | _second_size = 1000 * _millisecond_size 13 | _minute_size = 60 * _second_size 14 | _hour_size = 60 * _minute_size 15 | _day_size = 24 * _hour_size 16 | _week_size = 7 * _day_size 17 | _month_size = 30 * _day_size 18 | _year_size = 365 * _day_size 19 | 20 | units = { 21 | "ns": _nanosecond_size, 22 | "us": _microsecond_size, 23 | "µs": _microsecond_size, 24 | "μs": _microsecond_size, 25 | "ms": _millisecond_size, 26 | "s": _second_size, 27 | "m": _minute_size, 28 | "h": _hour_size, 29 | "d": _day_size, 30 | "w": _week_size, 31 | "mm": _month_size, 32 | "y": _year_size, 33 | } 34 | 35 | 36 | def from_str(duration): 37 | """Parse a duration string to a datetime.timedelta""" 38 | 39 | if duration in ("0", "+0", "-0"): 40 | return datetime.timedelta() 41 | 42 | pattern = re.compile('([\d\.]+)([a-zµμ]+)') 43 | total = 0 44 | sign = -1 if duration[0] == '-' else 1 45 | matches = pattern.findall(duration) 46 | 47 | if not len(matches): 48 | raise Exception("Invalid duration {}".format(duration)) 49 | 50 | for (value, unit) in matches: 51 | if unit not in units: 52 | raise Exception( 53 | "Unknown unit {} in duration {}".format(unit, duration)) 54 | try: 55 | total += float(value) * units[unit] 56 | except: 57 | raise Exception( 58 | "Invalid value {} in duration {}".format(value, duration)) 59 | 60 | #microseconds = total / _microsecond_size 61 | nanoseconds = int(total) 62 | return pandas.Timedelta(nanoseconds=sign * nanoseconds) 63 | -------------------------------------------------------------------------------- /wasm-engines/node-timer.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | if (process.argv.length < 3) { 4 | console.log('Missing argument (wasm file)'); 5 | process.exit(1); 6 | } 7 | 8 | var args = process.argv.slice(2); 9 | var wasmfile = args[0]; 10 | 11 | console.log('args:', args); 12 | 13 | console.log('---- reading wasm file..'); 14 | const readAsBinary = filename => { 15 | if (typeof process === 'object' && typeof require === 'function') { 16 | const binary = require('fs').readFileSync(filename); 17 | return !binary.buffer ? new Uint8Array(binary) : binary; 18 | } else { 19 | return typeof readbuffer === 'function' 20 | ? new Uint8Array(readbuffer(filename)) 21 | : read(filename, 'binary'); 22 | } 23 | }; 24 | 25 | const wasmBytes = readAsBinary(wasmfile); 26 | 27 | console.log('---- wasm file read.'); 28 | 29 | const imports = { 30 | env: {} 31 | }; 32 | 33 | imports.env.memory = new WebAssembly.Memory({ initial: 10 }); 34 | 35 | console.time('instantiate'); 36 | WebAssembly.instantiate(wasmBytes, imports) 37 | .then(result => { 38 | console.timeEnd('instantiate'); 39 | console.log('---- calling main...') 40 | console.time('run-main'); 41 | try { 42 | const syncReturn = result.instance.exports.main(); 43 | console.timeEnd('run-main'); 44 | console.log('---- wasm returns:', syncReturn); 45 | } catch (e) { 46 | console.timeEnd('run-main'); 47 | console.log('caught error:', e); 48 | } 49 | }); 50 | -------------------------------------------------------------------------------- /wasm-engines/run_benchmarks.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | docker run --privileged \ 4 | -v $(pwd)/fluence_bencher:/benchrunner/fluence_bencher \ 5 | -v $(pwd)/main.py:/benchrunner/main.py \ 6 | -v $(pwd)/benchnativerust_prepwasm.py:/benchprep/benchnativerust_prepwasm.py \ 7 | -v $(pwd)/wasmfiles:/wasmfiles \ 8 | -v $(pwd)/benchmark_results_data:/benchmark_results_data \ 9 | -v $(pwd)/nanodurationpy.py:/benchprep/nanodurationpy.py \ 10 | -v $(pwd)/rust-code:/benchprep/rust-code \ 11 | -v $(pwd)/inputvectors:/benchprep/inputvectors \ 12 | -v $(pwd)/benchmeteredstandalone.sh:/benchprep/benchmeteredstandalone.sh \ 13 | -v $(pwd)/bench_wasm_and_native.sh:/benchprep/bench_wasm_and_native.sh \ 14 | -v $(pwd)/node-timer.js:/engines/node/node-timer.js \ 15 | -v $(pwd)/wamr_aot.sh:/engines/wamr/wamr_aot.sh \ 16 | -v $(pwd)/fizzy.sh:/engines/fizzy/fizzy.sh \ 17 | -it ewasm/wasm-engines-bench:1 bash /benchprep/bench_wasm_and_native.sh 18 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/.cargo/config: -------------------------------------------------------------------------------- 1 | [build] 2 | target = "wasm32-unknown-unknown" 3 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/blake2b/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ewasm-bench-blake2b" 3 | version = "0.1.0" 4 | license = "Apache-2.0" 5 | description = "Ethereum BLAKE2b benchmark in Rust" 6 | publish = false 7 | edition = "2018" 8 | 9 | [dependencies] 10 | blake2 = "0.7" 11 | 12 | [target.'cfg(target_arch = "wasm32")'.dependencies] 13 | wee_alloc = "0.4.2" 14 | 15 | [lib] 16 | name = "blake2b_wasm" 17 | crate-type = ["cdylib"] 18 | path = "src/lib.rs" 19 | 20 | [[bin]] 21 | name = "blake2b_native" 22 | path = "src/main.rs" 23 | 24 | [profile.release] 25 | opt-level = 3 26 | debug = false 27 | lto = true 28 | debug-assertions = false 29 | overflow-checks = false 30 | panic = "abort" -------------------------------------------------------------------------------- /wasm-engines/rust-code/blake2b/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/blake2b/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bls12-381/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bls12-381-aggregate-sigs-bench" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [dependencies] 7 | bls-aggregates = { git = "https://github.com/sigp/signature-schemes", tag = "0.5.3" } 8 | 9 | [dependencies.rand] 10 | version = "^0.5.5" 11 | 12 | [patch.crates-io] 13 | # needed to prevent wasm target error from "same-file" crate, a dependency of criterion 14 | # https://github.com/BurntSushi/same-file/issues/42 15 | criterion = { path = "./crate-override"} 16 | 17 | [target.'cfg(target_arch = "wasm32")'.dependencies] 18 | wee_alloc = "0.4.2" 19 | 20 | [lib] 21 | name = "bls12_381_wasm" 22 | crate-type = ["cdylib"] 23 | path = "src/lib.rs" 24 | 25 | [[bin]] 26 | name = "bls12_381_native" 27 | path = "src/main.rs" 28 | 29 | [profile.release] 30 | opt-level = 3 31 | debug = false 32 | lto = true 33 | debug-assertions = false 34 | overflow-checks = false 35 | panic = "abort" 36 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/bls12-381/crate-override/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "criterion" 3 | version = "0.2.10" 4 | edition = "2018" 5 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/bls12-381/crate-override/src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | 3 | pub fn main() { 4 | let _hello = "world"; 5 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bls12-381/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bls12-381/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_add/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bn128_add-bench" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [dependencies] 7 | ethereum-bn128 = { git = "https://github.com/ewasm/ethereum-bn128.rs", tag = "0.1.1" } 8 | 9 | [target.'cfg(target_arch = "wasm32")'.dependencies] 10 | wee_alloc = "0.4.2" 11 | 12 | [lib] 13 | name = "bn128_add_wasm" 14 | crate-type = ["cdylib"] 15 | path = "src/lib.rs" 16 | 17 | [[bin]] 18 | name = "bn128_add_native" 19 | path = "src/main.rs" 20 | 21 | [profile.release] 22 | opt-level = 3 23 | debug = false 24 | lto = true 25 | debug-assertions = false 26 | overflow-checks = false 27 | panic = "abort" 28 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_add/src/bench.rs: -------------------------------------------------------------------------------- 1 | extern crate ethereum_bn128; 2 | 3 | pub fn bench() { 4 | 5 | // let input: [u8; 128] = [ 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8 ]; 6 | 7 | {{input}} 8 | 9 | // let expected: [u8; 64] = [ 3u8, 6u8, 68u8, 231u8, 46u8, 19u8, 26u8, 2u8, 155u8, 133u8, 4u8, 91u8, 104u8, 24u8, 21u8, 133u8, 217u8, 120u8, 22u8, 169u8, 22u8, 135u8, 28u8, 168u8, 211u8, 194u8, 8u8, 193u8, 109u8, 135u8, 207u8, 211u8, 21u8, 237u8, 115u8, 140u8, 14u8, 10u8, 124u8, 146u8, 231u8, 132u8, 95u8, 150u8, 178u8, 174u8, 156u8, 10u8, 104u8, 166u8, 164u8, 73u8, 227u8, 83u8, 143u8, 199u8, 255u8, 62u8, 191u8, 122u8, 90u8, 24u8, 162u8, 196u8 ]; 10 | 11 | {{expected}} 12 | 13 | let mut output = [0u8; 64]; 14 | match ethereum_bn128::bn128_add(&input[..], &mut output) { 15 | Ok(_) => { 16 | if !(output).eq(expected.as_ref()) { 17 | panic!("crash and burn"); 18 | } 19 | }, 20 | Err(_) => panic!(), 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_add/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_add/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_mul/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bn128_mul-bench" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [dependencies] 7 | ethereum-bn128 = { git = "https://github.com/ewasm/ethereum-bn128.rs", tag = "0.1.1" } 8 | 9 | [target.'cfg(target_arch = "wasm32")'.dependencies] 10 | wee_alloc = "0.4.2" 11 | 12 | [lib] 13 | name = "bn128_mul_wasm" 14 | crate-type = ["cdylib"] 15 | path = "src/lib.rs" 16 | 17 | [[bin]] 18 | name = "bn128_mul_native" 19 | path = "src/main.rs" 20 | 21 | [profile.release] 22 | opt-level = 3 23 | debug = false 24 | lto = true 25 | debug-assertions = false 26 | overflow-checks = false 27 | panic = "abort" 28 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_mul/src/bench.rs: -------------------------------------------------------------------------------- 1 | extern crate ethereum_bn128; 2 | 3 | pub fn bench() { 4 | 5 | // let input: [u8; 96] = [ 3u8, 151u8, 48u8, 234u8, 141u8, 255u8, 18u8, 84u8, 192u8, 254u8, 233u8, 192u8, 234u8, 119u8, 125u8, 41u8, 169u8, 199u8, 16u8, 183u8, 230u8, 22u8, 104u8, 63u8, 25u8, 79u8, 24u8, 196u8, 59u8, 67u8, 184u8, 105u8, 7u8, 58u8, 95u8, 252u8, 198u8, 252u8, 122u8, 40u8, 195u8, 7u8, 35u8, 214u8, 229u8, 140u8, 229u8, 119u8, 53u8, 105u8, 130u8, 214u8, 91u8, 131u8, 58u8, 90u8, 92u8, 21u8, 191u8, 144u8, 36u8, 180u8, 61u8, 152u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8, 255u8 ]; 6 | 7 | {{input}} 8 | 9 | // let expected: [u8; 64] = [ 0u8, 161u8, 162u8, 52u8, 208u8, 142u8, 250u8, 162u8, 97u8, 102u8, 7u8, 227u8, 30u8, 202u8, 25u8, 128u8, 18u8, 139u8, 0u8, 180u8, 21u8, 200u8, 69u8, 255u8, 37u8, 187u8, 163u8, 175u8, 203u8, 129u8, 220u8, 0u8, 36u8, 32u8, 119u8, 41u8, 14u8, 211u8, 57u8, 6u8, 174u8, 184u8, 228u8, 47u8, 217u8, 140u8, 65u8, 188u8, 185u8, 5u8, 123u8, 160u8, 52u8, 33u8, 175u8, 63u8, 45u8, 8u8, 207u8, 196u8, 65u8, 24u8, 96u8, 36u8 ]; 10 | 11 | {{expected}} 12 | 13 | let mut output = [0u8; 64]; 14 | match ethereum_bn128::bn128_mul(&input[..], &mut output) { 15 | Ok(_) => { 16 | if !(output).eq(expected.as_ref()) { 17 | panic!("crash and burn"); 18 | } 19 | }, 20 | Err(_) => panic!(), 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_mul/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_mul/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_pairing/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bn128_pairing-bench" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | [dependencies] 7 | ethereum-bn128 = { git = "https://github.com/ewasm/ethereum-bn128.rs", tag = "0.1.1" } 8 | 9 | [target.'cfg(target_arch = "wasm32")'.dependencies] 10 | wee_alloc = "0.4.3" 11 | 12 | [lib] 13 | name = "bn128_pairing_wasm" 14 | crate-type = ["cdylib"] 15 | path = "src/lib.rs" 16 | 17 | [[bin]] 18 | name = "bn128_pairing_native" 19 | path = "src/main.rs" 20 | 21 | [profile.release] 22 | opt-level = 3 23 | debug = false 24 | lto = true 25 | debug-assertions = false 26 | overflow-checks = false 27 | panic = "abort" 28 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_pairing/src/bench.rs: -------------------------------------------------------------------------------- 1 | extern crate ethereum_bn128; 2 | 3 | pub fn bench() { 4 | 5 | // gas logic is neglible, can exclude from benchmark 6 | /* 7 | // let length = ewasm_api::calldata_size(); 8 | // charge a base fee plus a word fee for every element 9 | let base_fee = 100000; 10 | let element_fee = 80000; 11 | let total_cost = base_fee + (length / 192) * element_fee; 12 | ewasm_api::consume_gas(total_cost as u64); 13 | */ 14 | 15 | // 00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed275dc4a288d1afb3cbb1ac09187524c7db36395df7be3b99e673b13a075a65ec1d9befcd05a5323e6da4d435f3b617cdb3af83285c2df711ef39c01571827f9d 16 | 17 | // let input: [u8; 384] = [ 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8, 25u8, 142u8, 147u8, 147u8, 146u8, 13u8, 72u8, 58u8, 114u8, 96u8, 191u8, 183u8, 49u8, 251u8, 93u8, 37u8, 241u8, 170u8, 73u8, 51u8, 53u8, 169u8, 231u8, 18u8, 151u8, 228u8, 133u8, 183u8, 174u8, 243u8, 18u8, 194u8, 24u8, 0u8, 222u8, 239u8, 18u8, 31u8, 30u8, 118u8, 66u8, 106u8, 0u8, 102u8, 94u8, 92u8, 68u8, 121u8, 103u8, 67u8, 34u8, 212u8, 247u8, 94u8, 218u8, 221u8, 70u8, 222u8, 189u8, 92u8, 217u8, 146u8, 246u8, 237u8, 9u8, 6u8, 137u8, 208u8, 88u8, 95u8, 240u8, 117u8, 236u8, 158u8, 153u8, 173u8, 105u8, 12u8, 51u8, 149u8, 188u8, 75u8, 49u8, 51u8, 112u8, 179u8, 142u8, 243u8, 85u8, 172u8, 218u8, 220u8, 209u8, 34u8, 151u8, 91u8, 18u8, 200u8, 94u8, 165u8, 219u8, 140u8, 109u8, 235u8, 74u8, 171u8, 113u8, 128u8, 141u8, 203u8, 64u8, 143u8, 227u8, 209u8, 231u8, 105u8, 12u8, 67u8, 211u8, 123u8, 76u8, 230u8, 204u8, 1u8, 102u8, 250u8, 125u8, 170u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 2u8, 25u8, 142u8, 147u8, 147u8, 146u8, 13u8, 72u8, 58u8, 114u8, 96u8, 191u8, 183u8, 49u8, 251u8, 93u8, 37u8, 241u8, 170u8, 73u8, 51u8, 53u8, 169u8, 231u8, 18u8, 151u8, 228u8, 133u8, 183u8, 174u8, 243u8, 18u8, 194u8, 24u8, 0u8, 222u8, 239u8, 18u8, 31u8, 30u8, 118u8, 66u8, 106u8, 0u8, 102u8, 94u8, 92u8, 68u8, 121u8, 103u8, 67u8, 34u8, 212u8, 247u8, 94u8, 218u8, 221u8, 70u8, 222u8, 189u8, 92u8, 217u8, 146u8, 246u8, 237u8, 39u8, 93u8, 196u8, 162u8, 136u8, 209u8, 175u8, 179u8, 203u8, 177u8, 172u8, 9u8, 24u8, 117u8, 36u8, 199u8, 219u8, 54u8, 57u8, 93u8, 247u8, 190u8, 59u8, 153u8, 230u8, 115u8, 177u8, 58u8, 7u8, 90u8, 101u8, 236u8, 29u8, 155u8, 239u8, 205u8, 5u8, 165u8, 50u8, 62u8, 109u8, 164u8, 212u8, 53u8, 243u8, 182u8, 23u8, 205u8, 179u8, 175u8, 131u8, 40u8, 92u8, 45u8, 247u8, 17u8, 239u8, 57u8, 192u8, 21u8, 113u8, 130u8, 127u8, 157u8 ]; 18 | 19 | {{input}} 20 | 21 | // NOTE: this validation will also be done by bn128_pairing 22 | if input.len() % 192 != 0 { 23 | panic!(); 24 | } 25 | 26 | // let expected: [u8; 32] = [ 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8 ]; 27 | 28 | {{expected}} 29 | 30 | let mut output = [0u8; 32]; 31 | match ethereum_bn128::bn128_pairing(&input[..], &mut output) { 32 | Ok(_) => { 33 | // check that output is equal to expected 34 | if !(output).eq(expected.as_ref()) { 35 | panic!("crash and burn"); 36 | } 37 | }, 38 | Err(_) => panic!(), 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_pairing/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/bn128_pairing/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/ed25519/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ed25519-bench" 3 | version = "0.1.0" 4 | authors = ["Jared Wasinger "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | sha2 = "^0.8" 9 | 10 | [dependencies.rand] 11 | version = "^0.6.0" 12 | 13 | [dependencies.ed25519-dalek] 14 | version = "^0.9.1" 15 | 16 | [dependencies.clear_on_drop] 17 | features = ["no_cc"] 18 | version = "^0.2.3" 19 | 20 | [target.'cfg(target_arch = "wasm32")'.dependencies] 21 | wee_alloc = "0.4.2" 22 | 23 | [lib] 24 | name = "ed25519_wasm" 25 | crate-type = ["cdylib"] 26 | path = "src/lib.rs" 27 | 28 | [[bin]] 29 | name = "ed25519_native" 30 | path = "src/main.rs" 31 | 32 | [profile.release] 33 | opt-level = 3 34 | debug = false 35 | lto = true 36 | debug-assertions = false 37 | overflow-checks = false 38 | panic = "abort" 39 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/ed25519/src/bench.rs: -------------------------------------------------------------------------------- 1 | extern crate ed25519_dalek; 2 | extern crate sha2; 3 | 4 | use ed25519_dalek::{PublicKey, Signature}; 5 | use sha2::Sha512; 6 | 7 | #[derive(Debug)] 8 | pub struct Error(pub &'static str); 9 | 10 | impl From<&'static str> for self::Error { 11 | fn from(val: &'static str) -> Self { 12 | self::Error(val) 13 | } 14 | } 15 | 16 | pub fn verify(input: &[u8; 128]) -> Result { 17 | let message = &input[..32]; 18 | 19 | let public_key = 20 | PublicKey::from_bytes(&input[32..64]).expect("public key should be correctly formed"); 21 | let sig = Signature::from_bytes(&input[64..128]).expect("signature should be correctly formed"); 22 | 23 | Ok(public_key.verify::(&message, &sig).is_ok()) 24 | } 25 | 26 | pub fn bench() { 27 | 28 | // all of these inputs have 32 octet message length, as specified by ed25519 EIP http://eips.ethereum.org/EIPS/eip-665 29 | static INPUT: [[u8; 128]; 10] = [ 30 | [ 117u8, 87u8, 240u8, 26u8, 37u8, 90u8, 201u8, 138u8, 50u8, 90u8, 27u8, 250u8, 174u8, 72u8, 75u8, 161u8, 27u8, 1u8, 54u8, 142u8, 41u8, 156u8, 59u8, 141u8, 147u8, 112u8, 24u8, 7u8, 80u8, 130u8, 59u8, 234u8, 217u8, 68u8, 48u8, 176u8, 25u8, 242u8, 155u8, 199u8, 139u8, 221u8, 42u8, 156u8, 190u8, 121u8, 108u8, 155u8, 99u8, 58u8, 213u8, 203u8, 228u8, 172u8, 128u8, 74u8, 193u8, 24u8, 86u8, 55u8, 144u8, 228u8, 198u8, 87u8, 169u8, 120u8, 200u8, 158u8, 27u8, 131u8, 196u8, 162u8, 243u8, 55u8, 167u8, 123u8, 16u8, 53u8, 29u8, 14u8, 24u8, 64u8, 137u8, 254u8, 207u8, 14u8, 168u8, 135u8, 6u8, 20u8, 87u8, 3u8, 6u8, 237u8, 212u8, 169u8, 236u8, 231u8, 205u8, 188u8, 51u8, 120u8, 151u8, 139u8, 244u8, 164u8, 248u8, 92u8, 2u8, 82u8, 235u8, 181u8, 28u8, 240u8, 11u8, 42u8, 79u8, 194u8, 56u8, 51u8, 198u8, 161u8, 246u8, 135u8, 85u8, 3u8, 174u8, 8u8 ], 31 | [ 0u8, 205u8, 75u8, 254u8, 130u8, 243u8, 222u8, 112u8, 45u8, 108u8, 123u8, 219u8, 3u8, 251u8, 94u8, 25u8, 139u8, 44u8, 145u8, 157u8, 81u8, 29u8, 160u8, 83u8, 64u8, 217u8, 233u8, 168u8, 209u8, 159u8, 35u8, 163u8, 111u8, 88u8, 75u8, 220u8, 6u8, 227u8, 24u8, 182u8, 94u8, 188u8, 25u8, 233u8, 119u8, 15u8, 130u8, 104u8, 134u8, 134u8, 195u8, 48u8, 26u8, 70u8, 205u8, 167u8, 23u8, 166u8, 245u8, 217u8, 121u8, 151u8, 8u8, 253u8, 102u8, 132u8, 155u8, 4u8, 93u8, 1u8, 181u8, 9u8, 118u8, 242u8, 94u8, 9u8, 45u8, 130u8, 253u8, 133u8, 201u8, 50u8, 239u8, 40u8, 41u8, 78u8, 130u8, 112u8, 163u8, 171u8, 220u8, 152u8, 244u8, 200u8, 131u8, 106u8, 163u8, 146u8, 144u8, 2u8, 160u8, 199u8, 163u8, 59u8, 76u8, 141u8, 155u8, 180u8, 34u8, 204u8, 229u8, 205u8, 82u8, 149u8, 74u8, 222u8, 18u8, 40u8, 241u8, 85u8, 38u8, 148u8, 187u8, 111u8, 159u8, 2u8, 253u8, 10u8 ], 32 | [ 110u8, 171u8, 145u8, 231u8, 224u8, 73u8, 119u8, 8u8, 151u8, 76u8, 4u8, 205u8, 122u8, 146u8, 172u8, 89u8, 132u8, 199u8, 81u8, 255u8, 49u8, 75u8, 143u8, 253u8, 237u8, 249u8, 230u8, 85u8, 120u8, 145u8, 221u8, 155u8, 168u8, 243u8, 231u8, 155u8, 95u8, 217u8, 81u8, 133u8, 98u8, 175u8, 24u8, 252u8, 234u8, 184u8, 141u8, 211u8, 52u8, 162u8, 33u8, 122u8, 33u8, 164u8, 115u8, 214u8, 127u8, 28u8, 143u8, 47u8, 240u8, 214u8, 170u8, 63u8, 191u8, 117u8, 166u8, 62u8, 176u8, 124u8, 183u8, 26u8, 240u8, 218u8, 213u8, 73u8, 140u8, 184u8, 93u8, 238u8, 4u8, 238u8, 9u8, 181u8, 47u8, 8u8, 129u8, 14u8, 84u8, 56u8, 207u8, 80u8, 77u8, 54u8, 110u8, 141u8, 121u8, 255u8, 119u8, 19u8, 163u8, 123u8, 74u8, 173u8, 45u8, 113u8, 181u8, 145u8, 158u8, 0u8, 159u8, 41u8, 219u8, 237u8, 112u8, 0u8, 33u8, 109u8, 92u8, 48u8, 163u8, 50u8, 208u8, 52u8, 189u8, 109u8, 83u8, 6u8 ], 33 | [ 9u8, 22u8, 141u8, 166u8, 158u8, 152u8, 163u8, 32u8, 171u8, 175u8, 77u8, 104u8, 0u8, 248u8, 24u8, 195u8, 172u8, 24u8, 74u8, 35u8, 222u8, 162u8, 78u8, 234u8, 155u8, 249u8, 181u8, 98u8, 171u8, 92u8, 173u8, 26u8, 98u8, 226u8, 221u8, 157u8, 20u8, 178u8, 58u8, 216u8, 2u8, 19u8, 180u8, 255u8, 210u8, 189u8, 17u8, 185u8, 119u8, 132u8, 100u8, 185u8, 94u8, 95u8, 184u8, 14u8, 221u8, 222u8, 206u8, 254u8, 152u8, 171u8, 1u8, 117u8, 153u8, 22u8, 102u8, 94u8, 82u8, 17u8, 218u8, 229u8, 109u8, 12u8, 86u8, 207u8, 85u8, 50u8, 87u8, 133u8, 235u8, 4u8, 21u8, 162u8, 2u8, 74u8, 129u8, 154u8, 133u8, 3u8, 161u8, 242u8, 114u8, 180u8, 135u8, 13u8, 241u8, 67u8, 246u8, 68u8, 255u8, 182u8, 112u8, 158u8, 104u8, 205u8, 42u8, 72u8, 153u8, 198u8, 56u8, 242u8, 76u8, 125u8, 90u8, 176u8, 169u8, 122u8, 90u8, 96u8, 155u8, 0u8, 19u8, 248u8, 225u8, 168u8, 232u8, 12u8 ], 34 | [ 50u8, 141u8, 197u8, 228u8, 19u8, 84u8, 122u8, 178u8, 168u8, 128u8, 204u8, 49u8, 121u8, 157u8, 86u8, 251u8, 189u8, 116u8, 227u8, 205u8, 24u8, 155u8, 3u8, 194u8, 59u8, 82u8, 47u8, 60u8, 166u8, 208u8, 196u8, 202u8, 168u8, 52u8, 142u8, 25u8, 64u8, 202u8, 105u8, 9u8, 204u8, 210u8, 76u8, 148u8, 186u8, 63u8, 223u8, 240u8, 108u8, 224u8, 11u8, 232u8, 189u8, 248u8, 3u8, 198u8, 184u8, 229u8, 88u8, 148u8, 32u8, 66u8, 96u8, 176u8, 195u8, 202u8, 137u8, 204u8, 157u8, 1u8, 14u8, 69u8, 93u8, 240u8, 101u8, 23u8, 62u8, 233u8, 194u8, 164u8, 106u8, 192u8, 9u8, 218u8, 145u8, 188u8, 71u8, 253u8, 87u8, 240u8, 181u8, 47u8, 168u8, 58u8, 245u8, 141u8, 171u8, 141u8, 33u8, 89u8, 221u8, 173u8, 201u8, 64u8, 179u8, 240u8, 95u8, 127u8, 156u8, 195u8, 119u8, 51u8, 54u8, 189u8, 163u8, 27u8, 136u8, 97u8, 48u8, 239u8, 11u8, 131u8, 91u8, 154u8, 126u8, 77u8, 245u8, 4u8 ], 35 | [ 63u8, 134u8, 171u8, 12u8, 7u8, 145u8, 116u8, 86u8, 99u8, 54u8, 236u8, 220u8, 157u8, 238u8, 101u8, 18u8, 44u8, 171u8, 69u8, 9u8, 242u8, 20u8, 2u8, 51u8, 148u8, 207u8, 32u8, 147u8, 90u8, 47u8, 101u8, 46u8, 90u8, 8u8, 122u8, 230u8, 145u8, 72u8, 136u8, 182u8, 71u8, 122u8, 26u8, 191u8, 199u8, 162u8, 168u8, 130u8, 201u8, 76u8, 75u8, 226u8, 50u8, 207u8, 116u8, 199u8, 234u8, 23u8, 163u8, 83u8, 100u8, 37u8, 205u8, 218u8, 212u8, 85u8, 24u8, 94u8, 198u8, 246u8, 111u8, 129u8, 67u8, 127u8, 226u8, 49u8, 1u8, 143u8, 126u8, 47u8, 69u8, 224u8, 83u8, 196u8, 74u8, 111u8, 174u8, 187u8, 124u8, 102u8, 193u8, 32u8, 40u8, 228u8, 189u8, 29u8, 36u8, 232u8, 101u8, 123u8, 188u8, 92u8, 116u8, 114u8, 160u8, 18u8, 46u8, 236u8, 126u8, 86u8, 33u8, 205u8, 96u8, 214u8, 232u8, 164u8, 181u8, 70u8, 41u8, 127u8, 217u8, 136u8, 149u8, 223u8, 11u8, 209u8, 27u8, 10u8 ], 36 | [ 53u8, 191u8, 88u8, 13u8, 183u8, 15u8, 239u8, 17u8, 200u8, 242u8, 7u8, 3u8, 90u8, 134u8, 44u8, 36u8, 233u8, 25u8, 1u8, 5u8, 248u8, 140u8, 67u8, 55u8, 21u8, 125u8, 113u8, 219u8, 214u8, 221u8, 207u8, 109u8, 63u8, 142u8, 245u8, 236u8, 67u8, 81u8, 33u8, 15u8, 182u8, 69u8, 173u8, 179u8, 82u8, 122u8, 179u8, 84u8, 119u8, 15u8, 204u8, 106u8, 209u8, 37u8, 110u8, 163u8, 131u8, 18u8, 92u8, 79u8, 116u8, 253u8, 37u8, 77u8, 214u8, 77u8, 148u8, 152u8, 51u8, 53u8, 217u8, 170u8, 202u8, 232u8, 75u8, 40u8, 3u8, 164u8, 76u8, 40u8, 217u8, 46u8, 42u8, 17u8, 156u8, 49u8, 214u8, 46u8, 140u8, 171u8, 143u8, 212u8, 83u8, 215u8, 18u8, 181u8, 0u8, 68u8, 190u8, 126u8, 156u8, 84u8, 3u8, 48u8, 205u8, 74u8, 22u8, 71u8, 41u8, 180u8, 155u8, 80u8, 209u8, 248u8, 0u8, 132u8, 86u8, 142u8, 70u8, 55u8, 175u8, 189u8, 74u8, 102u8, 226u8, 9u8, 14u8, 0u8 ], 37 | [ 101u8, 6u8, 229u8, 86u8, 210u8, 222u8, 202u8, 160u8, 231u8, 158u8, 204u8, 124u8, 68u8, 24u8, 148u8, 47u8, 94u8, 83u8, 240u8, 114u8, 68u8, 121u8, 165u8, 210u8, 222u8, 126u8, 135u8, 69u8, 226u8, 143u8, 81u8, 181u8, 228u8, 72u8, 94u8, 246u8, 56u8, 191u8, 114u8, 5u8, 74u8, 222u8, 192u8, 87u8, 193u8, 138u8, 124u8, 170u8, 146u8, 115u8, 157u8, 131u8, 203u8, 139u8, 128u8, 162u8, 72u8, 109u8, 101u8, 254u8, 37u8, 115u8, 22u8, 42u8, 148u8, 64u8, 8u8, 18u8, 226u8, 132u8, 6u8, 0u8, 249u8, 142u8, 230u8, 2u8, 111u8, 244u8, 146u8, 243u8, 19u8, 15u8, 24u8, 156u8, 8u8, 0u8, 115u8, 236u8, 85u8, 53u8, 153u8, 225u8, 145u8, 96u8, 132u8, 239u8, 114u8, 87u8, 173u8, 17u8, 195u8, 104u8, 92u8, 252u8, 192u8, 193u8, 114u8, 178u8, 101u8, 148u8, 124u8, 172u8, 76u8, 120u8, 104u8, 119u8, 252u8, 87u8, 236u8, 126u8, 188u8, 195u8, 135u8, 160u8, 66u8, 179u8, 32u8, 14u8 ], 38 | [ 129u8, 82u8, 102u8, 165u8, 121u8, 194u8, 43u8, 149u8, 54u8, 107u8, 147u8, 70u8, 242u8, 43u8, 34u8, 29u8, 84u8, 158u8, 97u8, 184u8, 72u8, 10u8, 47u8, 109u8, 187u8, 9u8, 59u8, 58u8, 179u8, 149u8, 117u8, 142u8, 9u8, 16u8, 28u8, 224u8, 200u8, 49u8, 161u8, 114u8, 83u8, 138u8, 207u8, 11u8, 58u8, 222u8, 79u8, 46u8, 20u8, 104u8, 227u8, 29u8, 113u8, 199u8, 201u8, 89u8, 232u8, 187u8, 19u8, 172u8, 222u8, 145u8, 253u8, 221u8, 154u8, 23u8, 168u8, 173u8, 187u8, 57u8, 12u8, 81u8, 54u8, 107u8, 8u8, 158u8, 252u8, 254u8, 219u8, 53u8, 182u8, 167u8, 17u8, 206u8, 137u8, 12u8, 134u8, 226u8, 90u8, 153u8, 229u8, 159u8, 208u8, 89u8, 10u8, 248u8, 47u8, 172u8, 254u8, 222u8, 76u8, 50u8, 24u8, 119u8, 0u8, 78u8, 227u8, 92u8, 80u8, 105u8, 193u8, 245u8, 79u8, 234u8, 133u8, 97u8, 253u8, 241u8, 89u8, 198u8, 54u8, 45u8, 85u8, 235u8, 140u8, 15u8, 60u8, 10u8 ], 39 | [ 17u8, 16u8, 246u8, 228u8, 194u8, 92u8, 188u8, 148u8, 83u8, 160u8, 45u8, 141u8, 228u8, 66u8, 73u8, 111u8, 143u8, 171u8, 158u8, 159u8, 90u8, 152u8, 158u8, 100u8, 135u8, 32u8, 236u8, 113u8, 95u8, 67u8, 161u8, 70u8, 144u8, 112u8, 139u8, 9u8, 114u8, 129u8, 114u8, 64u8, 44u8, 248u8, 87u8, 211u8, 84u8, 94u8, 207u8, 72u8, 130u8, 211u8, 192u8, 130u8, 141u8, 121u8, 235u8, 242u8, 3u8, 96u8, 183u8, 55u8, 29u8, 167u8, 149u8, 175u8, 122u8, 13u8, 244u8, 69u8, 16u8, 1u8, 108u8, 3u8, 206u8, 19u8, 117u8, 36u8, 52u8, 159u8, 66u8, 47u8, 57u8, 148u8, 52u8, 231u8, 54u8, 94u8, 92u8, 107u8, 144u8, 77u8, 70u8, 109u8, 222u8, 221u8, 6u8, 57u8, 165u8, 52u8, 132u8, 19u8, 199u8, 88u8, 184u8, 165u8, 250u8, 74u8, 156u8, 74u8, 218u8, 242u8, 94u8, 28u8, 1u8, 244u8, 128u8, 250u8, 145u8, 5u8, 198u8, 130u8, 3u8, 7u8, 223u8, 115u8, 54u8, 86u8, 58u8, 11u8 ] 40 | ]; 41 | 42 | for i in INPUT.iter() { 43 | match verify(&i) { 44 | Ok(true) => { 45 | continue; 46 | }, 47 | Ok(false) => { 48 | panic!("failed"); 49 | } 50 | Err(_) => { 51 | panic!("failed"); 52 | } 53 | } 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/ed25519/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/ed25519/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/modexp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ewasm-precompile-modexp-bench" 3 | version = "0.1.0" 4 | authors = ["cdetrio", "Guillaume Ballet "] 5 | license = "Apache-2.0" 6 | edition = "2018" 7 | description = "Ethereum modexp precompile in Rust" 8 | publish = false 9 | 10 | [dependencies] 11 | num = {version = "0.1.36", default-features = false} 12 | num-bigint = {version = "0.1.36", default-features = false} 13 | 14 | [target.'cfg(target_arch = "wasm32")'.dependencies] 15 | wee_alloc = "0.4.2" 16 | 17 | [lib] 18 | name = "modexp_wasm" 19 | crate-type = ["cdylib"] 20 | path = "src/lib.rs" 21 | 22 | [[bin]] 23 | name = "modexp_native" 24 | path = "src/main.rs" 25 | 26 | [profile.release] 27 | opt-level = 3 28 | debug = false 29 | lto = true 30 | debug-assertions = false 31 | overflow-checks = false 32 | panic = "abort" 33 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/modexp/src/bench.rs: -------------------------------------------------------------------------------- 1 | extern crate num_bigint; 2 | 3 | use num::{One, Zero}; 4 | use num_bigint::{BigInt, Sign}; 5 | use std::cmp; 6 | use std::io::{self, Read}; 7 | use std::ops::{Rem, Shl}; 8 | 9 | const LENGTH_LENGTH: usize = 32; 10 | const G_QUAD_DIVISOR: u64 = 20; 11 | 12 | fn f(x: u64) -> u64 { 13 | match x { 14 | 0...64 => x * x, 15 | 65...1024 => (x * x / 4) + 96 * x - 3072, 16 | _ => (x * x / 16) + 480 * x - 199680, 17 | } 18 | } 19 | 20 | fn calculate_cost(lm: usize, lb: usize, exp: &BigInt) -> u64 { 21 | let le = exp.to_bytes_be().1.len(); 22 | let lep: u64 = match le { 23 | 0...32 => { 24 | if exp.is_zero() { 25 | 0u64 26 | } else { 27 | exp.bits() as u64 - 1 28 | } 29 | } 30 | _ => { 31 | let nbits = exp.bits(); 32 | let (loglow32bytes, low32bytes) = if nbits > 256 { 33 | let x = exp.rem(&BigInt::one().shl(256)); 34 | (x.bits() - 1, x) 35 | } else { 36 | (nbits - 1, exp.clone()) 37 | }; 38 | 39 | if low32bytes > BigInt::zero() { 40 | 8 * (le as u64 - 32) + loglow32bytes as u64 41 | } else { 42 | 8 * (le as u64 - 32) 43 | } 44 | } 45 | }; 46 | 47 | (f(cmp::max(lm, lb) as u64) * cmp::max(lep, 1 as u64)) / G_QUAD_DIVISOR 48 | } 49 | 50 | fn modexp(base: &BigInt, exp: &BigInt, modulus: &BigInt) -> Vec { 51 | let x = if modulus.is_zero() { 52 | BigInt::zero() 53 | } else { 54 | base.modpow(exp, modulus) 55 | }; 56 | let (_, mut data) = x.to_bytes_be(); 57 | 58 | /* padded on 32 bytes */ 59 | let mut padded = vec![0u8; (32 - (data.len() % 32)) % 32]; 60 | padded.append(&mut data); 61 | padded 62 | } 63 | 64 | 65 | pub fn bench() { 66 | use num::cast::ToPrimitive; 67 | 68 | // let input_size = ewasm_api::calldata_size(); 69 | 70 | // let input: [u8; 225] = [ 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 64u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 64u8, 224u8, 154u8, 217u8, 103u8, 84u8, 101u8, 197u8, 58u8, 16u8, 159u8, 172u8, 102u8, 164u8, 69u8, 201u8, 27u8, 41u8, 45u8, 43u8, 178u8, 197u8, 38u8, 138u8, 221u8, 179u8, 12u8, 216u8, 47u8, 128u8, 252u8, 176u8, 3u8, 63u8, 249u8, 124u8, 128u8, 165u8, 252u8, 111u8, 57u8, 25u8, 58u8, 233u8, 105u8, 198u8, 237u8, 230u8, 113u8, 10u8, 107u8, 122u8, 194u8, 112u8, 120u8, 160u8, 109u8, 144u8, 239u8, 28u8, 114u8, 229u8, 200u8, 95u8, 181u8, 2u8, 252u8, 158u8, 31u8, 107u8, 235u8, 129u8, 81u8, 101u8, 69u8, 151u8, 82u8, 24u8, 7u8, 94u8, 194u8, 175u8, 17u8, 140u8, 216u8, 121u8, 141u8, 246u8, 224u8, 138u8, 20u8, 124u8, 96u8, 253u8, 96u8, 149u8, 172u8, 43u8, 176u8, 44u8, 41u8, 8u8, 207u8, 77u8, 215u8, 200u8, 31u8, 17u8, 194u8, 137u8, 228u8, 188u8, 233u8, 143u8, 53u8, 83u8, 118u8, 143u8, 57u8, 42u8, 128u8, 206u8, 34u8, 191u8, 92u8, 79u8, 74u8, 36u8, 140u8, 107u8 ]; 71 | 72 | {{input}} 73 | 74 | // let expected: [u8; 64] = [ 96u8, 0u8, 143u8, 22u8, 20u8, 204u8, 1u8, 220u8, 251u8, 107u8, 251u8, 9u8, 198u8, 37u8, 207u8, 144u8, 180u8, 125u8, 68u8, 104u8, 219u8, 129u8, 181u8, 248u8, 183u8, 163u8, 157u8, 66u8, 243u8, 50u8, 234u8, 185u8, 178u8, 218u8, 143u8, 45u8, 149u8, 49u8, 22u8, 72u8, 168u8, 242u8, 67u8, 244u8, 187u8, 19u8, 207u8, 179u8, 216u8, 247u8, 242u8, 163u8, 192u8, 20u8, 18u8, 46u8, 187u8, 62u8, 212u8, 27u8, 2u8, 120u8, 58u8, 220u8 ]; 75 | 76 | {{expected}} 77 | 78 | let mut reader = input.chain(io::repeat(0)); 79 | 80 | let mut length_bytes = [0u8; LENGTH_LENGTH]; 81 | reader 82 | .read_exact(&mut length_bytes) 83 | .expect("Should be able to read 32 bytes from input"); 84 | let base_length = BigInt::from_bytes_be(Sign::Plus, &length_bytes[..]) 85 | .to_usize() // Get the `usize` version of base_length, as it won't 86 | .unwrap(); // be possible to read more anyway. 87 | 88 | reader 89 | .read_exact(&mut length_bytes) 90 | .expect("Should be able to read 32 bytes from input"); 91 | let exp_length = BigInt::from_bytes_be(Sign::Plus, &length_bytes[..]) 92 | .to_usize() // Same thing with exponent 93 | .unwrap(); 94 | 95 | reader 96 | .read_exact(&mut length_bytes) 97 | .expect("Should be able to read 32 bytes from input"); 98 | let mod_length = BigInt::from_bytes_be(Sign::Plus, &length_bytes[..]) 99 | .to_usize() 100 | .unwrap(); 101 | 102 | let mut base_bytes = vec![0u8; base_length]; 103 | reader 104 | .read_exact(&mut base_bytes[..]) 105 | .expect("Should be able to read base bytes from input"); 106 | let base = BigInt::from_bytes_be(Sign::Plus, &base_bytes[..]); 107 | let mut exp_bytes = vec![0u8; exp_length]; 108 | reader 109 | .read_exact(&mut exp_bytes[..]) 110 | .expect("Should be able to read exp bytes from input"); 111 | let exp = BigInt::from_bytes_be(Sign::Plus, &exp_bytes[..]); 112 | let mut mod_bytes = vec![0u8; mod_length]; 113 | reader 114 | .read_exact(&mut mod_bytes[..]) 115 | .expect("Should be able to read modulus bytes from input"); 116 | let modulus = BigInt::from_bytes_be(Sign::Plus, &mod_bytes[..]); 117 | 118 | let _cost = calculate_cost(mod_length, base_length, &exp); 119 | 120 | // Geth's returns an empty array when base and mod both have 121 | // zero length. 122 | if base_length == 0 && mod_length == 0 { 123 | //ewasm_api::finish(); 124 | return; 125 | } 126 | 127 | let output = modexp(&base, &exp, &modulus); 128 | //println!("output: {:?}", output); 129 | //println!("expected: {:?}", expected.as_ref()); 130 | //ewasm_api::finish_data(&output[..]) 131 | 132 | if output != expected.as_ref() { 133 | panic!("crash and burn"); 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/modexp/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/modexp/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/mul256/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ewasm-mul256" 3 | version = "0.1.0" 4 | license = "Apache-2.0" 5 | description = "Ethereum mul256 benchmark in Rust" 6 | publish = false 7 | edition = "2018" 8 | 9 | [dependencies] 10 | bigint = "4.4.1" 11 | wee_alloc = "0.4.3" 12 | 13 | [target.'cfg(target_arch = "wasm32")'.dependencies] 14 | wee_alloc = "0.4.3" 15 | 16 | [lib] 17 | name = "mul256_wasm" 18 | crate-type = ["cdylib"] 19 | path = "src/lib.rs" 20 | 21 | [[bin]] 22 | name = "mul256_native" 23 | path = "src/main.rs" 24 | 25 | [profile.release] 26 | opt-level = 3 27 | debug = false 28 | lto = true 29 | debug-assertions = false 30 | overflow-checks = false 31 | panic = "abort" -------------------------------------------------------------------------------- /wasm-engines/rust-code/mul256/src/bench.rs: -------------------------------------------------------------------------------- 1 | 2 | pub fn bench() { 3 | {{input}} 4 | 5 | 6 | let mut x = bigint::uint::U256::from(&input[4..36]); 7 | let y = bigint::uint::U256::from(&input[36..68]); 8 | 9 | // based on https://github.com/gcolvin/evm-drag-race/blob/550e4e85f4db9c1485d01498d8033ef91c55cd78/mul256c.cpp 10 | 11 | for _i in 0..10000 { 12 | //x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; 13 | //x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; x = x*y; 14 | 15 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 16 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 17 | 18 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 19 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 20 | 21 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 22 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 23 | 24 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 25 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 26 | 27 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 28 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 29 | 30 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 31 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 32 | 33 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 34 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 35 | 36 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 37 | x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; x = x.overflowing_mul(y).0; 38 | } 39 | 40 | let mut result = [0u8; 32]; 41 | x.to_big_endian(&mut result); 42 | 43 | {{expected}} 44 | 45 | if result != expected { 46 | panic!("crash and burn"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/mul256/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/mul256/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | } 12 | -------------------------------------------------------------------------------- /wasm-engines/rust-code/sha1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ewasm-bench-sha1" 3 | version = "0.1.0" 4 | license = "Apache-2.0" 5 | description = "Ethereum SHA1 benchmark in Rust" 6 | publish = false 7 | edition = "2018" 8 | 9 | [dependencies] 10 | sha1 = "0.6" 11 | 12 | [target.'cfg(target_arch = "wasm32")'.dependencies] 13 | wee_alloc = "0.4.2" 14 | 15 | [lib] 16 | name = "sha1_wasm" 17 | crate-type = ["cdylib"] 18 | path = "src/lib.rs" 19 | 20 | [[bin]] 21 | name = "sha1_native" 22 | path = "src/main.rs" 23 | 24 | [profile.release] 25 | opt-level = 3 26 | debug = false 27 | lto = true 28 | debug-assertions = false 29 | overflow-checks = false 30 | panic = "abort" -------------------------------------------------------------------------------- /wasm-engines/rust-code/sha1/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate wee_alloc; 2 | 3 | #[global_allocator] 4 | static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; 5 | 6 | mod bench; 7 | 8 | #[no_mangle] 9 | pub extern "C" fn main() { 10 | bench::bench(); 11 | } -------------------------------------------------------------------------------- /wasm-engines/rust-code/sha1/src/main.rs: -------------------------------------------------------------------------------- 1 | mod bench; 2 | 3 | use std::time::{Instant}; 4 | 5 | pub fn main() { 6 | let start = Instant::now(); 7 | bench::bench(); 8 | let duration = start.elapsed(); 9 | 10 | println!("Time elapsed in bench() is: {:?}", duration); 11 | //std::process::exit(bench::bench() as i32) 12 | } -------------------------------------------------------------------------------- /wasm-engines/wamr_aot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | /engines/wamr/wamrc -o wasm.aot $2 6 | /engines/wamr/iwasm -f $1 wasm.aot 7 | -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/blake2b-2805-bytes.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/blake2b-2805-bytes.wasm -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/blake2b-5610-bytes.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/blake2b-5610-bytes.wasm -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/blake2b-8415-bytes.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/blake2b-8415-bytes.wasm -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/ecpairing.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/ecpairing.wasm -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/guido-fuzzer-find-1.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/guido-fuzzer-find-1.wasm -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/guido-fuzzer-find-2-norotates.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/guido-fuzzer-find-2-norotates.wasm -------------------------------------------------------------------------------- /wasm-engines/wasmfiles/guido-fuzzer-find-2.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewasm/benchmarking/1cd9e480963ba7b946ea23fd5425d67bf32df4c0/wasm-engines/wasmfiles/guido-fuzzer-find-2.wasm --------------------------------------------------------------------------------