CosmWasm Tracing Is Live

Mitya
CosmWasm
Published in
4 min readFeb 20, 2024

If you’ve ever pooled your hair figuring out an error in your CosmWasm contract, you’re not alone. We’ve been there, and here is something that will help. We are introducing CosmWasm Tracing, a debugging tool for CosmWasm developers.

It addresses three challenges that exist in Cosmos:

  • Stack complexity: in Cosmos, smart contracts operate over a landscape of multiple SDK modules (which are often unique to a chain) and increasingly often cross-chain. In order to get to a root cause of an issue, you need to navigate all these layers of the stack.
  • Error redaction: smart contract errors are redacted to protect determinism, which means that contract A does not ‘know’ which error occurred in smart contract B. You need a special type of a tool to get ‘behind the scenes’ of the contract you’re querying.
  • Chasing efficiency: we see increased interest in effectiveness optimization, which requires detailed gas cost and execution time tracking tooling.

How CosmWasm Tracing works

Thanks to the community of CosmWasm subscribers, we now have time and focus to start addressing these issues. Our goal is to help the developers spend more time creating and less time debugging by quickly getting answers to these questions:

  • Did I have errors in my transactions/contracts, and which exactly?
  • Where did these errors occur, and what’s the most detailed information available about them?
  • What was the sequence of calls across all operations and SDK modules?
  • How long did it take on every step, and how much gas did it consume?

CosmWasm Tracing does this by collecting and providing access to rich debug data via a combination of three components:

  • Instrumented full node (chain-specific)
  • Database that stores detailed information about transaction traces
  • UI that developers can use to explore the data

The database contains detailed error logs, messages, gas usage, and other log types that can be navigated via tag-based search by transaction hash, block height, smart contract address, etc.

Where to start

Here are a few examples of the types of transaction analysis you can try right now:

Example 1: find a full detailed trace of a transaction I’m willing to analyze

Input tx=NNN in the Tags search field, replacing NNN with the actual transaction hash you’re seeking. This directs you to a detailed view of that transaction.

Example 2: find recent errors in traces

Use the query errored=true to filter transactions that have encountered errors. This efficient approach helps in pinpointing issues needing resolution.

Example 3: find recent errors in contracts that my contract interacted with

Typing sender_contract=NNN, where NNN is the contract’s address, filters the transactions to those initiated by the specified contract.

Example 4: get gas usage details

Go to trace details, and see the gas usage log at every operation in the trace.

Plans for the future

Currently, CosmWasm Tracing is supported for Subscriber chains, and we are planning to add many more chains later this year. This is an early version of the tool that will change a lot in the coming months, and we welcome the community’s feedback on it. Feel free to give it a try at tracing.cosmwasm.com, and let us know what you think!

In the meantime, there are some important updates we are working on already.

We have started designing an updated version of the UI, which will offer better support for the CosmWasm-specific use cases. We are going through a prototyping phase now and invite any volunteers to jump on a call with us and give us feedback on it.

The next big step for CosmWasm Tracing is going to be a locally deployed version of it. Currently, we only provide traces data for public chains (mainnets and testnets), but we are looking forward to providing similar functionality for local dev nets as well. This will allow you to have rich debugging functionality at the earliest stages of development when it is needed very frequently.

What to do now

  • Give it a try here: tracing.cosmwasm.com
  • Let us know what you think in the comment here or in X
  • Come to our workshop in Denver next week to talk about it in person

--

--