yihau / solana-local-cluster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Solana Local Cluster

A step-by-step guide for starting a local cluster.

Get Started

I will use docker to simulate environments in this reposotory. You definitely can use real machines to do it. Just remember to replace these IPs to yours

--gossip-host 192.168.0.101 \

solana -u http://192.168.0.101:8899 airdrop 500 id.json
solana -u http://192.168.0.101:8899 create-vote-account --allow-unsafe-authorized-withdrawer vote.json id.json id.json -k id.json
solana -u http://192.168.0.101:8899 create-stake-account stake.json 1.00228288 -k id.json
solana -u http://192.168.0.101:8899 delegate-stake stake.json vote.json --force -k id.json

--entrypoint 192.168.0.101:8001 \
--rpc-faucet-address 192.168.0.101:9900 \

Prequest

setup

follow https://docs.solana.com/running-validator/validator-start#system-tuning

Docker

Clone this repo

git clone https://github.com/yihau/solana-local-cluster.git

Create a network

docker network create --driver=bridge --subnet=192.168.0.0/8 solana-cluster

Create two nodes

docker run -it --name validator-1 --network=solana-cluster --ip=192.168.0.101 ubuntu:20.04 bash
docker run -it --name validator-2 --network=solana-cluster --ip=192.168.0.102 ubuntu:20.04 bash

Setup

copy workspace into containers
docker cp workspace validator-1:/workspace
docker cp workspace validator-2:/workspace
install dependencies for containers
apt update && apt install curl -y && sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)" && export PATH="/root/.local/share/solana/install/active_release/bin:$PATH"

Start a bootstarp validator

switch to validator-1 container

cd workspace && ./start-bootstrap-validator.sh

you can use these commands to check the cluster status

solana -ul validators
solana -ul gossip

(If it doesn't look correct, maybe there is some information in /workspace/logs)

Start a validator

switch to validator-2 container

cd workspace && ./start-validator.sh

You can switch back to validator-1 and check cluster status to know if `validator-2`` has cme on board

Additional Details

SPL programs

If you want to start a cluster that includes the SPL programs, you can

  1. fetch spl programs
cd workspace && bash <(curl -s https://raw.githubusercontent.com/solana-labs/solana/v1.16/fetch-spl.sh)
  1. it will generate a file called spl-genesis-args.sh. Add it to generate-genesis.sh like
solana-genesis \
  --enable-warmup-epochs \
  --bootstrap-validator id.json vote.json stake.json \
  --bootstrap-validator-stake-lamports 10002282880 \
  --max-genesis-archive-unpacked-size 1073741824 \
  --faucet-pubkey faucet.json \
  --faucet-lamports 500000000000000000 \
  --hashes-per-tick auto \
  --cluster-type development \
+ $(cat spl-genesis-args.sh) \
  --ledger ledger
  1. now you can start a cluster with SPL programs

About

License:MIT License


Languages

Language:Shell 100.0%