Coder Social home page Coder Social logo

cw-ibc-demo's Introduction

CosmWasm IBC Demo

Example IBC enabled contracts along with full stack integration tests

This package demos how to write a simple pair of IBC-enabled contracts that speak to each other. It includes unit tests on each contract in Rust, as well as full stack integration tests on two live blockchains using CosmJS and the TS-Relayer.

Design

This is a simple set of Interchain Account (ICA)-like contracts. simple-ica-host will receive messages from a remote connection and execute them on it's chain. simple-ica-controller will send messages from the original chain and get the results.

The main difference between this and ICA is the use of one unordered channel rather than multiple ordered channels. We also use a different payload with a CosmWasm/JSON focus.

This could be the basis of writing full ICA compatible contracts, but the main focus here is the ability to showcase how to write and test IBC contracts in general.

Rust Contracts

The package simple-ica holds common types and functionality used in both contracts. The concrete logic is stored in simple-ica-host and simple-ica-controller.

To ensure they are proper, run the following in the repo root:

cargo build --all-targets
cargo clippy --all-targets
cargo fmt

Unit Tests

All unit tests are in Rust and assume a mocked out environment. They don't actually send packets between contracts in any way, but return a fully mocked response. This can run through many code paths and get a reasonable level of confidence in the basic logic. However, you will need to run through full-stack integration tests to actually have any confidence it will work as expected in production.

To ensure they are proper, run the following in the repo root:

cargo test

Integration Tests

See tests/README.md

cw-ibc-demo's People

Contributors

ethanfrey avatar jakehartnell avatar webmaster128 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cw-ibc-demo's Issues

Provide gas limits for callbacks

There was a very important point raised: #14 (comment)

We should limit this somehow, so people can infinite loop on an ack.
It should probably be set by some contract config.

Let's continue discussion here

Remove nyc test coverage tooling

The JavaScript tests in ./tests do not test JavaScript code. Instead they test a complex setup of different contracts running on external chains. I don't see why a test coverage tooling for JavaScript files would be useful here. IMO we can remove nyc in order to reduce dependencies and run tests faster.

Handle ica controller's who_am_i timeout

If the controller's who_am_i packet sent during ChannelOpenAck times out, there is no way to re-dispatch the packet, rendering the channel unusable.

One suggestion is to add another executemsg to dispatch who_am_i to the controller's channel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.