#903 Removed Pre-Sync Feature

This commit is contained in:
rootzoll 2019-12-11 01:25:18 +01:00
parent 6c16db03da
commit 657ed40f8e
4 changed files with 2 additions and 109 deletions

View File

@ -18,7 +18,7 @@ Also, if your group is lager then 5 participants, calculate some extra time for
_Estimated Duration: 2 Hours_
Sure, one part of the fun for participents is to assemble the hardware themselves. But if you aim for the shortest workshop possible, then this is the way to go (around 2 hours lenght). If you have the RaspiBlitz already assembled to be operational at the workshop, you can utilize one big time saver feature: "The Pre-Sync". Before the workshop starts you can already plug an assembled RaspiBlitz into power+network and when there is a preloaded bitcoin blockchain on the HDD it will already start catching up. So your participants start with an on-the-spot synced blockchain and will just have to deal with waiting times during the lightning node setup. But keep in mind that you need budget to buy all the hardware and lots of time in preparation for this - order the parts two weeks before and start peparing at least 3 days before the workshop.
Sure, one part of the fun for participents is to assemble the hardware themselves. But if you aim for the shortest workshop possible, then this is the way to go (around 2 hours lenght). So your participants start with an almost on-the-spot synced blockchain (use copy station to keep HDDs presynced) and will just have to deal with waiting times during the lightning node setup. But keep in mind that you need budget to buy all the hardware and lots of time in preparation for this - order the parts two weeks before and start peparing at least 3 days before the workshop.
These are the following steps you need to prepare (follow links for details):
@ -27,7 +27,6 @@ These are the following steps you need to prepare (follow links for details):
- [Prepare HDDs with Blockchain Data](WORKSHOP.md#prepare-hdds-with-blockchain-data)
- [Prepare SD cards with latest RaspiBlitz image](WORKSHOP.md#prepare-sd-cards-with-latest-raspiblitz-image)
- [Setup Workshop Environment](WORKSHOP.md#setup-workshop-environment)
- [Pre-Sync RaspiBlitzes at Workshop Location]()
_NOTE: You will already take 2 hours to setup the RaspiBlitz software. For groups that are interested in getting experience on the Lightning Network and don't want to take the node home after the workshop, it may make sense to prepare the RaspiBlitz even more, having it fully setup on testnet with RTL turned on. Then you can directly start with funding the node with testnet coins, give intro and build channels over the RTL UI._
@ -200,8 +199,3 @@ Setup power outlets for everybody. Its always good to be way early at the worksh
Most important is the network setup. Every RaspiBlitz needs a LAN port in the switch and that switch needs to be on the same local network as the WLAN so that participants laptop can SSH into the RaspiBlitz. If that is not the case or you cannot confirm that before the event its best to bring an additional WLAN router. Then you give the WLAN router internet uplink thru the available LAN cable and you put the network switch for the Raspiblitzes behind that router and open an additional WLAN on that WLAN router for everybody to connect to. It's OK to be behind a NAT; it's just important for everybody to be behind the same NAT.
## Pre-Sync RaspiBlitzes at Workshop Location
In the ready-2-go scenario you have the RaspiBlitzes already assembled and a recent blockchain copy on the HDD. So one ot two hours before the workshop you setup your environment and already plug all RaspiBlitzes with power & network. You will see on the LCD at the top a pre-sync info and progress... if it's something '99.99...' it's good to go. Just leave it running until the workshop starts. You dont need to stop it - just let participants SSH in and they can to the setup.
It's also best practice to pre-sync all devices before you move them over to the workshop location. You dont need to SSH to shut them down before packing up - just unplug the network cable first, wait until the HDD is stopping to flash and then remove the power.

View File

@ -134,19 +134,6 @@ while :
if [ ${online} -eq 0 ]; then
message="no internet connection"
# when in presync - get more info on progress
elif [ "${state}" = "presync" ]; then
blockchaininfo="$(sudo -u root bitcoin-cli --conf=/home/admin/assets/bitcoin.conf getblockchaininfo 2>/dev/null)"
message="starting"
if [ ${#blockchaininfo} -gt 0 ]; then
message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
message=$(echo $message | awk '{printf( "%.2f%%", 100 * $1)}')
fi
# when old data - improve message
elif [ "${state}" = "olddata" ]; then
message="login for manual migration"
# when no HDD - improve message
elif [ "${state}" = "nohdd" ]; then
message="Connect external HDD/SSD"

View File

@ -84,47 +84,6 @@ if [ "${state}" = "copystation" ]; then
exit
fi
# if pre-sync is running - stop it - before continue
if [ "${state}" = "presync" ]; then
# stopping the pre-sync
echo ""
# analyse if blockchain was detected broken by pre-sync
blockchainBroken=$(sudo tail /mnt/hdd/bitcoin/debug.log 2>/dev/null | grep -c "Please restart with -reindex or -reindex-chainstate to recover.")
if [ ${blockchainBroken} -eq 1 ]; then
# dismiss if its just a date thing
futureBlock=$(sudo tail /mnt/hdd/bitcoin/debug.log 2>/dev/null | grep "Please restart with -reindex or -reindex-chainstate to recover." | grep -c "block database contains a block which appears to be from the future")
if [ ${futureBlock} -gt 0 ]; then
blockchainBroken=0
echo "-> Ignore reindex - its just a future block"
fi
fi
if [ ${blockchainBroken} -eq 1 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Detected corrupted blockchain on pre-sync !"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Deleting blockchain data ..."
echo "(needs to get downloaded fresh during setup)"
sudo rm -f -r /mnt/hdd/bitcoin
else
echo "************************************"
echo "Preparing ... pls wait (up to 1min) "
echo "************************************"
sudo -u root bitcoin-cli -conf=/home/admin/assets/bitcoin.conf stop 2>/dev/null
echo "Calling presync to finish up .."
sleep 50
fi
# unmount the temporary mount
echo "Unmount HDD .."
sudo umount -l /mnt/hdd
sleep 3
# update info file
state=waitsetup
sudo sed -i "s/^state=.*/state=waitsetup/g" $infoFile
sudo sed -i "s/^message=.*/message='Pre-Sync Stopped'/g" $infoFile
fi
# if state=ready -> setup is done or started
if [ "${state}" = "ready" ]; then
configExists=$(ls ${configFile} | grep -c '.conf')

View File

@ -226,6 +226,7 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
sudo mv ${configFile} /mnt/hdd/raspiblitz.invalid.conf
fi
fi
# if config is still valid ...
if [ ${configExists} -eq 1 ]; then
echo "Found valid configuration" >> $logFile
@ -250,54 +251,6 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
echo "OK - No config file found: ${configFile}" >> $logFile
fi
# check if HDD contains existing LND data (old RaspiBlitz Version)
echo "Check if HDD contains existing LND data .." >> $logFile
lndDataExists=$(ls /mnt/hdd/lnd/lnd.conf | grep -c '.conf')
if [ ${lndDataExists} -eq 1 ]; then
echo "Found existing LND data - old RaspiBlitz?" >> $logFile
sed -i "s/^state=.*/state=olddata/g" ${infoFile}
sed -i "s/^message=.*/message='No Auto-Update possible'/g" ${infoFile}
# keep HDD mounted if user wants to copy data
exit 0
else
echo "OK - No LND data found" >> $logFile
fi
# check if HDD contains pre-loaded blockchain data
echo "Check if HDD contains pre-loaded blockchain data .." >> $logFile
litecoinDataExists=$(ls /mnt/hdd/litecoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
bitcoinDataExists=$(ls /mnt/hdd/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
# check if node can go into presync (only for bitcoin)
if [ ${bitcoinDataExists} -eq 1 ]; then
# update info file
sed -i "s/^state=.*/state=presync/g" ${infoFile}
sed -i "s/^message=.*/message='starting presync'/g" ${infoFile}
# activating presync
# so that on a hackathon you can just connect a RaspiBlitz
# to the network and have it up-to-date for setting up
echo "Found pre-loaded blockchain" >> $logFile
# check if pre-sync was already activated on last power-on
#presyncActive=$(systemctl status bitcoind | grep -c 'could not be found')
echo "starting pre-sync in background" >> $logFile
# make sure that debug file is clean, so just pre-sync gets analysed on stop
sudo rm /mnt/hdd/bitcoin/debug.log 2>/dev/null
# starting in background, because this scripts is part of systemd
# so to change systemd needs to happen after delay in seperate process
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>> $logFile
sudo -u bitcoin /usr/local/bin/bitcoind -daemon -conf=/home/admin/assets/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid 2>> $logFile
echo "OK Started bitcoind for presync" >> $logFile
sudo sed -i "s/^message=.*/message='running presync'/g" ${infoFile}
# after admin login, presync will be stopped and HDD unmounted
exit 0
else
echo "OK - No bitcoin blockchain data found" >> $logFile
fi
# if it got until here: HDD is empty ext4
echo "Waiting for SetUp." >> $logFile
sed -i "s/^state=.*/state=waitsetup/g" ${infoFile}