Loading...

Install dependencies

Update system and install build tools
sudo apt update && sudo apt upgrade -y
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y
Install Go
cd $HOME
sudo rm -rf /usr/local/go
wget https://go.dev/dl/go1.21.11.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.11.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile
source ~/.bash_profile
[ ! -d ~/go/bin ] && mkdir -p ~/go/bin
go version
which go
rm -rf go1.21.11.linux-amd64.tar.gz

Download and build binary

Clone project repository
cd $HOME
rm -rf v4-chain
git clone https://github.com/dydxprotocol/v4-chain
cd v4-chain
git checkout v5.2.0
make install
dydxprotocold version
which dydxprotocold
Or download directly binary
wget -O dydxprotocold https://snapshots.tienthuattoan.com/mainnet/dydx/dydxprotocold && mv dydxprotocold $HOME/go/bin

Initialize the node

Set node configuration
dydxprotocold config chain-id dydx-mainnet-1
Initialize the node
dydxprotocold init you-node-name --chain-id dydx-mainnet-1
Download genesis and addrbook
curl -Ls https://snapshots.tienthuattoan.com/mainnet/dydx/genesis.json > $HOME/.dydxprotocol/config/genesis.json
curl -Ls https://snapshots.tienthuattoan.com/mainnet/dydx/addrbook.json > $HOME/.dydxprotocol/config/addrbook.json
Add seed
sed -i -e "s|^seeds *=.*|seeds = \"5272b3c1e877e1f025fcdf9dd3857d00452e09e1@dydx-mainnet-rpc.tienthuattoan.com:31656\"|" $HOME/.dydxprotocol/config/config.toml
Set minimum gas price
sed -i -e "s|^minimum-gas-prices *=.*|minimum-gas-prices = \"12500000000adydx\"|" $HOME/.dydxprotocol/config/app.toml
Update pruning and disable indexer to save disk space
sed -i \
  -e 's|^pruning *=.*|pruning = "custom"|' \
  -e 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|' \
  -e 's|^pruning-keep-every *=.*|pruning-keep-every = "0"|' \
  -e 's|^pruning-interval *=.*|pruning-interval = "10"|' \
  $HOME/.dydxprotocol/config/app.toml

sed -i 's/indexer = "kv"/indexer = "null"/g' $HOME/.dydxprotocol/config/config.toml

Download Snapshot

wget -O dydx_latest.tar.lz4 https://snapshots.tienthuattoan.com/mainnet/dydx/dydx_latest.tar.lz4 && lz4 -c -d dydx_latest.tar.lz4 | tar -x -C $HOME/.dydxprotocol

Create service

sudo tee </dev/null /etc/systemd/system/dydxprotocold.service
[Unit]
Description=dYdX node service
After=network-online.target
[Service]
User=$USER
ExecStart=$(which dydxprotocold) start
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
Start the service and check the logs
sudo systemctl daemon-reload
sudo systemctl enable dydxprotocold
sudo systemctl restart dydxprotocold
sudo journalctl -u dydxprotocold -f