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

#10 in #fvm

Download history 2064/week @ 2024-02-05 2067/week @ 2024-02-12 2777/week @ 2024-02-19 3472/week @ 2024-02-26 3112/week @ 2024-03-04 2821/week @ 2024-03-11 3856/week @ 2024-03-18 2091/week @ 2024-03-25 2748/week @ 2024-04-01 3956/week @ 2024-04-08 5170/week @ 2024-04-15 2200/week @ 2024-04-22 1665/week @ 2024-04-29 2488/week @ 2024-05-06 2163/week @ 2024-05-13 1396/week @ 2024-05-20

7,735 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

~4.5MB
~117K SLoC