This is a cosmwasm implementation of an interchain accounts controller.

Overview

CosmWasm ICA Controller Contract

This is a CosmWasm smart contract that communicates with the golang ica/host module on the host chain to create and manage one interchain account. This contract can also execute callbacks based on the result of the interchain account transaction. Because this is a CosmWasm implementation of the entire ICA controller, the chain that this contract is deployed on need not have the ICA module enabled. This contract can be deployed on any chain that supports IBC CosmWasm smart contracts.

This contract was originally written to test the json encoding and decoding feature being added to interchain accounts. Therefore, this contract cannot function in mainnet until this PR is merged, and backported to the version of ibc-go used by the host chain.

Note that the same approach used to build this contract can be used to build a contract that works in mainnet today, as long as the correct protobuf messages are used.

Usage

You can see the various ways this contract can be used in the end to end tests in the e2e directory. The following is a brief overview of the contract's functionality.

Create an interchain account

To create an interchain account, the relayer must start the channel handshake on the contract's chain. See end to end tests for an example of how to do this. Unfortunately, this is not possible to do in the contract itself. Also, you cannot initialize with an empty string as the version, this is due to a limitation of the IBCModule interface provided by ibc-go, see issue #3942. The version string we are using for tests is: {"version":"ics27-1","controller_connection_id":"connection-0","host_connection_id":"connection-0","address":"","encoding":"proto3json","tx_type":"sdk_multi_msg"}. You can see this in the end to end tests.

Execute an interchain account transaction

In this contract, the execute message is used to commit a packet to be sent to the host chain. This contract has two ways of executing an interchain transaction:

  1. SendCustomIcaMessages: This message requires the sender to give json/base64 encoded messages that will be sent to the host chain. The host chain will decode the messages and execute them. The result of the execution will be sent back to this contract, and the callback will be executed.

The format that json messages have to take are defined by the cosmos-sdk's json codec. The following is an example of a json message that is submitting a text legacy governance: (In this example, the proposer is the address of the interchain account on the host chain)

{
  "@type": "/cosmos.gov.v1beta1.MsgSubmitProposal",
  "content": {
    "@type": "/cosmos.gov.v1beta1.TextProposal",
    "title": "IBC Gov Proposal",
    "description": "tokens for all!"
  },
  "initial_deposit": [{ "denom": "stake", "amount": "5000" }],
  "proposer": "cosmos1k4epd6js8aa7fk4e5l7u6dwttxfarwu6yald9hlyckngv59syuyqnlqvk8"
}
  1. SendPredefinedAction: This message sends a 100 stake from the ica account to a user defined address on the host chain. This action is used to demonstrate how you can have a contract that executes a predefined action on the host chain. This is more useful for DAOs or other contracts that need to execute specific actions on the host chain.

Execute a callback

This contract supports callbacks. See src/ibc/relay.rs for how to decode whether a transaction was successful or not. Currently, a counter is incremented to record how many transactions were successful and how many failed. This is just a placeholder for more complex logic that can be executed in the callback.

Testing

There are two kinds of tests in this repository: unit tests and end to end tests. The unit tests are located inside the rust files in the src directory. The end to end tests are located in the e2e directory.

Unit tests

In general, the unit tests are for testing the verification functions for the handshake, and for testing that the serializers and deserializers are working correctly. To run the unit tests, run cargo test.

End to end tests

The end to end tests are for testing the contract's functionality in an environment mimicking production. To see whether or not it can perform the channel handshake, send packets, and execute callbacks. We achieve this by running two local chains, one for the contract, and one for the host chain. The relayer is then used to perform the channel handshake, and send packets. The contract then executes callbacks based on the result of the packet. To learn more about how to run the end to end tests, see the Readme in the e2e directory.

Limitations

This contract is not meant to be used in production. It is meant to be used as a reference implementation for how to build a CosmWasm contract that can communicate with the golang ica/host module. The following are some of the limitations of this contract:

  • The contract cannot create multiple interchain accounts. It can only create one.
  • ICA channels must be ordered (enforced by golang ica/host module). Due to the semantics of ordered channels in IBC, any timeout will cause the channel to be closed.
  • Channel re-opening is not supported (yet).
  • The relayer must start the channel handshake on the contract's chain. This is not possible to do in the contract itself. See e2e tests for an example of how to do this.
  • The contract cannot initialize with an empty string as the version. This is due to a limitation of the IBCModule interface provided by ibc-go, see issue #3942.
You might also like...
An implementation of Joker Calculus in Rust

Joker Calculus An implementation of Joker Calculus in Rust Based on paper Joker Calculus, by Daniel Fischer, William Alexander Morris and Sven Nilsen

A language server implementation for the WGSL shading language

wgsl-analyzer wgsl-analyzer is a language server plugin for the WGSL Shading language. It comes with a VS Code plugin located in ./editors/code, but d

dustls, a pure-rust DTLS implementation

dustls, a pure-rust DTLS implementation A DTLSv1.2 implementation in Rust, reusing rustls for cryptographic primitives and most message payload format

Default implementation of the Wayland protocol for use with wl

Wayland An implementation of core Wayland interfaces and convenience functions for accelerating the development of Wayland clients and servers using t

Mild RSA implementation written in Rust for a class.

rust_rsa About this repo This is my Rust implementation of the RSA encryption standard, based on this book. This is for my CS 3000 - Advanced Algorith

A clean implementation of Reso using Rust.

A clean implementation of Reso using Rust. The principle of Reso Rust is almost identical to Reso, only missing some functionality

An experimental implementation of gitbom in Rust

gitbom-rs "An experimental implementation of GitBOM in Rust" NOTICE: This project is still a work in progress and is not ready for any use beyond expe

RusTTS is an unofficial Coqui TTS implementation

RusTTS RusTTS is an unofficial Coqui TTS implementation. Currently, only the YourTTS for VC has been implemented. So, feel free to contribute us to ma

An implementation of Code Generation and Factoring for Fast Evaluation of Low-order Spherical Harmonic Products and Squares

sh_product An implementation of Code Generation and Factoring for Fast Evaluation of Low-order Spherical Harmonic Products and Squares (paper by John

Comments
  • Parallelize e2e tests

    Parallelize e2e tests

    Problem Summary

    Rather than having one monolithic e2e test, split it up into smaller tests that can be ran in parallel in github actions.

    Description

    Currently, all the end to end tests are in one monolithic test called TestIcaControllerContract as subtests. This means github actions cannot run these tests in parallel, leading to long waiting times for github actions to complete.

    e2e 
    opened by srdtrk 1
  • Turn the contract into library workspace

    Turn the contract into library workspace

    Problem Summary

    This contract is simply a reference implementation. Instead, it should be a library people can use in their own contracts.

    Description

    This repo should become a library instead for people to use in their contracts. And the reference implementation should be an example within this library. The end to end tests should remain in the repo, and more unit tests can be added to the library.

    enhancement 
    opened by srdtrk 0
  • Implement Channel Reopening

    Implement Channel Reopening

    Problem Summary

    Once a channel is closed due to timeout, or other reasons. Add the ability to reopen it.

    Description

    Once a channel is closed due to timeout, or other reasons, there should be a path to reopen it. This reopened channel should have the same ica address as the closed channel.

    Tasks

    • [ ] Implement the feature in a feature branch.
    • [ ] Write end to end tests for it.
    opened by srdtrk 0
Owner
null
IR Remote Controller for WS2812(or analog) LED Strip

ir-smart-led-controller IR Remote Controller for WS2812(or analog) LED Strip. Resources Schematics Gerber files BOM License Licensed under either of A

Vitaly Domnikov 9 Dec 22, 2022
Software adapter for various Chunithm slider controllers with a built-in Brokenithm web controller

slidershim Software adapter for various Chunithm slider controllers with a built-in Brokenithm web controller. Has support for keyboard/gamepad output

Si Yuan 45 Dec 17, 2022
xrd a next-gen server controller for TrackMania Forever and Nations ESWC

xrd is a next-gen server controller for TrackMania Forever and Nations ESWC that is designed to be hassle-free and easily updatable (with a bus factor of 0).

Autumn Leaf 6 Mar 26, 2022
OpenEMC: open embedded management controller

OpenEMC OpenEMC is an open-source firmware implementing an embedded management controller (EMC) on an STM32F1 microcontroller. It consists of a bootlo

Sebastian Urban 5 Dec 25, 2022
A Rust driver for the Arm Generic Interrupt Controller version 3 or 4 (GICv3 and GICv4).

Arm Generic Interrupt Controller driver This crate provides a Rust driver for the Arm Generic Interrupt Controller version 3 or 4 (GICv3 and GICv4). C

Google 7 Apr 17, 2023
unFlow is a Design as Code implementation, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.

unflow 是一个低代码、无代码设计语言。unFlow is a Design as Code implementation, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.

Inherd OS Team (硬核开源小组) 70 Nov 27, 2022
The official rust implementation of the SpamProtectionBot API

SpamProtection-rs Table of contents About Supported Rust version Features How to use Credits License About SpamProtection-Rust is a Rust wrapper for I

Intellivoid 0 Feb 26, 2022
RusTiny -- A Rust implementation of Tiny+ language

RusTiny -- A Rust implementation of Tiny+ language 编译器实践 基本要求: 参考《编译原理及实践》的TINY语言编译器(已上传到群中)完成TINY+ 语言(见附录 A)的解释器:即给定满足 TINY+语言的源代码输入,你的解 释器可以给出对其的解释执

M4tsuri 2 May 22, 2022
kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

Vinícius Miguel 26 Dec 5, 2022
A minimal RedDSA implementation for use in Zebra and zcashd.

A minimal RedDSA implementation for use in Zcash. Two specializations of RedDSA are used in Zcash: RedJubjub and RedPallas. For each of these, two par

Zcash Foundation 3 Jul 30, 2022