#vm #unit-tests

dev cosmwasm-vm

VM bindings to run cosmwams contracts

35 releases (9 breaking)

0.10.1 Aug 25, 2020
0.10.0 Jul 30, 2020
0.9.4 Jul 16, 2020
0.7.2 Mar 23, 2020
0.5.1 Nov 29, 2019
Download history 70/week @ 2020-05-27 96/week @ 2020-06-03 37/week @ 2020-06-10 73/week @ 2020-06-17 138/week @ 2020-06-24 116/week @ 2020-07-01 82/week @ 2020-07-08 112/week @ 2020-07-15 222/week @ 2020-07-22 140/week @ 2020-07-29 58/week @ 2020-08-05 194/week @ 2020-08-12 128/week @ 2020-08-19 186/week @ 2020-08-26 181/week @ 2020-09-02 83/week @ 2020-09-09

487 downloads per month
Used in less than 10 crates

Apache-2.0

515KB
9K 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.9.0 ./contracts/hackatom \
  && cp contracts/hackatom/contract.wasm packages/vm/testdata/contract_0.10.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

~6.5–8.5MB
~186K SLoC