Skip to content

Commit

Permalink
Merge branch 'main' into gstuart/native-token-bridge-teleporter-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-vball committed Dec 27, 2023
2 parents edf47be + 94aa3e7 commit 3efd7dc
Show file tree
Hide file tree
Showing 78 changed files with 946 additions and 305 deletions.
20 changes: 14 additions & 6 deletions .env.testnet
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# subnet A (Amplify)
subnet_a_rpc_url=https://subnets.avax.network/amplify/testnet/rpc
subnet_a_subnet_id=2PsShLjrFFwR51DMcAh8pyuwzLn1Ym3zRhuXLTmLCR1STk2mL6
subnet_a_chain_id=2nFUad4Nw4pCgEF6MwYgGuKrzKbHJzM8wF29jeVUL41RWHgNRa
subnet_a_chain_id_hex=ea70d815f0232f5419dabafe36c964ffe5c22d17ac367b60b556ab3e17a36458
subnet_a_blockchain_id=2nFUad4Nw4pCgEF6MwYgGuKrzKbHJzM8wF29jeVUL41RWHgNRa
subnet_a_blockchain_id_hex=ea70d815f0232f5419dabafe36c964ffe5c22d17ac367b60b556ab3e17a36458
subnet_a_erc20_bridge_contract=0x297C4dCBB51839caEBB550C8387a52b4F3676d35
subnet_a_native_erc20_contract=0x2010D09052e5D3d0F2E80f62b7FB2E564e83B865

# subnet B (Bulletin)
subnet_b_rpc_url=https://subnets.avax.network/bulletin/testnet/rpc
subnet_b_subnet_id=cbXsFGWSDWUYTmRXUoCirVDdQkZmUWrkQQYoVc2wUoDm8eFup
subnet_b_chain_id=2e3RJ3ub9Pceh8fJ3HX3gZ6nSXJLvBJ9WoXLcU4nwdpZ8X2RLq
subnet_b_chain_id_hex=d7cdc6f08b167595d1577e24838113a88b1005b471a6c430d79c48b4c89cfc53
subnet_b_blockchain_id=2e3RJ3ub9Pceh8fJ3HX3gZ6nSXJLvBJ9WoXLcU4nwdpZ8X2RLq
subnet_b_blockchain_id_hex=d7cdc6f08b167595d1577e24838113a88b1005b471a6c430d79c48b4c89cfc53
subnet_b_erc20_bridge_contract=0x48Db0f37e1Bfb569b420aEf96bcaaE9b889Bd2E9
subnet_b_bridge_token_contract=0x3C77573dF123f287470BC463835CE6dDc60d5eeD

# subnet C (Conduit)
subnet_c_rpc_url=https://subnets.avax.network/conduit/testnet/rpc
subnet_c_subnet_id=wW7JVmjXp8SKrpacGzM81RBXdfcLDVY6M2DkFyArEXgtkyozK
subnet_c_chain_id=9asUA3QckLh7vGnFQiiUJGPTx8KE4nFtP8c1wTWJuP8XiWW75
subnet_c_chain_id_hex=137daedb40251e7c196fd9711f6cd4a787d154cdc59fb7777d4d079cc116e5f1
subnet_c_blockchain_id=9asUA3QckLh7vGnFQiiUJGPTx8KE4nFtP8c1wTWJuP8XiWW75
subnet_c_blockchain_id_hex=137daedb40251e7c196fd9711f6cd4a787d154cdc59fb7777d4d079cc116e5f1
subnet_c_erc20_bridge_contract=0xa415AAC7979a0b68E1c3117763C8978F7e89C9E0
subnet_c_bridge_token_contract=0x6589D828F91790c50C097175FF6e3Ba3d934868D

# C-Chain
c_chain_rpc_url=
c_chain_subnet_id=
c_chain_blockchain_id=
c_chain_blockchain_id_hex=
c_chain_erc20_bridge_contract=
c_chain_bridge_token_contract=

# teleporter contract
teleporter_contract_address=0x50A46AA7b2eCBe2B1AbB7df865B9A87f5eed8635
warp_messenger_precompile_addr=0x0200000000000000000000000000000000000005
Expand Down
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ The Teleporter protocol, on the other hand, is implemented at the smart contract
## Run a local testnet in Docker
A docker setup for running a local network with Teleporter deployed is provided. This setup provides a convenient way to develop and test Teleporter as well as cross-chain applications built on top of Teleporter. Teleporter messages are relayed between subnets using [AWM Relayer](https://github.com/ava-labs/awm-relayer), a fully featured implementation of a Warp message relayer.

- Install Docker as described in the setup section of the README in the root of this repository.
- If using a local version of the `awm-relayer` image, build it using `./scripts/build_local_image.sh` from the root of the `awm-relayer` repository.

### Start up the local testnet

Expand All @@ -57,26 +55,35 @@ A docker setup for running a local network with Teleporter deployed is provided.
-p, --pause Pause the network on stop. Will attempt to restart the paused network on subsequent runs
-h, --help Print this help message
```
- If using `-l, --local` to use a local version of the `awm-relayer` image, build it using `./scripts/build_local_image.sh` from the root of the `awm-relayer` repository.
- Note that if `-l, --local` is not set, then the latest published `awm-relayer` image will be pulled from Dockerhub.
- Once it's running, try sending 1 AVAX on the local C-Chain:
```
cast balance --rpc-url http://127.0.0.1:9652/ext/bc/C/rpc 0x333d17d3b42bf7930dbc6e852ca7bcf560a69003
cast send --private-key 0x56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027 --value 1 0x333d17d3b42bf7930dbc6e852ca7bcf560a69003 --rpc-url http://127.0.0.1:9650/ext/bc/C/rpc
cast balance --rpc-url http://127.0.0.1:9652/ext/bc/C/rpc 0x333d17d3b42bf7930dbc6e852ca7bcf560a69003
```

- After calling `./scripts/local/run.sh`, you can interact with the deployed Teleporter contracts directly, or deploy a cross-chain application contract such as `ExampleCrossChainMessenger`. To open a terminal in the container and initialize it with the environment variables needed to interact with the contracts, run:
- After calling `./scripts/local/run.sh`, you'll know the network is ready once the "Waiting for subnets to start up." messages from the `relayer_run` container stop. Once the network is ready, you can interact with the deployed Teleporter contracts directly, or deploy a cross-chain application contract such as `ExampleCrossChainMessenger`. To open a terminal in the container and initialize it with the environment variables needed to interact with the contracts, run:

```
# Open a shell in the container
docker exec -it local_network_run /bin/bash
# In the container:
set -a # export all variables so child processes can access
source vars.sh
source vars.sh # source the variables needed to interact with the contracts
```
- Once you've opened a shell in the container, try interacting with the network.
- For example, send 1 AVAX on the C-Chain using `cast`
```
c_address=0x333d17d3b42bf7930dbc6e852ca7bcf560a69003 # pick an arbitrary address
cast balance --rpc-url $c_chain_rpc_url $c_address
cast send --private-key $user_private_key --value 1 $c_address --rpc-url $c_chain_rpc_url
cast balance --rpc-url $c_chain_rpc_url $c_address
```
- An example of how to interact with Teleporter is provided in `scripts/local/examples/basic_send_receive.sh`. This script sends a dummy payload via Teleporter from the C-Chain to a subnet, and back again.
```
./scripts/local/examples/basic_send_receive.sh
```
- You should see "Received on Subnet A is true" and "Received on the C-Chain is true" to indicate that Teleporter messages were successfully sent between the C-Chain and Subnet A.
- These examples can be adapted to send messages between any two subnets, or between the C-Chain and any subnet by changing the RPC URLs.
- Use these as a starting point to build and interact with your own cross-chain applications on top of Teleporter!

- Command line tools such as `cast` can also be used from the container.
- Similarly, you can send the above transaction on either of the subnets by replacing the above rpc-url with the subnet's corresponding URL.
- The script `./scripts/local/run_stop.sh` should be used to gracefully shut down the containers, preserving the local network state between runs. This script is called automatically at the end of `./scripts/local/run.sh`, but can be called at any time from a separate terminal to pause the network.
- `./scripts/local/run_stop.sh` usage is as follows:
```
Expand All @@ -88,7 +95,7 @@ source vars.sh

- The `./scripts/local/run.sh` script runs five local network nodes, with each of the nodes validating the primary network and three subnets (Subnet A, Subnet B, and Subnet C).
- Logs from the subnets on one of the five nodes are printed to stdout when run using either script.
- These logs can also be found at `~/.avalanche-cli/runs/network-runner-root-data_<DATE>_<TIMESTAMP>/node{1,5]/logs/<SUBNET_ID>.log` in the `local_network_run` container, or at `/var/lib/docker/overlay2/<CONTAINER_ID>/merged/root/.avalanche-cli/....` on your local machine. You will need to be the root user to access the logs under `/var/lib`.
- These logs can also be found at `~/.avalanche-cli/runs/network_<DATE>_<TIMESTAMP>/node{1,5]/logs/<SUBNET_ID>.log` in the `local_network_run` container.

## E2E tests

Expand Down Expand Up @@ -125,9 +132,9 @@ The auto-generated bindings should be written under the `abi-bindings/` director
- [Teleporter Protocol Overview](./contracts/src/Teleporter/README.md)
- [Cross Chain Applications](./contracts/src/CrossChainApplications/README.md)
- [Getting Started](./contracts/src/CrossChainApplications/GETTING_STARTED.md)
- [Teleporter Upgradeability](./contracts/src/Teleporter/upgrades/README.md)
- [Contract Deployment](./utils/contract-deployment/README.md)
- [ERC20Bridge](./contracts/src/CrossChainApplications/ERC20Bridge/README.md)
- [VerifiedBlockHash](./contracts/src/CrossChainApplications/VerifiedBlockHash/README.md)
- [Teleporter CLI](./cmd/teleporter-cli/README.md)

## Resources

Expand Down
Loading

0 comments on commit 3efd7dc

Please sign in to comment.