-
Notifications
You must be signed in to change notification settings - Fork 9
Panthalassa worker installation
================================
To run a single worker you need:
- 4 vCPU
- 16GB RAM
- 1TB SSD
- Stable 24/7 Internet connection, at least 1Gbit
- public IP and two ports open for incoming traffic:
- one UDP port for p2p communication (default 12345),
- one TCP port for Prometheus metrics (default 9090).
-
100_000
tSQD
tokens (funded to a special vesting contract owned by the Primary Address). - Some Arbitrum Sepolia ETH (for gas)
The same Primary Address can be used to register multiple workers (if the vesting contract has sufficient funds).
Worker itself is available in two forms:
- as a Docker image,
- as source code.
Please refer to the appropriate section for further instructions.
- Docker engine (tested with version 24.0.4)
- Docker compose (tested with version 2.19.1)
-
Create a new directory and save this
run_worker.sh
script in it. -
Generate your
key
file by running the following command in the newly created directory. It will display your peer ID – please copy this ID, as it will be needed for on-chain worker registration.$ docker run --rm subsquid/rpc-node:0.2.5 keygen >key Your peer ID: <THIS IS WHAT YOU NEED TO COPY>
⚠️ Note: Please make sure that the generated file is safe and secure (i.e. it will not be deleted accidentally and cannot be accessed by unauthorized parties). -
Register your worker by logging into the testnet Web APP with the Primary Wallet you provided in the onboarding form. You will need the Peer ID from the previous step. See the detailed instructions here.
-
Make the
run_worker.sh
script executable and runPUBLIC_IP=<your public ip> ./run_worker.sh <DATA_DIR> up -d
to start the node.<DATA_DIR>
is a directory where the downloaded data will be stored – please make sure it exists and can accommodate up to 1 TB of data. If you want to use a different port than the default 12345, set theLISTEN_PORT
environment variable.⚠️ Note: SettingPUBLIC_IP
is currently required for the node to be publicly discoverable. -
Check the status of the containers with
docker container ls
. Check the worker logs usingdocker logs -f worker-1
. After some time the worker should output some info on the downloaded data chunks. See Docker docs for a reference of Docker commands.
-
Install prerequisites (Python, Rust, Protobuf).
apt install python3.11 python3.11-venv gcc protobuf-compiler curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Clone & build a network node. Obtain
GITHUB_TOKEN
in the private node operator chat.git clone --branch 0.2.5 https://[email protected]/subsquid/subsquid-network.git cd subsquid-network/transport cargo build --release --bin node
-
Create a new Python virtual env and install the worker package. Use the same GITHUB_TOKEN as on the previous step.
python3.11 -m venv env . env/bin/activate pip install -U "subsquid-eth-archive[p2p-worker] @ git+https://[email protected]/subsquid/[email protected]"
-
Enter the
subsquid-network/transport
directory and generate your key file by running the command below. It will display your peer ID – please copy this ID, as it will be needed for on-chain worker registration.cargo run --bin keygen > <FILE PATH WHERE YOUR KEY WILL BE SAVED> Your peer ID: <THIS IS WHAT YOU NEED TO COPY>
-
Register your worker by logging into the testnet Web APP with the Primary Wallet you provided in the onboarding form. You will need the Peer ID from the previous step. See the detailed instructions here.
-
Run the network node using the command below (assuming you are in the
subsquid-network/transport
directory). It usesnohup
, but you may also consider daemonizing it withsystemd
. The libp2p address+port combination, specified by the--p2p-listen-addr
flag, should be available for external connections (in the reference command below the node listens on12345
):nohup cargo run --release --bin node -- \ --p2p-listen-addrs /ip4/0.0.0.0/udp/12345/quic-v1 \ --key <FILE PATH WHERE YOUR KEY IS SAVED> \ --boot-nodes '12D3KooWSRvKpvNbsrGbLXGFZV7GYdcrYNh4W2nipwHHMYikzV58 /dns4/testnet.subsquid.io/udp/22445/quic-v1' \ --boot-nodes '12D3KooWQC9tPzj2ShLn39RFHS5SGbvbP2pEd7bJ61kSW2LwxGSB /dns4/testnet.subsquid.io/udp/22446/quic-v1' \ --bootstrap \ > network.log 2>&1 &
If you see the error below in the console, ignore it.
2023-06-21T08:59:52.427Z ERROR [subsquid_network_transport::transport] Error broadcasting message: InsufficientPeers
Important
Be careful when supplying the path to the key you created at step 4 via --key
. If you supply the wrong path, a new random key will be automatically created there and your node will attempt to operate with a new (unregistered) peer ID - unsuccessfully.
-
Set up the credentials for read-only S3 access, sentry, and RPC via env variables:
cat <<EOF > .worker-env export AWS_ACCESS_KEY_ID=66dfc7705583f6fd9520947ac10d7e9f export AWS_SECRET_ACCESS_KEY=a68fdd7253232e30720a4c125f35a81bd495664a154b1643b5f5d4a4a5280a4f export AWS_S3_ENDPOINT=https://7a28e49ec5f4a60c66f216392792ac38.r2.cloudflarestorage.com export AWS_REGION=auto export SENTRY_DSN=https://[email protected]/4505589334081536 EOF source .worker-env
-
Run the worker process in a terminal where you have your virtualenv active. You may run it with
systemd
instead ofnohup
to tolerate server restarts.nohup python -m sqa.worker.p2p \ --scheduler-id 12D3KooWQER7HEpwsvqSzqzaiV36d3Bn6DZrnwEunnzS76pgZkMU \ --logs-collector-id 12D3KooWC3GvQVqnvPwWz23sTW8G8HVokMnox62A7mnL9wwaSujk \ --data-dir </path/where/you/want/to/store/downloaded/data> \ --proxy localhost:50051 \ --prometheus-port <port_on_which_you_want_to_expose_prometheus_metrics> \ --rpc-url https://sepolia-rollup.arbitrum.io/rpc \ > worker.log 2>&1 &
Withdrawing an active worker is done in 2 steps:
-
Execute this command to unregister the worker.
docker run subsquid/worker-registration:mirovia <PEER_ID> <WALLET_PRIVATE_KEY> deregister
-
Wait for an epoch to end (currently max 30 minutes) and execute this command. The bond will be be transferred back to your wallet immediately.
docker run subsquid/worker-registration:mirovia <PEER_ID> <WALLET_PRIVATE_KEY> withdraw
It is printed when you run keygen
(see the steps for running worker).
It is also in the first line of the worker log output. For the docker setup, list the containers with docker container ls
and inspect the
rpc_node
container logs with docker logs -f <rpc_node_container_id>
If you installed your worker from source, check the network.log
file.
In both cases, the log line you are looking for should look like this
INFO [subsquid_network_transport::transport] Local peer ID: <THIS IS WHAT YOU NEED TO COPY>
The tokens are distributed to dedicated vesting contracts owned by the Primary address. Only the node operators that were onboarded via the DeForm application received tSQD
allocations and are thus capable of running worker(s)
Just ignore it
Yes, copy the key file (located in the key
file located at KEY_PATH
) to the new working directory before starting. You don't need to re-register your worker.
This is normal. Wait for a few minutes and the logs should show some data being downloaded.
Docker makes for an easier setup. Building from sources is suitable only for experienced Linux/Unix users.
Check the pings endpoint and locate the version by your PeerID.
We recommend Ubuntu 22.04 LTS
This is a docker issue, not a problem with the worker. Look at this GitHub issue and this Stackoverflow thread for more context.
Copy your peer ID and look for an entry on this page. If the last ping timestamp is <1 minute ago, and the listed version is the most recent one, you should be good. Alternatively, you can use this Python script.