2019-09-01 15:02:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# https://github.com/sigp/lighthouse/blob/master/docs/interop.md
|
|
|
|
|
2019-09-08 00:16:46 +00:00
|
|
|
set -eu
|
|
|
|
|
2019-09-27 16:17:03 +00:00
|
|
|
VALIDATORS_START=${1:-0}
|
|
|
|
VALIDATORS_NUM=${2:-5}
|
2019-10-08 17:03:00 +00:00
|
|
|
VALIDATORS_TOTAL=${3:-30}
|
2019-09-27 16:17:03 +00:00
|
|
|
|
|
|
|
SRCDIR=${LIGHTHOUSE_PATH:-"lighthouse"}
|
|
|
|
|
2019-09-08 00:16:46 +00:00
|
|
|
echo Locating protoc...
|
|
|
|
if ! command -v protoc; then
|
|
|
|
MSG="protoc (the Google Protobuf compiler) is missing. Please install it manually"
|
|
|
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
|
|
|
MSG+=" with sudo apt install protobuf-compiler"
|
|
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
MSG+=" with 'brew install protobuf'"
|
|
|
|
elif [[ "$OSTYPE" == "cygwin" ]]; then
|
|
|
|
# POSIX compatibility layer and Linux environment emulation for Windows
|
|
|
|
MSG+=""
|
|
|
|
elif [[ "$OSTYPE" == "msys" ]]; then
|
|
|
|
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
|
|
|
|
MSG+=""
|
|
|
|
elif [[ "$OSTYPE" == "win32" ]]; then
|
|
|
|
# I'm not sure this can happen.
|
|
|
|
MSG+=""
|
|
|
|
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
|
|
|
# ...
|
|
|
|
MSG+=""
|
|
|
|
else
|
|
|
|
# Unknown.
|
|
|
|
MSG+=""
|
|
|
|
fi
|
|
|
|
echo $MSG
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-09-27 16:17:03 +00:00
|
|
|
command -v cargo > /dev/null || { echo "install rust first (https://rust-lang.org)"; exit 1; }
|
2019-09-08 00:16:46 +00:00
|
|
|
|
2019-09-27 16:17:03 +00:00
|
|
|
[[ -d "$SRCDIR" ]] || {
|
|
|
|
git clone https://github.com/sigp/lighthouse.git "$SRCDIR"
|
|
|
|
pushd "$SRCDIR"
|
2019-09-01 15:02:49 +00:00
|
|
|
git checkout interop # temporary interop branch - will get merged soon I expect!
|
|
|
|
cargo update
|
2019-09-08 00:16:46 +00:00
|
|
|
popd
|
2019-09-01 15:02:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 16:17:03 +00:00
|
|
|
pushd "$SRCDIR"
|
2019-09-10 21:55:58 +00:00
|
|
|
cargo build --release
|
|
|
|
popd
|
|
|
|
|
2019-09-01 15:02:49 +00:00
|
|
|
# Fetch genesis time, as set up by start.sh
|
2019-09-27 16:17:03 +00:00
|
|
|
if command -v jq > /dev/null; then
|
|
|
|
GENESIS_TIME=$(jq '.genesis_time' data/state_snapshot.json)
|
2019-09-08 00:16:46 +00:00
|
|
|
else
|
2019-09-27 16:17:03 +00:00
|
|
|
GENESIS_TIME=$(grep -oP '(?<=genesis_time": )\w+(?=,)' data/state_snapshot.json)
|
2019-09-08 00:16:46 +00:00
|
|
|
fi
|
|
|
|
|
2019-09-27 16:17:03 +00:00
|
|
|
echo Genesis time was $GENESIS_TIME
|
|
|
|
|
|
|
|
set -x
|
|
|
|
trap 'kill -9 -- -$$' SIGINT EXIT SIGTERM
|
2019-09-01 15:02:49 +00:00
|
|
|
|
2019-09-27 16:17:03 +00:00
|
|
|
cd "$SRCDIR/target/release"
|
2019-09-01 15:02:49 +00:00
|
|
|
|
|
|
|
#$export RUST_LOG=libp2p=trace,multistream=trace,gossipsub=trace
|
|
|
|
|
|
|
|
# fresh start!
|
|
|
|
rm -rf ~/.lighthouse
|
|
|
|
|
2019-09-27 17:42:53 +00:00
|
|
|
./beacon_node --libp2p-addresses="/ip4/127.0.0.1/tcp/50000" testnet --spec minimal quick $VALIDATORS_TOTAL $GENESIS_TIME &
|
2019-09-27 16:17:03 +00:00
|
|
|
|
|
|
|
./validator_client testnet -b insecure $VALIDATORS_START $VALIDATORS_NUM
|