Skip to main content
SUBMIT A PRSUBMIT AN ISSUElast edit: Mar 25, 2024

Running a Public Subtensor

You can run a public subtensor node and synchronize with the Bittensor network. You can run this subtensor node as either a lite node or as an archive node, and connect and sync with either the Bittensor mainchain or the testchain. This document describes how to run a public subtensor node either by compiling the subtensor source code into a binary and executing this binary, or by using a Docker container.

Lite node vs archive node

A public subtensor node refers to an internet-connected computer that is synchronized with the Bittensor blockchain database. A lite node or an archive node is a type of public subtensor node.

a subtensor node is not a neuron

A subtensor node is different from a Bittensor neuron. A Bittensor neuron is either a subnet validator node or a subnet miner node—it exists in a subnet, and it does not contain blockchain database.

Normally, a node in Bittensor blockchain must always be synchronized to the latest blockchain ledger state. Such a blockchain node accomplishes this by holding a copy of the entire Bittensor blockchain database, from the genesis block all the way to the current block. However, holding an entire copy of blockchain ledger state, which is continously increasing in size, can be expensive. Hence, two types of nodes, a lite node and an archive node, are defined, as below:

  • A lite node is configured to synchronize with only a few latest blocks of the Bittensor blockchain, and not the entire blockchain. The purpose of a lite node is to serve, with minimal storage requirements, as a local entry point into the Bittensor mainchain or testchain. A lite node's storage is always refreshed with only the latest few blocks from the Bittensor blockchain.

    lite node for a subnet miner

    A subnet miner should use a local lite node to communicate with the Bittensor blockchain.

  • On the other hand, an archive node stores all the Bittensor blockchain blocks from genesis up to the most recent block.

    archive node for a blockchain explorer

    Applications such as Bittensor blockchain explorer, for example, Taostats that require access to historical blockchain data use an archive node.

A public subtensor vs a local blockchain

Note that running a public subtensor node locally, as described above, is not the same as running a local blockchain, also referred as running on staging. When you run a local blockchain, it is for the purposes of developing and testing your subnet incentive mechanism. This local blockchain is not public and hence it is isolated from any Bittensor network. See the below diagram.

Components of Incentive MechanismComponents of Incentive Mechanism

Query archived data

We recommend that you use archive public subtensor node to retrieve blockchain data older than the previous 300 blocks. See the below example:

For example, to sync with a specific block number 12345 that is older than the 300 blocks:

import bittensor as bt
meta = bt.subtensor('archive').metagraph(netuid=18, block=12345)
print(meta)
See also

System requirements

To run a public subtensor, make sure that your computer satisfies the following system requirements:

  • Currently only x86_64 Linux architecture is supported.
  • Subtensor requires approximately ~286 MiB to run.
  • Only Linux OS and macOS are supported.

Linux x86_64

Requirements:

  • Linux kernel 2.6.32+.
  • glibc 2.11+.

macOS x86_64

Requirements:

  • macOS 10.7+

Network requirements and port settings

After you install the subtensor as per the below instructions, make sure that you open network ports on your subtensor node. This will allow other peer subtensor nodes to connect to your subtensor node.

  • Your subtensor node must have access to the public internet.
  • Your subtensor node runs in an IPv4 network.

Port settings

Make sure that your subtensor node listens on the following ports:

  • 9944 - Websocket. This port is used by Bittensor. This port only accepts connections from localhost. Make sure this port is firewalled off from the public internet domain.
  • 9933 - RPC. This port should be opened but it is not used.
  • 30333 - p2p socket. This port should accept connections from other subtensor nodes on the internet. Make sure your firewall allows incoming traffic to this port.
  • We assume that your default outgoing traffic policy is ACCEPT. If not, make sure that outbound traffic on port 30333 is allowed.

Method 1: By compiling the source code

Install basic packages

Install the basic requirements by running the below command on a terminal.

sudo apt install build-essential git make clang libssl-dev llvm libudev-dev protobuf-compiler -y

Install Rust

Next, install Rust and update the environment by running the following commands:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh

Next,

chmod +x rustup-init.sh

Then,

./rustup-init.sh # You can select default options in the prompts you will be given

and finally,

source "$HOME/.cargo/env"

Update rustup

Run the below command:

rustup default stable && \
rustup update && \
rustup update nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly

Compile

Next, compile the subtensor source code. Follow the below steps:

Clone the subtensor repo:

git clone https://github.com/opentensor/subtensor.git

cd into the subtensor directory:

cd subtensor

Compile with cargo:

cargo build --release --features runtime-benchmarks

You can now run the public subtensor node either as a lite node or as an archive node. See below:

Lite node on mainchain

To run a lite node connected to the mainchain, execute the below command:

sudo ./scripts/run/subtensor.sh -e binary --network mainnet --node-type lite

Archive node on mainchain

To run an archive node connected to the mainchain, execute the below command:

sudo ./scripts/run/subtensor.sh -e docker --network mainnet --node-type archive

Lite node on testchain

To run a lite node connected to the testchain, execute the below command:

sudo ./scripts/run/subtensor.sh -e binary --network testnet --node-type lite

Archive node on testchain

To run an archive node connected to the testchain, execute the below command:

sudo ./scripts/run/subtensor.sh -e docker --network testnet --node-type archive

Method 2: Using Docker

Install git

sudo apt install git

Install Docker

Follow Docker's official installation guides.

Clone the subtensor repo

Clone the subtensor repo:

git clone https://github.com/opentensor/subtensor.git

Then cd into the subtensor directory:

cd subtensor
Run Docker first

Before you proceed, make sure that Docker is running.

Lite node on mainchain

To run a lite node connected to the Bittensor mainchain, run the below command.

sudo ./scripts/run/subtensor.sh -e docker --network mainnet --node-type lite

Archive node on mainchain

To run an archive node connected to the Bittensor mainchain, run the below command.

sudo ./scripts/run/subtensor.sh -e docker --network mainnet --node-type archive

Lite node on testchain

To run a lite node connected to the Bittensor testchain, run the below command.

sudo ./scripts/run/subtensor.sh -e docker --network testnet --node-type lite

Archive node on testchain

To run an archive node connected to the Bittensor testchain, run the below command.

sudo ./scripts/run/subtensor.sh -e docker --network testnet --node-type archive

On cloud

Not tested on cloud

We have not tested these installation scripts on any cloud service. In addition, if you are using Runpod cloud service, then note that this service is already containerized. Hence, the only option available to you is to compile from source but these scripts have not been tested on Runpod.