Skip to content

adoriasoft/polkadot_cosmos_integration

Repository files navigation

Substrate Node with Cosmos ABCI pallet

A new FRAME-based Substrate node with Cosmos ABCI pallet.

Documentation

Documentation for this project is here.

Requirements

Refer to the instructions at the Substrate Developer Hub.

The application is known to compile with the following versions of Rust:

nightly-2020-08-19 (defined in rust-toolchain)

Build in local environment

Install Rust:

curl https://sh.rustup.rs -sSf | sh

Initialize your Wasm Build environment:

./scripts/init.sh

Build Wasm and native code:

cargo build --release

Build and start Cosmos node: Go to the our fork of the cosmos-sdk, switch to the branch feature/add_nameservice, then follow the instructions.

Build with selected consensus

Available consensuses
- `aura`
- `babe`

```sh
- cargo build --release --no-default-features --features <consensus_name>

Build in dockerized environment

First, install Docker and Docker Compose.

Then run the following command to start a single node development chain. Also, sometimes you have to share permission for the .maintain folder in Docker settings.

./scripts/docker_run.sh

Or:

docker-compose up -d

Run node in development mode

Start a development chain with:

./target/release/node-template\
 --abci_genesis_state_path $HOME/.nsd/config/genesis.json\
 --abci_server_url tcp:https://localhost:26658\
 --abci_rpc_url 127.0.0.1:26657 --dev

Purge any existing development chain state:

./target/release/node-template purge-chain --dev

To get detailed info about options that available for node, run:

./target/release/node-template --help

To show detailed logs, run the the node with the following environment variables set: RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev.

Testing

Unit and integration testing with cargo

# Test all cargo packages
cargo test --all

Integration testing with bash

Follow the docs from the directory.

How to use?

ABCI pallet allows launching applications based on Cosmos SDK (or any other application that uses ABCI) on top of Substrate consensus and network layers. When both Cosmos and Substrate nodes are running, users can interact with them using Polkadot GUI and Cosmos CLI.

In Polkadot GUI, users can send standard Substrate extrinsic including extrinsics to ABCI pallet to match Substrate and Cosmos accounts for validators elections and Cosmos transaction wrapped with Substrate extrinsics. In Cosmos CLI, users can make the majority of standards calls to Cosmos node (all available functions are described in the full documentation. Some examples of commands for Nameservice app are described here.

Perform calls to Cosmos RPC

  • Simple request to Cosmos RPC: { "jsonrpc": "2.0", "method": <method_name>, "id": 0, "params": <method_params> }