Skip to main content
SUBMIT A PRSUBMIT AN ISSUElast edit: Jun 28, 2024

Using Source Code

To install and run a subtensor node by compiling the source code, follow the below steps.

Not tested on cloud

We have not tested subtensor node 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 for Runpod is to install a subtensor node by compiling from source, as described below. Note that we have not tested any subtensor installation steps on Runpod.

Install basic packages

Install the basic requirements by running the below commands on a Linux terminal.

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

Install the basic requirements by running the below command on macOS.

macOS
brew install protobuf

Install Rust

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

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env

Next, install Rust toolchain:

rustup default stable
rustup update
rustup target add wasm32-unknown-unknown
rustup toolchain install nightly
rustup target add --toolchain nightly wasm32-unknown-unknown

Compile subtensor code

Next, to compile the subtensor source code, follow the below steps:

  1. Clone the Subtensor repository:
git clone https://github.com/opentensor/subtensor.git
  1. Change to the Subtensor directory:
cd subtensor
  1. Ensure you are on the main branch. If not, switch to it:
git checkout main
  1. Remove any previous chain state:
rm -rf /tmp/blockchain 
  1. Install Subtensor by compiling with Cargo:
cargo build --release --features=runtime-benchmarks

Run the subtensor node

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 (note the --sync=warp flag which runs the subtensor node in lite mode):

With --sync=warp setting, for lite node
./target/release/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=warp --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 64 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9933 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external

Archive node on mainchain

Archive node settings are currently being investigated.

Lite node on testchain

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

With bootnodes set to testnet and --sync=warp setting, for lite node.
./target/release/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=warp --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 64 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9933 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external

Archive node on testchain

Archive node settings are currently being investigated.