2019-09-01 15:02:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Helper script for running a lighthouse node and connecting to the beacon node
|
|
|
|
# that's set up by start.sh
|
|
|
|
|
|
|
|
# https://github.com/sigp/lighthouse/blob/master/docs/interop.md
|
|
|
|
|
2019-09-08 00:16:46 +00:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
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-01 15:02:49 +00:00
|
|
|
cargo_path=$(which cargo)
|
|
|
|
[[ -x "$cargo_path" ]] || { echo "install rust first (https://rust-lang.org)"; exit 1; }
|
|
|
|
|
2019-09-08 00:16:46 +00:00
|
|
|
LIGHTHOUSE=${LIGHTHOSE_PATH:-"lighthouse"}
|
|
|
|
|
|
|
|
[[ -d "$LIGHTHOUSE" ]] || {
|
|
|
|
git clone https://github.com/sigp/lighthouse.git "$LIGHTHOUSE"
|
|
|
|
pushd "$LIGHTHOUSE"
|
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
|
|
|
}
|
|
|
|
|
|
|
|
# Fetch genesis time, as set up by start.sh
|
2019-09-08 00:16:46 +00:00
|
|
|
if command -v jq; then
|
|
|
|
genesis_time=$(jq '.genesis_time' data/state_snapshot.json)
|
|
|
|
else
|
|
|
|
genesis_time=$(grep -oP '(?<=genesis_time": )\w+(?=,)' data/state_snapshot.json)
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Genesis time was $genesis_time
|
2019-09-01 15:02:49 +00:00
|
|
|
|
2019-09-08 00:16:46 +00:00
|
|
|
cd "$LIGHTHOUSE"
|
2019-09-01 15:02:49 +00:00
|
|
|
cargo build
|
|
|
|
|
|
|
|
cd target/debug
|
|
|
|
|
|
|
|
#$export RUST_LOG=libp2p=trace,multistream=trace,gossipsub=trace
|
|
|
|
|
|
|
|
# fresh start!
|
|
|
|
rm -rf ~/.lighthouse
|
|
|
|
|
2019-09-02 10:31:14 +00:00
|
|
|
./beacon_node --libp2p-addresses="/ip4/127.0.0.1/tcp/50000" testnet --spec minimal quick 16 $genesis_time
|