English | 中文
A wasm contract validation and optimization tool for Ontology. Before deploying the contract to the chain, this tool can parse and verify the binary code of wasm contract, clean up unused information in the contract to reduce the contract size and deployment cost.
validation and optimizations:
- The contract has an exported entry function
invoke
, with empty parameters and return values; - Clean up functions,import and export entries not used in contracts;
- Check floating point instructions in contracts;
- Check that all imports are Ontology runtime API with correct signatures;
- Check memory and table limits not exceeding the specified value to prevent malicious contract attacks;
- Clean up zeros in data section;
- Clean up custom section;
- Check that the size of the optimized contract does not exceed the specified value;
You can use one of the following method to install:
-
download binary file from releases
-
use
cargo
to install
cargo install --git=https://github.com/ontio/ontio-wasm-build
- install with source code
git clone https://github.com/ontio/ontio-wasm-build
cd ontio-wasm-build
cargo build --release
$ ontio-wasm-build --help
ontio-wasm-build 0.1.0
USAGE:
ontio-wasm-build [FLAGS] <input> <output>
FLAGS:
-h, --help Prints help information
--keep-custom Keep custom section in output wasm file
-V, --version Prints version information
ARGS:
<input> Wasm file generated by rustc compiler
<output> Output wasm file name
input
parameter is used to specify the wasm contract file to be optimized, generated with ontology-wasm-cdt-cpp or ontology-wasm-cdt-rust。
output
parameter is used to specify the optimized wasm contract file name
keep-custom
is the wasm file used to set the output retained `custom_section', only for debugging purposes
This project is licensed under the MIT license.