Advertisement
EvenoR

Allora Worker

Jul 7th, 2024 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.22 KB | None | 0 0
  1. 1.
  2. sudo apt update && sudo apt upgrade -y
  3. sudo apt install ca-certificates zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev curl git wget make
  4. 2.
  5. sudo apt install python3
  6. 2.1
  7. sudo apt install python3-pip
  8. 3.
  9. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  10. 3.1
  11. 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
  12. 3.2
  13. sudo apt-get update
  14. sudo apt-get install docker-ce docker-ce-cli containerd.io
  15. 4.
  16. sudo curl -L "https://github.com/docker/compose/releases/download/2.28.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  17. sudo chmod +x /usr/local/bin/docker-compose
  18.  
  19. 5.
  20. sudo groupadd docker
  21. sudo usermod -aG docker $USER
  22. 6.
  23. sudo rm -rf /usr/local/go
  24. curl -L https://go.dev/dl/go1.22.4.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
  25. echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
  26. echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> $HOME/.bash_profile
  27. source .bash_profile
  28. 7.
  29. git clone https://github.com/allora-network/allora-chain.git
  30.  
  31. cd allora-chain && make all
  32.  
  33. 8.
  34. allorad keys add testkey --recover
  35. 9.
  36. cd $HOME && git clone https://github.com/allora-network/basic-coin-prediction-node
  37.  
  38. cd basic-coin-prediction-node
  39.  
  40. mkdir worker-data
  41. mkdir head-data
  42. 10.
  43. sudo chmod -R 777 worker-data
  44. sudo chmod -R 777 head-data
  45. 11.
  46. 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)"
  47. 12.
  48. 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)"
  49. 13.
  50. cat head-data/keys/identity
  51. 14.
  52. apt install nano
  53. 15.
  54. rm -rf docker-compose.yml && nano docker-compose.yml
  55. 16.
  56. version: '3'
  57.  
  58. services:
  59.   inference:
  60.     container_name: inference-basic-eth-pred
  61.     build:
  62.       context: .
  63.     command: python -u /app/app.py
  64.     ports:
  65.       - "8000:8000"
  66.     networks:
  67.       eth-model-local:
  68.         aliases:
  69.           - inference
  70.         ipv4_address: 172.22.0.4
  71.     healthcheck:
  72.       test: ["CMD", "curl", "-f", "http://localhost:8000/inference/ETH"]
  73.       interval: 10s
  74.       timeout: 5s
  75.       retries: 12
  76.     volumes:
  77.       - ./inference-data:/app/data
  78.  
  79.   updater:
  80.     container_name: updater-basic-eth-pred
  81.     build: .
  82.     environment:
  83.       - INFERENCE_API_ADDRESS=http://inference:8000
  84.     command: >
  85.       sh -c "
  86.      while true; do
  87.        python -u /app/update_app.py;
  88.        sleep 24h;
  89.      done
  90.      "
  91.     depends_on:
  92.       inference:
  93.         condition: service_healthy
  94.     networks:
  95.       eth-model-local:
  96.         aliases:
  97.           - updater
  98.         ipv4_address: 172.22.0.5
  99.  
  100.   worker:
  101.     container_name: worker-basic-eth-pred
  102.     environment:
  103.       - INFERENCE_API_ADDRESS=http://inference:8000
  104.       - HOME=/data
  105.     build:
  106.       context: .
  107.       dockerfile: Dockerfile_b7s
  108.     entrypoint:
  109.       - "/bin/bash"
  110.       - "-c"
  111.       - |
  112.         if [ ! -f /data/keys/priv.bin ]; then
  113.           echo "Generating new private keys..."
  114.           mkdir -p /data/keys
  115.           cd /data/keys
  116.           allora-keys
  117.         fi
  118.         # Change boot-nodes below to the key advertised by your head
  119.         allora-node --role=worker --peer-db=/data/peerdb --function-db=/data/function-db \
  120.           --runtime-path=/app/runtime --runtime-cli=bls-runtime --workspace=/data/workspace \
  121.           --private-key=/data/keys/priv.bin --log-level=debug --port=9011 \
  122.           --boot-nodes=/ip4/172.22.0.100/tcp/9010/p2p/head-id \
  123.           --topic=allora-topic-1-worker \
  124.           --allora-chain-key-name=testkey \
  125.           --allora-chain-restore-mnemonic='WALLET_SEED_PHRASE' \
  126.           --allora-node-rpc-address=https://allora-rpc.edgenet.allora.network/ \
  127.           --allora-chain-topic-id=1
  128.     volumes:
  129.       - ./worker-data:/data
  130.     working_dir: /data
  131.     depends_on:
  132.       - inference
  133.       - head
  134.     networks:
  135.       eth-model-local:
  136.         aliases:
  137.           - worker
  138.         ipv4_address: 172.22.0.10
  139.  
  140.   head:
  141.     container_name: head-basic-eth-pred
  142.     image: alloranetwork/allora-inference-base-head:latest
  143.     environment:
  144.       - HOME=/data
  145.     entrypoint:
  146.       - "/bin/bash"
  147.       - "-c"
  148.       - |
  149.         if [ ! -f /data/keys/priv.bin ]; then
  150.           echo "Generating new private keys..."
  151.           mkdir -p /data/keys
  152.           cd /data/keys
  153.           allora-keys
  154.         fi
  155.         allora-node --role=head --peer-db=/data/peerdb --function-db=/data/function-db  \
  156.           --runtime-path=/app/runtime --runtime-cli=bls-runtime --workspace=/data/workspace \
  157.           --private-key=/data/keys/priv.bin --log-level=debug --port=9010 --rest-api=:6000
  158.     ports:
  159.       - "6000:6000"
  160.     volumes:
  161.       - ./head-data:/data
  162.     working_dir: /data
  163.     networks:
  164.       eth-model-local:
  165.         aliases:
  166.           - head
  167.         ipv4_address: 172.22.0.100
  168.  
  169.  
  170. networks:
  171.   eth-model-local:
  172.     driver: bridge
  173.     ipam:
  174.       config:
  175.         - subnet: 172.22.0.0/24
  176.  
  177. volumes:
  178.   inference-data:
  179.   worker-data:
  180.   head-data:
  181.  
  182.  
  183. 17.
  184. docker compose build
  185. docker compose up -d
  186. 18.
  187. docker ps
  188. 19.
  189. docker logs -f COINTERID
  190. 20.
  191. curl --location 'http://localhost:6000/api/v1/functions/execute' \
  192. --header 'Content-Type: application/json' \
  193. --data '{
  194.    "function_id": "bafybeigpiwl3o73zvvl6dxdqu7zqcub5mhg65jiky2xqb4rdhfmikswzqm",
  195.    "method": "allora-inference-function.wasm",
  196.    "parameters": null,
  197.    "topic": "1",
  198.    "config": {
  199.        "env_vars": [
  200.            {
  201.                "name": "BLS_REQUEST_PATH",
  202.                "value": "/api"
  203.            },
  204.            {
  205.                "name": "ALLORA_ARG_PARAMS",
  206.                "value": "ETH"
  207.            }
  208.        ],
  209.        "number_of_nodes": -1,
  210.        "timeout": 2
  211.    }
  212. }'
  213.  
  214.  
  215. 21.
  216. curl http://localhost:8000/update
  217.  
  218. 22.
  219. curl http://localhost:8000/inference/ETH
  220.  
  221. 23.
  222. cd $HOME
  223. cd basic-coin-prediction-node
  224. nano docker-compose.yml
  225.  
  226. 24.
  227. docker compose build
  228. docker compose up -d
  229.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement