Remove everything not needed by substrate

Also rename to wasm-instrument
This commit is contained in:
Alexander Theißen
2022-01-08 20:50:18 +02:00
parent b22696aaa5
commit e882111f92
33 changed files with 418 additions and 4720 deletions
+16 -34
View File
@@ -1,51 +1,33 @@
# pwasm-utils
# wasm-instrument
[![Build Status](https://travis-ci.org/paritytech/wasm-utils.svg?branch=master)](https://travis-ci.org/paritytech/wasm-utils)
A Rust library containing a collection of wasm module instrumentations and transformations
mainly useful for wasm based block chains and smart contracts.
A collection of WASM utilities used in pwasm-ethereum and substrate contract development.
## Provided functionality
This repository contains the package `pwasm-utils` which consists of a library crate
and a collection of cli binaries that make use of this library.
This is a non exhaustive list of provided functionality. Please check out the documentation for details.
## Installation of cli tools
```
cargo install pwasm-utils --features cli
```
### Gas Metering
This will install the following binaries:
* wasm-build
* wasm-check
* wasm-ext
* wasm-gas
* wasm-pack
* wasm-prune
* wasm-stack-height
Add gas metering to your platform by injecting the necessary code directly into the wasm module. This allows having a uniform gas metering implementation across different execution engines (interpreters, JIT compilers).
## Symbols pruning (wasm-prune)
### Stack Height Limiter
```
wasm-prune <input_wasm_binary.wasm> <output_wasm_binary.wasm>
```
Neither the wasm standard nor any sufficiently complex execution engine specifies how many items on the wasm stack are supported before the execution aborts or malfunctions. Even the same execution engine on different operating systems or host architectures could support a different number of stack items and be well within its rights.
This will optimize WASM symbols tree to leave only those elements that are used by contract `call` function entry.
This is the kind of indeterminism that can lead to consensus failures when used in a blockchain context.
## Gas counter (wasm-gas)
To address this issue we can inject some code that meters the stack height at runtime and aborts the execution when it reaches a predefined limit. Choosing this limit suffciently small so that it is smaller than any what any reasonbly written execution engine would support solves the issue: All execution engines would reach the injected limit before hitting any implementation specific limitation.
For development purposes, a raw WASM contract can be injected with gas counters (the same way as it done in the `pwasm-ethereum/substrate` runtime when running contracts)
## License
```
wasm-gas <input_wasm_binary.wasm> <output_wasm_binary.wasm>
```
# License
`wasm-utils` is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0), at your choice.
`wasm-instrument` is distributed under the terms of both the MIT license and the
Apache License (Version 2.0), at your choice.
See LICENSE-APACHE, and LICENSE-MIT for details.
## Contribution
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in `wasm-utils` by you, as defined in the Apache-2.0 license, shall be
for inclusion in `wasm-instrument` by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.