Sao-Network

Nibiru测试网 Quasar命令结构一样

2 核心;4 GB 内存;硬盘:100GB。

sudo apt update && sudo apt upgrade -y
sudo apt install curl tar wget clang pkg-config libssl-dev jq build-essential manpages-dev git make ncdu -y


echo "安装go"
if ! command -v go > /dev/null; then
  apt-get update
  wget https://go.dev/dl/go1.20.1.linux-amd64.tar.gz
  rm -rf /usr/local/go && tar -C /usr/local -xzf go1.20.1.linux-amd64.tar.gz
  export PATH=$PATH:/usr/local/go/bin
  go version
fi
cat <<'EOF' >>$HOME/.profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source $HOME/.profile

echo "编译"
git clone https://github.com/SaoNetwork/sao-consensus.git
cd sao-consensus
git checkout testnet0
make
#chainID:
saod init NodeName --chain-id=sao-testnet0
#Genesis:
curl -Ls https://ss-t.sao.nodestake.top/genesis.json > $HOME/.sao/config/genesis.json 
#addressbook Sao:
curl -Ls https://ss-t.sao.nodestake.top/addrbook.json > $HOME/.sao/config/addrbook.json

SNAP_NAME=$(curl -s https://ss-t.sao.nodestake.top/ | egrep -o ">20.*\.tar.lz4" | tr -d ">")

curl -o - -L https://ss-t.sao.nodestake.top/${SNAP_NAME}  | lz4 -c -d - | tar -x -C $HOME/.sao

#Add state Sync:
    SNAP_RPC="https://rpc-t.sao.nodestake.top:443"
    LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
    BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000)); \
    TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
    echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH
    sudo systemctl stop saod
    saod tendermint unsafe-reset-all --home ~/.sao/
    sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
    s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
    s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
    s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \
    s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" ~/.sao/config/config.toml
    more ~/.sao/config/config.toml | grep 'rpc_servers'
    more ~/.sao/config/config.toml | grep 'trust_height'
    more ~/.sao/config/config.toml | grep 'trust_hash'

#Add Peer:
PEERS="61e9e3927c1d25d91e8fefbdc880791e7974bfb5@159.223.19.154:27656,4a4c330115ed36bf8a5c8ffbc568d165ee91bd72@207.154.243.48:20656,244c464e3d500ee3f242fa3a10ae50d4cd02fc26@164.90.221.101:26656,d99276e75a528b1e5a40bee3fe41ffe80a3a5b1b@195.3.221.58:47656,59cef823c1a426f15eb9e688287cd1bc2b6ea42d@152.70.126.187:26656,39320c6f494f7e091ce9b40e7ed49b1abb6b6c5d@95.217.57.232:46656"
    sed -i 's|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.sao/config/config.toml

#systemD:
sudo tee /etc/systemd/system/saod.service > /dev/null <<EOF
[Unit]
Description=saod Daemon
After=network-online.target
[Service]
User=$USER
ExecStart=$(which saod) start
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable saod
sudo systemctl restart saod
#log
sudo journalctl -u saod -f --no-hostname -o cat

#Sao:
saod keys add wallet

#recover:
saod keys add wallet --recover

# tin:
cat $HOME/.saod/config/priv_validator_key.json

#synced
saod tx staking create-validator \
--amount=10000000sao \
--pubkey=$(saod tendermint show-validator) \
--moniker="Node & Validator VietNam" \
--identity=1342DBE69C23B662 \
--details="https://t.me/NodeValidatorVietNam" \
--chain-id=sao-testnet0 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--min-self-delegation="1000000" \
--gas="2000000" \
--gas-prices="0.0025sao" \
--from=wallet \
-y

#sync:
saod status 2>&1 | jq .SyncInfo.catching_up
#tại:
saod status 2>&1 | jq .SyncInfo.latest_block_height

使用docker部署,Dockerfile构建镜像,

# Use the official Golang image as the base image
FROM golang:latest

# Install required packages
RUN apt-get update && apt-get install -y \
    git \
    curl \
    build-essential \
    make \
    jq \
    gcc \
    snapd \
    chrony \
    lz4 \
    tmux \
    unzip \
    bc

# Clone the repository and switch to the desired branch
RUN git clone https://github.com/SaoNetwork/sao-consensus.git && \
    cd sao-consensus && \
    git checkout testnet0

# Build and install the project
RUN cd sao-consensus && \
    make && \
    make install
WORKDIR /app
# RUN cd /app
# Set the default command to start the application
COPY script.sh script.sh
RUN chmod +x script.sh
CMD ./script.sh

script.sh代码

#!/bin/bash
saod init NodeName --chain-id="sao-testnet0"
curl -Ls https://ss-t.sao.nodestake.top/genesis.json > $HOME/.sao/config/genesis.json 
$(which saod) start