Network init script
This commit is contained in:
parent
5b90121577
commit
75e823d581
@ -1,109 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
############
|
||||
## Settings
|
||||
GENESIS_HOST=root@147.75.80.29
|
||||
BOOTSTRAPPERS=( root@147.75.80.17 )
|
||||
|
||||
############
|
||||
|
||||
read -p "You are about to deploy new DevNet, killing bootstrap nodes. Proceed? (y/n)? " r
|
||||
case "$r" in
|
||||
y|Y ) echo "Proceding";;
|
||||
n|N ) exit 0;;
|
||||
* ) exit 1;;
|
||||
esac
|
||||
|
||||
log() {
|
||||
echo -e "\e[33m$1\e[39m"
|
||||
}
|
||||
|
||||
rm -f build/bootstrap/*.pi
|
||||
|
||||
log '> Generating genesis'
|
||||
|
||||
make
|
||||
|
||||
GENPATH=$(mktemp -d)
|
||||
|
||||
log 'staring temp daemon'
|
||||
|
||||
./lotus --repo="${GENPATH}" daemon --lotus-make-random-genesis="${GENPATH}/devnet.car" &
|
||||
GDPID=$!
|
||||
|
||||
sleep 3
|
||||
|
||||
log 'Extracting genesis miner prvate key'
|
||||
|
||||
ADDR=$(./lotus --repo="${GENPATH}" wallet list)
|
||||
./lotus --repo="${GENPATH}" wallet export "$ADDR" > "${GENPATH}/wallet.key"
|
||||
|
||||
kill "$GDPID"
|
||||
|
||||
wait
|
||||
|
||||
log '> Creating genesis binary'
|
||||
cp "${GENPATH}/devnet.car" build/genesis/devnet.car
|
||||
rm -f build/bootstrap/*.pi
|
||||
|
||||
make
|
||||
|
||||
log '> Deploying and starting genesis miner'
|
||||
|
||||
ssh $GENESIS_HOST 'systemctl stop lotus-daemon' &
|
||||
ssh $GENESIS_HOST 'systemctl stop lotus-storage-miner' &
|
||||
|
||||
wait
|
||||
|
||||
ssh $GENESIS_HOST 'rm -rf .lotus' &
|
||||
ssh $GENESIS_HOST 'rm -rf .lotusstorage' &
|
||||
|
||||
scp -C lotus "${GENESIS_HOST}":/usr/local/bin/lotus &
|
||||
scp -C lotus-storage-miner "${GENESIS_HOST}":/usr/local/bin/lotus-storage-miner &
|
||||
|
||||
wait
|
||||
|
||||
log 'Initializing genesis miner repo'
|
||||
|
||||
ssh $GENESIS_HOST 'systemctl start lotus-daemon'
|
||||
|
||||
scp scripts/bootstrap.toml "${GENESIS_HOST}:.lotus/config.toml" &
|
||||
ssh < "${GENPATH}/wallet.key" $GENESIS_HOST '/usr/local/bin/lotus wallet import' &
|
||||
wait
|
||||
|
||||
ssh $GENESIS_HOST "echo -e '[Metrics]\nNickname=\"Boot-genesis\"' >> .lotus/config.toml"
|
||||
|
||||
ssh $GENESIS_HOST 'systemctl restart lotus-daemon'
|
||||
|
||||
log 'Starting genesis mining'
|
||||
|
||||
ssh $GENESIS_HOST '/usr/local/bin/lotus-storage-miner init --genesis-miner --actor=t0101'
|
||||
ssh $GENESIS_HOST 'systemctl start lotus-storage-miner'
|
||||
|
||||
|
||||
log 'Getting genesis addr info'
|
||||
|
||||
ssh $GENESIS_HOST 'lotus net listen' | grep -v '/10' | grep -v '/127' > build/bootstrap/root.pi
|
||||
|
||||
log '> Creating bootstrap binaries'
|
||||
make
|
||||
|
||||
|
||||
for host in "${BOOTSTRAPPERS[@]}"
|
||||
do
|
||||
./scripts/deploy-bootstrapper.sh $host
|
||||
done
|
||||
|
||||
log 'Updating genesis node with bootstrapable binaries'
|
||||
|
||||
ssh "$GENESIS_HOST" 'systemctl stop lotus-daemon' &
|
||||
ssh "$GENESIS_HOST" 'systemctl stop lotus-storage-miner' &
|
||||
wait
|
||||
|
||||
scp -C lotus "${GENESIS_HOST}":/usr/local/bin/lotus &
|
||||
scp -C lotus-storage-miner "${GENESIS_HOST}":/usr/local/bin/lotus-storage-miner &
|
||||
wait
|
||||
|
||||
ssh "$GENESIS_HOST" 'systemctl start lotus-daemon' &
|
||||
ssh "$GENESIS_HOST" 'systemctl start lotus-storage-miner' &
|
||||
wait
|
115
scripts/init-network.sh
Executable file
115
scripts/init-network.sh
Executable file
@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xeo
|
||||
|
||||
NUM_SECTORS=2
|
||||
SECTOR_SIZE=1024
|
||||
|
||||
|
||||
sdt0111=$(mktemp -d)
|
||||
sdt0222=$(mktemp -d)
|
||||
sdt0333=$(mktemp -d)
|
||||
|
||||
staging=$(mktemp -d)
|
||||
|
||||
make debug
|
||||
|
||||
./lotus-seed --sectorbuilder-dir="${sdt0111}" pre-seal --miner-addr=t0111 --sector-offset=0 --sector-size=${SECTOR_SIZE} --num-sectors=${NUM_SECTORS} &
|
||||
./lotus-seed --sectorbuilder-dir="${sdt0222}" pre-seal --miner-addr=t0222 --sector-offset=0 --sector-size=${SECTOR_SIZE} --num-sectors=${NUM_SECTORS} &
|
||||
./lotus-seed --sectorbuilder-dir="${sdt0333}" pre-seal --miner-addr=t0333 --sector-offset=0 --sector-size=${SECTOR_SIZE} --num-sectors=${NUM_SECTORS} &
|
||||
|
||||
wait
|
||||
|
||||
./lotus-seed aggregate-manifests "${sdt0111}/pre-seal-t0111.json" "${sdt0222}/pre-seal-t0222.json" "${sdt0333}/pre-seal-t0333.json" > "${staging}/genesis.json"
|
||||
|
||||
lotus_path=$(mktemp -d)
|
||||
|
||||
./lotus --repo="${lotus_path}" daemon --lotus-make-random-genesis="${staging}/devnet.car" --genesis-presealed-sectors="${staging}/genesis.json" --bootstrap=false &
|
||||
lpid=$!
|
||||
|
||||
sleep 3
|
||||
|
||||
kill "$lpid"
|
||||
|
||||
wait
|
||||
|
||||
cp "${staging}/devnet.car" build/genesis/devnet.car
|
||||
|
||||
make debug
|
||||
|
||||
ldt0111=$(mktemp -d)
|
||||
ldt0222=$(mktemp -d)
|
||||
ldt0333=$(mktemp -d)
|
||||
|
||||
sdlist=( "$sdt0111" "$sdt0222" "$sdt0333" )
|
||||
ldlist=( "$ldt0111" "$ldt0222" "$ldt0333" )
|
||||
|
||||
for (( i=0; i<${#sdlist[@]}; i++ )); do
|
||||
preseal=${sdlist[$i]}
|
||||
fullpath=$(find ${preseal} -type f -iname 'pre-seal-*.json')
|
||||
filefull=$(basename ${fullpath})
|
||||
filename=${filefull%%.*}
|
||||
mineraddr=$(echo $filename | sed 's/pre-seal-//g')
|
||||
|
||||
wallet_raw=$(jq -rc ".${mineraddr}.Key" < ${preseal}/${filefull})
|
||||
wallet_b16=$(./lotus-shed base16 "${wallet_raw}")
|
||||
wallet_adr=$(./lotus-shed keyinfo --format="{{.Address}}" "${wallet_b16}")
|
||||
wallet_adr_enc=$(./lotus-shed base32 "wallet-${wallet_adr}")
|
||||
|
||||
mkdir -p "${ldlist[$i]}/keystore"
|
||||
cat > "${ldlist[$i]}/keystore/${wallet_adr_enc}" <<EOF
|
||||
${wallet_raw}
|
||||
EOF
|
||||
|
||||
chmod 0700 "${ldlist[$i]}/keystore/${wallet_adr_enc}"
|
||||
done
|
||||
|
||||
pids=()
|
||||
for (( i=0; i<${#ldlist[@]}; i++ )); do
|
||||
repo=${ldlist[$i]}
|
||||
./lotus --repo="${repo}" daemon --api "3000$i" --bootstrap=false &
|
||||
pids+=($!)
|
||||
done
|
||||
|
||||
sleep 10
|
||||
|
||||
boot=$(./lotus --repo="${ldlist[0]}" net listen)
|
||||
|
||||
for (( i=1; i<${#ldlist[@]}; i++ )); do
|
||||
repo=${ldlist[$i]}
|
||||
./lotus --repo="${repo}" net connect ${boot}
|
||||
done
|
||||
|
||||
sleep 3
|
||||
|
||||
mdt0111=$(mktemp -d)
|
||||
mdt0222=$(mktemp -d)
|
||||
mdt0333=$(mktemp -d)
|
||||
|
||||
env LOTUS_PATH="${ldt0111}" LOTUS_STORAGE_PATH="${mdt0111}" ./lotus-storage-miner init --genesis-miner --actor=t0111 --pre-sealed-sectors="${sdt0111}" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
||||
env LOTUS_PATH="${ldt0111}" LOTUS_STORAGE_PATH="${mdt0111}" ./lotus-storage-miner run --nosync &
|
||||
mpid=$!
|
||||
|
||||
env LOTUS_PATH="${ldt0222}" LOTUS_STORAGE_PATH="${mdt0222}" ./lotus-storage-miner init --actor=t0222 --pre-sealed-sectors="${sdt0222}" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
||||
env LOTUS_PATH="${ldt0333}" LOTUS_STORAGE_PATH="${mdt0333}" ./lotus-storage-miner init --actor=t0333 --pre-sealed-sectors="${sdt0333}" --nosync=true --sector-size="${SECTOR_SIZE}" || true
|
||||
|
||||
kill $mpid
|
||||
for (( i=0; i<${#pids[@]}; i++ )); do
|
||||
kill ${pids[$i]}
|
||||
done
|
||||
|
||||
wait
|
||||
|
||||
rm -rf $mdt0111
|
||||
rm -rf $mdt0222
|
||||
rm -rf $mdt0333
|
||||
|
||||
rm -rf $ldt0111
|
||||
rm -rf $ldt0222
|
||||
rm -rf $ldt0333
|
||||
|
||||
rm -rf $sdt0111
|
||||
rm -rf $sdt0222
|
||||
rm -rf $sdt0333
|
||||
|
||||
rm -rf $staging
|
Loading…
Reference in New Issue
Block a user