Skip to content

Commit

Permalink
chore: add ITS hub documentation (#1244)
Browse files Browse the repository at this point in the history
  • Loading branch information
Olanetsoft authored Dec 11, 2024
1 parent c5a46af commit 954c2d6
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 0 deletions.
10 changes: 10 additions & 0 deletions public/images/its-hub/amplifier-to-its-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/images/its-hub/amplifier-to-its-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/images/its-hub/consensus-to-its-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/images/its-hub/consensus-to-its-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions public/images/its-hub/its-hub-routing-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions public/images/its-hub/its-hub-routing-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/images/its-hub/its-to-amplifier-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/images/its-hub/its-to-amplifier-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions src/content/docs/dev/amplifier/its-hub/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ITS Hub

import { Callout } from "/src/components/callout";

<Callout>
The Interchain Token Service (ITS) Hub is currently under active development,
please check back frequently for updates.
</Callout>

The Interchain Token Service (ITS) Hub is a Cosmwasm [contract](https://github.com/axelarnetwork/axelar-amplifier/tree/feat/its-hub/interchain-token-service) on the Axelar network that acts as a central routing hub for token transfers across Amplifier and consensus chains.
The ITS Hub is designed to enhance the security, interoperability, and extensibility of cross-chain token transfers by ensuring that all ITS-enabled chains route their token transactions through this hub.
This approach helps maintain consistent security measures, enables scalability, and supports a diverse set of connected chains, including [EVM](/resources/contract-addresses/mainnet/#evm-contract-addresses) and non-smart contract chains.

Axelar supports two types of tokens: **Gateway Tokens** and **ITS Tokens**.

- **Gateway Tokens**: Cross-chain tokens deployed natively via the Axelar network and the old EVM Axelar gateway.
These are legacy tokens that the [ITS Edge Contracts](https://github.com/axelarnetwork/interchain-token-service/blob/main/contracts/InterchainTokenService.sol) support. They are native tokens registered and minted within the Axelar consensus model.
- **ITS Tokens**: Tokens deployed via ITS or integrated with ITS. These tokens are based on [General Message Passing (GMP)](/dev/general-message-passing/overview/) and are minted, burned, and managed on the connected [EVM chains](/resources/contract-addresses/mainnet/#evm-contract-addresses) directly.

The ITS Hub supports only ITS tokens and enables the secure bridging of these tokens across different types of chains.

ITS Hub brings significant value to Axelar's ecosystem by addressing the limitations of a peer-to-peer Interchain Token Service (ITS) model, which posed scalability challenges.

By routing through a central hub, token bridging is simplified and protected by an invariant that tracks the total balance bridged per chain per token.

The key outcomes of the ITS Hub implementation include:

<Callout>
[Custom ITS token](/dev/send-tokens/interchain-tokens/integrate-custom-token/)
are not supported in the current version of the ITS Hub.
</Callout>

- **Unified Token Routing**: All token bridging across ITS-enabled chains is handled through the ITS Hub, regardless of chain type ([Amplifier](/dev/amplifier/introduction/) or consensus). While peer-to-peer bridging might seem more decentralized, the ITS Hub is necessary to handle complex token translations between different blockchain technology stacks and maintain consistent state tracking.
- **Support for ITS Tokens**: ITS tokens can be securely transferred across chains, reducing fragmentation and complexity.
- **Balance Invariance**: ITS Hub maintains balance tracking to ensure that tokens escrowed to a chain cannot be over-bridged.
- **Rate Limits**: Ability to set rate limits per token by chain, adding an additional security layer.

The ITS Hub's future iterations are designed to be compatible with new features like General Message Passing (GMP) express while avoiding breaking changes to the existing ITS contracts.
148 changes: 148 additions & 0 deletions src/content/docs/dev/amplifier/its-hub/routing-mechanics.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Routing Mechanics

[ITS Hub](/dev/amplifier/its-hub/introduction/) modifies the existing token transfer mechanism by introducing a centralized routing point. Instead of ITS Edge Contracts communicating directly, all ITS calls are routed through the ITS Hub. This approach allows for enhanced security measures, balance tracking, and prepares the system for future features.

## How Routing Works

ITS Hub routing works in the following way:

- [Dual GMP calls](#dual-gmp-calls)
- [Payload wrapping](#payload-wrapping)

### Dual GMP Calls

Each token transfer or deployment involves two General Message Passing (GMP) calls:

1. **From Source Chain to ITS Hub**: The ITS Edge Contract on the source chain sends a GMP call to the ITS Hub, wrapping the original payload.
2. **From ITS Hub to Destination Chain**: The ITS Hub processes the payload, applies security measures, and forwards it to the ITS Edge Contract on the destination chain.

### Payload Wrapping

To facilitate routing through the ITS Hub, new message types are introduced:

```solidity
uint256 private constant MESSAGE_TYPE_SEND_TO_HUB = 3;
uint256 private constant MESSAGE_TYPE_RECEIVE_FROM_HUB = 4;
```

- **MESSAGE_TYPE_SEND_TO_HUB (3)**: Indicates the message is intended for the ITS Hub.
- **MESSAGE_TYPE_RECEIVE_FROM_HUB (4)**: Indicates the message is coming from the ITS Hub.

**Example Payload Wrapping:**

On the source chain:

```solidity
string destinationAddress = trustedAddresses[destinationChain];
if (destinationAddress == itsHubAddress) {
payload = abi.encode(
MESSAGE_TYPE_SEND_TO_HUB,
destinationChain, // True destination chain
originalPayload // Original ITS payload
);
destinationChain = axelarChainName; // Route to ITS Hub
}
gateway.callContract(destinationChain, destinationAddress, payload);
```

On the ITS Hub:

```solidity
// Unwrap the payload
(destinationChain, originalPayload) = abi.decode(payload, (string, bytes));
// Process the payload (apply security checks, balance tracking, etc.)
// Wrap the payload to send to the destination chain
payload = abi.encode(
MESSAGE_TYPE_RECEIVE_FROM_HUB,
sourceChain, // True source chain
originalPayload // Original ITS payload
);
gateway.callContract(destinationChain, destinationAddress, payload);
```

## Visualizing the Routing Process

### ITS Chain A to ITS Chain B via ITS Hub

<object
type="image/svg+xml"
data="/images/its-hub/its-hub-routing-dark.svg"
class="hidden dark:block w-full max-w-[60rem] mx-auto py-6"
></object>
<object
type="image/svg+xml"
data="/images/its-hub/its-hub-routing-light.svg"
class=" dark:hidden w-full max-w-[60rem] mx-auto py-6"
></object>

## Interacting with Different Chain Types

### Amplifier Chains

- **Smart Contract Chains**: Have [ITS Edge Contracts](https://github.com/axelarnetwork/axelar-cgp-sui/tree/main/move/example/sources/its) similar to EVM chains. The routing mechanics are consistent with the dual GMP call approach.
- **Non-Smart Contract Chains**: The Axelar Gateway on these chains acts as an ITS Edge Contract, translating ITS commands into custom token transfer or deployment transactions.

**Amplifier Chain to ITS Hub**

<object
type="image/svg+xml"
data="/images/its-hub/amplifier-to-its-dark.svg"
class="hidden dark:block w-full max-w-[60rem] mx-auto py-6"
></object>
<object
type="image/svg+xml"
data="/images/its-hub/amplifier-to-its-light.svg"
class=" dark:hidden w-full max-w-[60rem] mx-auto py-6"
></object>

**ITS Hub to Amplifier Chain**

<object
type="image/svg+xml"
data="/images/its-hub/its-to-amplifier-dark.svg"
class="hidden dark:block w-full max-w-[60rem] mx-auto py-6"
></object>
<object
type="image/svg+xml"
data="/images/its-hub/its-to-amplifier-light.svg"
class=" dark:hidden w-full max-w-[60rem] mx-auto py-6"
></object>

### Consensus Chains

- Use the existing Axelar protocol for GMP calls.
- The ITS Hub interacts with consensus modules to handle GMP calls with tokens (Gateway tokens).

**Consensus Chain to ITS Hub with Gateway Token**

<object
type="image/svg+xml"
data="/images/its-hub/consensus-to-its-dark.svg"
class="hidden dark:block w-full max-w-[60rem] mx-auto py-6"
></object>
<object
type="image/svg+xml"
data="/images/its-hub/consensus-to-its-light.svg"
class=" dark:hidden w-full max-w-[60rem] mx-auto py-6"
></object>

## Security Measures

The ITS Hub enhances security through:

- **Balance Tracking**: Keeps track of the total bridged balance per token per chain to prevent over-escrow or unauthorized minting.
- **Rate Limits**: Applies per-token rate limits to mitigate risks from compromised chains or contracts.
- **Centralized Control**: Allows pausing or disconnecting specific chain connections in case of security threats.

## Future Compatibility

The ITS Hub is designed to accommodate future features:

- **GMP Express**: Support for faster message passing without compromising security.
- **Integration with Axelar and Cosmos Chains**: Enabling ITS functionalities on these chains through the ITS Hub.
- **Migration Support**: Existing P2P ITS connections can be migrated to route through the ITS Hub.
13 changes: 13 additions & 0 deletions src/layouts/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ export const getNavigation = (section) => {
title: "Roadmap",
href: "/dev/amplifier/roadmap/",
},
{
title: "ITS Hub",
children: [
{
title: "Introduction",
href: "/dev/amplifier/its-hub/introduction/",
},
{
title: "Routing Mechanics",
href: "/dev/amplifier/its-hub/routing-mechanics/",
},
],
},
],
},
{
Expand Down

0 comments on commit 954c2d6

Please sign in to comment.