2020-04-27 19:52:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
session="lotus-interop"
|
|
|
|
wdaemon="daemon"
|
|
|
|
wminer="miner"
|
|
|
|
wsetup="setup"
|
|
|
|
wpledging="pledging"
|
|
|
|
wcli="cli"
|
2020-05-07 05:19:09 +00:00
|
|
|
faucet="https://t01000.miner.interopnet.kittyhawk.wtf"
|
2020-04-27 19:52:55 +00:00
|
|
|
|
|
|
|
PLEDGE_COUNT="${1:-20}"
|
|
|
|
BRANCH="interopnet"
|
|
|
|
BASEDIR=$(mktemp -d -t "lotus-interopnet.XXXX")
|
|
|
|
|
|
|
|
git clone --branch "$BRANCH" https://github.com/filecoin-project/lotus.git "${BASEDIR}/build"
|
|
|
|
|
|
|
|
mkdir -p "${BASEDIR}/scripts"
|
|
|
|
mkdir -p "${BASEDIR}/bin"
|
|
|
|
|
|
|
|
cat > "${BASEDIR}/scripts/build.bash" <<EOF
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -x
|
|
|
|
|
|
|
|
SCRIPTDIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
pushd \$SCRIPTDIR/../build
|
|
|
|
|
|
|
|
pwd
|
2020-07-08 10:38:59 +00:00
|
|
|
env RUSTFLAGS="-C target-cpu=native -g" FFI_BUILD_FROM_SOURCE=1 make clean deps lotus lotus-miner lotus-shed
|
|
|
|
cp lotus lotus-miner lotus-shed ../bin/
|
2020-04-27 19:52:55 +00:00
|
|
|
|
|
|
|
popd
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "${BASEDIR}/scripts/env.fish" <<EOF
|
|
|
|
set -x PATH ${BASEDIR}/bin \$PATH
|
|
|
|
set -x LOTUS_PATH ${BASEDIR}/.lotus
|
2020-07-08 10:53:04 +00:00
|
|
|
set -x LOTUS_MINER_PATH ${BASEDIR}/.lotusminer
|
2020-04-27 19:52:55 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "${BASEDIR}/scripts/env.bash" <<EOF
|
|
|
|
export PATH=${BASEDIR}/bin:\$PATH
|
|
|
|
export LOTUS_PATH=${BASEDIR}/.lotus
|
2020-07-08 10:53:04 +00:00
|
|
|
export LOTUS_MINER_PATH=${BASEDIR}/.lotusminer
|
2020-04-27 19:52:55 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "${BASEDIR}/scripts/create_miner.bash" <<EOF
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -x
|
|
|
|
|
|
|
|
owner=\$(lotus wallet new bls)
|
|
|
|
result=\$(curl -D - -XPOST -F "sectorSize=536870912" -F "address=\$owner" $faucet/mkminer | grep Location)
|
|
|
|
query_string=\$(grep -o "\bf=.*\b" <<<\$(echo \$result))
|
|
|
|
|
|
|
|
declare -A param
|
|
|
|
while IFS='=' read -r -d '&' key value && [[ -n "\$key" ]]; do
|
|
|
|
param["\$key"]=\$value
|
|
|
|
done <<<"\${query_string}&"
|
|
|
|
|
|
|
|
lotus state wait-msg "\${param[f]}"
|
|
|
|
|
|
|
|
maddr=\$(curl "$faucet/msgwaitaddr?cid=\${param[f]}" | jq -r '.addr')
|
|
|
|
|
2020-07-08 10:38:59 +00:00
|
|
|
lotus-miner init --actor=\$maddr --owner=\$owner
|
2020-04-27 19:52:55 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "${BASEDIR}/scripts/pledge_sectors.bash" <<EOF
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
2020-07-08 10:53:04 +00:00
|
|
|
while [ ! -d ${BASEDIR}/.lotusminer ]; do
|
2020-04-27 19:52:55 +00:00
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
2020-07-08 10:53:04 +00:00
|
|
|
while [ ! -f ${BASEDIR}/.lotusminer/api ]; do
|
2020-04-27 19:52:55 +00:00
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
sleep 30
|
|
|
|
|
2020-07-08 10:38:59 +00:00
|
|
|
sector=\$(lotus-miner sectors list | tail -n1 | awk '{print \$1}' | tr -d ':')
|
2020-04-27 19:52:55 +00:00
|
|
|
current="\$sector"
|
|
|
|
|
|
|
|
while true; do
|
2020-07-08 10:38:59 +00:00
|
|
|
if (( \$(lotus-miner sectors list | wc -l) > ${PLEDGE_COUNT} )); then
|
2020-04-27 19:52:55 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
while true; do
|
2020-07-08 10:38:59 +00:00
|
|
|
state=\$(lotus-miner sectors list | tail -n1 | awk '{print \$2}')
|
2020-04-27 19:52:55 +00:00
|
|
|
|
|
|
|
if [ -z "\$state" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
case \$state in
|
|
|
|
PreCommit1 | PreCommit2 | Packing | Unsealed | PreCommitting | Committing | CommitWait | FinalizeSector ) sleep 30 ;;
|
|
|
|
WaitSeed | Proving ) break ;;
|
|
|
|
* ) echo "Unknown Sector State: \$state"
|
2020-07-08 10:38:59 +00:00
|
|
|
lotus-miner sectors status --log \$current
|
2020-04-27 19:52:55 +00:00
|
|
|
break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2020-07-08 10:38:59 +00:00
|
|
|
lotus-miner sectors pledge
|
2020-04-27 19:52:55 +00:00
|
|
|
|
|
|
|
while [ "\$current" == "\$sector" ]; do
|
2020-07-08 10:38:59 +00:00
|
|
|
sector=\$(lotus-miner sectors list | tail -n1 | awk '{print \$1}' | tr -d ':')
|
2020-04-27 19:52:55 +00:00
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
current="\$sector"
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > "${BASEDIR}/scripts/monitor.bash" <<EOF
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
clear
|
|
|
|
lotus sync status
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
2020-07-11 08:55:13 +00:00
|
|
|
echo Miner Info
|
2020-07-08 10:38:59 +00:00
|
|
|
lotus-miner info
|
2020-04-27 19:52:55 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo Sector List
|
2020-07-08 10:38:59 +00:00
|
|
|
lotus-miner sectors list | tail -n4
|
2020-04-27 19:52:55 +00:00
|
|
|
|
|
|
|
sleep 25
|
|
|
|
|
|
|
|
lotus-shed noncefix --addr \$(lotus wallet list) --auto
|
|
|
|
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x "${BASEDIR}/scripts/build.bash"
|
|
|
|
chmod +x "${BASEDIR}/scripts/create_miner.bash"
|
|
|
|
chmod +x "${BASEDIR}/scripts/pledge_sectors.bash"
|
|
|
|
chmod +x "${BASEDIR}/scripts/monitor.bash"
|
|
|
|
|
|
|
|
bash "${BASEDIR}/scripts/build.bash"
|
|
|
|
|
|
|
|
tmux new-session -d -s $session -n $wsetup
|
|
|
|
|
|
|
|
tmux set-environment -t $session BASEDIR "$BASEDIR"
|
|
|
|
|
|
|
|
tmux new-window -t $session -n $wcli
|
|
|
|
tmux new-window -t $session -n $wdaemon
|
|
|
|
tmux new-window -t $session -n $wminer
|
|
|
|
tmux new-window -t $session -n $wpledging
|
|
|
|
|
|
|
|
tmux kill-window -t $session:$wsetup
|
|
|
|
|
|
|
|
case $(basename $SHELL) in
|
|
|
|
fish ) shell=fish ;;
|
|
|
|
* ) shell=bash ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
tmux send-keys -t $session:$wdaemon "source ${BASEDIR}/scripts/env.$shell" C-m
|
|
|
|
tmux send-keys -t $session:$wminer "source ${BASEDIR}/scripts/env.$shell" C-m
|
|
|
|
tmux send-keys -t $session:$wcli "source ${BASEDIR}/scripts/env.$shell" C-m
|
|
|
|
tmux send-keys -t $session:$wpledging "source ${BASEDIR}/scripts/env.$shell" C-m
|
|
|
|
|
|
|
|
tmux send-keys -t $session:$wdaemon "lotus daemon --api 48010 daemon 2>&1 | tee -a ${BASEDIR}/daemon.log" C-m
|
|
|
|
|
|
|
|
sleep 30
|
|
|
|
|
|
|
|
tmux send-keys -t $session:$wminer "${BASEDIR}/scripts/create_miner.bash" C-m
|
2020-07-08 10:38:59 +00:00
|
|
|
tmux send-keys -t $session:$wminer "lotus-miner run --api 48020 2>&1 | tee -a ${BASEDIR}/miner.log" C-m
|
2020-04-27 19:52:55 +00:00
|
|
|
tmux send-keys -t $session:$wcli "${BASEDIR}/scripts/monitor.bash" C-m
|
|
|
|
tmux send-keys -t $session:$wpleding "${BASEDIR}/scripts/pledge_sectors.bash" C-m
|
|
|
|
|
|
|
|
tmux select-window -t $session:$wcli
|
|
|
|
|
|
|
|
tmux attach-session -t $session
|
|
|
|
|