CosmWasm 2.0

Simon Warta
CosmWasm
Published in
4 min readMar 12, 2024

Two years after the first stable release of CosmWasm, we are proud to publish CosmWasm 2.0. This first breaking release was announced at AwesomWasm Berlin last year and was developed in parallel to the feature releases 1.4 and 1.5.

Shiny new things

Major releases are for breaking, but we also have a few nice additions that make CosmWasm more complete and convenient for its users.

Error messages in replies

Whenever an error is coming from a smart contract, we know it is deterministic. In those cases, we now skip redacting the error in wasmd and preserve the full text in the reply (SubMsgResult::Err). While this is great for debugging and logging, developers should not make assumptions about the text contents of those errors, which might be changed by the other contract.

Grpc query

The Grpc query is a protobuf-in protobuf-out replacement for Stargate query. This way, responses can be processed more efficiently and use a well-specified encoding. As before, chains have to specify which queries they want to allow.

Submessage payloads

A SubMsg can now get a binary payload that is returned untouched in the reply. This allows you to pass context from the original call to the replay without having to store it to state.

Message responses

A SubMsgResponse now has msg_responses next to data. In there the message execution results are stored as a list of protobuf Anys. This is needed for getting the data on chains running Cosmos SDK 0.50.

Optional acknowledgments

In ibc_packet_receive/IbcReceiveResponse, the acknowledgment is now optional. This advanced feature allows contracts not to write them. Some exotic protocols might want to never create acknowledgments. But this change primarily prepares for asynchonous acknowledgments where the acknowledgment is created later than the receive call (not yet implemented).

memo field in IbcMsg::Transfer

The long-awaited memo field is here, adding the possibility to pass arbitrary text along the ICS-20 token send. This is also required for packet forward middleware, IBC hooks, or the upcoming ADR-8 implementation. Please note that chains with wasmvm 1.x ignore this field if set.

Good to know

Changes you might want to be aware of:

  • The CosmWasm gas values were reduced by a factor of 1000. This does not affect the measurements in Cosmos SDK gas, which is used in almost all interfaces.
  • CosmosMsg::Stargate was renamed to CosmosMsg::Any without changing semantics.
  • The JSON serialization of u128/i128 changed from string to numbers. Use Uint128/Int128 instead to keep the string representation.
  • MockApi now uses and requires bech32 as the human-readable address format in order to simplify the testing flow. Use api.addr_make(“some name”) to create testing addresses.
  • A new default “std” feature in cosmwasm-std must be enabled. Otherwise, a no_std build is attempted. But at this point no_std support is not yet fully implemented.

Removed

Time to say goodbye to things not relevant anymore today:

  • The cosmwasm-storage crate. Use cw-storage-plus for types storage access or cosmwasm-std for raw access.
  • Addr and String/&str cannot be compared directly anymore for safety reasons. It’s recommended to convert both sides to an Addr first.
  • Mixed type arithmetics were removed (especially multiply Decimal with Uint*). The functions Uint{128,256}::mul_floor or Uint{128,256}::mul_ceil can be used instead.

Compatibility and upgrading

Existing contracts compiled with cosmwasm-std ^1.0.0 continue to run as before on chains with wasmvm 2.0. Contracts compiled with cosmwasm-std ^2.0.0 do run on chains with wasmvm 1.x or 2.0. This way, it does not matter in which order you upgrade the chain or contracts.

If you enable the cosmwasm_2_0 feature of cosmwasm-std, the contract will require 2.0 features on the chain and unlock some of the new features above.

A migration guide for contract developers is here: MIGRATING.md.

Integration on-chain

CosmWasm 2.0 will be shipped as part of wasmd 0.51. The integration work for the Wasm Light Client in IBC-Go has started already.

A migration guide for wasmvm users is here: MIGRATING.md.

Acknowledgments

We’d like to take the opportunity to thank everyone who contributed to this major release with ideas, feature requests, user stories, and code. Many people inside of Confio contributed to the release one way or another but the majority of the work was done by Chris — thank you!

As part of the Interchain Stack, the ongoing maintenance and some well-defined features are funded by the Interchain Foundation in 2024. If you have specific needs that you want to see in upcoming CosmWasm releases, consider becoming a CosmWasm Subscriber and help us make the next major release possible.

--

--

Simon Warta
CosmWasm

Building CosmWasm and CosmJS at Confio | Ex IOV | Co-Founder of Kullo | Board member prolina Foundation