-
Notifications
You must be signed in to change notification settings - Fork 31
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
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
1811862
Release workflow
geoff-vball fe83d6c
Fix name
geoff-vball c38d423
Update trigger
geoff-vball 260fb91
Fix artifacts
geoff-vball baaa3f9
Fix values for release
geoff-vball 4f5f305
Add deploy script
geoff-vball c16138d
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball e7c4a78
Update scripts/deploy_teleporter.sh
geoff-vball 53e8351
Use env vars for filenames
geoff-vball faabaca
Merge branch 'gstuart/teleporter-release-flow' of github.com:ava-labs…
geoff-vball 7e180ec
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball 76f2c76
Update .github/workflows/release.yml
geoff-vball 497b8b0
Update scripts/deploy_teleporter.sh
geoff-vball 1fdd98a
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball 32b5f67
check balance before funding
geoff-vball 45447cc
rpc url always first
geoff-vball ed5fed0
Update scripts/deploy_teleporter.sh
geoff-vball 47d7541
Update scripts/deploy_teleporter.sh
geoff-vball a4fd9f9
Review fixes
geoff-vball 8e70113
Merge branch 'gstuart/teleporter-release-flow' of github.com:ava-labs…
geoff-vball 1e75638
Fix file names in script
geoff-vball b3ccb37
Don't automatically install foundry
geoff-vball 6fdde85
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball 794c06e
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball 693ef30
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball e6efd96
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball aad35eb
README instructions for deploying teleporter
geoff-vball 86db191
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball 96fc556
Update README.md
geoff-vball 7d4081c
Merge branch 'main' into gstuart/teleporter-release-flow
geoff-vball File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
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 | ||
geoff-vball marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
geoff-vball marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.