|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eo pipefail |
| 4 | + |
| 5 | +([ -z ${CONFIG_JSON_GZ_URL+x} ] || [ -z ${NETWORK_NAME+x} ] || [ -z ${MINA_DEB_CODENAME+x} ]) && echo "required env vars were not provided" && exit 1 |
| 6 | + |
| 7 | +# Set the DUNE_PROFILE from the NETWORK_NAME. For now, these are 1-1, but in the future, this may need to be a case statement |
| 8 | +case "${NETWORK_NAME}" in |
| 9 | + mainnet) |
| 10 | + DUNE_PROFILE=mainnet |
| 11 | + ;; |
| 12 | + devnet|berkeley) |
| 13 | + DUNE_PROFILE=devnet |
| 14 | + ;; |
| 15 | + *) |
| 16 | + echo "unrecognized network name: ${NETWORK_NAME}" |
| 17 | + exit 1 |
| 18 | + ;; |
| 19 | +esac |
| 20 | +export DUNE_PROFILE |
| 21 | + |
| 22 | +# Set the base network config for ./scripts/hardfork/create_runtime_config.sh |
| 23 | +export FORKING_FROM_CONFIG_JSON="genesis_ledgers/${NETWORK_NAME}.json" |
| 24 | +[ ! -f "${FORKING_FROM_CONFIG_JSON}" ] && echo "${NETWORK_NAME} is not a known network name; check for existing network configs in 'genesis_ledgers/'" && exit 1 |
| 25 | + |
| 26 | +source ~/.profile |
| 27 | + |
| 28 | +MINA_COMMIT_SHA1=$(git rev-parse HEAD) |
| 29 | + |
| 30 | +echo "--- Download and extract previous network config" |
| 31 | +curl -o config.json.gz $CONFIG_JSON_GZ_URL |
| 32 | +gunzip config.json.gz |
| 33 | + |
| 34 | +echo "--- Migrate accounts to new network format" |
| 35 | +# TODO: At this stage, we need to migrate the json accounts into the new network's format. |
| 36 | +# For now, this is hard-coded to the mainnet -> berkeley migration, but we need to select |
| 37 | +# a migration to perform in the future. |
| 38 | +# NB: we use sed here instead of jq, because jq is extremely slow at processing this file |
| 39 | +sed -i -e 's/"set_verification_key": "signature"/"set_verification_key": {"auth": "signature", "txn_version": "2"}/' config.json |
| 40 | + |
| 41 | +case "${NETWORK_NAME}" in |
| 42 | + mainnet) |
| 43 | + MINA_BUILD_MAINNET=true ./buildkite/scripts/build-artifact.sh |
| 44 | + ;; |
| 45 | + *) |
| 46 | + ./buildkite/scripts/build-artifact.sh |
| 47 | + ;; |
| 48 | +esac |
| 49 | + |
| 50 | +echo "--- Generate hardfork ledger tarballs" |
| 51 | +mkdir hardfork_ledgers |
| 52 | +_build/default/src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe --config-file config.json --genesis-dir hardfork_ledgers/ --hash-output-file hardfork_ledger_hashes.json | tee runtime_genesis_ledger.log | _build/default/src/app/logproc/logproc.exe |
| 53 | + |
| 54 | +echo "--- Create hardfork config" |
| 55 | +FORK_CONFIG_JSON=config.json LEDGER_HASHES_JSON=hardfork_ledger_hashes.json scripts/hardfork/create_runtime_config.sh > new_config.json |
| 56 | + |
| 57 | +existing_files=$(aws s3 ls s3://snark-keys.o1test.net/ | awk '{print $4}') |
| 58 | +for file in hardfork_ledgers/*; do |
| 59 | + filename=$(basename "$file") |
| 60 | + |
| 61 | + if echo "$existing_files" | grep -q "$filename"; then |
| 62 | + echo "Info: $filename already exists in the bucket, packaging it instead." |
| 63 | + oldhash=$(openssl dgst -r -sha3-256 "$file" | awk '{print $1}') |
| 64 | + aws s3 cp "s3://snark-keys.o1test.net/$filename" "$file" |
| 65 | + newhash=$(openssl dgst -r -sha3-256 "$file" | awk '{print $1}') |
| 66 | + sed -i 's/$oldhash/$newhash/g' new_config.json |
| 67 | + else |
| 68 | + aws s3 cp --acl public-read "$file" s3://snark-keys.o1test.net/ |
| 69 | + fi |
| 70 | +done |
| 71 | + |
| 72 | +echo "--- Build hardfork package for Debian ${MINA_DEB_CODENAME}" |
| 73 | +RUNTIME_CONFIG_JSON=new_config.json LEDGER_TARBALLS="$(echo hardfork_ledgers/*.tar.gz)" ./scripts/create_hardfork_deb.sh |
| 74 | +mkdir -p /tmp/artifacts |
| 75 | +cp _build/mina*.deb /tmp/artifacts/. |
| 76 | + |
| 77 | +echo "--- Upload debs to amazon s3 repo" |
| 78 | +make publish_debs |
| 79 | + |
| 80 | +echo "--- Git diff after build is complete:" |
| 81 | +git diff --exit-code -- . |
0 commit comments