From abe9822bcf9e33ce63e1d000b7ffba8977c723c1 Mon Sep 17 00:00:00 2001 From: Tuan Pham Anh Date: Sun, 29 Oct 2023 01:31:49 +0700 Subject: [PATCH 1/2] subnode: change lcd/api port to 1317 --- notionalapi/proxy/generate_upstream.sh | 2 +- proxy/legacy/generate_upstream.sh | 2 +- proxy/public/generate_upstream.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/notionalapi/proxy/generate_upstream.sh b/notionalapi/proxy/generate_upstream.sh index 67527f2c..b50dafbc 100644 --- a/notionalapi/proxy/generate_upstream.sh +++ b/notionalapi/proxy/generate_upstream.sh @@ -79,7 +79,7 @@ for service_name in $SERVICES_SUBNODE; do upstream backend_api_sub_$service_name { keepalive 16; - server $gw_ip:1337; + server $gw_ip:1317; } upstream backend_grpc_sub_$service_name { diff --git a/proxy/legacy/generate_upstream.sh b/proxy/legacy/generate_upstream.sh index b46976a3..ea7c6411 100644 --- a/proxy/legacy/generate_upstream.sh +++ b/proxy/legacy/generate_upstream.sh @@ -74,7 +74,7 @@ for service_name in $SERVICES_SUBNODE; do upstream backend_api_sub_$service_name { keepalive 16; - server $lb_ip:1337; + server $lb_ip:1317; } upstream backend_grpc_sub_$service_name { diff --git a/proxy/public/generate_upstream.sh b/proxy/public/generate_upstream.sh index f7d075ab..294564de 100644 --- a/proxy/public/generate_upstream.sh +++ b/proxy/public/generate_upstream.sh @@ -79,7 +79,7 @@ for service_name in $SERVICES_SUBNODE; do upstream backend_api_sub_$service_name { keepalive 16; - server $gw_ip:1337; + server $gw_ip:1317; } upstream backend_grpc_sub_$service_name { From 3b8a4307661cd6bfafbde80ef9d7c2fb9d3585d2 Mon Sep 17 00:00:00 2001 From: Tuan Pham Anh Date: Sun, 29 Oct 2023 01:47:59 +0700 Subject: [PATCH 2/2] napi: subnode --- docs/prepare.md | 3 +++ notionalapi/gateway/docker_service_create.sh | 24 ++++++++++++------ notionalapi/gateway/run.sh | 26 +++++++++++++++++++- subnode/docker_service_create.sh | 2 +- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/docs/prepare.md b/docs/prepare.md index 6d81cdab..af546ea0 100644 --- a/docs/prepare.md +++ b/docs/prepare.md @@ -78,6 +78,9 @@ docker network create -d overlay --attachable snapshot # create an overlay network for agent service docker network create -d overlay --attachable agent +# create an overlay network for subnode service +docker network create -d overlay --attachable subnode + # create 8 overlay networks for rpc services docker network create -d overlay --attachable net1 docker network create -d overlay --attachable net2 diff --git a/notionalapi/gateway/docker_service_create.sh b/notionalapi/gateway/docker_service_create.sh index 7ebe87fd..a5b9fb94 100644 --- a/notionalapi/gateway/docker_service_create.sh +++ b/notionalapi/gateway/docker_service_create.sh @@ -1,5 +1,6 @@ # usage: ./docker_service_create.sh chain_name # eg., ./docker_service_create.sh cosmoshub +# for subnode: eg., ./docker_service_create.sh sub_cosmoshub chain_name="$1" if [ -f "../../env.sh" ]; then @@ -14,8 +15,14 @@ if [[ -z $chain_name ]]; then exit fi -# to get the url to the config file -eval "$(curl -s "$CHAIN_REGISTRY_INI_URL" |awk -v TARGET=$chain_name -F ' = ' ' + +net="" +# check if subnode +if [[ $chain_name == "sub*" ]]; then + net="subnode" +else + # to get the url to the config file + eval "$(curl -s "$CHAIN_REGISTRY_INI_URL" |awk -v TARGET=$chain_name -F ' = ' ' { if ($0 ~ /^\[.*\]$/) { gsub(/^\[|\]$/, "", $0) @@ -26,12 +33,13 @@ eval "$(curl -s "$CHAIN_REGISTRY_INI_URL" |awk -v TARGET=$chain_name -F ' = ' ' } ')" -echo "config=$config" -# load config -eval "$(curl -s "$config" |sed 's/ = /=/g')" - -echo "network=$network" + echo "config=$config" + # load config + eval "$(curl -s "$config" |sed 's/ = /=/g')" + net="$network" +fi +echo "net=$net" SERVICE_NAME="napigw_${chain_name}" @@ -42,7 +50,7 @@ docker service create \ --name $SERVICE_NAME \ --replicas 1 \ --constraint "node.labels.cosmosia.notionalapi.gw==true" \ - --network $network \ + --network $net \ --network notionalapi \ --label 'cosmosia.service=napigw' \ --endpoint-mode dnsrr \ diff --git a/notionalapi/gateway/run.sh b/notionalapi/gateway/run.sh index c7d9678e..fc3712b2 100644 --- a/notionalapi/gateway/run.sh +++ b/notionalapi/gateway/run.sh @@ -1,5 +1,6 @@ # usage: ./run.sh chain_name # eg., ./run.sh cosmoshub +# for subnode: eg., ./run.sh sub_cosmoshub chain_name="$1" @@ -28,7 +29,28 @@ make install ######################################################################################################################## # config file -cat < $HOME/gateway.yaml + +if [[ $chain_name == "sub*" ]]; then + + cat < $HOME/gateway.yaml +loglevel: "error" +mode: "" +pprof: "" +aggrurl: "http://tasks.napiaggregator:8300/metering" +mysqlsrc: "root:invalid@tcp(tasks.napi_mysql:3306)/db_apicount" +dbconurl: "http://tasks.napidb_1:4001/" +chain: "$chain_name" +rpc: "http://tasks.${chain_name}:26657" +wsrpc: "ws://tasks.${chain_name}:26657/websocket" +api: "http://tasks.${chain_name}:1317" +grpc: "tasks.lb_${chain_name}:9090" +eth: "http://tasks.${chain_name}:8545" +ethws: "ws://tasks.${chain_name}:8546" +EOT + +else + + cat < $HOME/gateway.yaml loglevel: "error" mode: "" pprof: "" @@ -44,6 +66,8 @@ eth: "http://tasks.lb_${chain_name}:8004" ethws: "ws://tasks.lb_${chain_name}:8005" EOT +fi + ######################################################################################################################## # run cd $HOME diff --git a/subnode/docker_service_create.sh b/subnode/docker_service_create.sh index a33adfe4..162403c6 100644 --- a/subnode/docker_service_create.sh +++ b/subnode/docker_service_create.sh @@ -33,7 +33,7 @@ docker service create \ --name $subnode_service_name \ --replicas 1 \ --network $network \ - --network cosmosia \ + --network subnode \ --label 'cosmosia.service=subnode' \ --endpoint-mode dnsrr \ --constraint 'node.labels.cosmosia.subnode==true' \