Running locally - Subtensor
Subtensor is our network blockchain and keeps a record of every transaction that occurs. A new block is created and recorded every 12 seconds - or "blockstep" - at which time a new round of Tao is distributed.
By connecting to Nakamoto, you automatically gain access to Subtensor. Running a Subtensor instance locally, however, will ensure a faster and more consistent experience in the case that the network is compromised or slowed by high traffic. It is therefore highly recommended to run Subtensor locally for serious Servers.
Running Subtensor
Should any of the below commands fail, try running with sudo.
- Prepare your system by updating outdated packages in your system, and installing the newest available ones. You can do this in two commands.
apt-get update
apt-get upgrade
- Download Docker.
curl -fsSL https://get.docker.com -o get-docker.sh
- Make the Docker install script executable.
chmod +x ./get-docker.sh
- Install Docker. For more information, follow this link.
./get-docker.sh
- Clone the Subtensor repository.
git clone https://github.com/opentensor/subtensorv3.git
- Open the Subtensor directory.
cd subtensorv3
- Pull the latest Subtensor image.
docker pull opentensor/subtensor
- Run Subtensor inside of Docker.
docker compose up -d
- Check that Subtensor is fully synced.
docker logs --since=1h node-subtensor 2>&1 | grep "best"
Here is an example of a synced copy of Subtensor:
/node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50564.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50568.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50572.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50576.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50580.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50584.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50588.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50592.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50596.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50600.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50604.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50608.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50612.
node-subtensor | 2022-04-27 01:32:22 Accepted a new tcp connection from 172.22.0.1:50616.
In case your Subtensor goes down, here is the command to restart it:
# quick restart
cd subtensorv3 && \
docker-compose down && \
docker-compose up -d
# full restart
cd subtensorv3 && \
docker-compose down && \
docker system prune -a -f && \
git pull && \
docker pull opentensor/subtensor && \
docker-compose up -d
Lastly, here are the steps to ensure both Bittensor and Subtensor are up to date.
Update Bittensor:
git -C ~/.bittensor/bittensor pull origin master
python3 -m pip install -e ~/.bittensor/bittensor
Update Subtensor:
#Bring Subtensor down
docker compose down
#Connect to directory
cd subtensorv3
#update Subtensor
git pull
#Bring Subtensor back up
docker compose up -d