The Inter-Blockchain Communication (IBC) protocol has emerged as a groundbreaking technology that enables seamless communication and interoperability between distinct blockchain networks. IBC relayers play a crucial role in this process by facilitating the transfer of data, tokens, and information across various chains, enhancing the potential for collaboration and innovation in the blockchain ecosystem.
Astroport, initially a single blockchain protocol operating solely on Terra, has now expanded to other networks such as Injective, with upcoming launches on Neutron and Sei. As a next-generation AMM and DEX, Astroport embraces the power of IBC to create a unified, cross-chain experience. IBC relayers serve as the backbone of this expansion, connecting Astroport's ecosystem across multiple networks while ensuring the reliable and secure transmission of information.
With the integration of IBC relayers, Astroport is positioned to support a range of use cases, including cross-chain governance, token transfers, and fee collection. These relayers are essential for fostering a more interconnected and collaborative DeFi landscape, allowing Astroport to reach and influence a broader range of blockchain networks, and ultimately benefit the entire ecosystem.
How Astroport Uses Relayers
IBC relayers are an essential component of Astroport's cross-chain governance proposal pipeline, ensuring the reliable and secure transmission of governance proposals between the Astroport ecosystem and remote chains.
The cross-chain governance proposal pipeline in Astroport consists of several stages:
- Proposal Initiation: If a proposal is intended for a remote chain, it is executed on the ibc_controller contract on the source chain. This contract creates a custom Astroport IBC packet, which is relayed by IBC relayers to the remote chain.
- Remote Chain Execution: On the remote chain, a satellite contract receives the custom IBC packet and executes the proposal messages. This satellite contract acts as a "remote Assembly contract," possessing the same permissions as the Assembly on Terra, effectively controlling all Astroport contracts on the remote chain.
- Acknowledgment and Proposal Update: If the proposal is successful, an acknowledgment packet is sent back to the source chain, updating the proposal state from "in progress" to "executed."
In addition to cross-chain governance, IBC relayers also support other important use cases within the Astroport ecosystem:
- Token transfers: IBC relayers enable the secure and efficient transfer of IBC tokens, such as cw20 assets like ASTRO and native tokens, between various chains, further expanding the utility and reach of these digital assets.
- Fee collection: The Astroport "hub" on Terra collects fees generated from other chains, and IBC relayers play a pivotal role in transferring these fees from remote chains to the hub, contributing to the growth and sustainability of the Astroport ecosystem.
By utilizing IBC relayers, Astroport is able to establish a robust, decentralized protocol that transcends the boundaries of individual blockchains. This facilitates a seamless flow of information and assets across multiple networks in a cohesive and efficient manner. In the context of Astroport, IBC relayers exemplify the potential of blockchain interoperability, paving the way for a more connected, collaborative, and innovative DeFi landscape.
This tutorial will provide an in-depth and technical guide on how to set up and configure IBC relayers to support these use cases, empowering the community to contribute to the smooth operation of the Astroport ecosystem.
Understanding IBC and IBC Relayers
IBC is a protocol designed for communication between heterogeneous blockchains. It provides a standardized way for data transfer, transactions, and smart contract calls across blockchains. IBC relies on a set of data structures, state machines, and communication protocols to enable this interoperability.
IBC relayers are responsible for facilitating the communication between the source and destination blockchains by monitoring and relaying packets between them. The relayer listens for events on both chains, constructs and signs IBC packets, and submits them to the appropriate chain.
The core components of the IBC relayer include:
- Light clients: Used to verify headers and state transitions of connected blockchains.
- Connections: Represent the connection between two chains, enabling data transfer.
- Channels: Logical paths for data transfer, built on top of connections.
- Packets: Data structures containing application-specific information that flows through channels.
Relaying with Hermes
As Astroport aims to establish a robust decentralized exchange and AMM on multiple networks, efficient and reliable IBC relayers are crucial. Hermes, a cutting-edge IBC relayer implementation, stands out with its superior multi-chain support, performance optimizations, and modular architecture, making it the ideal choice for Astroport relayers.
Designed to handle multiple chains concurrently, Hermes is perfectly suited for relaying packets across Terra, Injective, Sei, and Neutron within the Astroport ecosystem. Its flexible and extensible design allows developers to easily integrate additional functionality as the ecosystem evolves. Furthermore, Hermes is built with performance in mind, ensuring fast and efficient packet relaying for Astroport users. The user-friendly command-line interface makes Hermes accessible to both developers and non-technical users involved in the Astroport network, contributing to a seamless and efficient cross-chain experience.
Setting Up the Environment
Before installing and configuring an IBC relayer with Hermes, ensure that you have set up the environment correctly. You will need:
- Rust (minimum version 1.65)
- Installed and configured source and destination blockchain nodes
- Addresses on each chain that are funded in order to pay for gas/fees for submitted transactions
- A machine to host the relayer
- Linux operating system
This tutorial will show you how to install Hermes from the source. However, if you prefer to install the latest binary, visit the Hermes Installation Guide.
Step 1: Clone the ibc-rs repository
The ibc-rs repository, which contains the Rust implementation of the IBC relayer, including Hermes:
Step 2: Change to the ibc-rs directory
Step 3: Checkout the latest release
Go to the ibc-rs releases page to see the latest release. At the time of writing, the latest release is v1.4.1 (please replace it with the latest release when you perform the step).
Step 4: Change to the relayer-cli directory
Step 5: Build Hermes
This will build Hermes with the latest release. The binary will be available at ./target/release/hermes.
Step 6: Add Hermes to PATH (Optional)
To make it easy to use Hermes from any location on your system, you can add the hermes binary to your PATH. Replace <path-to-ibc-rs> with the actual path to the ibc-rs directory on your system:
You can also add the above line to your shell's configuration file (e.g., .bashrc, .bash_profile, or .zshrc) to make the change permanent.
Step 7: Verify Installation
To verify that Hermes has been installed correctly, run the following command:
This command should display the version number of Hermes, indicating that the installation was successful.
Step 8: Familiarize yourself with Hermes
Once you've built the Hermes binary, you can run it without any additional parameters to see the usage and help information. This will help you get acquainted with the various commands and options available in Hermes.
Configuring a Hermes IBC Relayer
In this section, we will lead you through the procedure of setting up a Hermes IBC relayer to enable secure communication and asset transfers between various blockchains, particularly concentrating on Terra and Injective chains. Rather than creating new channels, we will configure the relayer's toml file to connect to the pre-existing channels utilized by Astroport. This approach ensures a seamless exchange of data and assets between these chains.
Step 0: Prepare Wallet Seed Files
Before we begin, make sure you have the seed mnemonic phrase for both the Terra and Injective wallets. Save these in separate files named, for example, phoenix-relayer-wallet.seed and injective-relayer-wallet.seed, with the seed phrase on the first row.
Step 1: Add Wallet Keys to Hermes
We will add the wallet keys for both Terra and Injective to Hermes. Run the following commands to do so:
Step 2: Understand Hermes Configuration Options
Before we dive into the Hermes configuration, let's understand a few key options that will be used in the config.toml file:
- clear_interval: This option forces the relayer to relay pending packets every specified number of blocks. In our example, we will set this value to 100, meaning that Hermes will relay pending packets every 100 blocks.
- clear_on_start: This option forces the relayer to relay pending packets each time Hermes starts. We will set this value to true.
- trusting_period: This option specifies the duration for which the relayer should trust the header timestamps of the connected chains. It should be set to a value lower than the chain's unbonding period. Typically, chains have a 14- or 21-day unbonding period, so setting this to 10 days (around 80% of the unbonding period) should work for most cases.
Step 3: Configure Hermes
Create a new file named config.toml and add the following contents, replacing the <terra grpc endpoint>, <terra rpc endpoint>, <terra ws endpoint>, <injective grpc endpoint>, <injective rpc endpoint>, and <injective ws endpoint> placeholders with the appropriate values for your setup.
Step 4: Start the Hermes Relayer
Now that you have configured Hermes, you can start the relayer using the following command:
This will start the Hermes relayer with the given configuration, establishing a connection between the Terra and Injective blockchains and relaying IBC packets between them.
Configuring Multiple Chains
In this section, we will explore how to extend the Hermes IBC relayer configuration to support multiple chains simultaneously, using Sei and Neutron as examples. Please note that these are just examples, as their mainnet configurations have not been released yet. This approach will enable you to relay IBC packets across various blockchains, enhancing the flexibility and interoperability of your relayer setup.
Step 0: Prepare Additional Wallet Seed Files
In addition to the Terra and Injective wallets, make sure you have the seed mnemonic phrases for the new blockchains you want to add to the relayer. Save these in separate files named accordingly, for example, sei-relayer-wallet.seed and neutron-relayer-wallet.seed, with the seed phrase on the first row.
Step 1: Add Additional Wallet Keys to Hermes
First, we will add the wallet keys for the new blockchains to Hermes. Run the following commands with the appropriate values for each chain:
Step 2: Update Configuration for Additional Chains
Upon the release of new filtering policies for Sei and Neutron, users will be able to integrate these additional chains into their toml configurations and seamlessly connect them with Hermes. To accomplish this, modify the existing config.toml file created in the third step of the "Configuring a Hermes IBC Relayer" section. Add separate [[chains]] sections for each chain, specifying essential parameters like id, grpc_addr, rpc_addr, and others. Replace the placeholders for Sei and Neutron with the appropriate values for your setup. Additionally, ensure that the existing [[chains]] sections for Terra and Injective are already present in the config.toml file.
Step 3: Start the Hermes Relayer for Multiple Chains
Now that you have updated the Hermes configuration to include the additional chains, you can start the relayer to handle multiple chains simultaneously using the following command:
This will start the Hermes relayer with the updated configuration, establishing connections between all the configured chains (Terra, Injective, Sei, and Neutron) and relaying IBC packets between them.
Monitoring Hermes Relayer with Telemetry and Grafana
In this tutorial, we have focused on the configuration and setup of a Hermes IBC relayer. However, there are additional topics related to monitoring and optimizing the Hermes relayer that are outside the scope of this guide. Two such topics are telemetry and Grafana, which can help users gain insights into the relayer's performance, identify bottlenecks, and make informed decisions on optimization. While we will not cover these topics in detail here, interested users can learn more about telemetry and Grafana by visiting the Hermes Documentation. The following section provides a brief overview of these topics to give you an idea of their importance in the context of Hermes.
Telemetry refers to the automatic collection and transmission of data from remote sources to a central monitoring system. In the context of Hermes, telemetry enables users to gather performance metrics and other relevant information from the relayer as it operates. These metrics can include transaction throughput, latency, and resource usage, among others. By collecting and analyzing telemetry data, users can gain insights into the relayer's performance, identify bottlenecks or inefficiencies, and make informed decisions on how to optimize the relayer for better performance and reliability.
Grafana is an open-source platform for data visualization, monitoring, and analysis. It provides a highly customizable dashboard that can display a wide range of data sources, including Prometheus, InfluxDB, and many more. Grafana is often used to visualize telemetry data collected from various sources, enabling users to gain insights into the performance and health of their systems. In the context of Hermes, Grafana can be used to create a comprehensive dashboard that displays real-time metrics and other relevant information about the relayer. This dashboard can help users monitor the relayer's performance, detect anomalies, and troubleshoot issues, ensuring the smooth operation of the IBC relayer and contributing to the overall stability of the connected blockchain networks.
Hermes IBC relayers play a vital role in facilitating cross-chain communication within the Cosmos ecosystem, enabling seamless interoperability between distinct blockchain networks. By implementing a decentralized communication model that transcends individual blockchains, Hermes empowers its users to establish connections and transfer assets across multiple networks, including the Astroport ecosystem.
This tutorial has provided an in-depth understanding of Hermes IBC relayers and their importance in supporting various use cases within the Astroport ecosystem, with a primary focus on cross-chain governance and additional emphasis on token transfers and fee collection. Armed with the knowledge and technical guidance shared, community members can now actively participate in setting up, configuring, and optimizing Hermes IBC relayers, contributing to the growth and success of Astroport and the wider blockchain ecosystem.
As the blockchain ecosystem continues to evolve, Hermes IBC relayers and interoperability will remain key drivers of innovation, collaboration, and connectivity, paving the way for a more robust, efficient, and cohesive landscape for all participants, including Astroport and the broader DeFi landscape.