Skip to content

Commit

Permalink
feat: Local-Interchain environment (#663)
Browse files Browse the repository at this point in the history
* Squashed commit of the following:

commit bfa7653
Merge: 55aeeb8 cedf87f
Author: Reece Williams <[email protected]>
Date:   Wed Jun 28 16:44:56 2023 -0500

    Merge branch 'main' into reece/localic-tweaks

commit 55aeeb8
Author: Reece Williams <[email protected]>
Date:   Wed Jun 28 16:41:57 2023 -0500

    Fix hostAPIPort

commit ba71ff1
Author: Reece Williams <[email protected]>
Date:   Wed Jun 28 16:37:07 2023 -0500

    Adds REST API support

commit 87804b1
Merge: c79a765 220ce33
Author: Reece Williams <[email protected]>
Date:   Fri Jun 23 10:49:43 2023 -0500

    Merge branch 'main' into reece/localic-tweaks

commit c79a765
Author: Reece Williams <[email protected]>
Date:   Wed Jun 21 16:17:47 2023 -0500

    Revert TxCommand gas auto

commit 2650ce1
Merge: 7abc87b b8ef5ef
Author: Reece Williams <[email protected]>
Date:   Wed Jun 21 16:12:08 2023 -0500

    Merge branch 'reece/juno-improvements-v47' into reece/localic-tweaks

commit 7abc87b
Merge: c2f6c02 c4bf11d
Author: Reece Williams <[email protected]>
Date:   Wed Jun 21 16:11:57 2023 -0500

    Merge branch 'main' into reece/localic-tweaks

commit b8ef5ef
Author: Reece Williams <[email protected]>
Date:   Wed Jun 21 16:02:38 2023 -0500

    Revert "TxCommand gas auto"

    This reverts commit 83b50de.

commit 2b9025f
Merge: 5fe9709 c4bf11d
Author: Reece Williams <[email protected]>
Date:   Wed Jun 21 15:59:15 2023 -0500

    Merge branch 'main' into reece/juno-improvements-v47

commit 5fe9709
Merge: 35497b6 3c63f8c
Author: Reece Williams <[email protected]>
Date:   Fri Jun 2 18:21:03 2023 -0500

    Merge branch 'main' into reece/juno-improvements-v47

commit c2f6c02
Merge: 91fdcfd 3c63f8c
Author: Reece Williams <[email protected]>
Date:   Fri Jun 2 18:19:42 2023 -0500

    Merge branch 'main' into reece/localic-tweaks

commit 91fdcfd
Author: Reece Williams <[email protected]>
Date:   Thu Jun 1 21:54:13 2023 -0500

    Squashed commit of the following:

    commit 35497b6
    Author: Reece Williams <[email protected]>
    Date:   Fri May 19 16:21:04 2023 -0500

        rename result -> path (of components)

    commit 66c2c32
    Merge: a01b723 4c903c4
    Author: Reece Williams <[email protected]>
    Date:   Fri May 19 16:11:18 2023 -0500

        Merge branch 'main' into reece/juno-improvements-v47

    commit a01b723
    Author: Reece Williams <[email protected]>
    Date:   Fri May 19 16:08:24 2023 -0500

        Adds ModifyGenesis generalized Function + test

    commit 33d7faf
    Author: Reece Williams <[email protected]>
    Date:   Fri May 12 11:14:06 2023 -0500

        Remove uneeded BuildProposal arg

    commit 62fd485
    Author: Reece Williams <[email protected]>
    Date:   Fri May 12 11:07:12 2023 -0500

        Adds BuildProposal for govv1

    commit 268df1f
    Author: Reece Williams <[email protected]>
    Date:   Fri May 12 11:04:41 2023 -0500

        comment

    commit 80e66c2
    Author: Reece Williams <[email protected]>
    Date:   Fri May 12 10:27:54 2023 -0500

        makes SubmitProposal public for chains

    commit 83b50de
    Author: Reece Williams <[email protected]>
    Date:   Thu May 11 14:45:28 2023 -0500

        TxCommand gas auto

commit 1383abd
Author: Reece Williams <[email protected]>
Date:   Thu Jun 1 21:52:27 2023 -0500

    Interface tweaks

commit 35497b6
Author: Reece Williams <[email protected]>
Date:   Fri May 19 16:21:04 2023 -0500

    rename result -> path (of components)

commit 66c2c32
Merge: a01b723 4c903c4
Author: Reece Williams <[email protected]>
Date:   Fri May 19 16:11:18 2023 -0500

    Merge branch 'main' into reece/juno-improvements-v47

commit a01b723
Author: Reece Williams <[email protected]>
Date:   Fri May 19 16:08:24 2023 -0500

    Adds ModifyGenesis generalized Function + test

commit 33d7faf
Author: Reece Williams <[email protected]>
Date:   Fri May 12 11:14:06 2023 -0500

    Remove uneeded BuildProposal arg

commit 62fd485
Author: Reece Williams <[email protected]>
Date:   Fri May 12 11:07:12 2023 -0500

    Adds BuildProposal for govv1

commit 268df1f
Author: Reece Williams <[email protected]>
Date:   Fri May 12 11:04:41 2023 -0500

    comment

commit 80e66c2
Author: Reece Williams <[email protected]>
Date:   Fri May 12 10:27:54 2023 -0500

    makes SubmitProposal public for chains

commit 83b50de
Author: Reece Williams <[email protected]>
Date:   Thu May 11 14:45:28 2023 -0500

    TxCommand gas auto

* Upload Local-Interchain

* Minor readme fix

* Remove comma from readme JSON

Co-authored-by: Dan Kanefsky <[email protected]>

* Remove default events from relayre

Co-authored-by: Dan Kanefsky <[email protected]>

* Better error for root cli execute

Co-authored-by: Dan Kanefsky <[email protected]>

* Remove debugging print

* Add signal & endpoint kill-all (stop & cleanup)

* Remove validation panics for Chain types

* Show F32 + 64 in defaults output

* Remove BlocksTTL and use math.MaxInt instead

* Kill relayer & all containers on ctrl+c / kill endpoint

* Require `configs` and `chains` in ICTEST_HOME

* `docs`: relative paths

* TODO: cleanup on ctrl+c

---------

Co-authored-by: Dan Kanefsky <[email protected]>
Co-authored-by: David Nix <[email protected]>
(cherry picked from commit bd6da21)
  • Loading branch information
Reecepbcups authored and mergify[bot] committed Aug 15, 2023
1 parent 3f42106 commit 9b6c4f7
Show file tree
Hide file tree
Showing 47 changed files with 5,318 additions and 0 deletions.
31 changes: 31 additions & 0 deletions local-interchain/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[flake8]

plugins =
flake8-simplify
flake8-bandit
flake8-bugbear
flake8-builtins
flake8-comprehensions
flake8-eradicate
flake8-isort
flake8-pytest-style
flakehell
pep8-naming

spellcheck-targets=comments

extend-ignore =
E501
; docstrings
D
; try pass
S110
; dict(k=v)
C408

exclude =
.git,
__pycache__,
.mypy_cache

max-complexity = 10
14 changes: 14 additions & 0 deletions local-interchain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bin/

dist/

chains/*_ignored.json
chains/*_ignore.json

configs/logs.json
configs/contracts.json

contracts/*.wasm


__pycache__/
20 changes: 20 additions & 0 deletions local-interchain/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/make -f

CWD := $(dir $(abspath $(firstword $(MAKEFILE_LIST))))

ldflags = -X main.MakeFileInstallDirectory=$(CWD)
ldflags := $(strip $(ldflags))
BUILD_FLAGS := -ldflags '$(ldflags)'

.PHONY: build
build:
go build $(BUILD_FLAGS) -o ../bin/local-ic ./cmd/local-ic

.PHONY: run
run:
../bin/local-ic $(filter-out $@,$(MAKECMDGOALS))

.PHONY: install
install:
go install $(BUILD_FLAGS) ./cmd/local-ic ./interchain

136 changes: 136 additions & 0 deletions local-interchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Local Interchain

A simple way to config and run IBC local chain testing environments with any language of choice for interaction.

## Installing

**Install on Mac / Linux**
```bash
git clone https://github.com/strangelove-ventures/interchaintest.git

cd interchaintest/local-interchain

# NOTE: your binary will link back to this location of where you install.
# If you rename the folder or move it, you need to `make install` the binary again.
make install
```
**Install on Windows**

Follow [this guide](./docs/WINDOWS.md) to setup the Windows OS environment for installing Local Interchain.

## Running

- *(optional)* Edit `./configs/relayer.json`
- Copy: `cp ./configs/base_ibc.json ./configs/mytest1_ignored.json`
- Run: `local-ic start mytest1_ignored.json`
- Run in different directory: `ICTEST_HOME=/root/local-interchain local-ic start myother_ignored.json`

**NOTE** The ICTEST_HOME path must contain the directories `chains` and `configs` to be valid.

*(Default: `make install` links to the cloned directory. `go install .` will use your home directory /local-interchain)*

*(Ending the config file with `_ignored.json` or `_ignore.json` will ignore it from git)*

---

## REST API

A rest API can be found at `curl localhost:8080/` by default. Other actions can take place here such as file uploads, actions, querying chain config information, and more!

Read more about the API [here](./docs/REST_API.md)

## Helpful Tips

- Auto complete: edit ~/.bashrc or ~/.zshrc and add `source <(local-ic completion bash)` or `source <(local-ic completion zsh)`.
(fish & windows powershell is also supported)

- After starting the chain(s), you can read the `./configs/logs.json` file to get useful information. This includes the chain's id, name, RPC address, and more.

```json
// ./configs/logs.json
[
{
"chain_id": "exampleid-1",
"chain_name": "example",
"rpc_address": "http://localhost:38829",
"grpc_address": "localhost:34917",
"ibc_paths": []
}
]
```

- 'ibc-path' should only be set if you are using 2+ chains. If you are using 1 chain, you can leave it blank.

- You can use `%DENOM%` anywhere in the chain's config to use the `denom` line. This is useful for gas prices, Genesis accounts, etc.

- Configuration's have set defaults. The minimum you need to run a single chain is the following

```json
{
"name": "juno",
"chain_id": "localjuno-2",
"denom": "ujuno",
"docker_image": {
"version": "v14.1.0"
},
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0
}
```

---

## Base Chain Template

Here is a base chain template with every feature the configuration accepts. Accounts have extra data to make it simpler for scripting and read from the file directly.

```json
{
"name": "juno",
"chain_id": "localjuno-1",
"denom": "ujuno",
"binary": "junod",
"bech32_prefix": "juno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0",
"uid_gid": "1000:1000"
},
"chain_type": "cosmos",
"coin_type": 118,
"trusting_period": "112h",
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"number_vals": 1,
"number_node": 0,
"use_new_genesis_command": false,
"ibc_paths": ["juno-ibc-1"],
"debugging": true,
"block_time": "500ms",
"encoding-options": ["juno"],
"genesis": {
"modify": [
{
"key": "app_state.gov.voting_params.voting_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.max_deposit_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.denom",
"value": "ujuno"
}
],
"accounts": [
{
"name": "acc0",
"address": "juno1efd63aw40lxf3n4mhf7dzhjkr453axurv2zdzk",
"amount": "10000000%DENOM%",
"mnemonic": "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
}
]
}
},
```
63 changes: 63 additions & 0 deletions local-interchain/chains/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"chains": [
{
"name": "juno",
"chain_id": "localjuno-1",
"denom": "ujuno",
"binary": "junod",
"bech32_prefix": "juno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0"
},
"use_new_genesis_command": false,
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
"coin_type": 118,
"trusting_period": "112h",
"gas_adjustment": 2.0,
"number_vals": 1,
"number_node": 0,
"debugging": true,
"block_time": "500ms",
"encoding-options": ["juno"],
"genesis": {
"modify": [
{
"key": "app_state.gov.voting_params.voting_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.max_deposit_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.denom",
"value": "ujuno"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.amount",
"value": "1"
}
],
"accounts": [
{
"name": "acc0",
"address": "juno1hj5fveer5cjtn4wd6wstzugjfdxzl0xps73ftl",
"amount": "10000000000%DENOM%",
"mnemonic": "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
},
{
"name": "acc1",
"address": "juno1efd63aw40lxf3n4mhf7dzhjkr453axurv2zdzk",
"amount": "10000000000%DENOM%",
"mnemonic": "wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise"
}
],
"startup_commands": [
"%BIN% keys add example-key-after --keyring-backend test --home %HOME%"
]
}
}
]
}
59 changes: 59 additions & 0 deletions local-interchain/chains/base_ibc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"chains": [
{
"name": "gaia",
"chain_id": "localcosmos-1",
"denom": "uatom",
"binary": "gaiad",
"bech32_prefix": "cosmos",
"docker_image": {
"version": "v9.1.0"
},
"block_time": "6s",
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"ibc_paths": ["atom-juno", "atom-terra"],
"genesis": {
"accounts": [
{
"name": "acc0",
"address": "cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr",
"amount": "10000000%DENOM%",
"mnemonic": "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
}
]
}
},
{
"name": "juno",
"chain_id": "localjuno-1",
"binary": "junod",
"bech32_prefix": "juno",
"denom": "ujuno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0"
},
"block_time": "2s",
"encoding-options": ["juno"],
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"ibc_paths": ["atom-juno", "juno-terra"]
},
{
"name": "terra",
"chain_id": "localterra-1",
"binary": "terrad",
"bech32_prefix": "terra",
"denom": "uluna",
"docker_image": {
"version": "v2.3.4"
},
"block_time": "6s",
"encoding-options": ["wasm"],
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"ibc_paths": ["atom-terra", "juno-terra"]
}
]
}
48 changes: 48 additions & 0 deletions local-interchain/chains/cosmoshub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"chains": [
{
"name": "gaia",
"chain_id": "localcosmos-1",
"denom": "uatom",
"binary": "gaiad",
"bech32_prefix": "cosmos",
"docker_image": {
"version": "v10.0.1"
},
"use_new_genesis_command": false,
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
"coin_type": 118,
"trusting_period": "112h",
"gas_adjustment": 2.0,
"number_vals": 1,
"number_node": 0,
"debugging": true,
"block_time": "500ms",
"genesis": {
"modify": [
{
"key": "app_state.gov.voting_params.voting_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.max_deposit_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.denom",
"value": "uatom"
}
],
"accounts": [
{
"name": "acc0",
"address": "cosmos1hj5fveer5cjtn4wd6wstzugjfdxzl0xpxvjjvr",
"amount": "10000000000%DENOM%",
"mnemonic": "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry"
}
]
}
}
]
}
Loading

0 comments on commit 9b6c4f7

Please sign in to comment.