4 releases (breaking)

0.4.0 Dec 9, 2022
0.3.0 Dec 9, 2022
0.2.0 Apr 21, 2022
0.1.2 Apr 14, 2022

#8 in #fvm

Download history 2068/week @ 2024-07-20 1706/week @ 2024-07-27 3191/week @ 2024-08-03 1520/week @ 2024-08-10 2588/week @ 2024-08-17 1809/week @ 2024-08-24 2802/week @ 2024-08-31 2926/week @ 2024-09-07 3201/week @ 2024-09-14 3210/week @ 2024-09-21 1745/week @ 2024-09-28 2044/week @ 2024-10-05 2122/week @ 2024-10-12 1401/week @ 2024-10-19 1731/week @ 2024-10-26 1469/week @ 2024-11-02

7,053 downloads per month
Used in 7 crates (via fvm)

MIT/Apache

190KB
4.5K SLoC

fvm-wasm-instrument

This started as a wasm-instrumet with some FVM specific changes, but has since been significantly refactored to move away from parity-wasm which reached EOL.

fvm-wasm-instrument is a Rust library containing a collection of WASM module instrumentations and transformations mainly useful for wasm based block chains and smart contracts.

Provided functionality

This library provides two features:

  • Gas metering.
  • Stack height limiting.

Gas Metering

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).

Stack Height Limiter

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 is the kind of indeterminism that can lead to consensus failures when used in a blockchain context.

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 what any reasonably parameterized execution engine would support solves the issue: All execution engines would reach the injected limit before hitting any implementation specific limitation.

License

fvm-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

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in fvm-wasm-instrument by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~6.5MB
~118K SLoC