Skip to content

Vecno-Foundation/vecnod

Repository files navigation

Vecnod

Welcome to the Rust-based implementation of the Vecno full-node and its ancillary libraries.

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 Vecno blockchain.

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.

Recommended Hardware Specifications

  • Minimum:

    • 8 CPU cores
    • 16 GB RAM
    • 256 GB SSD
    • 5 MB/s (or ~40 Mbit/s) network bandwidth
  • Preferred for Higher Performance:

    • 12–16 CPU cores
    • 32 GB RAM
    • 512 GB SSD
    • Higher network bandwidth for robust peer support

While the minimum specs suffice to sync and maintain a 1 bps node, increasing CPU cores, RAM, storage, and bandwidth allows your node to serve as a stronger focal point on the network. This leads to faster initial block download (IBD) for peers syncing from your node and provides more leeway for future storage growth and optimization.

If you are a pool operator, it is strongly recommended that you pick specs that are closer to the preferred specifications above.

Installation

Building on Linux
  1. Install general prerequisites

    sudo apt install curl git build-essential libssl-dev pkg-config
  2. Install Protobuf (required for gRPC)

    sudo apt install protobuf-compiler libprotobuf-dev #Required for gRPC
  3. 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
  4. Install the rust toolchain

    If you already have rust installed, update it by running: rustup update

  5. Install wasm-pack

    cargo install wasm-pack
  6. Install wasm32 target

    rustup target add wasm32-unknown-unknown
  7. Clone the repo

    git clone https://github.com/Vecno-Foundation/vecnod
    cd vecnod
Building on Windows
  1. Install Git for Windows or an alternative Git distribution.

  2. Install Protocol Buffers and add the bin directory to your Path

  3. Install LLVM-15.0.6-win64.exe

    Add the bin directory of the LLVM installation (C:\Program Files\LLVM\bin) to PATH

    set LIBCLANG_PATH environment variable to point to the bin directory as well

    IMPORTANT: Due to C++ dependency configuration issues, LLVM AR installation on Windows may not function correctly when switching between WASM and native C++ code compilation (native RocksDB+secp256k1 vs WASM32 builds of secp256k1). Unfortunately, manually setting AR environment 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 target bin installation directory and copy or rename LLVM_AR.exe to AR.exe.

  4. Install the rust toolchain

    If you already have rust installed, update it by running: rustup update

  5. Install wasm-pack

    cargo install wasm-pack
  6. Install wasm32 target

    rustup target add wasm32-unknown-unknown
  7. Clone the repo

    git clone https://github.com/Vecno-Foundation/vecnod
    cd vecnod
Building on Mac OS
  1. Install Protobuf (required for gRPC)

    brew install protobuf
  2. Install llvm.

    The default XCode installation of llvm does not support WASM build targets. To build WASM on MacOS you need to install llvm from 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 llvm command 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 ~/.zshrc file:

    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 ~/.zshrc file

    source ~/.zshrc
  3. Install the rust toolchain

    If you already have rust installed, update it by running: rustup update

  4. Install wasm-pack

    cargo install wasm-pack
  5. Install wasm32 target

    rustup target add wasm32-unknown-unknown
  6. Clone the repo

    git clone https://github.com/Vecno-Foundation/vecnod
    cd vecnod
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.

Requirements

Builds & documentation

Vecno CLI + Wallet

vecno-cli crate provides a cli-driven RPC interface to the node and a terminal interface to the Vecno Wallet runtime. These wallets are compatible with WASM SDK Wallet API

cd cli
cargo run --release
Local 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-server

The 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.

Running the node

Start a mainnet node

  cargo run --release --bin vecnod
  # or with UTXO-index enabled (needed when using wallets)
  cargo run --release --bin vecnod -- --utxoindex

Start a testnet node

cargo run --release --bin vecnod -- --testnet

Leave this process running. Closing it will stop your node. If you have other flags that you use for your current node, you may continue to use those.

  • Advanced Command-Line Options:
    • --disable-upnp if you don't want your node to be automatically publicly connectable (if your router supports UPnP). Recommended for pools and exchanges.
    • --rpclisten=0.0.0.0 to listen for RPC connections on all network interfaces (public RPC). Use --rpclisten=127.0.0.1 if you are running your pool/exchange software on the same machine
    • --rpclisten-borsh for local borsh RPC access from the vecno-cli binary.
    • --unsaferpc for allowing P2P peer query and management via RPC (recommended to use only if not exposing RPC publicly).
    • --perf-metrics --loglevel=info,vecnod_lib::daemon=debug,vecno_mining::monitor=debug for detailed performance logs.
    • --loglevel=vecno_grpc_server=warn for suppressing most RPC connect/disconnect log reports.
    • --ram-scale=3.0 for increasing cache size threefold (relevant for utilizing large RAM; can be set between 0.1 and 10).
Using a configuration file
cargo run --release --bin vecnod -- --configfile /path/to/configfile.toml
# or
cargo run --release --bin vecnod -- -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=value and arg = value are 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 vecnod -- --help
wRPC

wRPC subsystem is disabled by default in vecnod and can be enabled via:

JSON protocol:

  --rpclisten-json=<interface:port>
  # or use the defaults for current network
  --rpclisten-json=default

Borsh protocol:

  --rpclisten-borsh=<interface:port>
  # or use the defaults for current network
  --rpclisten-borsh=default

Sidenote:

Vecno 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 Vecno 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 Vecno WASM framework.

Benchmarking & Testing

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 -- --help

The 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=1000
Heap Profiling

Heap-profiling in vecnod and simpa can be done by enabling heap feature and profile using the --features argument

cargo run --bin vecnod --profile heap --features=heap

It 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 vecnod
cargo test --release
// or install nextest and run

Using nextest

cd vecnod
cargo nextest run --release
Lints
cd vecnd
./check
Benchmarks
cd vecnod
cargo bench
Logging

Logging in vecnod and simpa can be filtered by either:

  1. Defining the environment variable RUST_LOG

  2. Adding the --loglevel argument like in the following example:

    (cargo run --bin vecnod -- --loglevel info,vecno_rpc_core=trace,vecno_grpc_core=trace,consensus=trace,vecno_core=trace) 2>&1 | tee ~/vecnod.log
    

    In this command we set the loglevel to INFO.