Skip to content

Commit

Permalink
local-interchain: Rust Driver (#785)
Browse files Browse the repository at this point in the history
* cli: add app overrides for port and address

* init: rust client base

* request resp: use JSON

* minor: fmt

* bin builder

* feat: add query & binary actions + simple examples

* Add cw_std

* feat: tx, get_tx_hash, and query_tx_hash

* add: localic-std library

* condense main.rs to use new std lib

* use file_path for uploader instead

* lib misc: bank_send, errors, libs, bals

* CW: Store, Init, Query, Better ActionBuilder

* minor: test path cleanup

* ci: attempt basic local-ic + rust e2e

* ci: set manifest-path to sub-dir

* ci: fix manifest path

* cw: get_contract_address

* cw store: if err, return exact (may not be JSON)

* add execute_contract

* feat: Upload-Type for cosmwasm contracts

* better uploader error handling for debugging

* more test, get_files func,

* backup; more info queries

* move GetInfo into their own funcs

* query: get ibc config (denom, bin, etc)

* minor: more general test for node name

* recover-key, overwrite genesis, add-full-node

* format

* add relayer support

* upgrade old docker values

* tweaks, relayer Channel type

* CW: instantiate, execute, and query with mut CW object

* move CW & Bank -> a modules mod

* on Tx, poll for Tx hash resp. 5x before failure

* codebase lint

* ci: clippy lint workflow

* Move dump-contract-state to POST

* ci: fix lint

* add: `get_sdk_status_code`

* ci: change clippy working-directory

* `query_value`, Debug for CRBuilder

* remove old println, add err to fet_files

* migrate to a workspace

* mod tidy

* add back flags to start_chain

* abstract away required flags

* remove old panic, fmt

* move old rest server to be cli arg only

* Add setup documentation
  • Loading branch information
Reecepbcups authored Oct 11, 2023
1 parent 254c8f6 commit ea7ce03
Show file tree
Hide file tree
Showing 45 changed files with 4,258 additions and 82 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,24 @@ jobs:
version: v1.54
only-new-issues: true
args: --timeout=5m

clippy-lint:
defaults:
run:
working-directory: local-interchain/rust/localic-std
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- name: Install clippy
run: rustup component add clippy
- name: Update
run: cargo update
- name: Run clippy
run: make lint

54 changes: 53 additions & 1 deletion .github/workflows/local-interchain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
build:
runs-on: ubuntu-latest
name: build
defaults:
run:
working-directory: ./local-interchain
steps:
- name: Checkout interchaintest
uses: actions/checkout@v4
Expand All @@ -24,4 +27,53 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- run: cd local-interchain && go mod tidy && make install
- name: build local-interchain
run: go mod tidy && make install

- name: Upload localic artifact
uses: actions/upload-artifact@v3
with:
name: local-ic
path: ~/go/bin/local-ic

# TOOO: put the python workflow here. (https://github.com/strangelove-ventures/interchaintest/pull/775)

rust-e2e:
name: rust e2e
needs: build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./local-interchain
strategy:
fail-fast: false

steps:
- name: checkout chain
uses: actions/checkout@v3

- name: Install latest toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
with:
name: local-ic
path: /tmp

- name: Make local-ic executable
run: chmod +x /tmp/local-ic

- name: Start background ibc local-interchain
run: /tmp/local-ic start juno_ibc --api-port 8080 &

- name: Run Rust Script
run: cd rust && cargo run --package localic-bin --bin localic-bin

- name: Cleanup
run: killall local-ic && exit 0
1 change: 1 addition & 0 deletions local-interchain/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ configs/logs.json
configs/contracts.json

contracts/*.wasm
!contracts/cw_ibc_example.wasm


__pycache__/
9 changes: 6 additions & 3 deletions local-interchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

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

## Installing
## Repository CI

- [**Rust**](./rust/README.md)

## Installing Locally

**Install on Mac / Linux**
```bash
Expand Down Expand Up @@ -102,8 +106,7 @@ Here is a base chain template with every feature the configuration accepts. Acco
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"number_vals": 1,
"number_node": 0,
"use_new_genesis_command": false,
"number_node": 0,
"ibc_paths": ["juno-ibc-1"],
"debugging": true,
"block_time": "500ms",
Expand Down
15 changes: 7 additions & 8 deletions local-interchain/chains/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
"binary": "junod",
"bech32_prefix": "juno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0"
},
"use_new_genesis_command": false,
"repository": "ghcr.io/cosmoscontracts/juno",
"version": "v17.0.0"
},
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
"coin_type": 118,
Expand All @@ -24,19 +23,19 @@
"genesis": {
"modify": [
{
"key": "app_state.gov.voting_params.voting_period",
"key": "app_state.gov.params.voting_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.max_deposit_period",
"key": "app_state.gov.params.max_deposit_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.denom",
"key": "app_state.gov.params.min_deposit.0.denom",
"value": "ujuno"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.amount",
"key": "app_state.gov.params.min_deposit.0.amount",
"value": "1"
}
],
Expand Down
4 changes: 2 additions & 2 deletions local-interchain/chains/base_ibc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"bech32_prefix": "juno",
"denom": "ujuno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0"
"repository": "ghcr.io/cosmoscontracts/juno",
"version": "v17.0.0"
},
"block_time": "2s",
"encoding-options": ["juno"],
Expand Down
3 changes: 1 addition & 2 deletions local-interchain/chains/cosmoshub.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"bech32_prefix": "cosmos",
"docker_image": {
"version": "v10.0.1"
},
"use_new_genesis_command": false,
},
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
"coin_type": 118,
Expand Down
15 changes: 7 additions & 8 deletions local-interchain/chains/juno_ibc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
"binary": "junod",
"bech32_prefix": "juno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0"
"repository": "ghcr.io/cosmoscontracts/juno",
"version": "v17.0.0"
},
"use_new_genesis_command": false,
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
"coin_type": 118,
Expand All @@ -25,15 +24,15 @@
"genesis": {
"modify": [
{
"key": "app_state.gov.voting_params.voting_period",
"key": "app_state.gov.params.voting_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.max_deposit_period",
"key": "app_state.gov.params.max_deposit_period",
"value": "15s"
},
{
"key": "app_state.gov.deposit_params.min_deposit.0.denom",
"key": "app_state.gov.params.min_deposit.0.denom",
"value": "ujuno"
}
],
Expand All @@ -60,8 +59,8 @@
"bech32_prefix": "juno",
"denom": "ujuno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno-e2e",
"version": "v14.1.0"
"repository": "ghcr.io/cosmoscontracts/juno",
"version": "v17.0.0"
},
"genesis": {
"accounts": [
Expand Down
3 changes: 1 addition & 2 deletions local-interchain/chains/stargaze.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"bech32_prefix": "stars",
"docker_image": {
"version": "v10.0.1"
},
"use_new_genesis_command": false,
},
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
"coin_type": 118,
Expand Down
18 changes: 17 additions & 1 deletion local-interchain/cmd/local-ic/start_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"github.com/strangelove-ventures/localinterchain/interchain"
)

const (
FlagAPIAddressOverride = "api-address"
FlagAPIPortOverride = "api-port"
)

var startCmd = &cobra.Command{
Use: "start <config.json>",
Aliases: []string{"s", "run"},
Expand All @@ -27,6 +32,17 @@ var startCmd = &cobra.Command{
configPath = filepath.Base(configPath)
}

interchain.StartChain(parentDir, configPath)
apiAddr, _ := cmd.Flags().GetString(FlagAPIAddressOverride)
apiPort, _ := cmd.Flags().GetUint16(FlagAPIPortOverride)

interchain.StartChain(parentDir, configPath, &interchain.AppConfig{
Address: apiAddr,
Port: apiPort,
})
},
}

func init() {
startCmd.Flags().String(FlagAPIAddressOverride, "127.0.0.1", "override the default API address")
startCmd.Flags().Uint16(FlagAPIPortOverride, 8080, "override the default API port")
}
6 changes: 0 additions & 6 deletions local-interchain/configs/server.json

This file was deleted.

Binary file added local-interchain/contracts/cw_ibc_example.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion local-interchain/docs/REST_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Since local-interchain exposes a REST API, you can interact with the chains usin

## Defaults

By default, the API is served at <http://127.0.0.1:8080/>. You can modify this before starting the chain via [the configs/server.json configuration file](../configs/server.json).
By default, the API is served at <http://127.0.0.1:8080/>. You can modify this before starting the binary with `--api-address` and `--api-port`.

## Environment Variables

Expand Down
Loading

0 comments on commit ea7ce03

Please sign in to comment.