SSVM is a high performance, hardware optimal Wasm Virtual Machine for AI and Blockchain applications.
Our docker image use ubuntu 18.04
as base.
$ docker pull hydai/ssvm-dev:0.1.0
$ sudo apt install -y \
cmake \
g++ \
libboost-all-dev
SSVM provides various tools to enabling different runtime environment for optimal performance. After the build is finished, you can find there are two ssvm binaries:
ssvm
is for general wasm runtime (Still in the very early stage).ssvm-evm
is for Ewasm runtime.
$ mkdir -p build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON .. && make
The following built-in tests are only avaliable when the build flag BUILD_TESTS
sets to ON
.
Users can use these tests to verify the correctness of SSVM binaries.
$ cd <path/to/ssvm/build_folder>
$ cd test/regression
$ ./ssvmRegressionTests
$ cd ../loader
$ ./ssvmLoaderEthereumTests
$ ./ssvmLoaderFileMgrTests
$ ./ssvmLoaderWagonTests
$ cd ../ast/load
$ ./ssvmASTLoadTests
$ cd ../../evm
$ ./ssvmEVMTests
To run SSVM with Ewasm bytecode, you will need to provide a valid Ewasm bytecode and the calldata. Currently, SSVM doesn’t support ABI encoding for Ethereum, so users need to compose the calldata by theirselves.
SSVM will dump the log information of EEI function calls and print the state of storage in the end.
SSVM provides an ERC20 token contract example for the demo purpose. See the example below.
$ cd <path/to/ssvm/build_folder>
$ cd tools/ssvm-evm
# Usage: ./ssvm-evm wasm_file.wasm call_data_in_string_format
$ ./ssvm-evm ethereum/erc20.wasm 4e6ec24700000000000000000000000012345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000000064
# Expect output:
!!! start running...
Host func ethereum::getCallDataSize cost 1 us
Host func ethereum::callDataCopy cost 0 us
Host func ethereum::callDataCopy cost 0 us
Host func ethereum::storageLoad cost 13 us
Host func ethereum::storageStore cost 9 us
Host func ethereum::callStatic cost 3 us
Host func ethereum::returnDataCopy cost 0 us
Host func ethereum::callStatic cost 2 us
Host func ethereum::returnDataCopy cost 0 us
Host func ethereum::storageLoad cost 5 us
Host func ethereum::storageStore cost 9 us
Host func ethereum::finish cost 1 us
--- exec success
Instructions execution cost 273 us
Host functions cost 50 us
Total executed instructions: 1041
Instructions per second: 3813186
--- result storage:
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000064
f5b24dcea0e9381721a8c72784d30cfe64c11b4591226269f839d095b3e9cf10 0000000000000000000000000000000000000000000000000000000000000064
--- return data:
$ cd <path/to/ssvm/build_folder>
$ cd tools/ssvm
# ./ssvm wasm_file.wasm [exported_func_name]