Skip to content

Commit

Permalink
Merge pull request #3 from Team-Kujira/ibc
Browse files Browse the repository at this point in the history
Ibc
  • Loading branch information
starsquidnodes authored Feb 11, 2024
2 parents ecfe178 + cbcc7a6 commit 9c5b883
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 23 deletions.
68 changes: 67 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pond

Pond is an easy way to set up a local Kujira development chain.
Pond is an easy way to set up a local Kujira development chain. It uses docker containers to set up two local Kujira chains, price feeder and an IBC relayer connecting both chains.

The second chain is meant to test IBC related things and therefore has only one validator and no price feeder.

## Installation

Expand Down Expand Up @@ -35,3 +37,67 @@ pond stop
```bash
pond info
```

## Accounts

### Pre-funded test wallets

kujira1cyyzpxplxdzkeea7kwsydadg87357qnaww84dg

```text
notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius
```

kujira18s5lynnmx37hq4wlrw9gdn68sg2uxp5r39mjh5

```text
quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty
```

kujira1qwexv7c6sm95lwhzn9027vyu2ccneaqa5xl0d9

```text
symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb
```

kujira14hcxlnwlqtq75ttaxf674vk6mafspg8xhmzm0f

```text
bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty
```

kujira12rr534cer5c0vj53eq4y32lcwguyy7nn5c753n

```text
second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal
```

kujira1nt33cjd5auzh36syym6azgc8tve0jlvkxq3kfc

```text
spatial forest elevator battle also spoon fun skirt flight initial nasty transfer glory palm drama gossip remove fan joke shove label dune debate quick
```

kujira10qfrpash5g2vk3hppvu45x0g860czur8s69vah

```text
noble width taxi input there patrol clown public spell aunt wish punch moment will misery eight excess arena pen turtle minimum grain vague inmate
```

kujira1f4tvsdukfwh6s9swrc24gkuz23tp8pd3qkjuj9

```text
cream sport mango believe inhale text fish rely elegant below earth april wall rug ritual blossom cherry detail length blind digital proof identify ride
```

kujira1myv43sqgnj5sm4zl98ftl45af9cfzk7nwph6m0

```text
index light average senior silent limit usual local involve delay update rack cause inmate wall render magnet common feature laundry exact casual resource hundred
```

kujira14gs9zqh8m49yy9kscjqu9h72exyf295asmt7nw

```text
prefer forget visit mistake mixture feel eyebrow autumn shop pair address airport diesel street pass vague innocent poem method awful require hurry unhappy shoulder
```
56 changes: 34 additions & 22 deletions pond
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import os
import json
import requests

VERSION = "v0.1.0"


def parse_args():
parser = argparse.ArgumentParser()
Expand All @@ -25,8 +27,8 @@ def parse_args():
help="use podman")
init_parser.add_argument("--docker", action="store_true",
help="use docker")
init_parser.add_argument("--kujira-version", default="mainnet")
init_parser.add_argument("--feeder-version", default="mainnet")
# init_parser.add_argument("--kujira-version", default="v0.9.3-1")
# init_parser.add_argument("--feeder-version", default="mainnet")

start_parser = subparsers.add_parser("start", help="start components")
start_parser.add_argument("target", nargs="?")
Expand All @@ -47,7 +49,6 @@ def get_tags(namespace, components=["kujira", "feeder"]):

for component in components:
url = f"{baseurl}/{component}/tags"
# print(url)
response = requests.get(url)
if response.status_code != 200:
print(f"docker api returned http-{response.status_code}")
Expand Down Expand Up @@ -102,6 +103,22 @@ def start_feeder_cmd(cmd, namespace, name, version, home, mnemonic):
return commands.get(cmd)


def start_relayer_cmd(cmd, namespace, version, home):
uid = os.getuid()

commands = {
"docker": [
f"docker rm relayer".split(),
f"docker run -e USER={uid} -d --network pond --network-alias relayer --name relayer -v {home}/relayer:/relayer {namespace}/relayer:{version} link-and-start-pond.sh".split(),
],
"podman": [
f"podman run --name relayer -d --pod pond -v {home}/relayer:/relayer {namespace}/relayer:{version} link-and-start-pond.sh".split(),
]
}

return commands.get(cmd)


def init(home, args):
cmd = None
extra_args = []
Expand Down Expand Up @@ -143,23 +160,13 @@ def init(home, args):
if choice in ["", "n", "no"]:
return

kujira_cmd = cmd + [
cmd += [
"-v", f"{home}:/tmp/pond",
f"docker.io/{args.namespace}/prepare-kujira:{args.kujira_version}",
f"docker.io/{args.namespace}/prepare:{VERSION}",
"prepare.py", "--nodes", f"{args.nodes}", "--clear"
] + extra_args

feeder_cmd = cmd + [
"-v", f"{home}:/tmp/pond",
f"docker.io/{args.namespace}/prepare-feeder:{args.feeder_version}",
"prepare.py",
] + extra_args

# print(kujira_cmd)
# print(feeder_cmd)

subprocess.run(kujira_cmd)
subprocess.run(feeder_cmd)
subprocess.run(cmd)


def info(home):
Expand All @@ -179,8 +186,8 @@ def start(args, config, home):
commands = [["sleep", "2"]]

ports = []
for chain_id, chain in config["chains"].items():
for validator in chain["validators"]:
for chain_id, validators in config["validators"].items():
for validator in validators:
_ports = [
validator["api_url"].split(":")[-1],
validator["rpc_url"].split(":")[-1]
Expand All @@ -201,6 +208,9 @@ def start(args, config, home):
cmd, ns, name, version, home, validator["mnemonic"]
)

version = config["version"]["relayer"]
commands += start_relayer_cmd(cmd, ns, version, home)

port_args = " ".join([f"-p {x}:{x}" for x in ports])

if cmd == "podman":
Expand All @@ -223,9 +233,12 @@ def stop(config):
if not cmd:
print("command not set")

commands = []
for chain_id, chain in config["chains"].items():
for validator in chain["validators"]:
commands = [
[cmd, "kill", "relayer"]
]

for chain_id, validators in config["validators"].items():
for validator in validators:
name = validator["moniker"].lower()
commands.append([cmd, "kill", name])

Expand All @@ -241,7 +254,6 @@ def stop(config):

def run(commands):
for cmd in commands:
# print(cmd)
subprocess.run(cmd)


Expand Down

0 comments on commit 9c5b883

Please sign in to comment.