From 1ced32231079c46344f4a490c5cb3de053acfeca Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 22 Jun 2022 10:42:41 -0700 Subject: [PATCH] feat: support overriding actor versions per-network --- build/actors/README.md | 8 ++++++++ build/actors/pack.sh | 28 ++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/build/actors/README.md b/build/actors/README.md index 097959f4f..981ad726a 100644 --- a/build/actors/README.md +++ b/build/actors/README.md @@ -16,3 +16,11 @@ This will: 1. Download the actors bundles and pack them into the appropriate tarfile (`$VERSION.tar.zst`). 2. Run `make bundle-gen` in the top-level directory to regenerate the bundle metadata file for _all_ network versions (all `*.tar.zst` files in this directory). + +## Overriding + +To build a bundle, but specify a different release/tag for a specific network, append `$network=$alternative_release` on the command line. For example: + +```bash +./pack.sh v8 dev/20220602 mainnet=v8.0.0 calibrationnet=v8.0.0-rc.1 +``` diff --git a/build/actors/pack.sh b/build/actors/pack.sh index acde5d769..c2060e67c 100755 --- a/build/actors/pack.sh +++ b/build/actors/pack.sh @@ -1,25 +1,42 @@ #!/bin/bash +NETWORKS=(devnet mainnet caterpillarnet butterflynet testing testing-fake-proofs calibrationnet) + set -e -if [[ $# -ne 2 ]]; then - echo "expected two arguments, an actors version (e.g., v8) and an actors release" +if [[ $# -lt 2 ]]; then + echo "Usage: $0 VERSION RELEASE [NETWORK=RELEASE_OVERRIDE]..." >&2 + echo "expected at least two arguments, an actors version (e.g., v8), an actors release, and any number of release overrides." >&2 exit 1 fi VERSION="$1" # actors version RELEASE="$2" # actors release name -NETWORKS=(devnet mainnet caterpillarnet butterflynet testing testing-fake-proofs calibrationnet) +RELEASE_OVERRIDES=("${@:3}") -echo "Downloading bundles for actors version ${VERSION}, release ${RELEASE}" +echo "Downloading bundles for actors version ${VERSION} release ${RELEASE}" +echo "With release overrides ${RELEASE_OVERRIDES[*]}" TARGET_FILE="$(pwd)/${VERSION}.tar.zst" WORKDIR=$(mktemp -d -t "actor-bundles-${VERSION}.XXXXXXXXXX") trap 'rm -rf -- "$WORKDIR"' EXIT +encode_release() { + jq -rn --arg release "$1" '$release | @uri' +} + pushd "${WORKDIR}" -encoded_release="$(jq -rn --arg release "$RELEASE" '$release | @uri')" for network in "${NETWORKS[@]}"; do + release="$RELEASE" + # Ideally, we'd use an associative array (map). But that's not supported on macos. + for override in "${RELEASE_OVERRIDES[@]}"; do + if [[ "${network}" = "${override%%=*}" ]]; then + release="${override#*=}" + break + fi + done + encoded_release="$(encode_release "$release")" + echo "Downloading $release for network $network." wget "https://github.com/filecoin-project/builtin-actors/releases/download/${encoded_release}/builtin-actors-${network}"{.car,.sha256} done @@ -27,7 +44,6 @@ echo "Checking the checksums..." sha256sum -c -- *.sha256 - echo "Packing..." rm -f -- "$TARGET_FILE"