Skip to content

Commit

Permalink
Add api port, extend build script
Browse files Browse the repository at this point in the history
  • Loading branch information
starsquidnodes committed Oct 22, 2023
1 parent 556e806 commit f3ba536
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
36 changes: 25 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
#!/bin/bash

cmd=""
action=build
if [ $# -eq 1 ] && [ "$1" == "manifest" ]; then
action=manifest
namespace="teamkujira"
if [ $# -gt 0 ]; then
if [ "$1" == "manifest" ]; then
action=manifest
fi

if [ "$1" == "docker" ] || [ "$1" == "podman" ]; then
cmd="$1"
fi

if [ $# -eq 2 ]; then
namespace=$2
fi
fi

if [ -n "$(which docker)" ]; then
cmd=docker
elif [ -n "$(which podman)" ]; then
cmd=podman
else
exit 1
if [ -z "$cmd" ]; then
if [ -n "$(which docker)" ]; then
cmd=docker
elif [ -n "$(which podman)" ]; then
cmd=podman
else
exit 1
fi
fi

arch=$(arch)

# kujirad
go_version=1.20.2
kujira_version=v0.9.0
tag=teamkujira/kujirad:${kujira_version}
tag=${namespace}/kujirad:${kujira_version}

if [ "$action" == "build" ]; then
$cmd build \
Expand All @@ -38,7 +52,7 @@ fi
# feeder
go_version=1.20.2
feeder_version=next
tag=teamkujira/feeder:${feeder_version}
tag=${namespace}/feeder:${feeder_version}

if [ "$action" == "build" ]; then
$cmd build \
Expand All @@ -58,7 +72,7 @@ fi

# prepare
prepare_version=latest
tag=teamkujira/prepare:${prepare_version}
tag=${namespace}/prepare:${prepare_version}

if [ "$action" == "build" ]; then
$cmd build \
Expand Down
6 changes: 5 additions & 1 deletion prepare/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Chain:
port_prefix = 1
podman = False
rpc_port = ""
api_port = ""

def __init__(self, name, chain_id, denom, num_validators, port_prefix, podman):
self.name = name
Expand All @@ -39,6 +40,7 @@ def __init__(self, name, chain_id, denom, num_validators, port_prefix, podman):

info, gentx = self.prepare_gentxs(chain_id, home)
info["rpc_port"] = f"{self.port_prefix}{i:02}57"
info["api_port"] = f"{self.port_prefix}{i:02}17"
self.validators.append(info)

gentxs.append(gentx)
Expand Down Expand Up @@ -259,11 +261,13 @@ def main():

for validator in chain.validators:
validator["rpc_url"] = f"http://localhost:{validator['rpc_port']}"
validator["api_url"] = f"http://localhost:{validator['api_port']}"
validator.pop("rpc_port")
validator.pop("api_port")
validator.pop("amount")

chain_info["validators"].append(validator)

info["chains"][chain.chain_id] = chain_info

json.dump(info, open(f"{WORKDIR}/info.json", "w"))
Expand Down
2 changes: 1 addition & 1 deletion prepare/templates/app.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ enable = true
swagger = false

# Address defines the API server to listen on.
address = "tcp://127.0.0.1:{{ api_port }}"
address = "tcp://0.0.0.0:{{ api_port }}"

# MaxOpenConnections defines the number of maximum open connections.
max-open-connections = 1000
Expand Down
7 changes: 4 additions & 3 deletions prepare/templates/start.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ cd $(dirname $0)

{% if podman -%}
podman pod rm --force pond
podman pod create --name pond{% for chain in chains %}{% for validator in chain.validators %} -p {{ validator.rpc_port }}:{{ validator.rpc_port }}{% endfor %}{% endfor %}
podman pod create --name pond{% for chain in chains %}{% for validator in chain.validators %} -p {{ validator.rpc_port }}:{{ validator.rpc_port }} -p {{ validator.api_port }}:{{ validator.api_port }}{% endfor %}{% endfor %}
{% else -%}
docker network rm pond
docker network create pond
{% endif -%}
{% for chain in chains -%}
{% for validator in chain.validators -%}
{% set port = validator.rpc_port %}
{% set rpc_port = validator.rpc_port %}
{% set api_port = validator.api_port %}
{% set name = validator.moniker | lower -%}
{% if podman %}
podman run --name {{ name }} -d --pod pond -v ./{{ name }}:/kujira teamkujira/kujirad:v0.9.0 kujirad --home /kujira start
{% else %}
docker rm {{ name }}
docker run -e USER=$UID -dp 127.0.0.1:{{ port }}:{{ port }} --network pond --name {{ name }} --network-alias {{ name }} -v ./{{ name }}:/kujira teamkujira/kujirad:v0.9.0 kujirad --home /kujira start
docker run -e USER=$UID -dp 127.0.0.1:{{ rpc_port }}:{{ rpc_port }} -p 127.0.0.1:{{ api_port }}:{{ api_port }} --network pond --name {{ name }} --network-alias {{ name }} -v ./{{ name }}:/kujira teamkujira/kujirad:v0.9.0 kujirad --home /kujira start
{% endif %}
{% endfor -%}
{% endfor %}
Expand Down

0 comments on commit f3ba536

Please sign in to comment.