Skip to content

Commit

Permalink
feat: support overriding actor versions per-network
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jun 22, 2022
1 parent f44ad26 commit 1ced322
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
8 changes: 8 additions & 0 deletions build/actors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
28 changes: 22 additions & 6 deletions build/actors/pack.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
#!/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

echo "Checking the checksums..."

sha256sum -c -- *.sha256


echo "Packing..."

rm -f -- "$TARGET_FILE"
Expand Down

0 comments on commit 1ced322

Please sign in to comment.