CODA Magic Window Automation
===
###### tags: `web3` `zk-SNARKs` `coda` `testnet`
:::info
- **Location:** Earth
- **Date:** Oct 25, 2019 23:00 (Melbourne Standard Time)
- **Topics**
Why Automate
What to Automate
How to Automate
When to Monitor
Where to Contribute
- **Docs:** bit.ly/CodaDocs
- **Blog:** bit.ly/CodaBlog
- **Discord:** bit.ly/CodaDiscord
- **Twitter:** bit.ly/CodaTweet
:::
## Why Automate
- The past two rounds of testnet we have an interesting challenge where certain tasks need to done during a pre-determined window a.k.a **Magic Window**
- The 4 one-hour windows are:
- Thursday October 24th, 9–10pm UTC-7
- Saturday October 26th 9–10am UTC-7
- Tuesday October 29th, 9–10pm UTC-7
- Wednesday October 30th, 9–10am UTC-7
- For more details on what tasks need to be accomplished, please check the Discord #announcements channel
- Given these windows lasts only for an hour and sometimes it might be happening when you're fast asleep
- So I chose to automate most of my tasks and watch the magic happen
## What to Automate
- Make sure your block-producer and snark-worker daemons are monitored for any sudden crashes, and a restart script is in place
- You can follow this [link](https://forums.codaprotocol.com/t/monitoring-coda-automatic-restarts/214) to automate your daemons
- Let's say your strategy is to send 1 CODA every minute to someone else in the community during the Magic Window
- We are going to automate this strategy using `crontab` and `scripts`
## How to Automate
- The **STEPS** are pretty simple
- Create a crontab entry to run a script during the magic window(s)
- Create the script(s) that sends 1 CODA using the CLI command
- **STEPS**
- *Crontab*
- Type `crontab -l` to see if you any entries already
- Type `crontab -e` to edit the crontab entries
- Here are my crontab entries ...use them if you find it useful
- Note: the date & time reflects my server timezone
- PS: please change the absolute directory paths and script names to reflect your installation
```
#Magic Window 1 - Thursday October 24th, 9-10pm UTC-7
* 12 25 10 * /mnt/coda/coda_send_payment_pk_to_kai.sh >> /tmp/pk_to_kai.log 2>&1
* 12 25 10 * /mnt/coda/coda_send_payment_pk_to_david.sh >> /tmp/pk_to_david.log 2>&1
Magic Window 2 - Saturday October 26th 9-10am UTC-7
* 00 27 10 * /mnt/coda/coda_send_payment_pk_to_kai.sh >> /tmp/pk_to_kai.log 2>&1
* 00 27 10 * /mnt/coda/coda_send_payment_pk_to_david.sh >> /tmp/pk_to_david.log 2>&1
Magic Window 3 - Tuesday October 29th, 9-10pm UTC-7
* 12 30 10 * /mnt/coda/coda_send_payment_pk_to_kai.sh >> /tmp/pk_to_kai.log 2>&1
* 12 30 10 * /mnt/coda/coda_send_payment_pk_to_david.sh >> /tmp/pk_to_david.log 2>&1
Magic Window 4 - Wednesday October 30th, 9-10am UTC-7
* 00 31 10 * /mnt/coda/coda_send_payment_pk_to_kai.sh >> /tmp/pk_to_kai.log 2>&1
* 00 31 10 * /mnt/coda/coda_send_payment_pk_to_david.sh >> /tmp/pk_to_david.log 2>&1
```
- *Scripts*
- coda_send_payment_pk_to_kai.sh
```
export CODA_KAI=<Kai-Public-Key>
export CODA_PRIVKEY_PASS=<Passphrase>
echo "$(date) sending coda from pk to kai"
/usr/local/bin/coda client send-payment -amount 1 -receiver $CODA_KAI -fee 0 -privkey-path /mnt/coda/keys/pk
```
- coda_send_payment_pk_to_david.sh
```
export CODA_DAVID=<David-Public-Key>
export CODA_PRIVKEY_PASS=<Passphrase>
echo "$(date) sending coda from pk to david"
/usr/local/bin/coda client send-payment -amount 1 -receiver $CODA_DAVID -fee 0 -privkey-path /mnt/coda/keys/pk
```
## When to Monitor
- If you're awake during the magic window, you can watch your log files live then
- In one window type `tail -f /tmp/pk_to_kai.log`
- In second window type `tail -f /tmp/pk_to_david.log`
- Otherwise, you view them later to make sure transactions went through alright
- In one window type `more /tmp/pk_to_kai.log`
- In second window type `more /tmp/pk_to_david.log`
- PS: please change the log file names to reflect your installation
## Where to Contribute
- There are several ways, one can contribute
- Join the Public Testnet
- Build on CODA if you're a developer
- Report Issues if and when you find them