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

feat: Local-Interchain environment #663

Merged
merged 16 commits into from
Aug 15, 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
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"
Comment on lines +34 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR... but there is no arm64 image so had to tweak this to get it to work on an m1 mac.

https://github.com/CosmosContracts/juno/pkgs/container/juno-e2e/109148503?tag=latest

},
"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