Allora Worker Node Setup

casual1st
Official Allora Community
6 min readJul 5, 2024

To participate in the Allora Network, ensure your system meets the following requirements:

Operating System: Any modern operating system including Windows, macOS, or Linux
CPU: Minimum of 1/2 core.
Memory: 2 to 4 GB.
Storage: SSD or NVMe with at least 5GB of space.

  1. Switch to the root if you are not logged in with the root user already.
sudo su -

2. Update the package index files and upgrade the actual packages

apt update && apt upgrade -y

3. Check whether reboot is required

cat /var/run/reboot-required

Reboot the system if the output has *** System restart required ***, if not skip the step below.

systemctl reboot

Note: switch to the root user again if you are on a different user

4. Install all the required packages

apt install ca-certificates zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev curl git wget make jq build-essential pkg-config lsb-release libssl-dev libreadline-dev libffi-dev gcc screen unzip lz4 -y

5. Install python 3 and pip packet manager

sudo apt install python3
sudo apt install python3-pip

6. Install docker

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
sudo apt install docker-ce docker-ce-cli containerd.io
docker version

7. Install docker-compose

VER=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d '"' -f 4)
curl -L "https://github.com/docker/compose/releases/download/$VER/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

8. User permissions for docker

sudo groupadd docker
sudo usermod -aG docker $USER

9. Install Go

cd $HOME && \
ver="1.22.4" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile && \
source $HOME/.bash_profile && \
go version

10. Install Allora Appchain CLI

git clone https://github.com/allora-network/allora-chain.git
cd allora-chain
make all
allorad version

11. Create a wallet

In case you have an existing wallet recover your wallet using the seed-phrase

allorad keys add testkey --recover

If you are creating a new wallet, just run the command below (do not forget to save your mnemonic!)

allorad keys add testkey

12. Get some test tokens from the faucet

13. Deploy a worker node

Clone the repo

cd $HOME && git clone https://github.com/allora-network/basic-coin-prediction-node

Create necessary directories

cd basic-coin-prediction-node
mkdir worker-data
mkdir head-data

Set the required permissions

sudo chmod -R 777 worker-data
sudo chmod -R 777 head-data

Create head keys

sudo docker run -it --entrypoint=bash -v ./head-data:/data alloranetwork/allora-inference-base:latest -c "mkdir -p /data/keys && (cd /data/keys && allora-keys)"

Create worker keys

sudo docker run -it --entrypoint=bash -v ./worker-data:/data alloranetwork/allora-inference-base:latest -c "mkdir -p /data/keys && (cd /data/keys && allora-keys)"

Copy head-id

cat head-data/keys/identity; echo

14. Connect to the chain

rm -rf docker-compose.yml

Open the “docker-compose.yml” file with a text editor

Replace head-id and WALLET_SEED_PHRASE

e.g:
head-id:
— boot-nodes=/ip4/172.22.0.100/tcp/9010/p2p/12D3KooLrwykjVq32p4dHZb \

mnemonic:

— allora-chain-restore-mnemonic='vintage put cliff hen happy sell save worth…’

version: '3'

services:
inference:
container_name: inference-basic-eth-pred
build:
context: .
command: python -u /app/app.py
ports:
- "8000:8000"
networks:
eth-model-local:
aliases:
- inference
ipv4_address: 172.22.0.4
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/inference/ETH"]
interval: 10s
timeout: 10s
retries: 12
volumes:
- ./inference-data:/app/data

updater:
container_name: updater-basic-eth-pred
build: .
environment:
- INFERENCE_API_ADDRESS=http://inference:8000
command: >
sh -c "
while true; do
python -u /app/update_app.py;
sleep 24h;
done
"
depends_on:
inference:
condition: service_healthy
networks:
eth-model-local:
aliases:
- updater
ipv4_address: 172.22.0.5

worker:
container_name: worker-basic-eth-pred
environment:
- INFERENCE_API_ADDRESS=http://inference:8000
- HOME=/data
build:
context: .
dockerfile: Dockerfile_b7s
entrypoint:
- "/bin/bash"
- "-c"
- |
if [ ! -f /data/keys/priv.bin ]; then
echo "Generating new private keys..."
mkdir -p /data/keys
cd /data/keys
allora-keys
fi
# Change boot-nodes below to the key advertised by your head
allora-node --role=worker --peer-db=/data/peerdb --function-db=/data/function-db \
--runtime-path=/app/runtime --runtime-cli=bls-runtime --workspace=/data/workspace \
--private-key=/data/keys/priv.bin --log-level=debug --port=9011 \
--boot-nodes=/ip4/172.22.0.100/tcp/9010/p2p/head-id \
--topic=allora-topic-1-worker \
--allora-chain-key-name=testkey \
--allora-chain-restore-mnemonic='WALLET_SEED_PHRASE' \
--allora-node-rpc-address=https://allora-rpc.edgenet.allora.network/ \
--allora-chain-topic-id=1
volumes:
- ./worker-data:/data
working_dir: /data
depends_on:
- inference
- head
networks:
eth-model-local:
aliases:
- worker
ipv4_address: 172.22.0.10

head:
container_name: head-basic-eth-pred
image: alloranetwork/allora-inference-base-head:latest
environment:
- HOME=/data
entrypoint:
- "/bin/bash"
- "-c"
- |
if [ ! -f /data/keys/priv.bin ]; then
echo "Generating new private keys..."
mkdir -p /data/keys
cd /data/keys
allora-keys
fi
allora-node --role=head --peer-db=/data/peerdb --function-db=/data/function-db \
--runtime-path=/app/runtime --runtime-cli=bls-runtime --workspace=/data/workspace \
--private-key=/data/keys/priv.bin --log-level=debug --port=9010 --rest-api=:6000
ports:
- "6000:6000"
volumes:
- ./head-data:/data
working_dir: /data
networks:
eth-model-local:
aliases:
- head
ipv4_address: 172.22.0.100


networks:
eth-model-local:
driver: bridge
ipam:
config:
- subnet: 172.22.0.0/24

volumes:
inference-data:
worker-data:
head-data:

15. Build and run your worker

docker compose build
docker compose up -d
docker ps

Post-checks

Check the state of the containers

docker ps -a

In the output of docker ps -a command you should see 4 containers with the image names given below. All containers must be running and you should see 4 containers that are always running.

CONTAINER ID   IMAGE                                             COMMAND                  CREATED      STATUS                PORTS                                        NAMES
fd2f4d2aa08d basic-coin-prediction-node-worker "/bin/bash -c 'if [ …" 3 days ago Up 3 days 8080/tcp, 9527/tcp worker-basic-eth-pred
9723e9fce76f basic-coin-prediction-node-updater "sh -c ' while true;…" 3 days ago Up 3 days updater-basic-eth-pred
cf9f212c8965 alloranetwork/allora-inference-base-head:latest "/bin/bash -c 'if [ …" 3 days ago Up 3 days 8080/tcp, 0.0.0.0:6000->6000/tcp, 9527/tcp head-basic-eth-pred
f64e8d6bc08c basic-coin-prediction-node-inference "python -u /app/app.…" 3 days ago Up 3 days (healthy) 0.0.0.0:8000->8000/tcp inference-basic-eth-pred

Check docker stats by executing “docker stats” command
All the containers should be running

CONTAINER ID   NAME                       CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O         PIDS
fd2f4d2aa08d worker-basic-eth-pred 0.05% 47.71MiB / 29.37GiB 0.16% 33.7MB / 28.2MB 191MB / 340kB 13
9723e9fce76f updater-basic-eth-pred 0.00% 520KiB / 29.37GiB 0.00% 1.7MB / 2.53kB 21.9MB / 0B 2
cf9f212c8965 head-basic-eth-pred 0.07% 17.08MiB / 29.37GiB 0.06% 30MB / 32MB 6.3MB / 36.9kB 13
f64e8d6bc08c inference-basic-eth-pred 0.02% 104.2MiB / 29.37GiB 0.35% 3.42MB / 535kB 1.14GB / 1.43MB 16

Check the logs of the worker container

docker logs -f <the id of basic-coin-prediction-node-worker>

You should see something similar to the following logs to understand that the node is running.

Success: register node Tx “Hash:=F47468EBEDE37A93432F3C2EC229A91169B732FFBA”

or

“node already registered for topic topic” in case you setup the node for more than once.

peer connected addr_info=

2024-07-01T10:40:47Z INF created host addresses=["/ip4/127.0.0.1/tcp/9011/p2p/12D3KooWRmuMCNxgeqbphEXGc5mTGR2Wk2","/ip4/172.22.0.10/tcp/9011/p2p/12D3KooWRmuMCNxgeqbphEXGc5mTGR2Wk2"] boot_nodes=1 dial_back_peers=1 id=12D3KooWRmuMCNxgeqbphEXGc5mTGR2Wk2
2024-07-01T10:40:48Z INF allora blockchain address loaded address=allo137xu0eye9gz4mhvlgs8kznsu7nwgjf4jvwem43
2024-07-01T10:40:48Z INF Node mode isReputer=false
2024-07-01T10:40:48Z INF Topics list topicsList=[1]
2024-07-01T10:40:48Z INF node already registered for topic topic=1
2024-07-01T10:40:48Z INF connected to allora blockchain
2024-07-01T10:40:48Z INF Allora Node starting role=worker
2024-07-01T10:40:48Z INF topics node will subscribe to component=node topics=["allora-topic-1-worker","blockless/b7s/general"]
2024-07-01T10:40:48Z INF starting node main loop component=node concurrency=10
2024-07-01T10:40:48Z DBG waiting for workers component=node
2024-07-01T10:40:48Z DBG adding dial-back peer addr_info={"Addrs":["/ip4/172.22.0.100/tcp/9010"],"ID":"12D3KooWFhkzXoAynQUfHnMpTuMoLr"} component=host peer=12D3KooWFhkzXoAynQUfHnMpTuMoLr
2024-07-01T10:40:48Z DBG adding dial-back peer addr_info={"Addrs":["/ip4/172.22.0.100/tcp/9010"],"ID":"12D3KooWFhkzXoAynQUfHnMpTuMoLr"} component=host peer=12D3KooWFhkzXoAynQUfHnMpTuMoLr
2024-07-01T10:40:48Z DBG peer connected addr_info={"Addrs":["/ip4/172.22.0.100/tcp/9010"],"ID":"12D3KooWFhkzXoAynQUfHnMpTuMoLr"} component=notifiee local_address=/ip4/172.22.0.10/tcp/9011 peer=12D3KooWFhkzXoAynQUfHnMpTuMoLr remote_address=/ip4/172.22.0.100/tcp/9010

You need to see “peer connected” in this log and then test with curl

curl --location 'http://localhost:6000/api/v1/functions/execute' \
--header 'Content-Type: application/json' \
--data '{
"function_id": "bafybeigpiwl3o73zvvl6dxdqu7zqcub5mhg65jiky2xqb4rdhfmikswzqm",
"method": "allora-inference-function.wasm",
"parameters": null,
"topic": "1",
"config": {
"env_vars": [
{
"name": "BLS_REQUEST_PATH",
"value": "/api"
},
{
"name": "ALLORA_ARG_PARAMS",
"value": "ETH"
}
],
"number_of_nodes": -1,
"timeout": 2
}
}' | jq

Here in the response of the curl query we expect to see
- 200 result code
- “exit_code”: 0 which states the execution is successful.
- and the peers configured above

{
"code": "200",
"request_id": "8bc381fc-fed7-4722-912c-6886df203cdc",
"results": [
{
"result": {
"stdout": "{\"infererValue\": \"2941.8035629998703\"}\n\n",
"stderr": "",
"exit_code": 0
},
"peers": [
"12D3KooWRmuMCNxgeqbphEXGc5mTGR2Wk2"
],
"frequency": 100
}
],
"cluster": {
"peers": [
"12D3KooWRmuMCNxgeqbphEXGc5mTGR2Wk2"
]
}
}

Test the inference container:

curl http://localhost:8000/inference/ETH

--

--