Long before the launch of decentralization, the Paradigm team has been trying to do their best for ICON, who recently faced some problems pertinent to every project launching public blockchain. We, like many other P-reps, strive to be ready for possible issues at the very beginning of the mainnet stage. Hence, in this short article, we describe the possible solution.
Daily, P-reps receive messages from developers of ICON Foundation with a request to check the validity of the database — to make sure that there are no errors and bugs in the infrastructure.
Moreover, the human factor can affect the work of the Foundation team so they can’t monitor the network 24/7 and notify P-reps about the problems that have arisen. Validators have to manually check the validity of the database several times a day, which makes the process very inconvenient.
The Paradigm Citadel team developed a bot that automates the process of checking and reporting bugs in the database. Every hour the bot checks the validity of the database and, in case of malfunctions, notifies a P-rep in the corresponding telegram channel. Here is a small installation guide:
1. Send /newbot to @BotFather and follow it’s instructions
2. Add bot to chat and open https://api.telegram.org/botBOT_TOKEN/getUpdates with your browser, replacing BOT_TOKEN with your bot token, taken from previous step. Find line, looking like “chat”:{“id”:-123456789 and take id(-123456789 for this example).
3. nano checkdb.sh at your home directory
4. Add these lines and replace BOT_TOKEN with your bot token, taken from the first step and CHAT_ID with chat ID, taken from 2-nd step.
```RESULT=”$(curl -s https://prep-iiss-check.s3-ap-northeast-1.amazonaws.com/check_and_sendme_v2.sh | sudo bash)”
if [[ ! $RESULT =~ “Valid DB, get some rest” ]]; then
echo “Should send!”;
curl -s -X POST https://api.telegram.org/botBOT_TOKEN/sendMessage -d chat_id=CHAT_ID -d text=$RESULT;
else
echo “Valid DB”;
fi```5. chmod +x checkdb.sh
6. sudo ln -s $PWD/checkdb-bot.sh /usr/bin/checkdb
7. run crontab -e and add following line.
00 */1 * * * checkdb
8. Take some rest. Now all checks will be done automatically every hour and bot will send it’s the result if it fails
We think that this solution will ease the work of P-reps and improve network stability.
If you have any questions, please DM our CTO Gregory Shabalov @grshabl