Welcome to the Rust-based implementation of the Kaspa full-node and its ancillary libraries. The contained node release serves as a drop-in replacement to the established Golang node and to date is the recommended node software for the Kaspa network, introducing developers to the possibilities of Rust in the Kaspa network's context.
We invite developers and blockchain enthusiasts to collaborate, test, and optimize our Rust implementation. Each line of code here is an opportunity to contribute to the open-source blockchain movement, shaping a platform designed for scalability and speed without compromising on security and decentralization.
Your feedback, contributions, and issue reports will be integral to evolving this codebase and continuing its maturity as a reliable node in the Kaspa network.
The default branch of this repository is master and new contributions are constantly merged into it. For a stable branch corresponding to the latest stable release please pull and compile the stable branch.
The Crescendo Hardfork took place on May 5, 2025, at approximately 15:00 UTC. The fork has transitioned the network from a blockrate of 1 BPS to that of 10 BPS, and incorporated several major KIPs.
Building on Linux
-
Install general prerequisites
sudo apt install curl git build-essential libssl-dev pkg-config
-
Install Protobuf (required for gRPC)
sudo apt install protobuf-compiler libprotobuf-dev #Required for gRPC -
Install the clang toolchain (required for RocksDB and WASM secp256k1 builds)
sudo apt-get install clang-format clang-tidy \ clang-tools clang clangd libc++-dev \ libc++1 libc++abi-dev libc++abi1 \ libclang-dev libclang1 liblldb-dev \ libllvm-ocaml-dev libomp-dev libomp5 \ lld lldb llvm-dev llvm-runtime \ llvm python3-clang
-
Install the rust toolchain
If you already have rust installed, update it by running:
rustup update -
Install wasm-pack
cargo install wasm-pack
-
Install wasm32 target
rustup target add wasm32-unknown-unknown
-
Clone the repo
git clone https://github.com/kaspanet/rusty-kaspa cd rusty-kaspa
Building on Windows
-
Install Git for Windows or an alternative Git distribution.
-
Install Protocol Buffers and add the
bindirectory to yourPath -
Install LLVM-15.0.6-win64.exe
Add the
bindirectory of the LLVM installation (C:\Program Files\LLVM\bin) to PATHset
LIBCLANG_PATHenvironment variable to point to thebindirectory as wellIMPORTANT: Due to C++ dependency configuration issues, LLVM
ARinstallation on Windows may not function correctly when switching between WASM and native C++ code compilation (nativeRocksDB+secp256k1vs WASM32 builds ofsecp256k1). Unfortunately, manually settingARenvironment variable also confuses C++ build toolchain (it should not be set for native but should be set for WASM32 targets). Currently, the best way to address this, is as follows: after installing LLVM on Windows, go to the targetbininstallation directory and copy or renameLLVM_AR.exetoAR.exe. -
Install the rust toolchain
If you already have rust installed, update it by running:
rustup update -
Install wasm-pack
cargo install wasm-pack
-
Install wasm32 target
rustup target add wasm32-unknown-unknown
-
Clone the repo
git clone https://github.com/kaspanet/rusty-kaspa cd rusty-kaspa
Building on Mac OS
-
Install Protobuf (required for gRPC)
brew install protobuf
-
Install llvm.
The default XCode installation of
llvmdoes not support WASM build targets. To build WASM on MacOS you need to installllvmfrom homebrew (at the time of writing, the llvm version for MacOS is 16.0.1).brew install llvm
NOTE: Homebrew can use different keg installation locations depending on your configuration. For example:
/opt/homebrew/opt/llvm->/opt/homebrew/Cellar/llvm/16.0.1/usr/local/Cellar/llvm/16.0.1
To determine the installation location you can use
brew list llvmcommand and then modify the paths below accordingly:% brew list llvm /usr/local/Cellar/llvm/16.0.1/bin/FileCheck /usr/local/Cellar/llvm/16.0.1/bin/UnicodeNameMappingGenerator ...
If you have
/opt/homebrew/Cellar, then you should be able to use/opt/homebrew/opt/llvm.Add the following to your
~/.zshrcfile:export PATH="/opt/homebrew/opt/llvm/bin:$PATH" export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" export AR=/opt/homebrew/opt/llvm/bin/llvm-ar
Reload the
~/.zshrcfilesource ~/.zshrc
-
Install the rust toolchain
If you already have rust installed, update it by running:
rustup update -
Install wasm-pack
cargo install wasm-pack
-
Install wasm32 target
rustup target add wasm32-unknown-unknown
-
Clone the repo
git clone https://github.com/kaspanet/rusty-kaspa cd rusty-kaspa
Building with Docker
You can build the project using Docker in two ways: a simple single-architecture build, or a multi-architecture build using the provided script.
To build for your current architecture (e.g., linux/amd64):
docker build -f docker/Dockerfile.kaspad -t kaspad:latest .Replace Dockerfile.kaspad with the appropriate Dockerfile for your target (kaspad, kaspa-wallet, rothschild, or simpa).
To build images for multiple architectures (e.g., linux/amd64 and linux/arm64) and optionally push them to a registry, use the build-docker-multi-arch.sh script:
./build-docker-multi-arch.sh --tag <tag> --artifact <artifact> [--arches "<arches>"] [--push]--tag <tag>: (required) The Docker image tag to use.--artifact <artifact>: The build target/artifact (default:kaspad). Must match the Dockerfile name, e.g.,kaspadforDockerfile.kaspad.--arches "<arches>": Space-separated list of architectures (default:"linux/amd64 linux/arm64").--push: If specified, the built images will be pushed to your Docker registry.
Examples:
Build and push a multi-arch image for kaspad:
./build-docker-multi-arch.sh --tag myrepo/kaspad:latest --artifact kaspad --pushBuild a multi-arch image for kaspa-wallet without pushing:
./build-docker-multi-arch.sh --tag kaspa-wallet:test --artifact kaspa-walletNote:
In order to use build-docker-multi-arch.sh, you need Docker with Buildx enabled.
Building WASM32 SDK
Rust WebAssembly (WASM) refers to the use of the Rust programming language to write code that can be compiled into WebAssembly, a binary instruction format that runs in web browsers and NodeJs. This allows for easy development using JavaScript and TypeScript programming languages while retaining the benefits of Rust.
WASM SDK components can be built from sources by running:
- ./build-release - build a full release package (includes both release and debug builds for web and nodejs targets)
- ./build-docs - build TypeScript documentation
- ./build-web - release web build
- ./build-web-dev - development web build
- ./build-nodejs - release nodejs build
- ./build-nodejs-dev - development nodejs build
IMPORTANT: do not use dev builds in production. They are significantly larger, slower and include debug symbols.
- NodeJs (v20+): https://nodejs.org/en
- TypeDoc: https://typedoc.org/
- Release builds: https://github.com/kaspanet/rusty-kaspa/releases
- Developer builds: https://kaspa.aspectron.org/nightly/downloads/
- Developer TypeScript documentation: https://kaspa.aspectron.org/docs/
Kaspa CLI + Wallet
kaspa-cli crate provides a cli-driven RPC interface to the node and a
terminal interface to the Rusty Kaspa Wallet runtime. These wallets are
compatible with WASM SDK Wallet API and Kaspa NG projects.
cd cli
cargo run --releaseLocal Web Wallet
Run an http server inside of wallet/wasm/web folder. If you don't have once, you can use the following:
cd wallet/wasm/web
cargo install basic-http-server
basic-http-serverThe basic-http-server will serve on port 4000 by default, so open your web browser and load http://localhost:4000
The framework is compatible with all major desktop and mobile browsers.
Start a mainnet node
cargo run --release --bin kaspad
# or with UTXO-index enabled (needed when using wallets)
cargo run --release --bin kaspad -- --utxoindexStart a testnet node
cargo run --release --bin kaspad -- --testnetStart a devnet node
Start the DevNet node with the following command:
cargo run --bin kaspad -- --devnet --enable-unsynced-mining --rpclisten=127.0.0.1 --rpclisten-borsh=127.0.0.1 --utxoindexenable-unsynced-miningis required when the network isn't synchronized, which is the case on the first launchuxtoindexenables the UTXO index, which is necessary for wallet functionality.rpclisten-borshandrpclisten-borshare likely to be required by mining softwares
note: it will take a bit of time for difficulty to adjust, so you may need to wait a bit before you see blocks being mined consistently.
Using a configuration file
cargo run --release --bin kaspad -- --configfile /path/to/configfile.toml
# or
cargo run --release --bin kaspad -- -C /path/to/configfile.toml- The config file should be a list of <CLI argument> = <value> separated by newlines.
- Whitespace around the
=is fine,arg=valueandarg = valueare both parsed correctly. - Values with special characters like
.or=will require quoting the value i.e <CLI argument> = "<value>". - Arguments with multiple values should be surrounded with brackets like
addpeer = ["10.0.0.1", "1.2.3.4"].
For example:
testnet = true
utxoindex = false
disable-upnp = true
perf-metrics = true
appdir = "some-dir"
netsuffix = 11
addpeer = ["10.0.0.1", "1.2.3.4"]
Pass the --help flag to view all possible arguments
cargo run --release --bin kaspad -- --helpwRPC
wRPC subsystem is disabled by default in kaspad and can be enabled via:
JSON protocol:
--rpclisten-json=<interface:port>
# or use the defaults for current network
--rpclisten-json=defaultBorsh protocol:
--rpclisten-borsh=<interface:port>
# or use the defaults for current network
--rpclisten-borsh=defaultSidenote:
Rusty Kaspa integrates an optional wRPC subsystem. wRPC is a high-performance, platform-neutral, Rust-centric, WebSocket-framed RPC implementation that can use Borsh and JSON protocol encoding.
JSON protocol messaging is similar to JSON-RPC 1.0, but differs from the specification due to server-side notifications.
Borsh encoding is meant for inter-process communication. When using Borsh both client and server should be built from the same codebase.
JSON protocol is based on Kaspa data structures and is data-structure-version agnostic. You can connect to the JSON endpoint using any WebSocket library. Built-in RPC clients for JavaScript and TypeScript capable of running in web browsers and Node.js are available as a part of the Kaspa WASM framework.
Simulation framework (Simpa)
The current codebase supports a full in-process network simulation, building an actual DAG over virtual time with virtual delay and benchmarking validation time (following the simulation generation).
To see the available commands
cargo run --release --bin simpa -- --helpThe following command will run a simulation to produce 1000 blocks with communication delay of 2 seconds and 8 BPS (blocks per second) while attempting to fill each block with up to 200 transactions.
cargo run --release --bin simpa -- -t=200 -d=2 -b=8 -n=1000Heap Profiling
Heap-profiling in kaspad and simpa can be done by enabling heap feature and profile using the --features argument
cargo run --bin kaspad --profile heap --features=heapIt will produce {bin-name}-heap.json file in the root of the workdir, that can be inspected by the dhat-viewer
Tests
Run unit and most integration tests
cd rusty-kaspa
cargo test --release
// or install nextest and runUsing nextest
cd rusty-kaspa
cargo nextest run --releaseLints
cd rusty-kaspa
./checkBenchmarks
cd rusty-kaspa
cargo benchLogging
Logging in kaspad and simpa can be filtered by either:
-
Defining the environment variable
RUST_LOG -
Adding the --loglevel argument like in the following example:
(cargo run --bin kaspad -- --loglevel info,kaspa_rpc_core=trace,kaspa_grpc_core=trace,consensus=trace,kaspa_core=trace) 2>&1 | tee ~/rusty-kaspa.logIn this command we set the
logleveltoINFO.