Skip to content

Commit

Permalink
Merge branch 'main' into damian/fix-begin-blocker-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Sep 5, 2023
2 parents aa60d73 + 1e3eee6 commit 9bd124c
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-callbacks-simd-image-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
build-image-at-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: "${{ env.GIT_TAG }}"
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-simd-image-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
build-image-at-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: "${{ env.GIT_TAG }}"
fetch-depth: 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/callbacks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: golangci/[email protected]
with:
version: v1.54.2
Expand All @@ -28,7 +28,7 @@ jobs:
matrix:
go-arch: ['amd64', 'arm', 'arm64']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand All @@ -40,7 +40,7 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/capability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
go-arch: ['amd64', 'arm', 'arm64']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand All @@ -26,7 +26,7 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
image: ghcr.io/cosmos/website-deployment
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract metadata (tags, labels) for Docker
id: meta
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compatibility-unreleased.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- release/v7.2.x
- release/v7.3.x
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: "${{ matrix.release-branch }}"
fetch-depth: 0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-compatibility-workflow-call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
test-matrix: ${{ steps.set-test-matrix.outputs.test-matrix }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: andstor/file-existence-action@v2
with:
files: '.github/compatibility-test-matrices/${{ inputs.test-file-directory }}/${{ inputs.test-suite }}.json'
Expand All @@ -38,7 +38,7 @@ jobs:
matrix: ${{ fromJSON(needs.load-test-matrix.outputs.test-matrix) }}
steps:
- name: Checkout the ibc-go repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: cosmos/ibc-go
- uses: actions/setup-go@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- release/v7.3.x
- main
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: env.RELEASE_BRANCH == matrix.release-branch
with:
ref: "${{ matrix.release-branch }}"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand All @@ -40,7 +40,7 @@ jobs:
fail-fast: false
matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Docker Build
run: docker build . -t "${CHAIN_IMAGE}:${CHAIN_A_TAG}" --build-arg IBC_GO_VERSION=latest
- name: Setup Go
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: ${{ inputs.build-and-push-docker-image }}
- name: Log in to the Container registry
if: ${{ inputs.build-and-push-docker-image }}
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: cosmos/ibc-go
- uses: actions/setup-go@v4
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
fail-fast: false
matrix: ${{ fromJSON(needs.build-test-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: cosmos/ibc-go
- uses: actions/setup-go@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
relayer: ${{ steps.get-relayer.outputs.relayer }}
relayer-tag: ${{ steps.get-relayer.outputs.relayer-tag }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/link-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: '.github/workflows/link-check-config.json'
2 changes: 1 addition & 1 deletion .github/workflows/proto-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-push-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
matrix:
go-arch: ['amd64', 'arm', 'arm64']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand All @@ -64,7 +64,7 @@ jobs:
split-test-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create a file with all the pkgs
run: go list ./... | grep -v e2e > pkgs.txt
- name: Split pkgs into 4 files
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
matrix:
part: ['00', '01', '02', '03']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand All @@ -122,7 +122,7 @@ jobs:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down
2 changes: 1 addition & 1 deletion docs/apps/interchain-accounts/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ simd tx interchain-accounts host --help

##### `generate-packet-data`

The `generate-packet-data` command allows users to generate protobuf encoded interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule's [`send-tx` command](#send-tx).
The `generate-packet-data` command allows users to generate protobuf or proto3 JSON encoded interchain accounts packet data for input message(s). The packet data can then be used with the controller submodule's [`send-tx` command](#send-tx). The `--encoding` flag can be uesd to specify the encoding format (value must be either `proto3` or `proto3json`); if not specified, the default will be `proto3`. The `--memo` flag can be used to include a memo string in the interchain accounts packet data.

```shell
simd tx interchain-accounts host generate-packet-data [message]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 26 additions & 13 deletions modules/apps/27-interchain-accounts/host/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,24 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"

"github.com/cosmos/ibc-go/v7/internal/collections"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
)

const (
memoFlag string = "memo"
memoFlag string = "memo"
encodingFlag string = "encoding"
)

func generatePacketDataCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "generate-packet-data [message]",
Short: "Generates protobuf encoded ICA packet data.",
Long: `generate-packet-data accepts a message string and serializes it using protobuf
into packet data which is outputted to stdout. It can be used in conjunction with send-tx"
which submits pre-built packet data containing messages to be executed on the host chain.
`,
Short: "Generates protobuf or proto3 JSON encoded ICA packet data.",
Long: `generate-packet-data accepts a message string and serializes it (depending on the
encoding parameter) using protobuf or proto3 JSON into packet data which is outputted to stdout.
It can be used in conjunction with send-tx which submits pre-built packet data containing messages
to be executed on the host chain. The default encoding format is protobuf if none is specified;
otherwise the encoding flag can be used in combination with either "proto3" or "proto3json".`,
Example: fmt.Sprintf(`%s tx interchain-accounts host generate-packet-data '{
"@type":"/cosmos.bank.v1beta1.MsgSend",
"from_address":"cosmos15ccshhmp0gsx29qpqq6g4zmltnnvgmyu9ueuadh9y2nc5zj0szls5gtddz",
Expand All @@ -37,7 +40,7 @@ which submits pre-built packet data containing messages to be executed on the ho
"amount": "1000"
}
]
}' --memo memo
}' --memo memo --encoding proto3json
%s tx interchain-accounts host generate-packet-data '[{
Expand Down Expand Up @@ -74,7 +77,16 @@ which submits pre-built packet data containing messages to be executed on the ho
return err
}

packetDataBytes, err := generatePacketData(cdc, []byte(args[0]), memo)
encoding, err := cmd.Flags().GetString(encodingFlag)
if err != nil {
return err
}

if !collections.Contains(encoding, []string{icatypes.EncodingProtobuf, icatypes.EncodingProto3JSON}) {
return fmt.Errorf("unsupported encoding type: %s", encoding)
}

packetDataBytes, err := generatePacketData(cdc, []byte(args[0]), memo, encoding)
if err != nil {
return err
}
Expand All @@ -85,19 +97,20 @@ which submits pre-built packet data containing messages to be executed on the ho
},
}

cmd.Flags().String(memoFlag, "", "an optional memo to be included in the interchain account packet data")
cmd.Flags().String(memoFlag, "", "optional memo to be included in the interchain accounts packet data")
cmd.Flags().String(encodingFlag, "", "optional encoding format of the messages in the interchain accounts packet data")
return cmd
}

// generatePacketData takes in message bytes and a memo and serializes the message into an
// instance of InterchainAccountPacketData which is returned as bytes.
func generatePacketData(cdc *codec.ProtoCodec, msgBytes []byte, memo string) ([]byte, error) {
func generatePacketData(cdc *codec.ProtoCodec, msgBytes []byte, memo string, encoding string) ([]byte, error) {
protoMessages, err := convertBytesIntoProtoMessages(cdc, msgBytes)
if err != nil {
return nil, err
}

return generateIcaPacketDataFromProtoMessages(cdc, protoMessages, memo)
return generateIcaPacketDataFromProtoMessages(cdc, protoMessages, memo, encoding)
}

// convertBytesIntoProtoMessages returns a list of proto messages from bytes. The bytes can be in the form of a single
Expand Down Expand Up @@ -129,8 +142,8 @@ func convertBytesIntoProtoMessages(cdc *codec.ProtoCodec, msgBytes []byte) ([]pr
}

// generateIcaPacketDataFromProtoMessages generates ica packet data as bytes from a given set of proto encoded sdk messages and a memo.
func generateIcaPacketDataFromProtoMessages(cdc *codec.ProtoCodec, sdkMessages []proto.Message, memo string) ([]byte, error) {
icaPacketDataBytes, err := icatypes.SerializeCosmosTx(cdc, sdkMessages, icatypes.EncodingProtobuf)
func generateIcaPacketDataFromProtoMessages(cdc *codec.ProtoCodec, sdkMessages []proto.Message, memo string, encoding string) ([]byte, error) {
icaPacketDataBytes, err := icatypes.SerializeCosmosTx(cdc, sdkMessages, encoding)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 9bd124c

Please sign in to comment.