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 release flow #210

Merged
merged 30 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1811862
Release workflow
geoff-vball Dec 19, 2023
fe83d6c
Fix name
geoff-vball Dec 19, 2023
c38d423
Update trigger
geoff-vball Dec 19, 2023
260fb91
Fix artifacts
geoff-vball Dec 19, 2023
baaa3f9
Fix values for release
geoff-vball Dec 19, 2023
4f5f305
Add deploy script
geoff-vball Dec 21, 2023
c16138d
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Dec 21, 2023
e7c4a78
Update scripts/deploy_teleporter.sh
geoff-vball Dec 21, 2023
53e8351
Use env vars for filenames
geoff-vball Dec 22, 2023
faabaca
Merge branch 'gstuart/teleporter-release-flow' of github.com:ava-labs…
geoff-vball Dec 22, 2023
7e180ec
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Dec 22, 2023
76f2c76
Update .github/workflows/release.yml
geoff-vball Dec 22, 2023
497b8b0
Update scripts/deploy_teleporter.sh
geoff-vball Dec 22, 2023
1fdd98a
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Dec 27, 2023
32b5f67
check balance before funding
geoff-vball Dec 27, 2023
45447cc
rpc url always first
geoff-vball Dec 27, 2023
ed5fed0
Update scripts/deploy_teleporter.sh
geoff-vball Dec 27, 2023
47d7541
Update scripts/deploy_teleporter.sh
geoff-vball Dec 27, 2023
a4fd9f9
Review fixes
geoff-vball Dec 27, 2023
8e70113
Merge branch 'gstuart/teleporter-release-flow' of github.com:ava-labs…
geoff-vball Dec 27, 2023
1e75638
Fix file names in script
geoff-vball Dec 27, 2023
b3ccb37
Don't automatically install foundry
geoff-vball Jan 2, 2024
6fdde85
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Jan 3, 2024
794c06e
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Jan 3, 2024
693ef30
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Jan 3, 2024
e6efd96
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Jan 5, 2024
aad35eb
README instructions for deploying teleporter
geoff-vball Jan 5, 2024
86db191
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Jan 5, 2024
96fc556
Update README.md
geoff-vball Jan 5, 2024
7d4081c
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball Jan 5, 2024
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
16 changes: 16 additions & 0 deletions .github/changelog.json
Original file line number Diff line number Diff line change
@@ -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"
}
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

name: Release Teleporter

on:
push:
tags:
- "v*.*.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we require the bugfix version to be 0 in order to issue a release? It's possible we'd release a fix that did not change the interface at all, in which case we'd want to tag it as a bugfix.

I don't think we should use semver tags for non-contract changes. Those can either be rc's or left untagged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can still manually make releases for the whole repo for, let's say v.0.1.2, but it won't trigger this flow. This flow just adds in the teleporter contract artifacts, which we only want to do for a new version of the teleporter contract.

To treat semver properly, we would probably only generate the teleporter artifacts on major version changes, but with the way golang treats major version changes, I think we should stick with minor versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

we would probably only generate the teleporter artifacts on major version changes

I think it's possible we'd generate Teleporter artifacts for major, minor, or bug fix versions. We should treat this as a Solidity repository primarily, and have the tagged releases map to Teleporter and the supporting contracts. Other changes, including the Golang tests and the example contracts, should not constitute tagged releases on their own IMO.

Copy link
Collaborator

Choose a reason for hiding this comment

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

With how Nick's method is used to deploy the contract to the same address on every chain, any change to the contract (even one that doesn't change the interface) would be a "breaking" change in the sense that the new contract will be deployed to a new address and not be able to send/receive message from older versions.

I think it makes sense to leave bugfix versions for changes to the test and/or golang utilities that other repos may consume, and require that any change to the Teleporter contract itself be at least a new minor version. While the "teleporter version" numbers in the registry contracts are completely independent, I think we should only create new Teleporter contract releases when we plan on updating the commonly used registries via an off-chain warp message.

Copy link
Contributor

@cam-schultz cam-schultz Jan 4, 2024

Choose a reason for hiding this comment

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

Sounds good to me. Can we document somewhere how we're planning on treating release versions since we're diverging from semver as a it relates to the Teleporter contract? @geoff-vball

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cam-schultz Yep I'll add it.


jobs:
build_and_upload_artifacts:
name: Build and Upload Teleporter Artifacts
runs-on: ubuntu-20.04
env:
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
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 }}

- name: Create Artifacts
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
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: |
${{ env.deployment_tx_fn }}
${{ env.deployer_addr_fn }}
${{ env.contract_addr_fn }}

103 changes: 103 additions & 0 deletions scripts/deploy_teleporter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/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 <private_key> Optional. Funds the deployer address with the account held by <private_key>"
echo " --version <version> Required. Specify the release version to deploy"
echo " --rpc-url <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 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_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_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_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
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
fi
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

echo "Deploying TeleporterMessenger $teleporter_version"
cast publish --rpc-url $rpc_url $teleporter_deploy_tx

echo "Success! TeleporterMessenger $teleporter_version deployed to $teleporter_deployer_address"
exit 0