From af9c8286ae2fbd4f2a06b88be8e967648fe2865d Mon Sep 17 00:00:00 2001 From: Ian Suvak Date: Wed, 20 Nov 2024 08:30:12 -0500 Subject: [PATCH 1/6] convert to require.ErrorIs --- signature-aggregator/aggregator/aggregator_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/signature-aggregator/aggregator/aggregator_test.go b/signature-aggregator/aggregator/aggregator_test.go index 32b7507c..8c386808 100644 --- a/signature-aggregator/aggregator/aggregator_test.go +++ b/signature-aggregator/aggregator/aggregator_test.go @@ -241,10 +241,10 @@ func TestCreateSignedMessageRetriesAndFailsWithoutP2PResponses(t *testing.T) { ).Times(maxRelayerQueryAttempts) _, err = aggregator.CreateSignedMessage(msg, nil, subnetID, 80) - require.ErrorContains( + require.ErrorIs( t, err, - "failed to collect a threshold of signatures", + errNotEnoughSignatures, ) } From 03f80db17c1a651fe638deae300d560bbef31403 Mon Sep 17 00:00:00 2001 From: Ian Suvak Date: Wed, 20 Nov 2024 09:04:31 -0500 Subject: [PATCH 2/6] use local copy of install_avalanchego_release.sh --- scripts/e2e_test.sh | 2 +- scripts/install_avalanchego_release.sh | 133 +++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100755 scripts/install_avalanchego_release.sh diff --git a/scripts/e2e_test.sh b/scripts/e2e_test.sh index 028d2547..9d29d848 100755 --- a/scripts/e2e_test.sh +++ b/scripts/e2e_test.sh @@ -43,8 +43,8 @@ if [ "$LOCAL" = true ]; then exit 1 fi cwd=$PWD - cd $SUBNET_EVM_PATH BASEDIR=$DATA_DIRECTORY AVALANCHEGO_BUILD_PATH=$DATA_DIRECTORY/avalanchego ./scripts/install_avalanchego_release.sh + cd $SUBNET_EVM_PATH ./scripts/build.sh $DATA_DIRECTORY/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy cd $cwd diff --git a/scripts/install_avalanchego_release.sh b/scripts/install_avalanchego_release.sh new file mode 100755 index 00000000..420a885e --- /dev/null +++ b/scripts/install_avalanchego_release.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bash +# Copyright (C) 2024, Ava Labs, Inc. All rights reserved. +# See the file LICENSE for licensing terms. + +# Following script is adapted from https://github.com/ava-labs/subnet-evm/blob/master/scripts/install_avalanchego_release.sh +set -e + +# Load the versions +ICM_OFFCHAIN_CONTRACTS_PATH=$( + cd "$(dirname "${BASH_SOURCE[0]}")" + cd .. && pwd +) +source "$ICM_OFFCHAIN_CONTRACTS_PATH"/scripts/versions.sh + +# Load the constants +source "$ICM_OFFCHAIN_CONTRACTS_PATH"/scripts/constants.sh + +############################ +# download avalanchego +# https://github.com/ava-labs/avalanchego/releases +GOARCH=$(go env GOARCH) +GOOS=$(go env GOOS) +BASEDIR=${BASEDIR:-"/tmp/avalanchego-release"} +AVALANCHEGO_BUILD_PATH=${AVALANCHEGO_BUILD_PATH:-${BASEDIR}/avalanchego} + +mkdir -p ${BASEDIR} + +AVAGO_DOWNLOAD_URL=https://github.com/ava-labs/avalanchego/releases/download/${AVALANCHEGO_VERSION}/avalanchego-linux-${GOARCH}-${AVALANCHEGO_VERSION}.tar.gz +AVAGO_DOWNLOAD_PATH=${BASEDIR}/avalanchego-linux-${GOARCH}-${AVALANCHEGO_VERSION}.tar.gz + +if [[ ${GOOS} == "darwin" ]]; then + AVAGO_DOWNLOAD_URL=https://github.com/ava-labs/avalanchego/releases/download/${AVALANCHEGO_VERSION}/avalanchego-macos-${AVALANCHEGO_VERSION}.zip + AVAGO_DOWNLOAD_PATH=${BASEDIR}/avalanchego-macos-${AVALANCHEGO_VERSION}.zip +fi + +BUILD_DIR=${AVALANCHEGO_BUILD_PATH}-${AVALANCHEGO_VERSION} + +extract_archive() { + mkdir -p ${BUILD_DIR} + + if [[ ${AVAGO_DOWNLOAD_PATH} == *.tar.gz ]]; then + tar xzvf ${AVAGO_DOWNLOAD_PATH} --directory ${BUILD_DIR} --strip-components 1 + elif [[ ${AVAGO_DOWNLOAD_PATH} == *.zip ]]; then + unzip ${AVAGO_DOWNLOAD_PATH} -d ${BUILD_DIR} + mv ${BUILD_DIR}/build/* ${BUILD_DIR} + rm -rf ${BUILD_DIR}/build/ + fi +} + +# first check if we already have the archive +if [[ -f ${AVAGO_DOWNLOAD_PATH} ]]; then + # if the download path already exists, extract and exit + echo "found avalanchego ${AVALANCHEGO_VERSION} at ${AVAGO_DOWNLOAD_PATH}" + + extract_archive +else + # try to download the archive if it exists + if curl -s --head --request GET ${AVAGO_DOWNLOAD_URL} | grep "302" > /dev/null; then + echo "${AVAGO_DOWNLOAD_URL} found" + echo "downloading to ${AVAGO_DOWNLOAD_PATH}" + curl -L ${AVAGO_DOWNLOAD_URL} -o ${AVAGO_DOWNLOAD_PATH} + + extract_archive + else + # else the version is a git commit (or it's invalid) + GIT_CLONE_URL=https://github.com/ava-labs/avalanchego.git + GIT_CLONE_PATH=${BASEDIR}/avalanchego-repo/ + + # check to see if the repo already exists, if not clone it + if [[ ! -d ${GIT_CLONE_PATH} ]]; then + echo "cloning ${GIT_CLONE_URL} to ${GIT_CLONE_PATH}" + git clone --no-checkout ${GIT_CLONE_URL} ${GIT_CLONE_PATH} + fi + + # check to see if the commitish exists in the repo + WORKDIR=$(pwd) + + cd ${GIT_CLONE_PATH} + + git fetch + + echo "checking out ${AVALANCHEGO_VERSION}" + + set +e + # try to checkout the branch + git checkout origin/${AVALANCHEGO_VERSION} > /dev/null 2>&1 + CHECKOUT_STATUS=$? + set -e + + # if it's not a branch, try to checkout the commit + # Try to checkout the branch. If it fails, try the commit. + if ! git checkout "origin/${AVALANCHEGO_VERSION}" > /dev/null 2>&1; then + if ! git checkout "${AVALANCHEGO_VERSION}" > /dev/null 2>&1; then + # If the version is in the format of tag-commit, try to extract the commit and checkout. + AVALANCHEGO_VERSION=$(extract_commit "${AVALANCHEGO_VERSION}") + if ! git checkout "${AVALANCHEGO_VERSION}" > /dev/null 2>&1; then + echo + echo "'${AVALANCHEGO_VERSION}' is not a valid release tag, commit hash, or branch name" + exit 1 + fi + fi + fi + + COMMIT=$(git rev-parse HEAD) + + # use the commit hash instead of the branch name or tag + BUILD_DIR=${AVALANCHEGO_BUILD_PATH}-${COMMIT} + + # if the build-directory doesn't exist, build avalanchego + if [[ ! -d ${BUILD_DIR} ]]; then + echo "building avalanchego ${COMMIT} to ${BUILD_DIR}" + ./scripts/build.sh + mkdir -p ${BUILD_DIR} + + mv ${GIT_CLONE_PATH}/build/* ${BUILD_DIR}/ + fi + + cd $WORKDIR + fi +fi + +AVALANCHEGO_PATH=${AVALANCHEGO_BUILD_PATH}/avalanchego +AVALANCHEGO_PLUGIN_DIR=${AVALANCHEGO_BUILD_PATH}/plugins + +mkdir -p ${AVALANCHEGO_BUILD_PATH} +mkdir -p ${AVALANCHEGO_PLUGIN_DIR} + +cp ${BUILD_DIR}/avalanchego ${AVALANCHEGO_PATH} + + +echo "Installed AvalancheGo release ${AVALANCHEGO_VERSION}" +echo "AvalancheGo Path: ${AVALANCHEGO_PATH}" +echo "Plugin Dir: ${AVALANCHEGO_PLUGIN_DIR}" From 14d5b741a8365674f9b808e30299ec3615369c37 Mon Sep 17 00:00:00 2001 From: Ian Suvak Date: Wed, 20 Nov 2024 09:13:51 -0500 Subject: [PATCH 3/6] update .github/workflows/e2e.yml --- .github/workflows/e2e.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 5b77e647..72475449 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -27,6 +27,9 @@ jobs: with: go-version-file: 'go.mod' + - name: Install AvalancheGo Release + run: BASEDIR=/tmp/e2e-test AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/install_avalanchego_release.sh + - name: Set subnet-evm version run: | source ./scripts/versions.sh @@ -38,9 +41,6 @@ jobs: repository: ava-labs/subnet-evm ref: ${{ env.SUBNET_EVM_VERSION }} - - name: Install AvalancheGo Release - run: BASEDIR=/tmp/e2e-test AVALANCHEGO_BUILD_PATH=/tmp/e2e-test/avalanchego ./scripts/install_avalanchego_release.sh - - name: Build Subnet-EVM Plugin Binary run: ./scripts/build.sh /tmp/e2e-test/avalanchego/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy From ac1e47cab3366c06951d4a8765c3353c289fd162 Mon Sep 17 00:00:00 2001 From: Ian Suvak Date: Wed, 20 Nov 2024 09:32:45 -0500 Subject: [PATCH 4/6] simplify docs --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 79e0708f..23a1924a 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,16 @@ Applications in this repository depend on the following upstream repositories, b > [!NOTE] > We require any commits referenced in our `main` branch to be present in the default branches of the repositories above, but during active development it might be useful to work against changes in progress that are still on feature branches. -When developing such features that require updates to one or more of the above, care must be taken to understand where the relevant code comes from. The binaries of applications built in this repo are built against versions referenced in the `go.mod` file. The E2E tests run against a simulated network running locally that is started by calling a separately compiled `avalanchego` binary as well as its plugins. These are compiled based on the values of `AVALANCHEGO_VERSION` in the local checkout of `subnet-evm` when running the tests locally and directly in this repository's `./scripts/versions.sh` when running E2E tests remotely through GitHub actions. +When developing such features that require updates to one or more of the above, care must be taken to understand where the relevant code comes from. The binaries of applications built in this repo are built against versions referenced in the `go.mod` file. The E2E tests run against a simulated network running locally that is started by calling a separately compiled `avalanchego` binary as well as its plugins. These are compiled based on the values of `AVALANCHEGO_VERSION` in this repository's `./scripts/versions.sh`. `avalanchego` and `coreth` have a direct circular dependency and this repository is only indirectly dependent on `coreth` but directly dependent on `avalanchego`. Therefore if any updates are required from the `coreth` side, a corresponding `avalanchego` commit referencing those changes is required. On the other hand `subnet-evm` just depends directly on `avalanchego`. +> [!NOTE] +> It's possible that a `subnet-evm` version is compatible with multiple different `avalanchego` versions and not limited to the one listed in `subnet-evm`'s `/scripts/versions.sh` + ### Example dependency update flow -The most complicated example case that can arise above is that a feature depends on a new change in `coreth`. And the steps below outline the necessary commits: +The most complicated example case that can arise above is that a feature depends on a new change in `coreth` and all versions are mutually incompatible. The steps below outline the necessary commits: 1. If an `avalanchego` commit referencing this change in its `go.mod` file doesn't exist yet then it needs to be added. 2. Add a commit in `subnet-evm` that references the `avalanchego` commit from above in both its `go.mod` file as well as its `scripts/versions.sh` file. @@ -34,13 +37,8 @@ The most complicated example case that can arise above is that a feature depends Publishing all of the commits mentioned above to GitHub branches will enable running E2E tests through the CI. -Running the tests locally doesn't require publishing the `subnet-evm` commit since `./scripts/e2e_test.sh` takes a flag specifying local checkout of `subnet-evm` repository. - -> [!NOTE] -> Locally running E2E tests using local checkout of `subnet-evm` will install `avalanchego` version specified by the `AVALANCHEGO_VERSION` in that working tree's `./scripts/versions.sh`. - > [!TIP] -> Using the local checkout it's possible to run tests against a `tmpnet` consisting of nodes using a different version of `avalanchego` than the application being tested which might be helpful when troubleshooting. +> Running the tests locally doesn't require publishing the `subnet-evm` commit since `./scripts/e2e_test.sh` takes a flag specifying local checkout of `subnet-evm` repository. ## Releases GoReleaser is used to build the binaries of the services and also Docker images with those binaries. The monorepo feature of GoReleaser Pro is used to automate the release flow in response to tags like `signature-aggregator/v0.0.0`. The release actions in .github/workflows automate this, but the release build can also be run locally. Be sure to install the "pro" distribution of the command line utility, so that it can parse the `monorepo` key. For example: From 3efcd9d3511361d28e174305b33ae6f8472f870f Mon Sep 17 00:00:00 2001 From: Ian Suvak Date: Wed, 20 Nov 2024 10:31:36 -0500 Subject: [PATCH 5/6] Update README.md Co-authored-by: bernard-avalabs <53795885+bernard-avalabs@users.noreply.github.com> Signed-off-by: Ian Suvak --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23a1924a..e6480e0c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The most complicated example case that can arise above is that a feature depends Publishing all of the commits mentioned above to GitHub branches will enable running E2E tests through the CI. > [!TIP] -> Running the tests locally doesn't require publishing the `subnet-evm` commit since `./scripts/e2e_test.sh` takes a flag specifying local checkout of `subnet-evm` repository. +> Running the tests locally doesn't require publishing the `subnet-evm` commit since `./scripts/e2e_test.sh` takes a flag specifying a local checkout of the `subnet-evm` repository. ## Releases GoReleaser is used to build the binaries of the services and also Docker images with those binaries. The monorepo feature of GoReleaser Pro is used to automate the release flow in response to tags like `signature-aggregator/v0.0.0`. The release actions in .github/workflows automate this, but the release build can also be run locally. Be sure to install the "pro" distribution of the command line utility, so that it can parse the `monorepo` key. For example: From 4d4ef13ab52ea80e45efef9aec4cb7038153896a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:25:51 +0000 Subject: [PATCH 6/6] Bump github.com/onsi/ginkgo/v2 from 2.21.0 to 2.22.0 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.21.0 to 2.22.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.21.0...v2.22.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 14f16363..18897af6 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/kms v1.37.6 github.com/ethereum/go-ethereum v1.13.14 github.com/hashicorp/golang-lru/v2 v2.0.7 - github.com/onsi/ginkgo/v2 v2.21.0 + github.com/onsi/ginkgo/v2 v2.22.0 github.com/onsi/gomega v1.35.1 github.com/pingcap/errors v0.11.4 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index d714b62d..71691993 100644 --- a/go.sum +++ b/go.sum @@ -523,8 +523,8 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= -github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= +github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= +github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=