Skip to content

Commit

Permalink
Merge branch 'main' into reece/ics-ibc-v8
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Apr 24, 2024
2 parents cda86b8 + 3428d39 commit 9e78db2
Show file tree
Hide file tree
Showing 13 changed files with 489 additions and 1,364 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ interchaintest.test
.idea
/bin
vendor
examples/hyperspace/exported_state.json
examples/hyperspace/exported_state.json

go.work.sum
19 changes: 18 additions & 1 deletion chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,12 @@ func (tn *ChainNode) CreateNodeContainer(ctx context.Context) error {
for k, v := range sentryPorts {
usingPorts[k] = v
}
for _, port := range chainCfg.ExposeAdditionalPorts {
usingPorts[nat.Port(port)] = []nat.PortBinding{}
}

if tn.Index == 0 && chainCfg.HostPortOverride != nil {
// to prevent port binding conflicts, host port overrides are only exposed on the first validator node.
if tn.Validator && tn.Index == 0 && chainCfg.HostPortOverride != nil {
for intP, extP := range chainCfg.HostPortOverride {
usingPorts[nat.Port(fmt.Sprintf("%d/tcp", intP))] = []nat.PortBinding{
{
Expand Down Expand Up @@ -1418,3 +1422,16 @@ func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, from
_, err := tn.SendICATx(ctx, fromAddr, connectionID, ir, msgs, icaTxMemo, "proto3")
return err
}

// GetHostAddress returns the host-accessible url for a port in the container.
// This is useful for finding the url & random host port for ports exposed via ChainConfig.ExposeAdditionalPorts
func (tn *ChainNode) GetHostAddress(ctx context.Context, portID string) (string, error) {
ports, err := tn.containerLifecycle.GetHostPorts(ctx, portID)
if err != nil {
return "", err
}
if len(ports) == 0 || ports[0] == "" {
return "", fmt.Errorf("no port with id '%s' found", portID)
}
return "http://" + ports[0], nil
}
4 changes: 4 additions & 0 deletions chainspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func (s *ChainSpec) Config(log *zap.Logger) (*ibc.ChainConfig, error) {
}
}

if len(s.ExposeAdditionalPorts) > 0 {
s.ChainConfig.ExposeAdditionalPorts = append(s.ChainConfig.ExposeAdditionalPorts, s.ExposeAdditionalPorts...)
}

// s.Name and chainConfig.Name are interchangeable
if s.Name == "" && s.ChainConfig.Name != "" {
s.Name = s.ChainConfig.Name
Expand Down
40 changes: 35 additions & 5 deletions examples/cosmos/ethermint_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package cosmos_test

import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
"testing"
"time"

Expand All @@ -11,6 +15,7 @@ import (
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)
Expand All @@ -27,9 +32,6 @@ func TestEthermintChain(t *testing.T) {
t.Skip("skipping in short mode")
}

numVals := 1
numFullNodes := 0

cosmos.SetSDKConfig(wallet)

genesis := []cosmos.GenesisKV{
Expand Down Expand Up @@ -83,6 +85,11 @@ func TestEthermintChain(t *testing.T) {
}),
}

jsonRpcOverrides := make(testutil.Toml)
jsonRpcOverrides["address"] = "0.0.0.0:8545"
appTomlOverrides := make(testutil.Toml)
appTomlOverrides["json-rpc"] = jsonRpcOverrides

decimals := int64(decimals)
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Expand All @@ -100,9 +107,10 @@ func TestEthermintChain(t *testing.T) {
TrustingPeriod: "168h0m0s",
ModifyGenesis: cosmos.ModifyGenesis(genesis),
CoinDecimals: &decimals,
// open the port for the EVM on all nodes
ExposeAdditionalPorts: []string{"8545/tcp"},
ConfigFileOverrides: map[string]any{"config/app.toml": appTomlOverrides},
},
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
})

Expand Down Expand Up @@ -133,6 +141,28 @@ func TestEthermintChain(t *testing.T) {
balance, err := chain.GetNode().Chain.GetBalance(ctx, user.FormattedAddress(), denom)
require.NoError(t, err)
require.Equal(t, "10000000000", balance.String())

// verify access to port exposed via ExposeAdditionalPorts
evmJsonRpcUrl, err := chain.FullNodes[0].GetHostAddress(ctx, "8545/tcp")
require.NoError(t, err)

data := []byte(`{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["0x1", null]}`)
resp, err := http.Post(evmJsonRpcUrl, "application/json", bytes.NewBuffer(data))
require.NoError(t, err)
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
require.NoError(t, err)

response := struct {
Result struct {
Number string `json:"number"`
} `json:"result"`
}{}
err = json.Unmarshal(body, &response)
require.NoError(t, err)

require.Equal(t, "0x1", response.Result.Number)
}

type evmEpoch struct {
Expand Down
128 changes: 63 additions & 65 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ module github.com/strangelove-ventures/interchaintest/v8

go 1.22.2

replace (
github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7
)

require (
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.0.2
cosmossdk.io/store v1.1.0
cosmossdk.io/x/feegrant v0.1.0
cosmossdk.io/x/upgrade v0.1.1
github.com/99designs/keyring v1.2.2
Expand All @@ -14,18 +21,18 @@ require (
github.com/StirlingMarketingGroup/go-namecase v1.0.0
github.com/atotto/clipboard v0.1.4
github.com/avast/retry-go/v4 v4.5.1
github.com/cometbft/cometbft v0.38.5
github.com/cosmos/cosmos-sdk v0.50.4
github.com/cometbft/cometbft v0.38.6
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/modules/capability v1.0.0
github.com/cosmos/ibc-go/v8 v8.1.0
github.com/cosmos/ibc-go/v8 v8.2.0
github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240423100140-781f691e7f89
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.1
github.com/docker/docker v24.0.7+incompatible
github.com/docker/docker v24.0.9+incompatible
github.com/docker/go-connections v0.5.0
github.com/ethereum/go-ethereum v1.13.14
github.com/ethereum/go-ethereum v1.13.15
github.com/gdamore/tcell/v2 v2.7.4
github.com/google/go-cmp v0.6.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
Expand All @@ -35,36 +42,36 @@ require (
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2
github.com/mr-tron/base58 v1.2.0
github.com/pelletier/go-toml v1.9.5
github.com/pelletier/go-toml/v2 v2.1.0
github.com/pelletier/go-toml/v2 v2.2.0
github.com/rivo/tview v0.0.0-20220307222120-9994674d60a8
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
github.com/tyler-smith/go-bip32 v1.0.0
github.com/tyler-smith/go-bip39 v1.1.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.20.0
golang.org/x/sync v0.6.0
golang.org/x/tools v0.18.0
google.golang.org/grpc v1.62.0
golang.org/x/crypto v0.22.0
golang.org/x/sync v0.7.0
golang.org/x/tools v0.20.0
google.golang.org/grpc v1.63.2
gopkg.in/yaml.v3 v3.0.1
modernc.org/sqlite v1.28.0
modernc.org/sqlite v1.29.5
)

require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
cosmossdk.io/api v0.7.3 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.37.0 // indirect
cosmossdk.io/api v0.7.4 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core v0.11.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.3.1 // indirect
cosmossdk.io/x/evidence v0.1.0 // indirect
cosmossdk.io/x/tx v0.13.0 // indirect
cosmossdk.io/x/tx v0.13.2 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
Expand All @@ -83,7 +90,7 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
Expand All @@ -93,10 +100,10 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.10.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.0 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.0.1 // indirect
github.com/cosmos/iavl v1.1.2 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
Expand All @@ -121,7 +128,7 @@ require (
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gobwas/ws v1.2.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
Expand All @@ -130,7 +137,7 @@ require (
github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/orderedcode v0.0.1 // indirect
Expand All @@ -149,10 +156,12 @@ require (
github.com/hashicorp/go-getter v1.7.3 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.2 // indirect
github.com/hashicorp/go-metrics v0.5.3 // indirect
github.com/hashicorp/go-plugin v1.5.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
Expand All @@ -164,14 +173,13 @@ require (
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.12 // indirect
github.com/linxGnu/grocksdb v1.8.14 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
Expand All @@ -192,19 +200,20 @@ require (
github.com/multiformats/go-multicodec v0.9.0 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/onsi/gomega v1.27.8 // indirect
github.com/onsi/gomega v1.27.10 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.47.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.3 // indirect
Expand All @@ -229,48 +238,37 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.155.0 // indirect
google.golang.org/api v0.162.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/protobuf v1.32.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.29.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.41.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.0.1 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
nhooyr.io/websocket v1.8.7 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace (
github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7
)
Loading

0 comments on commit 9e78db2

Please sign in to comment.