Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teleporter devnet guide #1624

Closed
wants to merge 15 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions docs/tooling/cli-guides/setup-a-devnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,144 @@ curl http://52.204.202.216:9650/ext/bc/JjDfmxM3hAEX3VuaKH4PpQskhrvp2pzGTgYLpDwin

C-Chain endpoint follows the same scheme but with the blockchain alias of `C`: `http://52.204.202.216:9650/ext/bc/C/rpc`

<!-- vale off -->

#### Deploy Teleporter

<!-- vale on -->
meaghanfitzgerald marked this conversation as resolved.
Show resolved Hide resolved

<!-- vale off -->

[Teleporter](https://github.com/ava-labs/teleporter) is a cross-chain messaging protocol built on top of Warp. Teleporter provides a user-friendly interface to Warp that provides additional features such as replay protection, message delivery incentives, and message execution, to name a few.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a link to something explaining what is warp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a first paragraph is needed as introduction of what is comming next in the tutorial, adding a basic explanation of the why of wapr/teleporter

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a link to the Warp documentation in the "Create a Devnet with Warp-Enabled Subnets" section.

As for the changes here, can you suggest specific changes? I believe the link to the Teleporter repo, a brief explanation of what Teleporter is, and how we are using it to extend the devnet example already covers what you asked for.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Now that the Warp-enabled devnet is up and running, Teleporter can be deployed to the C-Chain and subnet-evm subnets. Teleporter is deployed using [Nick's method](https://yamenmerhi.medium.com/nicks-method-ethereum-keyless-execution-168a6659479c) to ensure that the Teleporter contract is deployed to the same address on all chains. For instructions on how to deploy Teleporter, please see the guide [here.](https://github.com/ava-labs/teleporter/blob/main/utils/contract-deployment/README.md) Follow those instructions to deploy Teleporter to Subnet A, Subnet B, and the C-Chain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need to list here the commands, to deploy the contract(s) and to fund the needed addresses, with a brief explanation of those.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to not repeat documentation in multiple places - the requested steps are already included in the linked documentation.


<!-- vale on -->

#### Run an AWM Relayer instance
meaghanfitzgerald marked this conversation as resolved.
Show resolved Hide resolved

<!-- vale off -->

In order to deliver Warp and Teleporter messages between chains, an off-chain relayer is required. For this tutorial, we will use [AWM Relayer.](https://github.com/ava-labs/awm-relayer)

<!-- vale on -->

> **_NOTE:_** In this tutorial, we'll run the relayer on the same local machine from which we deployed the devnets, but these steps can be adapted to deploy the relayer in a cloud environment as well. The application itself has minimal hardware requirements, and is essentially stateless.

<!-- vale off -->

##### Configure the Relayer

<!-- vale on -->

First, we need to set the configuration using our devnet values. Below is a template relayer configuration with the values for Subnet A (which we deployed previously) filled in:
meaghanfitzgerald marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"network-id": 1337,
"p-chain-api-url": "http://52.204.202.216:9650",
"encrypt-connection": false,
"source-subnets": [
{
"subnet-id": "11111111111111111111111111111111LpoYY",
"blockchain-id": "<C_CHAIN_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
"encrypt-connection": false,
"message-contracts": {
"<TELEPORTER_CONTRACT_ADDRESS>": {
"message-format": "teleporter",
"settings": {
"reward-address": "<REWARD_ADDRESS>"
}
}
}
},
{
"subnet-id": "giY8tswWgZmcAWzPkoNrmjjrykited7GJ9799SsFzTiq5a1ML",
"blockchain-id": "JjDfmxM3hAEX3VuaKH4PpQskhrvp2pzGTgYLpDwinMzFeHJYA",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
"encrypt-connection": false,
"message-contracts": {
"<TELEPORTER_CONTRACT_ADDRESS>": {
"message-format": "teleporter",
"settings": {
"reward-address": "<REWARD_ADDRESS>"
}
}
}
}
],
"destination-subnets": [
{
"subnet-id": "11111111111111111111111111111111LpoYY",
"blockchain-id": "<C_CHAIN_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
"encrypt-connection": false,
"account-private-key": "<ACCOUNT_PRIVATE_KEY>"
},
{
"subnet-id": "giY8tswWgZmcAWzPkoNrmjjrykited7GJ9799SsFzTiq5a1ML",
"blockchain-id": "JjDfmxM3hAEX3VuaKH4PpQskhrvp2pzGTgYLpDwinMzFeHJYA",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
"encrypt-connection": false,
"account-private-key": "<ACCOUNT_PRIVATE_KEY>"
}
]
}
```

The following values need to be populated:

<!-- vale off -->

- `<C_CHAIN_BLOCKCHAIN_ID>`: The blockchain ID of the C-Chain. This can be retrieved using [platform.getBlockchains](https://docs.avax.network/reference/avalanchego/p-chain/api#platformgetblockchains) and looking for the blockchain with alias `C`.
- `<TELEPORTER_CONTRACT_ADDRESS>`: The address of the Teleporter contract on the source and destination chains. This is the same address that Teleporter was deployed to in [Deploy Teleporter](#deploy-teleporter).
- `<REWARD_ADDRESS>`: The address that the relayer will use to collect rewards for delivering messages. This can be any address.
- `<ACCOUNT_PRIVATE_KEY>`: The private key of the account that will be used to sign transactions on the source and destination chains. This account must have enough funds to pay for transaction fees on both chains.

<!-- vale on -->

The relayer is now configured to relay messages between the C-Chain and Subnet A. Subnet B can be added as well by extending the `source-subnets` and `destination-subnets` arrays with the appropriate values.

##### Run the Relayer

To run the relayer, we can either build the application from source, or run using a published [Docker image](https://hub.docker.com/r/avaplatform/awm-relayer/tags). For the following examples, assume we've written the relayer configuration to `~/config/config.json` on the host machine.

To run the relayer built from source:

```bash
# Clone the repository
git clone [email protected]:ava-labs/awm-relayer.git

# Build the application
./scripts/build.sh

# Run the relayer
./build/awm-relayer --config-file ~/config/config.json
```

To run the relayer from the Docker image:

```bash
# Pull the image
docker pull avaplatform/awm-relayer:latest

# Run the relayer
docker run --env CONFIG_FILE=/config/config.json -v ~/config:/config avaplatform/awm-relayer:latest
```

<!-- vale off -->

#### Interact with Teleporter

With the Warp-enabled devnet deployed, Teleporter deployed on each of the chains, and an AWM Relayer instance running, the Teleporter development environment is ready to go! A good place to start are the [example applications](https://github.com/ava-labs/teleporter/blob/main/contracts/src/CrossChainApplications/README.md) included in the Teleporter repository. These dApps are built on top of Teleporter and demonstrate various cross-chain messaging use cases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a simplest example, maybe using curl, outside of any other ref, and then link to other docs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think any example included inline here would make this doc unnecessarily messy. Instead, I've linked to the various Teleporter getting started guides and example scripts to serve as a starting point. Specifically, https://github.com/ava-labs/teleporter/blob/main/scripts/local/examples/basic_send_receive.sh includes all the commands for interacting with Teleporter, and serves as documentation in and of itself.


<!-- vale on -->
Loading