Skip to content

Commit

Permalink
feat(local-ic): genesis config builder (#1141)
Browse files Browse the repository at this point in the history
* builder,

* migrate types & MnemonicToAddress

* default builder test

* add eth + avs load state example (avs)

* use cosmos as base example

* update v47 params for cosmoshub

* remove unused

* more chains with IBC generation

* update chains, `SetAppendedIBCPathLink`, 4 IBC gen

* use ibc.DockerImage instead of custom type

* `uid_gid` -> original `uid-gid` for Yaml

* `SetStartupCommands`

* only override ports if first new chain

* nit

* fix uidgid

* fix: local-ic go namespace (#1142)

* `github.com/strangelove-ventures/interchaintest/localinterchain`

* `interchaintest/localic`

* `interchaintest/local-interchain`

* uid-gid

* order

* remove stale comment
  • Loading branch information
Reecepbcups authored May 29, 2024
1 parent 1340e70 commit 2e881e2
Show file tree
Hide file tree
Showing 36 changed files with 680 additions and 272 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ interchaintest.test
vendor
examples/hyperspace/exported_state.json

go.work.sum
go.work.sum

# testing generation
local-interchain/interchain/types/chains
local-interchain/interchain/types/configs
2 changes: 1 addition & 1 deletion chain/cosmos/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ModifyGenesis(genesisKV []GenesisKV) func(ibc.ChainConfig, []byte) ([]byte,
}

if err := dyno.Set(g, values.Value, path...); err != nil {
return nil, fmt.Errorf("failed to set value (index:%d) in genesis json: %w", idx, err)
return nil, fmt.Errorf("failed to set key '%s' as '%+v' (index:%d) in genesis json: %w", values.Key, values.Value, idx, err)
}
}

Expand Down
21 changes: 14 additions & 7 deletions chain/cosmos/ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,21 @@ func (c *CosmosChain) transformCCVState(ctx context.Context, ccvState []byte, co
(semver.Compare(providerVersion, icsVer330) < 0 && semver.Compare(consumerVersion, icsVer330) < 0) {
return ccvState, nil
}

var imageVersion, toVersion string

if icsCfg.ProviderVerOverride != "" {
imageVersion = icsCfg.ProviderVerOverride
}

if icsCfg.ConsumerVerOverride != "" {
toVersion = icsCfg.ConsumerVerOverride
}

if imageVersion == toVersion && imageVersion != "" {
return ccvState, nil
}

// The trick here is that when we convert the state to a consumer < 3.3.0, we need a converter that knows about that version; those are >= 4.0.0, and need a --to flag.
// Other than that, this is a question of using whichever version is newer. If it's the provider's, we need a --to flag to tell it the consumer version.
// If it's the consumer's, we don't need a --to flag cause it'll assume the consumer version.
Expand All @@ -382,13 +396,6 @@ func (c *CosmosChain) transformCCVState(ctx context.Context, ccvState []byte, co
imageVersion = consumerVersion
}

if icsCfg.ProviderVerOverride != "" {
imageVersion = icsCfg.ProviderVerOverride
}
if icsCfg.ConsumerVerOverride != "" {
toVersion = icsCfg.ConsumerVerOverride
}

c.log.Info("Transforming CCV state", zap.String("provider", providerVersion), zap.String("consumer", consumerVersion), zap.String("imageVersion", imageVersion), zap.String("toVersion", toVersion))

err := c.GetNode().WriteFile(ctx, ccvState, "ccvconsumer.json")
Expand Down
4 changes: 2 additions & 2 deletions cmd/interchaintest/example_matrix_custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"Repository": "ghcr.io/strangelove-ventures/heighliner/gaia",
"Version": "latest",
"UidGid": "1025:1025"
"uid-gid": "1025:1025"
}
],
"Bin": "gaiad",
Expand All @@ -35,7 +35,7 @@
{
"Repository": "ghcr.io/strangelove-ventures/heighliner/osmosis",
"Version": "latest",
"UidGid": "1025:1025"
"uid-gid": "1025:1025"
}
],
"Bin": "osmosisd",
Expand Down
10 changes: 5 additions & 5 deletions ibc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ type SidecarConfig struct {
}

type DockerImage struct {
Repository string `yaml:"repository"`
Version string `yaml:"version"`
UidGid string `yaml:"uid-gid"`
Repository string `json:"repository" yaml:"repository"`
Version string `json:"version" yaml:"version"`
UidGid string `json:"uid-gid" yaml:"uid-gid"`
}

type CometMockConfig struct {
Expand Down Expand Up @@ -410,6 +410,6 @@ type PathUpdateOptions struct {
}

type ICSConfig struct {
ProviderVerOverride string
ConsumerVerOverride string
ProviderVerOverride string `yaml:"provider,omitempty" json:"provider,omitempty"`
ConsumerVerOverride string `yaml:"consumer,omitempty" json:"consumer,omitempty"`
}
1 change: 0 additions & 1 deletion local-interchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ Here is a base chain template with every feature the configuration accepts. Acco
"ibc_paths": ["juno-ibc-1"],
"debugging": true,
"block_time": "500ms",
"encoding-options": ["juno"],
"host_port_override": {
"26656": "26656",
"26657": "26657",
Expand Down
4 changes: 2 additions & 2 deletions local-interchain/chains/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"bech32_prefix": "juno",
"docker_image": {
"repository": "ghcr.io/cosmoscontracts/juno",
"version": "v17.0.0"
"version": "v17.0.0",
"uid-gid": "1000:1000"
},
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
Expand All @@ -19,7 +20,6 @@
"number_node": 0,
"debugging": true,
"block_time": "5000ms",
"encoding-options": ["juno"],
"host_port_override": {
"26657": "26657",
"1317": "1317",
Expand Down
2 changes: 0 additions & 2 deletions local-interchain/chains/base_ibc.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"version": "v17.0.0"
},
"block_time": "2s",
"encoding-options": ["juno"],
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"ibc_paths": ["atom-juno", "juno-terra"]
Expand All @@ -50,7 +49,6 @@
"version": "v2.3.4"
},
"block_time": "2s",
"encoding-options": ["wasm"],
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"ibc_paths": ["atom-terra", "juno-terra"]
Expand Down
8 changes: 4 additions & 4 deletions local-interchain/chains/cosmoshub.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"binary": "gaiad",
"bech32_prefix": "cosmos",
"docker_image": {
"version": "v10.0.1"
"version": "v16.0.0"
},
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
Expand All @@ -21,15 +21,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": "uatom"
}
],
Expand Down
11 changes: 9 additions & 2 deletions local-interchain/chains/eth.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"chain_id": "31337",
"denom": "wei",
"binary": "anvil",
"bech32_prefix": "n/a",
"bech32_prefix": "0x",
"docker_image": {
"repository": "ghcr.io/foundry-rs/foundry",
"version": "latest"
Expand All @@ -18,7 +18,14 @@
"debugging": true,
"host_port_override": {
"8545": "8545"
}
},
"config_file_overrides": [
{
"paths": {
"--load-state": "chains/state/avs-and-eigenlayer-deployed-anvil-state.json"
}
}
]
}
]
}
2 changes: 0 additions & 2 deletions local-interchain/chains/juno_ibc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"block_time": "500ms",
"ibc_paths": ["juno-ibc-1"],
"debugging": true,
"encoding-options": ["juno"],
"genesis": {
"modify": [
{
Expand Down Expand Up @@ -79,7 +78,6 @@
]
},
"block_time": "500ms",
"encoding-options": ["juno"],
"gas_prices": "0%DENOM%",
"gas_adjustment": 2.0,
"ibc_paths": ["juno-ibc-1"]
Expand Down
28 changes: 28 additions & 0 deletions local-interchain/chains/osmosis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"chains": [
{
"name": "osmosis",
"chain_id": "localosmo-1",
"denom": "uosmo",
"binary": "osmosisd",
"bech32_prefix": "osmo",
"docker_image": {
"version": "v25.0.0"
},
"ibc_paths": ["osmo-ibc-1"]
},
{
"name": "osmosis",
"chain_id": "localosmo-2",
"denom": "uosmo",
"binary": "osmosisd",
"bech32_prefix": "osmo",
"docker_image": {
"version": "v25.0.0"
},
"ibc_paths": ["osmo-ibc-1"]
}
]
}


9 changes: 4 additions & 5 deletions local-interchain/chains/stargaze.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"binary": "starsd",
"bech32_prefix": "stars",
"docker_image": {
"version": "v10.0.1"
"version": "v13.0.0"
},
"gas_prices": "0%DENOM%",
"chain_type": "cosmos",
Expand All @@ -18,19 +18,18 @@
"number_node": 0,
"debugging": true,
"block_time": "500ms",
"encoding-options": ["wasm"],
"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": "ustars"
}
],
Expand Down
3 changes: 3 additions & 0 deletions local-interchain/chains/state/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

## avs-and-eigenlayer-deployed-anvil-state.json
- <https://github.com/mangata-finance/eigen-layer-monorepo/blob/main/tests/integration/avs-and-eigenlayer-deployed-anvil-state.json>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion local-interchain/cmd/local-ic/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/spf13/cobra"
"github.com/strangelove-ventures/localinterchain/interchain/handlers"
"github.com/strangelove-ventures/interchaintest/local-interchain/interchain/handlers"
)

const (
Expand Down
Loading

0 comments on commit 2e881e2

Please sign in to comment.