How to run Incognito Chain Full Node on Mainnet

Hello everyone,

This tutorial is for anyone in the community who would like to build pApps.

The full node contains data of all Incognito Shards and Beacons which help validate and relay new transactions to corresponding shards, as well as fetching account balance, etc.

If you haven’t already, I recommend you read this post first: How to run Incognito Blockchain on your local server


There are two ways to accomplish this:

Method 1 - build and run from code:

  1. Find latest tag here:
    https://github.com/incognitochain/incognito-chain/tags
  2. Clone repo and checkout tag
    git clone https://github.com/incognitochain/incognito-chain.git
    cd incognito-chain
    git checkout mainnet_20210426_1
step 2 deprecated. Keylist already included in config/ folder
  1. Copy keylist-mainnet.json to keylist.json and also keylist-v2.json:
    cp -f keylist-mainnet.json keylist.json
    cp -f keylist-mainnet-v2.json keylist-v2.json
  1. Build Incognito binary
    go build -o incognito

  2. Create tmux session and attach to it:
    tmux new -s mainnet_fullnode
    tmux attach

  3. Register an Infura account copy endpoints of mainnet, set the local environment variable:

export GETH_NAME="mainnet.infura.io/v3/12047eb6d7e6439fa3449d00c769XXXX"
export GETH_PROTOCOL=https
export GETH_PORT=""
  1. Enable multi access to database and then run Incognito Fullnode
ulimit -Sn 10000
./incognito --discoverpeersaddress "mainnet-bootnode.incognito.org:9330" --testnet false --relayshards "all" --datadir "data/full_node" --listen "0.0.0.0:9433" --externaladdress "0.0.0.0:9433" --norpcauth --rpclisten "0.0.0.0:9334" --rpcwslisten 0.0.0.0:19334 --txpoolmaxtx 100000 --loglevel debug 2>&1 | tee fullnode_mainnet.log
  1. Wait a few hours to sync blockchain data
  2. Send request getblockchaininfo to your fullnode
  • Request:
curl -s --header "Content-Type: application/json" \
  --request GET \
  --data '{ "id": 1, "jsonrpc": "1.0", "method": "getblockchaininfo", "params": []}' \
  http://localhost:9334 | grep Height
  • Response: If the response’s block-height is the same as what is shown on the website https://mainnet.incognito.org/, then your full node is synchronized and up to date.
				"Height": 2356944,
				"Height": 2348242,
				"Height": 2351783,
				"Height": 2350636,
				"Height": 2347362,
				"Height": 2347332,
				"Height": 2344263,
				"Height": 2348354,
				"Height": 2347212,

Method 2 - running Full Node from official Incognito Docker:

  1. Save this script as incognito-fullnode.sh
#!/bin/sh bash
run()
{
  validator_key=xxx
  bootnode="mainnet-bootnode.incognito.org:9330"
  latest_tag=$1
  current_tag=$2
  data_dir="data_fullnode"

  docker -v || bash -c "wget -qO- https://get.docker.com/ | sh"

  docker stop inc_mainnet_fullnode
  docker rm -f inc_mainnet_fullnode

  if [ "$current_tag" != "" ]
  then
    docker image rm -f incognitochain/incognito-mainnet:"${current_tag}"
  fi

  docker pull incognitochain/incognito-mainnet:"${latest_tag}"

  docker run --restart=always -p 9334:9334 -p 9433:9433 -p 19334:19334 -e BOOTNODE_IP=$bootnode -e FULLNODE=1 -e MININGKEY=${validator_key} -e TESTNET=false -v "$PWD"/${data_dir}:/data -d --name inc_mainnet_fullnode incognitochain/incognito-mainnet:"${latest_tag}"

}

# kill existing run.sh processes
ps aux | grep '[i]ncognito-fullnode.sh' | awk '{ print $2}' | grep -v "^$$\$" | xargs kill -9
current_latest_tag=$(docker ps  | awk '{print $2}' | grep "incognito-mainnet")

while [ 1 = 1 ]
do
  tags=$(curl -s -X GET https://hub.docker.com/v2/namespaces/incognitochain/repositories/incognito-mainnet/tags?page_size=100 | jq '.results[].name' | tr -d "\"")
  IFS=$'\n'
  sorted_tags=($(sort -nr <<< "${tags[*]}"))
  latest_tag=${sorted_tags[0]}
  unset IFS

  if [ "$current_latest_tag" != "$latest_tag" ]
  then
    run $latest_tag "$current_latest_tag"
    current_latest_tag=$latest_tag
  fi
  sleep 3600s
done &
  1. Running script: sudo bash incognito-fullnode.sh
  2. Double check your docker container:
khanhlh@staking-khanhle:~$ docker ps | grep incognito
7b2d7a5e3c95        incognitochain/incognito-mainnet:20220921_1   "/bin/sh run_incogni…"   About a minute ago   Up 58 seconds       0.0.0.0:9334->9334/tcp, 0.0.0.0:9433->9433/tcp   inc_mainnet_fullnode
  1. Wait a few hours to sync blockchain data
  2. Send request getblockchaininfo to your fullnode
  • Request:
curl -s --header "Content-Type: application/json" \
  --request GET \
  --data '{ "id": 1, "jsonrpc": "1.0", "method": "getblockchaininfo", "params": []}' \
  http://localhost:9334 | grep Height
				"Height": 2356944,
				"Height": 2348242,
				"Height": 2351783,
				"Height": 2350636,
				"Height": 2347362,
				"Height": 2347332,
				"Height": 2344263,
				"Height": 2348354,
				"Height": 2347212,


PS. You can also try these RPCs with your new Full Node.

Any questions? Post them below.

16 Likes

Hi,

I’d like to build and run a node but

$ git checkout dbv2_20200330_1
error: pathspec 'dbv2_20200330_1' did not match any file(s) known to git

What tag/commit hash should I checkout? As a validator, how will I know when to update the code going forward?

@3ncrypt3d,

It could be this tag was deleted. Please try these command:

git fetch -a
git checkout mainnet_20200416_1

If you try method 2, this one is latest image:
incognitochain/incognito-mainnet:20200416_1


I’m updating 1st post as well

1 Like

Hi @khanhj,

I have two questions.
1- Is the first post still up-to-date? :slight_smile:
2- Is using my validator node (I mean process, not hardware) as a full node OK? Or should I use two separate accounts for validator node and full node?

Thanks.

Hey @abduraman,

How you doing?
Check my responses below:
2 - You can run them both (2 processes) on same server. Actually the fullnode doesn’t require validator key

./incognito --discoverpeersaddress "mainnet-bootnode.incognito.org:9330" --testnet false --nodemode "relay" --relayshards "all" --datadir "data/full_node" --listen "0.0.0.0:9433" --externaladdress "0.0.0.0:9433" --norpcauth --rpclisten "0.0.0.0:9334" --txpoolmaxtx 100000 --loglevel debug

1 - My Answer:
Method 1:
Step1: get latest tag mainnet_20200910_1

image

Step2: add keylist-v2.json

cp ./keylist-mainnet-v2.json ./keylist-v2.json

Method2: Still up to date

Again, feel free to ask us if you have any problems.

1 Like

1st post updated

1 Like

So can I remove “validator_key” from the script? Does it also mean that a full node cannot be a validator node? I mean that I cannot use a “single process” for both validator and full node, can’t I? @khanhj

Thanks. I hope you are well.

Fullnode accept incoming request from wallet app or RPC. It’s still validate transaction but not sending vote to committee to submit new blocks.
Fullnode contain all data of all shards and beacon, that why you need fullnode to check balance, check your validator status.

A validator contains specific data of a shard that its current mining (send vote, validate block). Example: a validator of shard2 only have data of shard 2.

these 2 need to run separated processes as the command to run them is different.

1 Like

This means that I cannot earn the block rewards via a full node. This is what I look for. I was looking for whether I could save some CPU/memory :slight_smile: Thanks.

1 Like

Hey @khanj,

My full-node is synchronizing now. I want to share my experience step-by-step for method1.

After cloning, before checkout, “cd incognito-chain” is required :slight_smile:

This requires at least go 1.14. I initially used go 1.10 which did not work. I built the code via go 1.15.2. In addition, package dependency issues may arise. In that case, go get ./... can be used to install dependencies.

1 Like

great, i will update my post

1 Like

Hi again @khanhj ,

I checked the last state just now. The process exited 7-8 hours ago by raising “panic: Database is corrupt”. I started the application and it continues from the height at which it stops. I sent RPC and websocket calls and they work. However, it seems that method1 is not fault-tolerant since it doesn’t benefit from docker features. Could you add those steps for method1, too?

Thanks.

Oops. While I was writing the post above, it crashed once again. This time I send the log file via PM.

Update: Fully crashed. Does not restart anymore. Sent its log, too.

Did you manage to resolve this in the end?

3 Likes

i you use method 1 to run your fullnode, you need to enter this command: ulimit -Sn 10000

example:

shindo@dell:~/Projects/incognito/incognito-chain$ ulimit -Sn 10000
2 Likes

Great stuff, so far so good!

2 Likes

We were communicating with @khanhj at Telegram. Yes, I’ve solved it by applying method 1 after running ulimit command as Khanh wrote.

1 Like

Hello. What are the minimum requirements for the VPS in order to run the full node well?

1 Like

Hey @J053,

If you use this fullnode to serve around 10 devices, I think a server with 4CPUs and 4GBs RAM, 128GB of SSD, will working well.

2 Likes

I tried Method 1, and on step 6 I get the following error:

“tee: fullnode_mainnet.log: Permission denied
-bash: ./incognito: No such file or directory”

Anyone know what I did wrong?