Skip to content

Latest commit

 

History

History
180 lines (131 loc) · 3.35 KB

local-environment-setup.md

File metadata and controls

180 lines (131 loc) · 3.35 KB

Local Development Environment Guide for Shardeum

This guide provides detailed instructions for setting up a local development environment for Shardeum.

Table of Contents

Environment Setup

To run a Shardeum network for local development, you need to configure your machine to spin up local validator, archiver, and monitor servers.

Node.js and NVM

Shardeum requires Node.js version 18.16.1 and npm version 9.5.1. We recommend using Node Version Manager (NVM) to manage multiple Node.js versions.

  1. Install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
  1. Set NVM directory:
export NVM_DIR="$HOME/.nvm"
  1. Add the following to your .bashrc or .bash_profile:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
  1. Install and use the correct Node.js version
nvm install 18.16.1
nvm use 18.16.1

Rust Toolchain

  1. Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Import Rust environment variables:
source "$HOME/.cargo/env"
  1. Install and set the correct Rust version:
rustup install 1.74.1
rustup default 1.74.1

Build Essentials

For Linux:

sudo apt-get install build-essential

For MacOS:

brew install gcc

Node-gyp

  1. Install node-gyp globally:
npm i -g node-gyp
  1. Configure Python version:
npm config set python `which python3`
  1. Verify the configuration:
npm config list

Project Setup

  1. Clone the repository:
git clone https://github.com/shardeum/shardeum.git
cd shardeum
  1. Install project dependencies:
npm ci
  1. Compile the project:
npm run prepare
  1. Install the Shardus CLI:
npm install -g shardus
npm update @shardus/archiver

Network Configuration

You can configure the Shardeum network for local development using either the automatic or manual mode.

Automatic Mode

Apply a pre-configured patch:

git apply debug-10-nodes.patch

Manual Mode

  1. Configure Debug Mode in src/config/index.ts
forceBogonFilteringOn: false,
mode: 'debug'
  1. Modify flags in src/shardeum/shardeumFlags.ts:
txBalancePreCheck: false,
StakingEnabled: false
  1. Adjust settings for local testing:
// src/config/index.ts
cycleDuration: 30,

// src/shardeum/shardeumFlags.ts
blockProductionRate: 3,
  1. Recompile the project:
npm run prepare

Running the Network

Start a Shardeum network with 10 nodes:

shardus start 10

Stopping and Cleaning Up

To stop the network and clean up resources:

shardus stop && shardus clean && rm -rf instances

This guide should help you set up and run a local Shardeum network for development purposes. If you encounter any issues, please refer to our community resources or open an issue on this repo.