Skip to main content

Build BBAChain from Source

This guide explains how to build and install BBAChain validator software from source code on your server.

Table of Contents

Prerequisites

Before building BBAChain from source, ensure you have:

  • Server Setup: Your server is configured as described in the configuration guide
  • User Account: You have access to the bbachain user account
  • System Updates: All system packages are up to date
  • Build Tools: Required build dependencies installed (see below)

Required Build Dependencies

Install the required build dependencies:

sudo apt-get update
sudo apt-get install -y build-essential curl git pkg-config libssl-dev

Install Rust

BBAChain is written in Rust, so you need to install Rust and Cargo. BBAChain requires Cargo version 1.59.0.

Step 1: Install Rust

Install Rust using rustup:

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

Step 2: Install Required Cargo Version

BBAChain requires Cargo version 1.59.0. Install this specific version:

rustup install 1.59.0
rustup default 1.59.0

Step 3: Verify Installation

Verify that Rust and Cargo are installed with the correct versions:

rustc --version
cargo --version

You should see output similar to:

rustc 1.59.0 (9d1b2106e 2022-02-23)
cargo 1.59.0 (49d8809dc 2022-02-10)
warning

Important: BBAChain requires Cargo version 1.59.0. Using a different version may cause build errors or compatibility issues.

tip

If you're building as the bbachain user, make sure to install Rust in that user's home directory.

Clone Repository

Step 1: Navigate to Home Directory

Switch to the bbachain user and navigate to the home directory:

sudo su - bbachain
cd ~

Step 2: Clone BBAChain Repository

Clone the BBAChain repository from GitHub:

git clone https://github.com/bbachain/bbachain.git
cd bbachain

This creates a bbachain directory in your home directory with the source code.

Step 3: Check Repository

Verify the repository was cloned successfully:

ls -la
git status

You should see the BBAChain source code files.

Build from Source

Step 1: Navigate to Repository

If you're not already in the repository directory:

cd ~/bbachain

Step 2: Checkout Latest Release (Optional)

For production use, it's recommended to checkout a specific release tag:

# List available tags
git tag -l

# Checkout latest stable release (replace with actual tag)
git checkout v1.0.0
info

For development or testing, you can use the main branch. For production, always use a stable release tag.

Step 3: Build Validator

Build the BBAChain validator from source:

cargo build --release

This command:

  • Compiles the BBAChain validator software
  • Creates optimized release binaries
  • May take 30-60 minutes depending on your hardware
tip

The --release flag creates optimized binaries suitable for production use. For faster builds during development, you can use cargo build without the --release flag.

Step 4: Monitor Build Progress

The build process will show progress. You can monitor it in real-time. The build will download dependencies and compile the code.

Expected Output:

   Compiling bbachain v1.0.0 (/home/bbachain/bbachain)
...
Finished release [optimized] target(s) in 25m 30s

Install Validator

Step 1: Locate Built Binaries

After the build completes, the binaries will be in:

ls -lh ~/bbachain/target/release/

You should see binaries like:

  • bbachain-validator - The validator node software
  • bbachain - CLI tools
  • bbachain-keygen - Keypair generation tool

Step 2: Install Binaries

Install the binaries to a system-wide location:

# Create installation directory
sudo mkdir -p /usr/local/bin

# Copy binaries
sudo cp ~/bbachain/target/release/bbachain-validator /usr/local/bin/
sudo cp ~/bbachain/target/release/bbachain /usr/local/bin/
sudo cp ~/bbachain/target/release/bbachain-keygen /usr/local/bin/

# Set permissions
sudo chmod +x /usr/local/bin/bbachain-validator
sudo chmod +x /usr/local/bin/bbachain
sudo chmod +x /usr/local/bin/bbachain-keygen

Step 3: Verify PATH

Ensure /usr/local/bin is in your PATH:

echo $PATH | grep /usr/local/bin

If not, add it to your shell profile:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Verify Installation

Step 1: Check Validator Version

Verify the validator software is installed correctly:

bbachain-validator --version

You should see output similar to:

bbachain-validator 1.0.0

Step 2: Check CLI Version

Verify the CLI tools are installed:

bbachain --version

Expected output:

bbachain-cli 1.0.0

Step 3: Check Keygen Version

Verify the keygen tool is installed:

bbachain-keygen --version

Expected output:

bbachain-keygen 1.0.0

Step 4: Test CLI Commands

Test that the CLI is working correctly:

bbachain --help

This should display the available commands and options.

success

Success! If all version commands work correctly, you have successfully built and installed BBAChain from source.

Alternative: Install from Pre-built Binaries

If you prefer not to build from source, you can download pre-built binaries:

# Download latest release (example)
wget https://github.com/bbachain/bbachain/releases/download/v1.0.0/bbachain-validator-linux-x86_64
chmod +x bbachain-validator-linux-x86_64
sudo mv bbachain-validator-linux-x86_64 /usr/local/bin/bbachain-validator
info

Check the GitHub releases page for the latest pre-built binaries.

Next Steps

Now that you have successfully built and installed BBAChain (including CLI and keygen tools):

  1. Generate keypairs: Create the required keypairs for your validator
  2. Start validator: Begin running your validator node (see next guide)
  3. Monitor validator: Set up monitoring and health checks for your validator node

Troubleshooting

Build Errors

If you encounter build errors:

  1. Check Cargo Version:

    cargo --version

    Ensure you have Cargo version 1.59.0 (required for BBAChain).

  2. Install Correct Version:

    If you have a different version, install the required version:

    rustup install 1.59.0
    rustup default 1.59.0
  3. Verify Version:

    cargo --version

    You should see: cargo 1.59.0

  4. Clean Build:

    cd ~/bbachain
    cargo clean
    cargo build --release

Missing Dependencies

If you get dependency errors:

sudo apt-get update
sudo apt-get install -y build-essential curl git pkg-config libssl-dev

Permission Issues

If you encounter permission issues:

  • Ensure you're using the bbachain user for building
  • Use sudo only when installing to system directories
  • Check file permissions on binaries

Build Takes Too Long

If the build is taking too long:

  • Ensure you have sufficient CPU cores (build uses parallel compilation)
  • Check available RAM (build requires significant memory)
  • Consider using pre-built binaries for faster setup

Version Command Not Found

If bbachain --version doesn't work:

  1. Check Installation:

    ls -la /usr/local/bin/bbachain*
  2. Check PATH:

    echo $PATH
    which bbachain
  3. Reinstall:

    sudo cp ~/bbachain/target/release/bbachain /usr/local/bin/
    sudo chmod +x /usr/local/bin/bbachain

Next Steps: After verifying the installation, proceed to generate keypairs for your validator.