Unlocking the Power of Rollups using Rollkit and Avail DA

Deepak
Vitwit
Published in
7 min readMar 27, 2024

This article illustrates how one can make a Cosmos appchain using Rollkit framework and Avail as a data availability layer.

Any Cosmos appchain can be made into a rollup using Rollkit framework. Below is an example of how a Cosmos chain can be made into a rollup.

The following software versions has been used in making this video

  • rust — v1.74.0
  • go-1.21.5

Let us make our hands dirty by making Paloma chain into a rollup on top of Avail-DA.

Let us start running Avail nodes in order to have Avail as a DA layer. We are supposed to run three nodes and the DA server

  • Avail DA node — official client for the Avail blockchain
  • Avail light node — DA light client which listens on Avail network for finalized blocks
  • Avail light Bootstrap node — Bootstrap node for Avail light client
  • Avail DA server

Setting up Local Avail DA

To setup local Avail nodes, you can follow the given steps below or refer this readme file here.

Clone Avail DA from here

Run the following command in your desired directory

git clone https://github.com/availproject/avail.git

After cloning the Avail node, open the directory by running the following command

cd avail

Checkout to the following branch

git fetch && git checkout v1.10.0.0

We can start the Avail node by the following command

cargo run --locked --release -- --dev --enable-kate-rpc

You can see the following once the Avail DA starts running successfully

Avail light bootstrap node

While the Avail node is up and running, let us start Avail light bootstrap node.

Clone the Avail light bootstrap node from here

From the directory of your choice, run the following command

git clone https://github.com/availproject/avail-light-bootstrap.git

Let us get into the Avail light bootstrap with the following command

cd avail-light-bootstrap

Start the Avail light bootstrap node with the following command

cargo run --release

Upon successfully running, you can view the log as follows

Avail light bootstrap node

While the Avail node is up and running, let us start Avail light node.

Avail light node

Clone the Avail light node from here

From the directory of your choice, clone Avail light node using the following command

git clone https://github.com/availproject/avail-light.git

open the Avail light node by executing the following command

cd avail-light

checkout to the following branch

git fetch && checkout v1.7.8

Let us create a config.yaml file in the root folder

touch config.yaml

Copy the following file and paste it in the config.yaml file

http_server_host = '127.0.0.1'
http_server_port = 8000
port = 38000
tcp_port_reuse = false
autonat_only_global_ips = false
autonat_throttle = 1
autonat_retry_interval = 10
autonat_refresh_interval = 30
autonat_boot_delay = 5
identify_protocol = '/avail_kad/id/1.0.0'
identify_agent = 'avail-light-client/rust-client'
bootstraps = [["12D3KooWStAKPADXqJ7cngPYXd2mSANpdgh1xQ34aouufHA2xShz", "/ip4/127.0.0.1/udp/39000"]]
bootstrap_period = 300
relays = []
full_node_ws = ['ws://127.0.0.1:9944']
confidence = 92.0
avail_path = 'avail_path'
log_level = 'INFO'
log_format_json = false
ot_collector_endpoint = 'http://otelcollector.avail.tools:4317'
disable_rpc = false
disable_proof_verification = false
dht_parallelization_limit = 20
put_batch_size = 1000
query_proof_rpc_parallel_tasks = 8
max_cells_per_rpc = 30
threshold = 5000
kad_record_ttl = 86400
publication_interval = 43200
replication_interval = 10800
replication_factor = 20
connection_idle_timeout = 30
query_timeout = 60
query_parallelism = 3
caching_max_peers = 1
disjoint_query_paths = false
max_kad_record_number = 2400000
max_kad_record_size = 8192
max_kad_provided_keys = 1024
app_id=1

We need to add the mnemonic in identity.toml. Make sure that it has sufficient balance to make transactions

Let us start the Avail light by the following command

cargo run --release -- --network local -c config.yaml --clean

Upon successfully running the light node, you can view the logs as follow

Avail light client

All the required Avail nodes are up and running. We need to start the Avail-DA server in order to submit transactions. This can be done using Avail DA

Avail DA server

Clone Avail-DA from here

From the directory of your choice, run the following command

git clone https://github.com/rollkit/avail-da.git

Get into the root directory by the following command

cd avail-da

Start the server by the following command

go run cmd/avail-da/main.go

Server gets started as below

We have done the setup required to submit transactions to Avail DA

The setup is ready, palomachain has been considered in this article as a Cosmos chain, any Cosmos chain can be made into a rollup in a similar fashion

Palomachain is a rapid and decentralized blockchain built on the Cosmos-SDK framework, facilitating the secure transmission of messages across various blockchains.

Transforming Cosmos chain into rollup

Clone palomachain from here in the desired directory

git clone https://github.com/palomachain/paloma.git

Checkout to fix-build branch with the help of the following command

git checkout fix-build

Now that we have paloma chain let us add few dependencies so that we can make use of rollkit. To add rollkit dependency in paloma chain we need to replace Cosmos-sdk with the rollkit enabled Cosmos-sdk in go.mod file

github.com/cosmos/cosmos-sdk => github.com/rollkit/cosmos-sdk v0.50.1-rollkit-v0.11.9-no-fraud-proofs

Once the dependency has been added into the go.mod file, we need to make sure that the dependency has been installed using the following command

go mod tidy

To avoid the semantic error while running the chain add the following line in makefile

VERSION=2.3.1

go mod tidy updates the go.mod file and downloads all dependencies mentioned in the go.mod file

Now from the root directory of palomachain create a file named as init-local.sh by the following command

touch init-local.sh

Copy the following script in that file and save the file

From the root directory, run the following command to start the paloma chain as a rollup

bash init-local.sh

Upon successfully running the following command, you can view the logs as follows

paloma chain as a rollup

The script starts of with the DA block height from the Avail DA node running in background and generates the metadata. It also generates two keys as mentioned in the script. We can make use of those keys for doing a transaction where the tokens for those keys will be generated in the script

You can view the rollup chain logs as follows

rollup chain logs

Now that the paloma rollup chain is up and running let us make a transaction.

We can view the keys generated by the script using the following command

palomad keys list --keyring-backend test

The keys will be shown as follows

Before making a transaction, let us check the balance of both the keys by the follwing command

palomad q bank balances <address-of-the-key> 

This is how the balances will look like

Let us make a transaction between two keys by the following command

palomad tx bank send <from-address> <to-address> <amount>ugrain --chain-id <chain-id name>--keyring-backend test -y

ugrain is the denom for paloma chain. The transaction has been made using bank module -y is the flag to confirm the transaction before signing and broadcasting. The following logs will appear if the transaction is successful (code 0)

Transaction

We can query the transaction using the tx hash that has been generated using the following command

palomad q tx <tx-hash>

We can view the transaction metadata as follows

Transaction metadata

We can now check the balances of the accouns to make sure that the money got debited from one account and credited to another account by using the following command

palomad q bank balances <key-address>

The transaction is successfully submitted to Avail DA, we can check this by looking the logs in Avail-DA server which looks as follows

That’s it, This is how we can have a roll on rollups on top of Avail DA :) 🥳

--

--