Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Napi subnode #466

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 16 additions & 8 deletions notionalapi/gateway/docker_service_create.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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}"

Expand All @@ -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 \
Expand Down
26 changes: 25 additions & 1 deletion notionalapi/gateway/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# usage: ./run.sh chain_name
# eg., ./run.sh cosmoshub
# for subnode: eg., ./run.sh sub_cosmoshub

chain_name="$1"

Expand Down Expand Up @@ -28,7 +29,28 @@ make install

########################################################################################################################
# config file
cat <<EOT > $HOME/gateway.yaml

if [[ $chain_name == "sub*" ]]; then

cat <<EOT > $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 <<EOT > $HOME/gateway.yaml
loglevel: "error"
mode: ""
pprof: ""
Expand All @@ -44,6 +66,8 @@ eth: "http://tasks.lb_${chain_name}:8004"
ethws: "ws://tasks.lb_${chain_name}:8005"
EOT

fi

########################################################################################################################
# run
cd $HOME
Expand Down
2 changes: 1 addition & 1 deletion notionalapi/proxy/generate_upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion proxy/legacy/generate_upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion proxy/public/generate_upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion subnode/docker_service_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down