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

subnode #287

Merged
merged 10 commits into from
Apr 7, 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
2 changes: 2 additions & 0 deletions data/subnode_registry.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[osmosis]
network = "net6"
44 changes: 44 additions & 0 deletions subnode/docker_service_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# usage: ./docker_service_create.sh subnode_name
# eg., ./docker_service_create.sh osmosis

subnode_name="$1"

if [[ -z $subnode_name ]]
then
echo "No subnode_name. usage eg., ./docker_service_create.sh osmosis"
exit
fi

eval "$(awk -v TARGET=$subnode_name -F ' = ' '
{
if ($0 ~ /^\[.*\]$/) {
gsub(/^\[|\]$/, "", $0)
SECTION=$0
} else if (($2 != "") && (SECTION==TARGET)) {
print $1 "=" $2
}
}
' ../data/subnode_registry.ini )"

echo "network=$network"

subnode_service_name="sub_${subnode_name}"


# delete existing service
docker service rm $subnode_service_name

# create new service
docker service create \
--name $subnode_service_name \
--replicas 1 \
--network $network \
--network cosmosia \
--endpoint-mode dnsrr \
--constraint 'node.hostname==cosmosia32' \
--sysctl 'net.ipv4.tcp_tw_reuse=1' \
--restart-condition none \
archlinux:latest \
/bin/bash -c \
"curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/subnode/run.sh > ~/run.sh && \
/bin/bash ~/run.sh $subnode_name"
13 changes: 13 additions & 0 deletions subnode/osmosis_subnode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
upstream:
- rpc: "http://tasks.lb_osmosis:8000"
api: "http://tasks.lb_osmosis:8001"
grpc: "tasks.lb_osmosis:8003"
blocks: [362880]
- rpc: "http://tasks.lb_osmosis-archive-sub:8000"
api: "http://tasks.lb_osmosis-archive-sub:8001"
grpc: "tasks.lb_osmosis-archive-sub:8003"
blocks: [5599641,0]
- rpc: "http://tasks.lb_osmosis-archive-sub1:8000"
api: "http://tasks.lb_osmosis-archive-sub1:8001"
grpc: "tasks.lb_osmosis-archive-sub1:8003"
blocks: [0,5599640]
43 changes: 43 additions & 0 deletions subnode/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# usage: ./run.sh subnode_name
# eg., ./run.sh osmosis

subnode_name="$1"

if [[ -z $subnode_name ]]; then
echo "No subnode_name. usage eg., ./run.sh osmosis"
exit
fi

pacman -Syu --noconfirm
pacman -Sy --noconfirm go git base-devel wget jq inetutils screen

echo "#################################################################################################################"
echo "install go..."

export GOPATH="$HOME/go"
export GOROOT="/usr/lib/go"
export GOBIN="${GOPATH}/bin"
export PATH="${PATH}:${GOROOT}/bin:${GOBIN}"

cd $HOME

echo "#################################################################################################################"
echo "install subnode"

cd $HOME
git clone --single-branch --branch main https://github.com/notional-labs/subnode
cd subnode
make install


# get config
curl -s https://raw.githubusercontent.com/notional-labs/cosmosia/main/subnode/${subnode_name}_subnode.yaml > ~/subnode.yaml

# run subnode with screen to avoid log to docker
cd $HOME
screen -S subnode -dm /root/go/bin/subnode start --conf=/root/subnode.yaml

########################################################################################################################
echo "Done!"
# loop forever for debugging only
while true; do sleep 5; done