|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +WALLET_DIR="/prysm-wallet" |
| 4 | + |
| 5 | +# Cleanup wallet directories if already exists. |
| 6 | +rm -rf $WALLET_DIR |
| 7 | +mkdir $WALLET_DIR |
| 8 | + |
| 9 | +# Refer: https://docs.prylabs.network/docs/install/install-with-script#step-5-run-a-validator-using-prysm |
| 10 | +# Running a prysm VC involves two steps which need to run in order: |
| 11 | +# 1. Import validator keys in a prysm wallet account. |
| 12 | +# 2. Run the validator client. |
| 13 | +WALLET_PASSWORD="prysm-validator-secret" |
| 14 | +echo $WALLET_PASSWORD > /wallet-password.txt |
| 15 | +/app/cmd/validator/validator wallet create --accept-terms-of-use --wallet-password-file=wallet-password.txt --keymanager-kind=direct --wallet-dir="$WALLET_DIR" |
| 16 | + |
| 17 | +tmpkeys="/home/validator_keys/tmpkeys" |
| 18 | +mkdir -p ${tmpkeys} |
| 19 | + |
| 20 | +for f in /home/charon/validator_keys/keystore-*.json; do |
| 21 | + echo "Importing key ${f}" |
| 22 | + |
| 23 | + # Copy keystore file to tmpkeys/ directory. |
| 24 | + cp "${f}" "${tmpkeys}" |
| 25 | + |
| 26 | + # Import keystore with password. |
| 27 | + /app/cmd/validator/validator accounts import \ |
| 28 | + --accept-terms-of-use=true \ |
| 29 | + --wallet-dir="$WALLET_DIR" \ |
| 30 | + --keys-dir="${tmpkeys}" \ |
| 31 | + --account-password-file="${f//json/txt}" \ |
| 32 | + --wallet-password-file=wallet-password.txt |
| 33 | + |
| 34 | + # Delete tmpkeys/keystore-*.json file that was copied before. |
| 35 | + filename="$(basename ${f})" |
| 36 | + rm "${tmpkeys}/${filename}" |
| 37 | +done |
| 38 | + |
| 39 | +# Delete the tmpkeys/ directory since it's no longer needed. |
| 40 | +rm -r ${tmpkeys} |
| 41 | + |
| 42 | +echo "Imported all keys" |
| 43 | + |
| 44 | +# Now run prysm VC |
| 45 | +/app/cmd/validator/validator --wallet-dir="$WALLET_DIR" \ |
| 46 | + --accept-terms-of-use=true \ |
| 47 | + --datadir="/data/vc" \ |
| 48 | + --wallet-password-file="/wallet-password.txt" \ |
| 49 | + --enable-beacon-rest-api \ |
| 50 | + --beacon-rest-api-provider="${BEACON_NODE_ADDRESS}" \ |
| 51 | + --beacon-rpc-provider="${BEACON_NODE_ADDRESS}" \ |
| 52 | + --beacon-rpc-gateway-provider="${BEACON_NODE_ADDRESS}" \ |
| 53 | + --"${NETWORK}" \ |
| 54 | + --distributed |
0 commit comments