Setting up Snark Stopper
v1.2.4
The script will be useful for those who run the Block Producer and Snark Worker on the same server. Worker uses all your CPU cores 100%, which negatively affects the block producer. The script allows you to stop the Worker Snark 3 minutes before the block is produced and turn it on again after 10 minutes.
sudo apt install jq -y
yes | sudo apt install git
Your snark worker should be RUNNING.
Check the config file. There are several options that you can remap.
Unblock the private network:
sudo iptables -D OUTPUT -d 172.16.0.0/12 -j DROP
You need to run in a new TMUX session
sudo apt-get update \
&& sudo apt-get install python3-venv tmux git -y \
&& git clone https://github.com/c29r3/mina-snark-stopper.git \
&& cd mina-snark-stopper \
&& python3 -m venv venv \
&& source ./venv/bin/activate \
&& pip3 install -r requirements.txt
Now you need to add your public key and Worker fee to the stopper config. Open the config with the command:
nano $HOME/mina-snark-stopper/config.yml
In the
WORKER_PUB_KEY: YOUR_PUBLIC_KEY
line, change YOUR_PUBLIC_KEY
to $MINA_PUBLIC_KEY
In the line WORKER_FEE: 1
, replace the commission value, for example, from 1 to 0.025 Done.
tmux new -s snark-stopper -d venv/bin/python3 snark-stopper.py
Logs:
tmux attach -t snark-stopper
Download the config file:
curl -s https://raw.githubusercontent.com/c29r3/mina-snark-stopper/master/config.yml > config.yml; \
touch snark_stopper.log
Now you need to add your public key and Worker commission to the stopper config.
Open the config with the command:
nano $HOME/config.yml
In the
WORKER_PUB_KEY: YOUR_PUBLIC_KEY
line, change YOUR_PUBLIC_KEY
to $MINA_PUBLIC_KEY
In the line WORKER_FEE: 1
, replace the commission value, for example, from 1 to 0.025 Run container:
touch snark_stopper.log; \
chmod 666 snark_stopper.log; \
sudo docker run -d \
--volume $(pwd)/config.yml:/mina/config.yml \
--volume $(pwd)/snark_stopper.log:/mina/snark_stopper.log \
--net=host \
--restart always \
--name snark-stopper \
c29r3/snark-stopper
Logs:
sudo docker logs -f snark-stopper
If the snark-stopper can't connect to port
3085
:Check port availability:
nc -t -vv localhost 3085
Output should be something like this:
Connection to localhost 3085 port [tcp/*] succeeded!
If the connection hangs, then the following options are possible:
- Access to port
3085
is blocked via ufw\iptables - You did not add a docker container flag
-p 127.0.0.1:3085:3085
- Node is not synced yet. For this reason the stopper can't connect
Port responds, but the stopper still can't connect:
sudo iptables -D OUTPUT -d 172.16.0.0/12 -j DROP
it's because of the blocking of private subnets that the docker uses.
Update docker image
After running the command below, go to step 2
sudo docker rm -f snark-stopper \
&& sudo docker pull c29r3/snark-stopper
Delete the config file and container and download the new image:
sudo docker rm -f snark-stopper; \
curl -s https://raw.githubusercontent.com/c29r3/mina-snark-stopper/master/config.yml > config.yml; \
sudo docker pull c29r3/snark-stopper
Then we continue from point 1 or 2.
rm -rf mina-snark-stopper \
&& sudo docker rm -f snark-stopper \
&& sudo docker system prune -af
Last modified 2yr ago