Skip to content

Instantly share code, notes, and snippets.

@0fuz
Created August 25, 2022 08:39
Show Gist options
  • Save 0fuz/8993a38019cb54e72dbdf44e2bed6734 to your computer and use it in GitHub Desktop.
Save 0fuz/8993a38019cb54e72dbdf44e2bed6734 to your computer and use it in GitHub Desktop.
Avalanche state-sync node

Positive

  • ~40GB space needed for state
  • Actual X,P,C chains state for recent 100blocks.
  • Really cheap (~30$) to start own state-sync-node compared to BSC full-node (700$+).

Negative

  • Pending transactions is rare event. ~1-10% pending txes will be catched.
  • Not enough to become validator

System requirements:

  • 2+cpu, 2+gb RAM, 60GB sdd.
  • t3.2xlarge, c5.xlarge, m5zn.large is enough.
  • m5zn sync time x2-3 times faster others (clock speed Ghz)

Install dependencies

cd ~
sudo apt update
sudo apt install git golang -y
git clone https://github.com/ava-labs/avalanchego

Compile avalanchego

cd avalanchego
./scripts/build.sh

One time config setup

mkdir -p ~/.avalanchego/configs/chains/C

cat > ~/.avalanchego/configs/node.json <<EOF
{
  "log-level": "trace",
  "http-port": 9650,
  "staking-port": 9651
}
EOF

cat > ~/.avalanchego/configs/chains/C/config.json <<EOF
{
  "state-sync-enabled": true
}
EOF

Start state-sync node light

cd ~/avalanchego/build
nohup ./avalanchego &; disown %1
tail -f nohup.out

Start state-sync node as service

cd ~/avalanchego/build
cat > avax.service <<EOF
[Unit]
  Description=avax
  StartLimitIntervalSec=500
  StartLimitBurst=5

[Service]
  Restart=on-failure
  RestartSec=5s
  WorkingDirectory=/home/ubuntu/avalanchego/build
  ExecStartPre=/bin/chmod +x /home/ubuntu/avalanchego/build/avalanchego
  ExecStart=/home/ubuntu/avalanchego/build/avalanchego
  Type=simple
  User=ubuntu
  KillSignal=SIGINT
  TimeoutStopSec=120

[Install]
  WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable ~/avalanchego/build/avax.service

sudo service avax start
service avax status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment