cosmwasm-vm 0.8.0-alpha3

VM bindings to run cosmwams contracts
Documentation

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/contract*.wasm. Those are compiled and optimized versions of contracts/hackatom run through cosmwasm-opt.

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

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  confio/cosmwasm-opt:0.7.3 ./contracts/hackatom \
  && cp contracts/hackatom/contract.wasm packages/vm/testdata/contract_0.8.wasm

To rebuild all contracts used by other repos for testing (before tagging a release):

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  confio/cosmwasm-opt:0.7.3 ./contracts/queue

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  confio/cosmwasm-opt:0.7.3 ./contracts/reflect

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  confio/cosmwasm-opt:0.7.3 ./contracts/staking

You can do the same for reflect and queue when there are breaking changes. Those are not used internally for testing, but provided here for use testing other projects, like go-cosmwasm.

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