Skip to content

Commit

Permalink
Merge branch 'v7' into mergify/bp/v7/pr-1064
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups authored Apr 23, 2024
2 parents 71d0e2f + e9641ff commit a0703bf
Show file tree
Hide file tree
Showing 13 changed files with 1,306 additions and 513 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
# Install and setup go
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: "1.21"

- name: checkout interchaintest
uses: actions/checkout@v3
Expand All @@ -35,10 +35,10 @@ jobs:
runs-on: ubuntu-latest
steps:
# Install and setup go
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: "1.21"
cache: false

- name: checkout interchaintest
Expand All @@ -57,10 +57,10 @@ jobs:
runs-on: ubuntu-latest
steps:
# Install and setup go
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: "1.21"
cache: false

- name: checkout interchaintest
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/local-interchain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:

# Ensures that only a single workflow per PR will run at a time. Cancels in-progress jobs if new commit is pushed.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GO_VERSION: 1.19
GO_VERSION: 1.21

jobs:
build:
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ env.GO_VERSION }}

- name: build local-interchain
run: go mod tidy && make install
Expand All @@ -36,7 +36,6 @@ jobs:
name: local-ic
path: ~/go/bin/local-ic


rust-e2e:
name: rust
needs: build
Expand Down Expand Up @@ -98,8 +97,8 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
python-version: "3.10"
cache: "pip"
- run: pip install -r python/requirements.txt --break-system-packages

- name: Download Tarball Artifact
Expand All @@ -118,4 +117,4 @@ jobs:
run: python3 ./python/${{ matrix.test[0] }}.py --api-port ${{ matrix.test[1] }}

- name: Cleanup
run: killall local-ic && exit 0
run: killall local-ic && exit 0
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
# Install and setup go
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: "1.21"

- name: checkout interchaintest
uses: actions/checkout@v3
Expand Down
79 changes: 56 additions & 23 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ import (
coretypes "github.com/cometbft/cometbft/rpc/core/types"
libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/cosmos/gogoproto/proto"
volumetypes "github.com/docker/docker/api/types/volume"
dockerclient "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
Expand All @@ -37,6 +42,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
ccvclient "github.com/cosmos/interchain-security/v3/x/ccv/provider/client"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/internal/blockdb"
Expand Down Expand Up @@ -1367,7 +1373,8 @@ func (tn *ChainNode) CreateNodeContainer(ctx context.Context) error {
usingPorts[k] = v
}

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 @@ -1597,22 +1604,21 @@ func (tn *ChainNode) logger() *zap.Logger {
// RegisterICA will attempt to register an interchain account on the counterparty chain.
func (tn *ChainNode) RegisterICA(ctx context.Context, keyName, connectionID string) (string, error) {
return tn.ExecTx(ctx, keyName,
"intertx", "register",
"--connection-id", connectionID,
"interchain-accounts", "controller", "register", connectionID,
)
}

// QueryICA will query for an interchain account controlled by the specified address on the counterparty chain.
func (tn *ChainNode) QueryICA(ctx context.Context, connectionID, address string) (string, error) {
stdout, _, err := tn.ExecQuery(ctx,
"intertx", "interchainaccounts", connectionID, address,
"interchain-accounts", "controller", "interchain-account", address, connectionID,
)
if err != nil {
return "", err
}

// at this point stdout should look like this:
// interchain_account_address: cosmos1p76n3mnanllea4d3av0v0e42tjj03cae06xq8fwn9at587rqp23qvxsv0j
// address: cosmos1p76n3mnanllea4d3av0v0e42tjj03cae06xq8fwn9at587rqp23qvxsv0j
// we split the string at the : and then just grab the address before returning.
parts := strings.SplitN(string(stdout), ":", 2)
if len(parts) < 2 {
Expand All @@ -1621,27 +1627,54 @@ func (tn *ChainNode) QueryICA(ctx context.Context, connectionID, address string)
return strings.TrimSpace(parts[1]), nil
}

// SendICABankTransfer builds a bank transfer message for a specified address and sends it to the specified
// SendICATx sends an interchain account transaction for a specified address and sends it to the specified
// interchain account.
func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, fromAddr string, amount ibc.WalletAmount) error {
msg, err := json.Marshal(map[string]any{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from_address": fromAddr,
"to_address": amount.Address,
"amount": []map[string]any{
{
"denom": amount.Denom,
"amount": amount.Amount.String(),
},
},
})
func (tn *ChainNode) SendICATx(ctx context.Context, keyName, connectionID string, registry codectypes.InterfaceRegistry, msgs []sdk.Msg, icaTxMemo string) (string, error) {
cdc := codec.NewProtoCodec(registry)

messages := make([]proto.Message, len(msgs))
for _, msg := range msgs {
protoMsg, ok := msg.(proto.Message)
if !ok {
return "", fmt.Errorf("failed to convert sdk.Msg to proto.Message")
}
messages = append(messages, protoMsg)
}

icaPacketDataBytes, err := icatypes.SerializeCosmosTx(cdc, messages)
if err != nil {
return err
return "", err
}

_, err = tn.ExecTx(ctx, fromAddr,
"intertx", "submit", string(msg),
"--connection-id", connectionID,
)
icaPacketData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: icaPacketDataBytes,
Memo: icaTxMemo,
}

if err := icaPacketData.ValidateBasic(); err != nil {
return "", err
}

icaPacketBytes, err := cdc.MarshalJSON(&icaPacketData)
if err != nil {
return "", err
}

return tn.ExecTx(ctx, keyName, "interchain-accounts", "controller", "send-tx", connectionID, string(icaPacketBytes))
}

// SendICABankTransfer builds a bank transfer message for a specified address and sends it to the specified
// interchain account.
func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, fromAddr string, amount ibc.WalletAmount) error {
fromAddress := sdk.MustAccAddressFromBech32(fromAddr)
toAddress := sdk.MustAccAddressFromBech32(amount.Address)
coin := sdk.NewCoin(amount.Denom, amount.Amount)
msg := banktypes.NewMsgSend(fromAddress, toAddress, sdk.NewCoins(coin))
msgs := []sdk.Msg{msg}

ir := tn.Chain.Config().EncodingConfig.InterfaceRegistry
icaTxMemo := "ica bank transfer"
_, err := tn.SendICATx(ctx, fromAddr, connectionID, ir, msgs, icaTxMemo)
return err
}
19 changes: 19 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankTypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
Expand Down Expand Up @@ -409,6 +410,24 @@ func (c *CosmosChain) QueryProposal(ctx context.Context, proposalID string) (*Pr
return c.getFullNode().QueryProposal(ctx, proposalID)
}

// RegisterICA will attempt to register an interchain account on the given counterparty chain.
func (c *CosmosChain) RegisterICA(ctx context.Context, keyName string, connectionID string) (string, error) {
return c.getFullNode().RegisterICA(ctx, keyName, connectionID)
}

// QueryICA will query for an interchain account controlled by the given address on the counterparty chain.
func (c *CosmosChain) QueryICAAddress(ctx context.Context, connectionID, address string) (string, error) {
return c.getFullNode().QueryICA(ctx, connectionID, address)
}

// SendICATx sends an interchain account transaction for a specified address and sends it to the respective
// interchain account on the counterparty chain.
func (c *CosmosChain) SendICATx(ctx context.Context, keyName, connectionID string, msgs []sdk.Msg, icaTxMemo string) (string, error) {
node := c.getFullNode()
registry := node.Chain.Config().EncodingConfig.InterfaceRegistry
return node.SendICATx(ctx, keyName, connectionID, registry, msgs, icaTxMemo)
}

// PushNewWasmClientProposal submits a new wasm client governance proposal to the chain
func (c *CosmosChain) PushNewWasmClientProposal(ctx context.Context, keyName string, fileName string, prop TxProposalv1) (TxProposal, string, error) {
tx := TxProposal{}
Expand Down
2 changes: 1 addition & 1 deletion chain/polkadot/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/decred/dcrd/dcrec/secp256k1/v2"

schnorrkel "github.com/ChainSafe/go-schnorrkel/1"
schnorrkel "github.com/ChainSafe/go-schnorrkel"
"github.com/StirlingMarketingGroup/go-namecase"
p2pCrypto "github.com/libp2p/go-libp2p/core/crypto"
"golang.org/x/crypto/blake2b"
Expand Down
Loading

0 comments on commit a0703bf

Please sign in to comment.