Installing a Mining Node
Mining nodes in the AIBlock system can be installed in one of two ways:
- Docker container
- Built from source
The Docker container is still currently being built, so for now you'll need to build from source in order to start mining.
..
Docker Container
⚠️ Running docker on your machine will get you up and running quickly but should not be considered production level. This requires a lot more orchestration that is not in scope of this document.
Running a mining node through Docker can be done through two main methods:
Running Docker directly
The Docker image for the miner node is available here:
ghcr.io/aiblockofficial/network/node-miner:latest
You can run the container from the image directly:
docker run -d -p --name aiblock-miner 3000:3000 \
-v ./miner:/src \
-v ./node_settings.toml:/etc/node_settings.toml \
-e ADDRESS="127.0.0.1:12340" \
-e WITH_USER_INDEX="127.0.0.1:12350" \
ghcr.io/aiblockofficial/network/node-miner:latest miner
-p 3000:3000
sets ports used for the miner's REST API.-v ./miner:/src
mounts your local filesystem so the miner's wallet may be persisted.-e ADDRESS
sets the ip:port of the node. If more than one node will be running from the same IP address, the port number has to be different for each node.-e WITH_USER_INDEX
also starts a miner node with a wallet to hold the tokens.
You might also need to run with --user
on some Linux systems for mounting permission purposes.
Using docker-compose
You can clone docker-compose.yml
files from the Docker nodes repo at: https://github.com/AIBlockOfficial/DockerNodes.
From the DockerNodes
folder you can cd miner-node
, and then run docker-compose up -d
for detached mode and inspect the logs using docker-compose logs --follow
. The miner node will
use the node_settings.toml
in the folder for all the settings that would normally be declared manually in a direct run.
..
Build from Source
To build a mining node from source, you can implement the following steps:
Setup
The AIBlock Network runs on Rust, so installing this is the first step before dealing with any code. You can install rustup
, Rust's toolchain installer, by running the following:
curl https://sh.rustup.rs -sSf | sh
When asked how to proceed, simply selecting the option 1) Proceed with installation
is generally the best. You can then run the following to update the PATH
variable and check whether everything installed correctly:
source $HOME/.cargo/env
rustc --version
If the terminal responds with the rustc
version you're currently running then everything went well, and you're ready to go.
Linux
Linux (Ubuntu 20.04.01 LTS) may require extra package installations depending on what you've developed before. The following package installs assume a completely new machine instance, and should cover everything you need to get going:
sudo apt install build-essential
sudo apt-get install m4
sudo apt-get install llvm
sudo apt-get install libclang-dev
The above should enable you to install librocksdb-sys
successfully, but older versions of this crate had bugs so it would be wise to ensure you've installed rocksdb = "0.21.0"
or higher in order to avoid compilation issues.
Mining Node Build
With the prerequisites set up, you can now clone the repo to your local machine:
git clone [email protected]:AIBlockOfficial/Network.git
You can then build everything by running
cargo build --release
This will compile everything into a release state, from which you can then run the following to connect to the Playground testnet to mine:
RUST_LOG=warp target/release/node miner --config=src/bin/node_settings_playground.toml --api_use_tls=0 --with_miner_index=0`