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

C chain integ tests #204

Merged
merged 43 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d8767f4
handle primary network case in relayer
cam-schultz Dec 15, 2023
c34b3d8
remove subnet C
cam-schultz Dec 15, 2023
e6f7a3e
expect 2 subnets
cam-schultz Dec 15, 2023
db7ea7d
basic send receive c chain
cam-schultz Dec 15, 2023
78ee57a
clean up data dir
cam-schultz Dec 16, 2023
1360541
most tests working w/c-chain
cam-schultz Dec 16, 2023
3958785
block hash test working c-chain
cam-schultz Dec 16, 2023
06253fc
remove dummy test
cam-schultz Dec 16, 2023
25eec62
export LocalNetwork
cam-schultz Dec 16, 2023
52e5f0c
export TearDownNetwork
cam-schultz Dec 16, 2023
1012306
update relayer config
cam-schultz Dec 18, 2023
e147529
latest avalanche-cli
cam-schultz Dec 18, 2023
368cc91
testnet primary network
cam-schultz Dec 19, 2023
1f89c95
fix block hash publisher c-chain test case
cam-schultz Dec 19, 2023
40da608
remove redundant var
cam-schultz Dec 19, 2023
6263664
replace chainid with blockchainid
cam-schultz Dec 20, 2023
f03cfab
add comment
cam-schultz Dec 20, 2023
37ff640
add getAllSubnetsInfo helper
cam-schultz Dec 20, 2023
f921089
Merge branch 'main' into c-chain-integ-tests
cam-schultz Dec 20, 2023
ef1c817
cleanup dbg logs
cam-schultz Dec 20, 2023
7a88621
clean up rpc vs ws client usage
cam-schultz Dec 20, 2023
13dc973
clean up rpc vs ws client usage 2
cam-schultz Dec 20, 2023
c129b21
block hash workaround
cam-schultz Dec 20, 2023
3091e05
go mod tidy
cam-schultz Dec 20, 2023
839ba3c
add Teleporter examplke script
cam-schultz Dec 20, 2023
78da15e
use node-config
cam-schultz Dec 20, 2023
b600491
deploy registry on c-chain
cam-schultz Dec 20, 2023
eaec7f2
Merge branch 'main' into c-chain-integ-tests
cam-schultz Dec 20, 2023
588b4cf
Merge branch 'main' into c-chain-integ-tests
cam-schultz Dec 20, 2023
c311907
c-chain specifier const
cam-schultz Dec 21, 2023
3a6a683
Update tests/flows/block_hash_publish_receive.go
cam-schultz Dec 21, 2023
fe7bd6c
comments
cam-schultz Dec 21, 2023
b497678
stream c chain logs
cam-schultz Dec 21, 2023
793ae1f
remove references to unused vars
cam-schultz Dec 21, 2023
d8214da
Merge branch 'c-chain-integ-tests' of github.com:ava-labs/teleporter …
cam-schultz Dec 21, 2023
826fa59
echo blockchain id
cam-schultz Dec 21, 2023
fdab992
update avalanche-cli
cam-schultz Dec 21, 2023
838e9b7
typo
cam-schultz Dec 21, 2023
d38c26d
example script interacts with c-chain
cam-schultz Dec 21, 2023
8a38f6e
comment command
cam-schultz Dec 21, 2023
3f8b6bf
awm relayer v0.2.7
cam-schultz Dec 21, 2023
43a8d3e
fix example script
cam-schultz Dec 21, 2023
87d3efd
cleanup docker setup readme
cam-schultz Dec 21, 2023
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
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
33 changes: 20 additions & 13 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
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ RUN apt-get update && \
RUN pip3 install base58

# Install avalanche-cli
RUN curl -sSfL https://raw.githubusercontent.com/ava-labs/avalanche-cli/main/scripts/install.sh | sh -s -- -b /usr/local/bin v1.3.3
RUN curl -sSfL https://raw.githubusercontent.com/ava-labs/avalanche-cli/main/scripts/install.sh | sh -s -- -b /usr/local/bin v1.3.6
RUN avalanche --version
RUN echo '{"MetricsEnabled}":false}' > ~/.avalanche-cli/config
2 changes: 1 addition & 1 deletion docker/docker-compose-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
source: ./
target: /code/
relayer:
image: avaplatform/awm-relayer:v0.2.4
image: avaplatform/awm-relayer:v0.2.7
container_name: relayer_run
init: true
working_dir: /code
Expand Down
16 changes: 8 additions & 8 deletions docker/relayerConfigTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"source-subnets": [
{
"subnet-id": "11111111111111111111111111111111LpoYY",
"chain-id": "<C_CHAIN_CHAIN_ID>",
"blockchain-id": "<C_CHAIN_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -21,7 +21,7 @@
},
{
"subnet-id": "<SUBNET_A_SUBNET_ID>",
"chain-id": "<SUBNET_A_CHAIN_ID>",
"blockchain-id": "<SUBNET_A_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -37,7 +37,7 @@
},
{
"subnet-id": "<SUBNET_B_SUBNET_ID>",
"chain-id": "<SUBNET_B_CHAIN_ID>",
"blockchain-id": "<SUBNET_B_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -53,7 +53,7 @@
},
{
"subnet-id": "<SUBNET_C_SUBNET_ID>",
"chain-id": "<SUBNET_C_CHAIN_ID>",
"blockchain-id": "<SUBNET_C_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -71,7 +71,7 @@
"destination-subnets": [
{
"subnet-id": "11111111111111111111111111111111LpoYY",
"chain-id": "<C_CHAIN_CHAIN_ID>",
"blockchain-id": "<C_CHAIN_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -80,7 +80,7 @@
},
{
"subnet-id": "<SUBNET_A_SUBNET_ID>",
"chain-id": "<SUBNET_A_CHAIN_ID>",
"blockchain-id": "<SUBNET_A_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -89,7 +89,7 @@
},
{
"subnet-id": "<SUBNET_B_SUBNET_ID>",
"chain-id": "<SUBNET_B_CHAIN_ID>",
"blockchain-id": "<SUBNET_B_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand All @@ -98,7 +98,7 @@
},
{
"subnet-id": "<SUBNET_C_SUBNET_ID>",
"chain-id": "<SUBNET_C_CHAIN_ID>",
"blockchain-id": "<SUBNET_C_BLOCKCHAIN_ID>",
"vm": "evm",
"api-node-host": "127.0.0.1",
"api-node-port": 9650,
Expand Down
8 changes: 4 additions & 4 deletions docker/run_relayer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ relayerConfigFile=./relayerConfig.json
rm -f $relayerConfigFile

# Avoid using sed -i due to Docker + MacOS M1 issues
sed "s/<SUBNET_A_CHAIN_ID>/$subnet_a_chain_id/g
sed "s/<SUBNET_A_BLOCKCHAIN_ID>/$subnet_a_blockchain_id/g
s/<SUBNET_A_SUBNET_ID>/$subnet_a_subnet_id/g
s/<SUBNET_B_CHAIN_ID>/$subnet_b_chain_id/g
s/<SUBNET_B_BLOCKCHAIN_ID>/$subnet_b_blockchain_id/g
s/<SUBNET_B_SUBNET_ID>/$subnet_b_subnet_id/g
s/<SUBNET_C_CHAIN_ID>/$subnet_c_chain_id/g
s/<SUBNET_C_BLOCKCHAIN_ID>/$subnet_c_blockchain_id/g
s/<SUBNET_C_SUBNET_ID>/$subnet_c_subnet_id/g
s/<TELEPORTER_CONTRACT_ADDRESS>/$teleporter_contract_address/g
s/<C_CHAIN_CHAIN_ID>/$c_chain_chain_id/g
s/<C_CHAIN_BLOCKCHAIN_ID>/$c_chain_blockchain_id/g
s/<REWARD_ADDRESS>/$reward_address/g
s/<ACCOUNT_PRIVATE_KEY>/$account_private_key/g" ./docker/relayerConfigTemplate.json > $relayerConfigFile

Expand Down
Loading