Skip to content

Instantly share code, notes, and snippets.

@Validatrium
Last active June 29, 2022 11:09
Show Gist options
  • Save Validatrium/9d6cdbcc87aa34db8ef3c98988ae30ae to your computer and use it in GitHub Desktop.
Save Validatrium/9d6cdbcc87aa34db8ef3c98988ae30ae to your computer and use it in GitHub Desktop.

Tutorial created by Validatrium (more info on our projects at validatrium.com)

NOTE: all wallet keys and mnemonics generated in this guide are fake, you should use your own.

keep your mnemonic phrases safe and never provide them to anyone!

Steps:

  1. Prerequires (off docs)
  2. Open Port requirements (default settings)
  3. Installation
  4. Additional links

1. Prerequires (off docs):

  • Ubuntu 20.04 (tested on this OS)
  • CPU: 6 cores
  • RAM: 32GB
  • 4TB+ SSD drive

2. Open Port requirements (default settings):

8090/tcp - external
8899/tcp - external
31270/tcp - external
31271/tcp - internal
31272/tcp - internal
31274/tcp - external
31275/tcp - external

3. Installation

Ken installation

version=v1.8.4
wget https://packages.klaytn.net/klaytn/$version/ken-$version-0-linux-amd64.tar.gz
tar zxf ken-$version-0-linux-amd64.tar.gz
mv ken-linux-amd64/bin/ken /usr/local/bin/ken
rm -rf ken-linux-amd64 ken-$version-0-linux-amd64.tar.gz
ken version

Download snapshot and untar

mkdir -p ~/node/full/klaytn/
wget https://s3.ap-northeast-2.amazonaws.com/klaytn-chaindata/cypress/klaytn-cypress-chaindata-20220628010611.tar.gz
tar -xzvf ~/.klaytn-cypress-chaindata-20220628010611.tar.gz -C ~/node/full/klaytn/

Startup with systemd

sudo tee <<EOF >/dev/null /etc/systemd/system/klaytn.service
[Unit]
Description=daemon
After=network-online.target

[Service]
User=root
ExecStart=/usr/local/bin/ken --cypress --datadir /home/${USER}/node/full/klaytn/ --syncmode full --gcmode full --multichannel --srvtype fasthttp --txpool.exec-slots.all 4096 --txpool.nonexec-slots.all 4096 --txpool.exec-slots.account 4096 --txpool.nonexec-slots.account 4096 --rpc --rpcaddr "localhost" --rpc.concurrencylimit 60000 --rpcapi "debug,klay,eth,personal,rpc,txpool,web3,net" --rpccorsdomain all --rpcvhosts all --ws --wsaddr "localhost" --wsapi "klay,eth,personal,rpc,txpool,web3" --wsorigins all --metrics --prometheus --port 31270 --rpcport 31271 --wsport 31272 --subport 31274 --prometheusport 31275
Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOF

# Enable auto-start when os startup and run klaytn service
sudo systemctl daemon-reload
sudo systemctl enable klaytn
sudo systemctl start klaytn
journalctl -u klaytn.service -f

Check status

# Command klay.syncing and return false means finishing syncing
ken attach ~/node/full/klaytn/klay.ipc
klay.syncing
klay.blockNumber

# Check the status by sending this RPC request
curl --data '{"method":"eth_syncing","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST http://127.0.0.1:31271/

# When the sync ends it should return
{"jsonrpc":"2.0","id":1,"result":false}

HyperNode Installation

# Download the latest version of HyperNode
mkdir ~/HyperNode
cd ~/HyperNode
version=`wget -qO- -t1 -T2 "https://api.github.com/repos/BlockPILabs/testnets/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g'`
wget https://github.com/BlockPILabs/testnets/releases/download/${version}/HyperNode
wget https://github.com/BlockPILabs/testnets/releases/download/${version}/config.yml
chmod +x ./HyperNode
sudo mv ./HyperNode /usr/local/bin/

Initialization node

cd ~/HyperNode
HyperNode init
# [root.go:97] [INFO] [05-12|02:18:57.924] node init                                module=app
# Your new account is locked with a password. Please give a password. Do not forget this password.
# Password: 
# Repeat password: 
# //Input twice,and the keystore file is in ./keystore directory

# Important!
# Next, you need to write down the node password, the public address of the key, secret key file and write the password to a txt file
echo <YOUR_PASSWORD> > ~/HyperNode/passwd.txt

Configure config file

nano ~/HyperNode/config.yml
# You need to bring the file to a similar form and enter your data

api:
    listen: :8899
beacon:
    - 141.95.205.50:9090
chain:
    name: klaytn
    network: "8217"
checksignature: true
fee:
# DO NOT CHANGE THE FOLLOWING LINE:
    baseurl: https://raw.githubusercontent.com/BlockPILabs/FeeConfig
    tag: main
gws:
# DO NOT CHANGE THE FOLLOWING LINE:
    - 0x****************************************
hub:
# DO NOT CHANGE THE FOLLOWING LINE:
    pkey: 0x****************************************
log:
    app:
        cout: true
        level: error
    bclient:
        cout: true
        level: error
    challenge:
        cout: true
        level: error
    rpc:
        cout: true
        level: error
    slb:
        cout: true
        level: error
logger:
    maxage: "1"
    rotationtime: "1"
# ENTER YOUR NAME:
name: "YOUR_NAME"
node:
    addr: http://127.0.0.1:31271
# ENTER THE PUBLIC ADDRESS OF THE KEY:
provider: "0x****************************************"
rpc:
    addr: 0.0.0.0:8060
    grpc: 0.0.0.0:8090
    istlsenabled: false
logger:
    maxage: "2"
    rotationtime: "1"
snapshot:
    packedttl: "1"
    path: ./snapshot

Run HyperNode from systemd file

# You need to specify the path to your key file in the ExecStart field
sudo tee <<EOF >/dev/null /etc/systemd/system/HyperNode.service
[Unit]
Description=daemon
After=network-online.target

[Service]
User=blockpi
WorkingDirectory=/home/blockpi/HyperNode
ExecStart=/usr/local/bin/HyperNode --datadir /home/${USER}/HyperNode --keystore_path /home/${USER}/HyperNode/keystore/UTC--<YOUR_KEY_FILE> --password_path /home/${USER}/HyperNode/passwd.txt
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOF

# Enable auto-start when os startup and run HyperNode service
sudo systemctl daemon-reload
sudo systemctl enable HyperNode
sudo systemctl enable HyperNode
journalctl -u HyperNode.service -f

# Read the program log
tail -f ~/HyperNode/log/HyperNode.log

You should now be able to see your validator from a block explorer like here

4. Additional links

Tutorial created by Validatrium (more info on our projects at validatrium.com)

If you have any additional questions regarding this tutorial, please join BlockPI official discord channel and tag Validatrium members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment