docker image incognitochain/incognito-mainnet run script

I’ve noticed there is a problem in the start script of the mainnet container. The script run_incognito.sh has an “autodetect” of the public IP that is not always correct:

if [ -z "$PUBLIC_IP" ]; then
    PUBLIC_IP=`dig -4 @resolver1.opendns.com ANY myip.opendns.com +short`;
fi

It uses a dns query with record type ANY (255) the doesn’t guarantee a response if such a record is not cached:
List of DNS record types

I think is better to query for an A record type:

if [ -z "$PUBLIC_IP" ]; then
    PUBLIC_IP=`dig -4 @resolver1.opendns.com A myip.opendns.com. +short`;
fi

This also causes the logfiles in the data directory to be named like this (beginning with a dash) when there is no response from dns:

-2021-01-21.log                                                                                                                      
-2021-01-22.log                                                                                                                      
-2021-01-23.log                                           
1 Like

Hey,

I dont know from where your get that run_incognito.sh but this is mine:

[email protected]:~$ cat run.sh 
#!/bin/sh bash

run()
{
  validator_key1=12bWyt99n5bWKPWydPtd6Fyxy9L4rtULCcBKCxQsSSXXXXXXXX
  validator_key2=12KwfRWNgDXrCFK8WMrcaLs8ZaDe1AWjiNyuLzLfXXXXXXXXXX
  validator_key3=1zd19gLoqgB1QzqwBTN4YWAPDVdeBh71EeixF1TAXXXXXXXXXX
  
  bootnode="mainnet-bootnode.incognito.org:9330"
  is_shipping_logs=0
  latest_tag=$1
  current_tag=$2
  data_dir="data"
  eth_data_dir="eth-mainnet-data"
  eth_data_dir_geth="eth-mainnet-data-geth"
  logshipper_data_dir="logshipper-mainnet-data"


  if [ -z "$node_port" ]; then
    node_port="9433";
  fi
  if [ -z "$rpc_port" ]; then
    rpc_port="9334";
  fi

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

  if [ ! -d "$PWD/${eth_data_dir}" ]
  then
    mkdir $PWD/${eth_data_dir}
    chmod -R 777 $PWD/${eth_data_dir}
  fi

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

  docker pull incognitochain/incognito-mainnet:${latest_tag}
  docker network create --driver bridge inc_net || true

  # eth with parity
  # docker run -ti --restart=always --net inc_net -d -p 8546:8545  -p 30303:30303 -p 30303:30303/udp -v $PWD/${eth_data_dir}:/home/parity/.local/share/io.parity.ethereum/ --name eth_mainnet  parity/parity:stable --light --jsonrpc-interface all --jsonrpc-hosts all  --jsonrpc-apis all --mode last --base-path=/home/parity/.local/share/io.parity.ethereum/

  # OR eth with geth
  docker run --restart=always --net inc_net -d --name eth_mainnet -p 8545:8545 -p 30303:30303 -v $PWD/${eth_data_dir_geth}:/geth -it ethereum/client-go --syncmode light --datadir /geth --rpcaddr 0.0.0.0 --rpcport 8545 --rpc --rpccorsdomain "*"

  docker run --restart=always --net inc_net -p 9301:$node_port -p 9001:$rpc_port -e NODE_PORT=$node_port -e RPC_PORT=$rpc_port -e BOOTNODE_IP=$bootnode -e GETH_NAME=eth_mainnet -e MININGKEY=${validator_key1} -e TESTNET=false -v $PWD/${data_dir}:/data1 -d --name inc_mainnet1 incognitochain/incognito-mainnet:${latest_tag}
  docker run --restart=always --net inc_net -p 9302:$node_port -p 9002:$rpc_port -e NODE_PORT=$node_port -e RPC_PORT=$rpc_port -e BOOTNODE_IP=$bootnode -e GETH_NAME=eth_mainnet -e MININGKEY=${validator_key2} -e TESTNET=false -v $PWD/${data_dir}:/data2 -d --name inc_mainnet2 incognitochain/incognito-mainnet:${latest_tag}
  docker run --restart=always --net inc_net -p 9303:$node_port -p 9003:$rpc_port -e NODE_PORT=$node_port -e RPC_PORT=$rpc_port -e BOOTNODE_IP=$bootnode -e GETH_NAME=eth_mainnet -e MININGKEY=${validator_key3} -e TESTNET=false -v $PWD/${data_dir}:/data3 -d --name inc_mainnet3 incognitochain/incognito-mainnet:${latest_tag}

if [ $is_shipping_logs -eq 1 ]
  then
    if [ ! -d "$PWD/${logshipper_data_dir}" ]
    then
      mkdir $PWD/${logshipper_data_dir}
      chmod -R 777 $PWD/${logshipper_data_dir}
    fi
    docker image rm -f incognitochain/logshipper:1.0.0
    docker run --restart=always -d --name inc_logshipper -e RAW_LOG_PATHS=/tmp/*.txt -e JSON_LOG_PATHS=/tmp/*.json -e LOGSTASH_ADDRESSES=34.94.14.147:5000 --mount type=bind,source=$PWD/${data_dir},target=/tmp --mount type=bind,source=$PWD/${logshipper_data_dir},target=/usr/share/filebeat/data incognitochain/logshipper:1.0.0
  fi
}

# kill existing run.sh processes
ps aux | grep '[r]un.sh' | awk '{ print $2}' | grep -v "^$$\$" | xargs kill -9

current_latest_tag=""
while [ 1 = 1 ]
do
  tags=`curl -X GET https://registry.hub.docker.com/v1/repositories/incognitochain/incognito-mainnet/tags  | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n'  | awk -F: '{print $3}' | sed -e 's/\n/;/g'`

  sorted_tags=($(echo ${tags[*]}| tr " " "\n" | sort -rn))
  latest_tag=${sorted_tags[0]}

  if [ "$current_latest_tag" != "$latest_tag" ]
  then
    run $latest_tag $current_latest_tag
    current_latest_tag=$latest_tag
  fi

  sleep 3600s

done &
[email protected]:~$ 

can you show me your file?

run_incognito.sh is the file inside the docker image, for example in your script, you have inc_mainnet1, inc_mainnet2 and inc_mainnet3 (–name parameter of docker run commands), you can enter to see in one of them with:

docker exec -it inc_mainnet1 bash
[email protected]:/# ls -l *.sh
-rw-r--r-- 1 root root  574 Jan 23 20:52 cmd.sh
-rwxr-xr-x 1 root root  845 Oct  7  2019 run_fullnode.sh
-rwxr-xr-x 1 root root 4499 Sep 22 10:40 run_incognito.sh
[email protected]:/# more run_incognito.sh

you can resolve passing yourself the public ip, adding -e PUBLIC_IP=12.34.56.78 in your run.sh in the three docker run commands where you launch the corresponding inc_mainnet images.

The problem is also here:
run_incognito.sh (line 30)
run_incognito2.sh (line 30)
run_incognito_dev.sh (line 20)
You can try yourself, if you launch this command it doesn’t returns nothing:

dig -4 @resolver1.opendns.com ANY myip.opendns.com +short

the correct command should be (and should return your public ip address):

dig -4 @resolver1.opendns.com A myip.opendns.com. +short
12.34.56.78

–edit–
(if you also append the final dot to myip.opendns.com. you also avoid a query appending your local search domains)

1 Like

We see the problem and will update it soon
Thank you for your notice.

1 Like

Thank you @Robotron2084
The fix should be included in next release

3 Likes