Skip to content

Build from Source

Anvil256 — Build from Source

Prerequisites

ComponentToolMin version
ContractsFoundry (forge + cast)0.2.x
CLIRust toolchain1.78
Kernel (NVIDIA)CUDA toolkit (nvcc)12.3
Kernel (AMD/Intel)OpenCL SDK (opencl-headers)3.0
WebsiteNode.js + pnpm20.x

Terminal window
docker run --rm -v $PWD:/src ghcr.io/anvil256/builder:latest
ls dist/ # binaries + sha256sums.txt

The Docker image pins exact compiler versions. The output sha256sums.txt must match the official release. Verify:

Terminal window
sha256sum -c dist/sha256sums.txt

Native Build

Contracts

Terminal window
cd contracts/
forge install # OpenZeppelin, forge-std
forge build # compiles Anvil256.sol + all sub-contracts
forge test -vvv # full test suite + fuzz runs

Key contracts and their role:

ContractRole
Anvil256.solCore: mine(), ERC-20, halving, fee, epoch counter
CascadePoW.solτ + inner + outer Cascade verification
PIController.solPI + NCT combined difficulty update
MinerWindow.sol256-slot circular buffer + uniqueCount + windowFreq
FixedPointMath.solQ60.18, 4th-order Maclaurin exp, O(1) log₂
FeeOracle.solChainlink ETH/USD → fee_wei

CLI

Terminal window
cd cli/
cargo build --release # produces target/release/anvil256-cli
cargo test --release

The CLI is responsible for:

  • Reading γ(miner) = minerEpochCount[address] from the contract
  • Reading epochEntropy from the contract
  • Computing τ = H(miner ∥ γ ∥ genesis) and inner = H(τ ∥ epoch)
  • Dispatching the kernel job with the derived inner value (not the raw address)
  • Watching for epoch transitions and re-dispatching immediately

Kernel — CUDA (NVIDIA)

Terminal window
cd kernel/
make cuda # produces ./miner
make cuda ARCHS="75 80 86 89 90" # fat binary for multiple SM architectures

Kernel — OpenCL (AMD / Intel / fallback)

Terminal window
cd kernel/
make opencl # produces ./miner-opencl

Website

Terminal window
cd website/
pnpm install
pnpm dev # local preview at http://localhost:4321
pnpm build # produces dist/

Cross-Compilation

TargetMethod
linux-x86_64-gnunative or cross Docker
linux-aarch64-gnucross build --target aarch64-unknown-linux-gnu
darwin-arm64on macOS: cargo build --target aarch64-apple-darwin
windows-x64-msvccargo build --target x86_64-pc-windows-msvc

CUDA kernel cross-compilation is not supported. Build natively on the target platform.


Test Coverage Targets

SuiteTargetCritical property verified
CascadePoW.t.sol100% branchTwo-pass correctness; γ-binding rejection
PIController.t.sol100% branchSteady-state convergence; NCT; anti-windup
MinerWindow.t.sol100% branchCircular buffer invariants; uniqueCount accuracy
FixedPointMath.t.sol100% branchexp4 error bound; log2Floor exactness
Fuzz≥ 10,000 runsSupply cap; epoch monotonicity; fee accounting
Integration (CLI)End-to-endγ fetch → kernel → submit → receipt → γ increment