From 18118621b5a04f7f45a90756855a7729c0f5d83e Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Tue, 19 Dec 2023 12:11:28 -0500 Subject: [PATCH 01/19] Release workflow --- .github/changelog.json | 16 ++++++++ .github/workflows/release.yml | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 .github/changelog.json create mode 100644 .github/workflows/release.yml diff --git a/.github/changelog.json b/.github/changelog.json new file mode 100644 index 000000000..4fe255e69 --- /dev/null +++ b/.github/changelog.json @@ -0,0 +1,16 @@ +{ + "categories": [ + { + "title": "## Features", + "labels": ["T-feature"] + }, + { + "title": "## Fixes", + "labels": ["T-bug", "T-fix"] + } + ], + "ignore_labels": ["L-ignore"], + "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}", + "pr_template": "- ${{TITLE}} (#${{NUMBER}})", + "empty_template": "- No changes" +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..a0cda82ed --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +name: Release Teleporter + +on: + push: + tags: + - "v*.*.*" + +jobs: + build_and_upload_artifacts: + name: Build and Upload Teleporter Artifacts + runs-on: ubuntu-20.04 + steps: + - name: Check out the repo + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set Go version + run: | + source ./scripts/versions.sh + echo GO_VERSION=$GO_VERSION >> $GITHUB_ENV + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install Foundry + run: ./scripts/install_foundry.sh + + - name: Build Contracts + run: | + export PATH=$PATH:$HOME/.foundry/bin + cd contracts/ + forge build + + - name: Build changelog + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v4 + with: + failOnError: true + configuration: "./.github/changelog.json" + toTag: ${{ github.ref_name }} +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Artifacts + id: artifacts + run: | + go run utils/contract-deployment/contractDeploymentTools.go constructKeylessTx contracts/out/TeleporterMessenger.sol/TeleporterMessenger.json + mv UniversalTeleporterDeployerTransaction.txt TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt + echo "file_name=TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterDeployerAddress.txt TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt + echo "file_name=TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterMessengerContractAddress.txt TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt + echo "file_name=TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + + - name: Update nightly release + uses: softprops/action-gh-release@v1 + with: + name: ${{ github.ref_name }} + tag_name: ${{ github.ref_name }} + prerelease: false + body: ${{ steps.build_changelog.outputs.changelog }} + files: | + ${{ steps.artifacts.outputs.file_name }} + \ No newline at end of file From fe83d6c7cece30a78ba788b68abee3d133fea037 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Tue, 19 Dec 2023 12:12:16 -0500 Subject: [PATCH 02/19] Fix name --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0cda82ed..944f3895d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,12 +58,12 @@ jobs: mv UniversalTeleporterMessengerContractAddress.txt TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt echo "file_name=TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT - - name: Update nightly release + - name: Create release uses: softprops/action-gh-release@v1 with: name: ${{ github.ref_name }} tag_name: ${{ github.ref_name }} - prerelease: false + prerelease: true # true for testing body: ${{ steps.build_changelog.outputs.changelog }} files: | ${{ steps.artifacts.outputs.file_name }} From c38d4232b857fb00a1d8918e13b8180a93da3a18 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Tue, 19 Dec 2023 13:56:44 -0500 Subject: [PATCH 03/19] Update trigger --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 944f3895d..546c04d45 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,8 @@ name: Release Teleporter on: push: tags: - - "v*.*.*" + #- "v*.*.*" + - "testflow-v*" jobs: build_and_upload_artifacts: From 260fb913519ec606d1512a54dea27638bbd2a4ed Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Tue, 19 Dec 2023 14:25:06 -0500 Subject: [PATCH 04/19] Fix artifacts --- .github/workflows/release.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 546c04d45..85e6819a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,19 +45,20 @@ jobs: failOnError: true configuration: "./.github/changelog.json" toTag: ${{ github.ref_name }} -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Artifacts id: artifacts run: | go run utils/contract-deployment/contractDeploymentTools.go constructKeylessTx contracts/out/TeleporterMessenger.sol/TeleporterMessenger.json + mv UniversalTeleporterDeployerTransaction.txt TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt - echo "file_name=TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + echo "tx=TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterDeployerAddress.txt TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt - echo "file_name=TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + echo "deployer=TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterMessengerContractAddress.txt TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt - echo "file_name=TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + echo "address=TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT - name: Create release uses: softprops/action-gh-release@v1 @@ -67,5 +68,7 @@ jobs: prerelease: true # true for testing body: ${{ steps.build_changelog.outputs.changelog }} files: | - ${{ steps.artifacts.outputs.file_name }} + ${{ steps.artifacts.outputs.tx }} + ${{ steps.artifacts.outputs.deployer }} + ${{ steps.artifacts.outputs.address }} \ No newline at end of file From baaa3f9fd34680ecb84e41b800b17047d20d613f Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Tue, 19 Dec 2023 14:38:52 -0500 Subject: [PATCH 05/19] Fix values for release --- .github/workflows/release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 85e6819a7..9022a5a39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,8 +6,7 @@ name: Release Teleporter on: push: tags: - #- "v*.*.*" - - "testflow-v*" + - "v*.*.0" jobs: build_and_upload_artifacts: @@ -65,7 +64,7 @@ jobs: with: name: ${{ github.ref_name }} tag_name: ${{ github.ref_name }} - prerelease: true # true for testing + prerelease: false body: ${{ steps.build_changelog.outputs.changelog }} files: | ${{ steps.artifacts.outputs.tx }} From 4f5f305ba3374c2ef777f4e5e4450e8299cb5dd3 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Thu, 21 Dec 2023 12:57:54 -0500 Subject: [PATCH 06/19] Add deploy script --- scripts/deploy_teleporter.sh | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 scripts/deploy_teleporter.sh diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh new file mode 100755 index 000000000..390b03225 --- /dev/null +++ b/scripts/deploy_teleporter.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# Copyright (C) 2023, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +set -e + +TELEPORTER_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd +) + +if ! command -v forge &> /dev/null; then + echo "forge not found, installing" + $TELEPORTER_PATH/scripts/install_foundry.sh +fi + +function printHelp() { + echo "Usage: ./scripts/deploy_teleporter.sh [OPTIONS]" + echo "Deploys a selected TeleporterMessenger contract to the specified chain" + echo "For a list of releases, go to https://github.com/ava-labs/teleporter/releases" + printUsage +} + +function printUsage() { + echo "Options:" + echo " --fund-deployer Optional. Funds the deployer address with the account held by " + echo " --version Required. Specify the release version to deploy" + echo " --rpc-url Required. Specify the rpc url of the node to use" + echo " --help Print this help message" +} + +teleporter_version= +user_private_key= +rpc_url= + +while [ $# -gt 0 ]; do + case "$1" in + --fund-deployer) + if [[ $2 != --* ]]; then + user_private_key=$2 + else + echo "Invalid private key $2" && printHelp && exit 1 + fi + shift;; + --version) + if [[ $2 != --* ]]; then + teleporter_version=$2 + else + echo "Invalid teleporter version $2" && printHelp && exit 1 + fi + shift;; + --rpc-url) + if [[ $2 != --* ]]; then + rpc_url=$2 + else + echo "Invalid rpc url $2" && printHelp && exit 1 + fi + shift;; + --help) + printHelp && exit 0 ;; + *) + echo "Invalid option: -$1" && printHelp && exit 1;; + esac + shift +done + +# Tokens required to deploy the contract. +# Equal to contractCreationGasLimit * contractCreationGasPrice +# from utils/deployment-utils/deployment_utils.go +gas_tokens_required=10000000000000000000 # 10^19 gwei + +teleporter_contract_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_ContractAddress_$teleporter_version.txt) +echo "TeleporterMessenger $teleporter_version contract address: $teleporter_contract_address" +teleporter_deployer_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerAddress_$teleporter_version.txt) +echo "TeleporterMessenger $teleporter_version deployer address: $teleporter_deployer_address" +teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerTransaction_$teleporter_version.txt) + + +if [[ $(cast code $teleporter_contract_address --rpc-url $rpc_url) != "0x" ]]; then + echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 1 +fi + +if [[ $user_private_key != "" ]]; then + echo -e "\nFunding Deployer Address" + cast send --private-key $user_private_key --value $gas_tokens_required $teleporter_deployer_address --rpc-url $rpc_url +fi + +echo -e "\nDeploying TeleporterMessenger $teleporter_version" +cast publish --rpc-url $rpc_url $teleporter_deploy_tx + +echo -e "\nSuccess! TeleporterMessenger $teleporter_version deployed to $teleporter_deployer_address" +exit 0 From e7c4a78f0c29e0f53d8fa135667019b01c9b63a2 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Thu, 21 Dec 2023 16:38:30 -0500 Subject: [PATCH 07/19] Update scripts/deploy_teleporter.sh Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: Geoff Stuart --- scripts/deploy_teleporter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index 390b03225..e484f7b31 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -23,7 +23,7 @@ function printHelp() { function printUsage() { echo "Options:" - echo " --fund-deployer Optional. Funds the deployer address with the account held by " + echo " --fund-deployer Optional. Funds the deployer address with the account held by " echo " --version Required. Specify the release version to deploy" echo " --rpc-url Required. Specify the rpc url of the node to use" echo " --help Print this help message" From 53e8351fe9632e0a77d3a526f88513309f0875bc Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Fri, 22 Dec 2023 09:57:13 -0500 Subject: [PATCH 08/19] Use env vars for filenames --- .github/workflows/release.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9022a5a39..b98d94b60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,10 @@ jobs: build_and_upload_artifacts: name: Build and Upload Teleporter Artifacts runs-on: ubuntu-20.04 + env: + deployment_tx_fn: TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt + deployer_addr_fn: TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt + contract_addr_fn: TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt steps: - name: Check out the repo uses: actions/checkout@v4 @@ -50,14 +54,11 @@ jobs: run: | go run utils/contract-deployment/contractDeploymentTools.go constructKeylessTx contracts/out/TeleporterMessenger.sol/TeleporterMessenger.json - mv UniversalTeleporterDeployerTransaction.txt TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt - echo "tx=TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterDeployerTransaction.txt ${{ env.deployment_tx_fn }} - mv UniversalTeleporterDeployerAddress.txt TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt - echo "deployer=TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterDeployerAddress.txt ${{ env.deployer_addr_fn }} - mv UniversalTeleporterMessengerContractAddress.txt TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt - echo "address=TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt" >> $GITHUB_OUTPUT + mv UniversalTeleporterMessengerContractAddress.txt ${{ env.contract_addr_fn }} - name: Create release uses: softprops/action-gh-release@v1 @@ -67,7 +68,7 @@ jobs: prerelease: false body: ${{ steps.build_changelog.outputs.changelog }} files: | - ${{ steps.artifacts.outputs.tx }} - ${{ steps.artifacts.outputs.deployer }} - ${{ steps.artifacts.outputs.address }} + ${{ env.deployment_tx_fn }} + ${{ env.deployer_addr_fn }} + ${{ env.contract_addr_fn }} \ No newline at end of file From 76f2c7631d1962925996f207e0aeff15820448c8 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Fri, 22 Dec 2023 11:28:39 -0500 Subject: [PATCH 09/19] Update .github/workflows/release.yml Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: Geoff Stuart --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b98d94b60..42353dce8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,11 +53,8 @@ jobs: id: artifacts run: | go run utils/contract-deployment/contractDeploymentTools.go constructKeylessTx contracts/out/TeleporterMessenger.sol/TeleporterMessenger.json - mv UniversalTeleporterDeployerTransaction.txt ${{ env.deployment_tx_fn }} - mv UniversalTeleporterDeployerAddress.txt ${{ env.deployer_addr_fn }} - mv UniversalTeleporterMessengerContractAddress.txt ${{ env.contract_addr_fn }} - name: Create release From 497b8b03bffc64d58083293ad9da1c83815adfba Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Fri, 22 Dec 2023 11:28:47 -0500 Subject: [PATCH 10/19] Update scripts/deploy_teleporter.sh Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: Geoff Stuart --- scripts/deploy_teleporter.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index e484f7b31..fac7e7055 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -75,7 +75,6 @@ teleporter_deployer_address=$(curl -sL https://github.com/ava-labs/teleporter/re echo "TeleporterMessenger $teleporter_version deployer address: $teleporter_deployer_address" teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerTransaction_$teleporter_version.txt) - if [[ $(cast code $teleporter_contract_address --rpc-url $rpc_url) != "0x" ]]; then echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 1 fi From 32b5f671392aae3d290a4233650e8790ad9d2d3f Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 27 Dec 2023 10:28:57 -0500 Subject: [PATCH 11/19] check balance before funding --- scripts/deploy_teleporter.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index fac7e7055..6b40863b2 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -5,8 +5,8 @@ set -e TELEPORTER_PATH=$( - cd "$(dirname "${BASH_SOURCE[0]}")" - cd .. && pwd + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd ) if ! command -v forge &> /dev/null; then @@ -59,7 +59,7 @@ while [ $# -gt 0 ]; do --help) printHelp && exit 0 ;; *) - echo "Invalid option: -$1" && printHelp && exit 1;; + echo "Invalid option: -$1" && printHelp && exit 1;; esac shift done @@ -67,7 +67,7 @@ done # Tokens required to deploy the contract. # Equal to contractCreationGasLimit * contractCreationGasPrice # from utils/deployment-utils/deployment_utils.go -gas_tokens_required=10000000000000000000 # 10^19 gwei +gas_tokens_required=10000000000000000000 # 10^19 wei = 10 eth teleporter_contract_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_ContractAddress_$teleporter_version.txt) echo "TeleporterMessenger $teleporter_version contract address: $teleporter_contract_address" @@ -76,16 +76,24 @@ echo "TeleporterMessenger $teleporter_version deployer address: $teleporter_depl teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerTransaction_$teleporter_version.txt) if [[ $(cast code $teleporter_contract_address --rpc-url $rpc_url) != "0x" ]]; then - echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 1 + echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 1 fi -if [[ $user_private_key != "" ]]; then - echo -e "\nFunding Deployer Address" - cast send --private-key $user_private_key --value $gas_tokens_required $teleporter_deployer_address --rpc-url $rpc_url +deployer_balance=$(cast balance --rpc-url $rpc_url $teleporter_deployer_address) + +if [[ $(echo "$deployer_balance>=$gas_tokens_required" | bc) == 1 ]]; then + echo "Deployer Address already funded" +else + transfer_amount=$(echo "$gas_tokens_required-$deployer_balance" | bc) + if [[ $user_private_key == "" ]]; then + echo "No private key provided. Deployer address must be funded with $transfer_amount wei to deploy contract" && exit 1 + fi + echo "Funding Deployer Address with $transfer_amount wei" + cast send --private-key $user_private_key --value $transfer_amount $teleporter_deployer_address --rpc-url $rpc_url fi -echo -e "\nDeploying TeleporterMessenger $teleporter_version" +echo "Deploying TeleporterMessenger $teleporter_version" cast publish --rpc-url $rpc_url $teleporter_deploy_tx -echo -e "\nSuccess! TeleporterMessenger $teleporter_version deployed to $teleporter_deployer_address" +echo "Success! TeleporterMessenger $teleporter_version deployed to $teleporter_deployer_address" exit 0 From 45447cc9cbae0cbab89893c2acb1da9ff5703a59 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 27 Dec 2023 10:30:21 -0500 Subject: [PATCH 12/19] rpc url always first --- scripts/deploy_teleporter.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index 6b40863b2..782b4f45a 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -75,7 +75,7 @@ teleporter_deployer_address=$(curl -sL https://github.com/ava-labs/teleporter/re echo "TeleporterMessenger $teleporter_version deployer address: $teleporter_deployer_address" teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerTransaction_$teleporter_version.txt) -if [[ $(cast code $teleporter_contract_address --rpc-url $rpc_url) != "0x" ]]; then +if [[ $(cast code --rpc-url $rpc_url $teleporter_contract_address) != "0x" ]]; then echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 1 fi @@ -89,7 +89,7 @@ else echo "No private key provided. Deployer address must be funded with $transfer_amount wei to deploy contract" && exit 1 fi echo "Funding Deployer Address with $transfer_amount wei" - cast send --private-key $user_private_key --value $transfer_amount $teleporter_deployer_address --rpc-url $rpc_url + cast send --rpc-url $rpc_url --private-key $user_private_key --value $transfer_amount $teleporter_deployer_address fi echo "Deploying TeleporterMessenger $teleporter_version" From ed5fed0f8001a03980e696fd241ad836a0414ed2 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 27 Dec 2023 14:09:22 -0500 Subject: [PATCH 13/19] Update scripts/deploy_teleporter.sh Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: Geoff Stuart --- scripts/deploy_teleporter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index 782b4f45a..ba4fcf61a 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -88,7 +88,7 @@ else if [[ $user_private_key == "" ]]; then echo "No private key provided. Deployer address must be funded with $transfer_amount wei to deploy contract" && exit 1 fi - echo "Funding Deployer Address with $transfer_amount wei" + echo "Funding deployer address with $transfer_amount wei" cast send --rpc-url $rpc_url --private-key $user_private_key --value $transfer_amount $teleporter_deployer_address fi From 47d7541ef325e6fdb43753351b7a8fa20b1d0da9 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 27 Dec 2023 14:09:28 -0500 Subject: [PATCH 14/19] Update scripts/deploy_teleporter.sh Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: Geoff Stuart --- scripts/deploy_teleporter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index ba4fcf61a..bd908a4b7 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -82,7 +82,7 @@ fi deployer_balance=$(cast balance --rpc-url $rpc_url $teleporter_deployer_address) if [[ $(echo "$deployer_balance>=$gas_tokens_required" | bc) == 1 ]]; then - echo "Deployer Address already funded" + echo "Deployer address already funded" else transfer_amount=$(echo "$gas_tokens_required-$deployer_balance" | bc) if [[ $user_private_key == "" ]]; then From a4fd9f9358374f2cd33d31ec89b992f2944b2a74 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 27 Dec 2023 14:15:17 -0500 Subject: [PATCH 15/19] Review fixes --- .github/workflows/release.yml | 6 +++--- scripts/deploy_teleporter.sh | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42353dce8..d5104703e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,9 +13,9 @@ jobs: name: Build and Upload Teleporter Artifacts runs-on: ubuntu-20.04 env: - deployment_tx_fn: TeleporterMessenger_DeployerTransaction_${{ github.ref_name }}.txt - deployer_addr_fn: TeleporterMessenger_DeployerAddress_${{ github.ref_name }}.txt - contract_addr_fn: TeleporterMessenger_ContractAddress_${{ github.ref_name }}.txt + deployment_tx_fn: TeleporterMessenger_Deployment_Transaction_${{ github.ref_name }}.txt + deployer_addr_fn: TeleporterMessenger_Deployer_Address_${{ github.ref_name }}.txt + contract_addr_fn: TeleporterMessenger_Contract_Address_${{ github.ref_name }}.txt steps: - name: Check out the repo uses: actions/checkout@v4 diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index 782b4f45a..4610c5fdd 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -69,21 +69,25 @@ done # from utils/deployment-utils/deployment_utils.go gas_tokens_required=10000000000000000000 # 10^19 wei = 10 eth +# Download the artifacts for this release. teleporter_contract_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_ContractAddress_$teleporter_version.txt) echo "TeleporterMessenger $teleporter_version contract address: $teleporter_contract_address" teleporter_deployer_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerAddress_$teleporter_version.txt) echo "TeleporterMessenger $teleporter_version deployer address: $teleporter_deployer_address" teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerTransaction_$teleporter_version.txt) +# Check if this TeleporterMessenger version has already been deployed on this chain. if [[ $(cast code --rpc-url $rpc_url $teleporter_contract_address) != "0x" ]]; then - echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 1 + echo "TeleporterMessenger $teleporter_version has already been deployed on this chain." && exit 0 fi +# Check the current balance of the deployer address. deployer_balance=$(cast balance --rpc-url $rpc_url $teleporter_deployer_address) if [[ $(echo "$deployer_balance>=$gas_tokens_required" | bc) == 1 ]]; then echo "Deployer Address already funded" else + # Calculate how many wei the deployer address needs to create the contract. transfer_amount=$(echo "$gas_tokens_required-$deployer_balance" | bc) if [[ $user_private_key == "" ]]; then echo "No private key provided. Deployer address must be funded with $transfer_amount wei to deploy contract" && exit 1 From 1e75638f774e01ab0529a5c277d3ece413d6c2b8 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 27 Dec 2023 15:42:10 -0500 Subject: [PATCH 16/19] Fix file names in script --- scripts/deploy_teleporter.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index dc0d5d300..d735bb27e 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -70,11 +70,11 @@ done gas_tokens_required=10000000000000000000 # 10^19 wei = 10 eth # Download the artifacts for this release. -teleporter_contract_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_ContractAddress_$teleporter_version.txt) +teleporter_contract_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_Contract_Address_$teleporter_version.txt) echo "TeleporterMessenger $teleporter_version contract address: $teleporter_contract_address" -teleporter_deployer_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerAddress_$teleporter_version.txt) +teleporter_deployer_address=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_Deployer_Address_$teleporter_version.txt) echo "TeleporterMessenger $teleporter_version deployer address: $teleporter_deployer_address" -teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_DeployerTransaction_$teleporter_version.txt) +teleporter_deploy_tx=$(curl -sL https://github.com/ava-labs/teleporter/releases/download/$teleporter_version/TeleporterMessenger_Deployment_Transaction_$teleporter_version.txt) # Check if this TeleporterMessenger version has already been deployed on this chain. if [[ $(cast code --rpc-url $rpc_url $teleporter_contract_address) != "0x" ]]; then From b3ccb37db3f54f344c4f640d1ba6d0f73d21f361 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Tue, 2 Jan 2024 11:33:07 -0500 Subject: [PATCH 17/19] Don't automatically install foundry --- scripts/deploy_teleporter.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/deploy_teleporter.sh b/scripts/deploy_teleporter.sh index d735bb27e..fd9991748 100755 --- a/scripts/deploy_teleporter.sh +++ b/scripts/deploy_teleporter.sh @@ -10,8 +10,7 @@ TELEPORTER_PATH=$( ) if ! command -v forge &> /dev/null; then - echo "forge not found, installing" - $TELEPORTER_PATH/scripts/install_foundry.sh + echo "forge not found. You can install by calling $TELEPORTER_PATH/scripts/install_foundry.sh" && exit 1 fi function printHelp() { From aad35ebb71383b62b6f6c08c43a78b7a1c427e33 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Fri, 5 Jan 2024 10:04:16 -0500 Subject: [PATCH 18/19] README instructions for deploying teleporter --- README.md | 15 +++++++++++++++ scripts/abi_bindings.sh | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81aa1030c..a5a156fb0 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,21 @@ cp .env.example .env # Set proper values after copying. The user wallet set in `.env` must have native tokens for each of the subnets used in order for the test flows to be able to send transactions on those networks. +## Deploy Teleporter to a Subnet + +From the root of the repo, the TeleporterMessenger contract can be deployed by calling +```bash +./scripts/deploy_teleporter.sh +``` +Options for this script: +- `--version ` Required. Specify the release version to deploy. These will all be of the form `v1.X.0`. Each Teleporter version can only send and receive messages from the **same** Teleporter version on another chain. You can see a list of released versions at https://github.com/ava-labs/teleporter/releases. +- `--rpc-url ` Required. Specify the rpc url of the node to use. +- `--fund-deployer ` Optional. Funds the deployer address with the account held by `` + +To ensure that Teleporter can be deployed to the same address on every EVM based chain, it uses [Nick's Method](https://yamenmerhi.medium.com/nicks-method-ethereum-keyless-execution-168a6659479c) to deploy from a pre-determined `deployer address`. Teleporter costs exactly `10eth` in the subnet's native gas token to deploy, which must be sent to the `deployer address`. + +`deploy_teleporter.sh` will send the necessary funds to the deployer address if it is provided with a private key to send the funds with. Alternatively, the `deployer address` can be funded externally. The `deployer address` for each version can be found by looking up the appropriate version at https://github.com/ava-labs/teleporter/releases and downloading `TeleporterMessenger_Deployer_Address_.txt`. + ## ABI Bindings To generate Golang ABI bindings for the Solidity smart contracts, run: diff --git a/scripts/abi_bindings.sh b/scripts/abi_bindings.sh index aa5faed3d..a4d5dd054 100755 --- a/scripts/abi_bindings.sh +++ b/scripts/abi_bindings.sh @@ -39,8 +39,7 @@ if [ "$HELP" = true ]; then fi if ! command -v forge &> /dev/null; then - echo "forge not found, installing" - $TELEPORTER_PATH/scripts/install_foundry.sh + echo "forge not found. You can install by calling $TELEPORTER_PATH/scripts/install_foundry.sh" && exit 1 fi echo "Building subnet-evm abigen" @@ -81,4 +80,4 @@ do echo "Done generating Go bindings for $contract_name." done -exit 0 \ No newline at end of file +exit 0 From 96fc556dd8a0fa1709d022422e37d220d28d3d21 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Fri, 5 Jan 2024 13:01:14 -0500 Subject: [PATCH 19/19] Update README.md Co-authored-by: Michael Kaplan <55204436+michaelkaplan13@users.noreply.github.com> Signed-off-by: Geoff Stuart --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5a156fb0..ebfb77bf0 100644 --- a/README.md +++ b/README.md @@ -129,9 +129,9 @@ Options for this script: - `--rpc-url ` Required. Specify the rpc url of the node to use. - `--fund-deployer ` Optional. Funds the deployer address with the account held by `` -To ensure that Teleporter can be deployed to the same address on every EVM based chain, it uses [Nick's Method](https://yamenmerhi.medium.com/nicks-method-ethereum-keyless-execution-168a6659479c) to deploy from a pre-determined `deployer address`. Teleporter costs exactly `10eth` in the subnet's native gas token to deploy, which must be sent to the `deployer address`. +To ensure that Teleporter can be deployed to the same address on every EVM based chain, it uses [Nick's Method](https://yamenmerhi.medium.com/nicks-method-ethereum-keyless-execution-168a6659479c) to deploy from a static deployer address. Teleporter costs exactly `10eth` in the subnet's native gas token to deploy, which must be sent to the deployer address. -`deploy_teleporter.sh` will send the necessary funds to the deployer address if it is provided with a private key to send the funds with. Alternatively, the `deployer address` can be funded externally. The `deployer address` for each version can be found by looking up the appropriate version at https://github.com/ava-labs/teleporter/releases and downloading `TeleporterMessenger_Deployer_Address_.txt`. +`deploy_teleporter.sh` will send the necessary native tokens to the deployer address if it is provided with a private key for an account with sufficient funds. Alternatively, the deployer address can be funded externally. The deployer address for each version can be found by looking up the appropriate version at https://github.com/ava-labs/teleporter/releases and downloading `TeleporterMessenger_Deployer_Address_.txt`. ## ABI Bindings