Skip to main content

Purpose and Scope

This document provides detailed instructions for building StableNet from source. It covers the build system architecture, available build targets, and cross-compilation options. For information on configuring a built node, see Node Configuration.
For initializing a new network with a genesis file, see Genesis Setup and Network Initialization.

Prerequisites

Building StableNet from source requires Go 1.22 or later. Additional dependencies required for building:
  • C compiler (gcc or clang) — required for CGO-enabled packages
  • Git — required for embedding version metadata
  • Make (optional, for convenience targets)

Build System Architecture

The StableNet build system is centered around Go-based build scripts that generate node executables, handle build environment detection, and apply shared build logic.

Build System Components

File PathPurpose
build/ci.goMain build orchestrator with subcommands
MakefileConvenience wrapper for common tasks
internal/build/util.goBuild utility functions
internal/build/gotool.goGo toolchain management
internal/build/env.goEnvironment detection (CI/local)
build/checksums.txtDependency checksums for verification

Building from Source

Using Make

StableNet can be built easily using Makefile targets.
git clone https://github.com/stable-net/go-stablenet
cd go-stablenet

# Build only the gstable client
make gstable

# Build only genesis_generator
make genesis_generator

# Build all executables (gstable, abigen, bootnode, evm, rlpdump, clef, genesis_generator, etc.)
make all

# Verify the build
./build/bin/gstable version
All built binaries are created in the build/bin/ directory.

Using build/ci.go Directly

For finer-grained control, you can invoke the build script directly:
# Build only gstable
go run build/ci.go install ./cmd/gstable

# Build for a specific architecture (e.g. ARM64)
go run build/ci.go install -arch arm64 ./cmd/gstable

# Create a statically linked binary (Linux)
go run build/ci.go install -static ./cmd/gstable

# Automatically download the Go version specified in checksums.txt and build
go run build/ci.go install -dlgo ./cmd/gstable

# Build all executables
go run build/ci.go install
Flags available for the install command:
FlagDescription
-dlgoDownload and use a specific Go version from checksums.txt
-archTarget architecture (amd64, 386, arm, arm64)
-ccC compiler for cross-compilation
-staticCreate a statically linked executable (Linux)

Available Build Targets

All executables are built into build/bin/:
ExecutablePurposeSource Path
gstableMain StableNet clientcmd/gstable/
genesis_generatorGenesis file generatorcmd/genesis_generator/
abigenSolidity ABI to Go binding generatorcmd/abigen/
bootnodeLightweight bootstrap nodecmd/bootnode/
evmEVM testing toolcmd/evm/
rlpdumpRLP data structure inspectorcmd/rlpdump/
clefExternal account signercmd/clef/
devp2pP2P network utilitiescmd/devp2p/

Cross-Compilation

The build system supports cross-compilation for multiple architectures and operating systems using Go’s built-in cross-compilation features and external C toolchains.

Supported Platforms

The CI system builds for the following platforms:
PlatformArchitectureNotes
Linuxamd64Default, full support
Linux38632-bit Intel/AMD
LinuxarmARMv5, ARMv6, ARMv7 (GOARM variants)
Linuxarm6464-bit ARM
macOSamd64Intel Macs
macOSarm64Apple Silicon (M1/M2)
Windowsamd6464-bit Windows
Windows38632-bit Windows

Build Verification

After building, run tests to verify correct operation:
# Run quick tests
make test-short

# Run full test suite
make test

# Run lint checks
make lint
The build/ci.go test command supports the following options:
# Coverage report
go run build/ci.go test -coverage ./...

# Race detection
go run build/ci.go test -race ./...

# Verbose output
go run build/ci.go test -v ./...