Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into faddat/ibc8
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Aug 21, 2023
2 parents 85d52bd + cc35cd3 commit 2196665
Show file tree
Hide file tree
Showing 63 changed files with 5,647 additions and 173 deletions.
7 changes: 2 additions & 5 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
pull_request_rules:
- name: backport to maintained branches
conditions:
- base~=^(main|v4|v4-ics|v5|v6)$
- base~=^(main|v6)$
- label=BACKPORT
actions:
backport:
branches:
- main
- v4-ics
- v4
- v5
- v6
assignees:
- "{{ author }}"
Expand All @@ -21,7 +18,7 @@ pull_request_rules:
- name: automerge backported PR's for maintained branches
conditions:
- label=automerge
- base~=^(v4|v4-ics|v5|v6)$
- base=v6
actions:
merge:
method: squash
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ It allows users to quickly spin up custom testnets and dev environments to test

### Maintained Branches

#### Backport Policy:
Strangelove maintains `n` and `n - 1` branches of interchaintest, `n` being current `main`.

We strive to keep interchaintest inline with the latest from the ibc-go and cosmos sdk teams. Once an alpha versions of the next major ibc-go version is released, we will discontinue `n - 1` and branch off a new `n`.

**Recommendation:** Even if your chain uses an older version of ibc-go, try importing from `main`. This should work unless you are decoding transactions that require a specific ibc-go version.

If there is a feature you would like backported to an older branch, make an issue! We are happy to work with you.

| **Branch Name** | **IBC-Go** | **Cosmos-sdk** | **Maintained** |
|:----------------------------------------------------------------------------:|:----------:|:--------------:|:-------------------:|
| main | v7 | v0.47 ||
| [main](https://github.com/strangelove-ventures/interchaintest) | v7 | v0.47 ||
| [v6](https://github.com/strangelove-ventures/interchaintest/tree/v6) | v6 | v0.46 ||
| [v5](https://github.com/strangelove-ventures/interchaintest/tree/v5) | v5 | v0.46 | |
| [v4](https://github.com/strangelove-ventures/interchaintest/tree/v4) | v4 | v0.45 | |
| [v4-ics](https://github.com/strangelove-ventures/interchaintest/tree/v4-ics) | v4 | v0.45.x-ics | |
| [v5](https://github.com/strangelove-ventures/interchaintest/tree/v5) | v5 | v0.46 |❌<br>(Aug 11 2023) |
| [v4](https://github.com/strangelove-ventures/interchaintest/tree/v4) | v4 | v0.45 |❌<br>(Aug 11 2023) |
| [v4-ics](https://github.com/strangelove-ventures/interchaintest/tree/v4-ics) | v4 | v0.45.x-ics |❌<br>(Aug 11 2023) |
| [v3](https://github.com/strangelove-ventures/interchaintest/tree/v3) | v3 | v0.45 |❌<br>(June 25 2023) |
| [v3-ics](https://github.com/strangelove-ventures/interchaintest/tree/v3-ics) | v3 | v0.45.11-ics |❌<br>(April 24 2023)|

Expand Down
47 changes: 43 additions & 4 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ import (
volumetypes "github.com/docker/docker/api/types/volume"
dockerclient "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/internal/blockdb"
"github.com/strangelove-ventures/interchaintest/v7/internal/dockerutil"
"github.com/strangelove-ventures/interchaintest/v7/testutil"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
)

// ChainNode represents a node in the test network that is being created
Expand All @@ -62,6 +63,7 @@ type ChainNode struct {

// Ports set during StartContainer.
hostRPCPort string
hostAPIPort string
hostGRPCPort string
}

Expand Down Expand Up @@ -192,6 +194,10 @@ func (tn *ChainNode) Name() string {
return fmt.Sprintf("%s-%s-%d-%s", tn.Chain.Config().ChainID, nodeType, tn.Index, dockerutil.SanitizeContainerName(tn.TestName))
}

func (tn *ChainNode) ContainerID() string {
return tn.containerLifecycle.ContainerID()
}

// hostname of the test node container
func (tn *ChainNode) HostName() string {
return dockerutil.CondenseHostName(tn.Name())
Expand Down Expand Up @@ -283,6 +289,7 @@ func (tn *ChainNode) SetTestConfig(ctx context.Context) error {

// Enable public RPC
rpc["laddr"] = "tcp://0.0.0.0:26657"
rpc["allowed_origins"] = []string{"*"}

c["rpc"] = rpc

Expand All @@ -308,6 +315,15 @@ func (tn *ChainNode) SetTestConfig(ctx context.Context) error {

a["grpc"] = grpc

api := make(testutil.Toml)

// Enable public REST API
api["enable"] = true
api["swagger"] = true
api["address"] = "tcp://0.0.0.0:1317"

a["api"] = api

return testutil.ModifyTomlConfigFile(
ctx,
tn.logger(),
Expand Down Expand Up @@ -626,6 +642,11 @@ func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, gene
}

command = append(command, "add-genesis-account", address, amount)

if tn.Chain.Config().UsingChainIDFlagCLI {
command = append(command, "--chain-id", tn.Chain.Config().ChainID)
}

_, _, err := tn.ExecBin(ctx, command...)

return err
Expand Down Expand Up @@ -1052,11 +1073,11 @@ func (tn *ChainNode) StartContainer(ctx context.Context) error {
}

// Set the host ports once since they will not change after the container has started.
hostPorts, err := tn.containerLifecycle.GetHostPorts(ctx, rpcPort, grpcPort)
hostPorts, err := tn.containerLifecycle.GetHostPorts(ctx, rpcPort, grpcPort, apiPort)
if err != nil {
return err
}
tn.hostRPCPort, tn.hostGRPCPort = hostPorts[0], hostPorts[1]
tn.hostRPCPort, tn.hostGRPCPort, tn.hostAPIPort = hostPorts[0], hostPorts[1], hostPorts[2]

err = tn.NewClient("tcp://" + tn.hostRPCPort)
if err != nil {
Expand All @@ -1078,6 +1099,24 @@ func (tn *ChainNode) StartContainer(ctx context.Context) error {
}, retry.Context(ctx), retry.Attempts(40), retry.Delay(3*time.Second), retry.DelayType(retry.FixedDelay))
}

func (tn *ChainNode) PauseContainer(ctx context.Context) error {
for _, s := range tn.Sidecars {
if err := s.PauseContainer(ctx); err != nil {
return err
}
}
return tn.containerLifecycle.PauseContainer(ctx)
}

func (tn *ChainNode) UnpauseContainer(ctx context.Context) error {
for _, s := range tn.Sidecars {
if err := s.UnpauseContainer(ctx); err != nil {
return err
}
}
return tn.containerLifecycle.UnpauseContainer(ctx)
}

func (tn *ChainNode) StopContainer(ctx context.Context) error {
for _, s := range tn.Sidecars {
if err := s.StopContainer(ctx); err != nil {
Expand Down
15 changes: 15 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ func (c *CosmosChain) GetRPCAddress() string {
return fmt.Sprintf("http://%s:26657", c.getFullNode().HostName())
}

// Implements Chain interface
func (c *CosmosChain) GetAPIAddress() string {
return fmt.Sprintf("http://%s:1317", c.getFullNode().HostName())
}

// Implements Chain interface
func (c *CosmosChain) GetGRPCAddress() string {
return fmt.Sprintf("%s:9090", c.getFullNode().HostName())
Expand All @@ -215,6 +220,12 @@ func (c *CosmosChain) GetHostRPCAddress() string {
return "http://" + c.getFullNode().hostRPCPort
}

// GetHostAPIAddress returns the address of the REST API server accessible by the host.
// This will not return a valid address until the chain has been started.
func (c *CosmosChain) GetHostAPIAddress() string {
return "http://" + c.getFullNode().hostAPIPort
}

// GetHostGRPCAddress returns the address of the gRPC server accessible by the host.
// This will not return a valid address until the chain has been started.
func (c *CosmosChain) GetHostGRPCAddress() string {
Expand Down Expand Up @@ -821,6 +832,10 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene
Denom: chainCfg.Denom,
}

if chainCfg.ModifyGenesisAmounts != nil {
genesisAmount, genesisSelfDelegation = chainCfg.ModifyGenesisAmounts()
}

genesisAmounts := []types.Coin{genesisAmount}

configFileOverrides := chainCfg.ConfigFileOverrides
Expand Down
11 changes: 10 additions & 1 deletion chain/cosmos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (

dockerclient "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"go.uber.org/zap"

"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/internal/dockerutil"
"go.uber.org/zap"
)

type SidecarProcesses []*SidecarProcess
Expand Down Expand Up @@ -110,6 +111,14 @@ func (s *SidecarProcess) StartContainer(ctx context.Context) error {
return s.containerLifecycle.StartContainer(ctx)
}

func (s *SidecarProcess) PauseContainer(ctx context.Context) error {
return s.containerLifecycle.PauseContainer(ctx)
}

func (s *SidecarProcess) UnpauseContainer(ctx context.Context) error {
return s.containerLifecycle.UnpauseContainer(ctx)
}

func (s *SidecarProcess) StopContainer(ctx context.Context) error {
return s.containerLifecycle.StopContainer(ctx)
}
Expand Down
5 changes: 5 additions & 0 deletions chainspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ func (s *ChainSpec) applyConfigOverrides(cfg ibc.ChainConfig) (*ibc.ChainConfig,
if s.PreGenesis != nil {
cfg.PreGenesis = s.PreGenesis
}
if s.ModifyGenesisAmounts != nil {
cfg.ModifyGenesisAmounts = s.ModifyGenesisAmounts
}

cfg.UsingNewGenesisCommand = s.UsingNewGenesisCommand
cfg.UsingChainIDFlagCLI = s.UsingChainIDFlagCLI

// Set the version depending on the chain type.
switch cfg.Type {
Expand Down
15 changes: 12 additions & 3 deletions conformance/relayersetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"testing"

conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
interchaintest "github.com/strangelove-ventures/interchaintest/v7"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testreporter"
"github.com/strangelove-ventures/interchaintest/v7/testutil"
Expand Down Expand Up @@ -98,7 +99,11 @@ func TestRelayerSetup(t *testing.T, ctx context.Context, cf interchaintest.Chain
conns0, err := r.GetConnections(ctx, eRep, c0.Config().ChainID)
req.NoError(err)

req.Len(conns0, 1)
req.True(len(conns0) == 1 || len(conns0) == 2)
if len(conns0) == 2 {
// Chain might have a localhost connection. Connection IDs are sorted, so this would be at position [1].
req.Equal(conns0[1].ID, exported.LocalhostConnectionID)
}
conn0 := conns0[0]
req.NotEmpty(conn0.ID)
req.NotEmpty(conn0.ClientID)
Expand All @@ -107,7 +112,11 @@ func TestRelayerSetup(t *testing.T, ctx context.Context, cf interchaintest.Chain
conns1, err := r.GetConnections(ctx, eRep, c1.Config().ChainID)
req.NoError(err)

req.Len(conns1, 1)
req.True(len(conns1) == 1 || len(conns1) == 2)
if len(conns1) == 2 {
// Chain might have a localhost connection. Connection IDs are sorted, so this would be at position [1].
req.Equal(conns1[1].ID, exported.LocalhostConnectionID)
}
conn1 := conns1[0]
req.NotEmpty(conn1.ID)
req.NotEmpty(conn1.ClientID)
Expand Down
Loading

0 comments on commit 2196665

Please sign in to comment.