Skip to content

Commit

Permalink
Merge branch 'main' into reece/localic-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya authored Aug 14, 2023
2 parents bfa7653 + 1698144 commit fa9bc6a
Show file tree
Hide file tree
Showing 35 changed files with 841 additions and 287 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
23 changes: 16 additions & 7 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 All @@ -49,7 +58,7 @@ It allows users to quickly spin up custom testnets and dev environments to test

## Building Binary

While it is not necessary to build the binary, sometimes it can be more convenient, *specifically* when running conformance test with custom chain sets.
While it is not necessary to build the binary, sometimes it can be more convenient, *specifically* when running conformance test with custom chain sets.

Building binary:
```shell
Expand All @@ -58,7 +67,7 @@ cd interchaintest
make interchaintest
```

This places the binary in `interchaintest/.bin/interchaintest`
This places the binary in `interchaintest/bin/interchaintest`

Note that this is not in your Go path.

Expand All @@ -74,4 +83,4 @@ Please read the [logging style guide](./docs/logging.md).
Significant bugs that were more easily fixed with `interchaintest`:

- [Juno network halt reproduction](https://github.com/strangelove-ventures/interchaintest/pull/7)
- [Juno network halt fix confirmation](https://github.com/strangelove-ventures/interchaintest/pull/8)
- [Juno network halt fix confirmation](https://github.com/strangelove-ventures/interchaintest/pull/8)
85 changes: 82 additions & 3 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
authTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
volumetypes "github.com/docker/docker/api/types/volume"
dockerclient "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
Expand All @@ -51,6 +52,9 @@ type ChainNode struct {
TestName string
Image ibc.DockerImage

// Additional processes that need to be run on a per-validator basis.
Sidecars SidecarProcesses

lock sync.Mutex
log *zap.Logger

Expand Down Expand Up @@ -121,6 +125,48 @@ func (tn *ChainNode) NewClient(addr string) error {
return nil
}

func (tn *ChainNode) NewSidecarProcess(
ctx context.Context,
preStart bool,
processName string,
cli *dockerclient.Client,
networkID string,
image ibc.DockerImage,
homeDir string,
ports []string,
startCmd []string,
) error {
s := NewSidecar(tn.log, true, preStart, tn.Chain, cli, networkID, processName, tn.TestName, image, homeDir, tn.Index, ports, startCmd)

v, err := cli.VolumeCreate(ctx, volumetypes.CreateOptions{
Labels: map[string]string{
dockerutil.CleanupLabel: tn.TestName,
dockerutil.NodeOwnerLabel: s.Name(),
},
})
if err != nil {
return fmt.Errorf("creating volume for sidecar process: %w", err)
}
s.VolumeName = v.Name

if err := dockerutil.SetVolumeOwner(ctx, dockerutil.VolumeOwnerOptions{
Log: tn.log,

Client: cli,

VolumeName: v.Name,
ImageRef: image.Ref(),
TestName: tn.TestName,
UidGid: image.UidGid,
}); err != nil {
return fmt.Errorf("set volume owner: %w", err)
}

tn.Sidecars = append(tn.Sidecars, s)

return nil
}

// CliContext creates a new Cosmos SDK client context
func (tn *ChainNode) CliContext() client.Context {
cfg := tn.Chain.Config()
Expand All @@ -147,6 +193,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 @@ -631,6 +681,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 @@ -685,7 +740,7 @@ func (tn *ChainNode) SendIBCTransfer(
) (string, error) {
command := []string{
"ibc-transfer", "transfer", "transfer", channelID,
amount.Address, fmt.Sprintf("%d%s", amount.Amount, amount.Denom),
amount.Address, fmt.Sprintf("%s%s", amount.Amount.String(), amount.Denom),
}
if options.Timeout != nil {
if options.Timeout.NanoSeconds > 0 {
Expand All @@ -703,7 +758,7 @@ func (tn *ChainNode) SendIBCTransfer(
func (tn *ChainNode) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error {
_, err := tn.ExecTx(ctx,
keyName, "bank", "send", keyName,
amount.Address, fmt.Sprintf("%d%s", amount.Amount, amount.Denom),
amount.Address, fmt.Sprintf("%s%s", amount.Amount.String(), amount.Denom),
)
return err
}
Expand Down Expand Up @@ -1038,6 +1093,20 @@ func (tn *ChainNode) CreateNodeContainer(ctx context.Context) error {
}

func (tn *ChainNode) StartContainer(ctx context.Context) error {
for _, s := range tn.Sidecars {
err := s.containerLifecycle.Running(ctx)

if s.preStart && err != nil {
if err := s.CreateContainer(ctx); err != nil {
return err
}

if err := s.StartContainer(ctx); err != nil {
return err
}
}
}

if err := tn.containerLifecycle.StartContainer(ctx); err != nil {
return err
}
Expand Down Expand Up @@ -1070,10 +1139,20 @@ func (tn *ChainNode) StartContainer(ctx context.Context) error {
}

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

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

Expand Down Expand Up @@ -1244,7 +1323,7 @@ func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, from
"amount": []map[string]any{
{
"denom": amount.Denom,
"amount": amount.Amount,
"amount": amount.Amount.String(),
},
},
})
Expand Down
Loading

0 comments on commit fa9bc6a

Please sign in to comment.