#vm #unit-tests

dev cosmwasm-vm

VM bindings to run cosmwams contracts

28 releases (8 breaking)

✓ Uses Rust 2018 edition

0.9.2 Jun 29, 2020
0.8.1 Jun 8, 2020
0.7.2 Mar 23, 2020
0.6.0 Dec 23, 2019
0.5.1 Nov 29, 2019
Download history 76/week @ 2020-03-16 102/week @ 2020-03-23 65/week @ 2020-03-30 68/week @ 2020-04-06 104/week @ 2020-04-13 36/week @ 2020-04-20 27/week @ 2020-04-27 33/week @ 2020-05-04 55/week @ 2020-05-11 93/week @ 2020-05-18 96/week @ 2020-05-25 93/week @ 2020-06-01 50/week @ 2020-06-08 50/week @ 2020-06-15 145/week @ 2020-06-22 113/week @ 2020-06-29

300 downloads per month
Used in less than 7 crates

Apache-2.0 and maybe MPL-2.0

440KB
8K SLoC

CosmWasm VM

cosmwasm-vm on crates.io

This is an abstraction layer around the wasmer VM to expose just what we need to run cosmwasm contracts in a high-level manner. This is intended both for efficient writing of unit tests, as well as a public API to run contracts in eg. go-cosmwasm. As such it includes all glue code needed for typical actions, like fs caching.

Setup

There are demo files in testdata/*.wasm. Those are compiled and optimized versions of contracts/hackatom and contracts/staking run through rust-optimizer.

To rebuild the test contracts, go to the repo root and do

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/rust-optimizer:0.8.0 ./contracts/hackatom \
  && cp contracts/hackatom/contract.wasm packages/vm/testdata/contract_0.9.wasm

Testing

By default, this repository is built and tested with the singlepass backend. This requires running Rust nighty:

cd packages/vm
cargo +nightly test

To test with Rust stable, you need to switch to cranelift:

cd packages/vm
cargo test --no-default-features --features default-cranelift

License

This package is part of the cosmwasm repository, licensed under the Apache License 2.0 (see NOTICE and LICENSE).

Dependencies

~8MB
~173K SLoC