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:
- Find latest tag here:
https://github.com/incognitochain/incognito-chain/tags - 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
- 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
-
Build Incognito binary
go build -o incognito
-
Create tmux session and attach to it:
tmux new -s mainnet_fullnode
tmux attach
-
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=""
- 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
- Wait a few hours to sync blockchain data
- 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:
- 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 &
- Running script:
sudo bash incognito-fullnode.sh
- 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
- Wait a few hours to sync blockchain data
- 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 same as our website https://mainnet.incognito.org/, then your full node is synchronized up to date.
"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.