diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index b355da087d..13f05c131a 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@master - name: lint - run: make proto-lint-docker + run: make proto-lint breakage: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: check-breakage - run: make proto-check-breaking-docker + run: make proto-check-breaking diff --git a/.github/workflows/release-sims.yml b/.github/workflows/release-sims.yml index 4f1dae7a97..68ca310511 100644 --- a/.github/workflows/release-sims.yml +++ b/.github/workflows/release-sims.yml @@ -30,7 +30,7 @@ jobs: - name: install runsim run: | export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary @@ -40,7 +40,7 @@ jobs: needs: [build, install-runsim] steps: - uses: actions/checkout@v2 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index de2e9bb102..d50ddb63a2 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -39,7 +39,7 @@ jobs: run: go version - name: Install runsim run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary @@ -60,7 +60,7 @@ jobs: **/**.go go.mod go.sum - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary @@ -88,7 +88,7 @@ jobs: go.sum SET_ENV_NAME_INSERTIONS: 1 SET_ENV_NAME_LINES: 1 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary @@ -116,7 +116,7 @@ jobs: go.sum SET_ENV_NAME_INSERTIONS: 1 SET_ENV_NAME_LINES: 1 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary @@ -144,7 +144,7 @@ jobs: go.sum SET_ENV_NAME_INSERTIONS: 1 SET_ENV_NAME_LINES: 1 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c81b22003..afa753e232 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - name: install tparse run: | export GO111MODULE="on" && go get github.com/mfridman/tparse@v0.8.3 - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-tparse-binary @@ -216,7 +216,7 @@ jobs: with: name: "${{ github.sha }}-03-race-output" if: env.GIT_DIFF - - uses: actions/cache@v2.1.2 + - uses: actions/cache@v2.1.3 with: path: ~/go/bin key: ${{ runner.os }}-go-tparse-binary diff --git a/.gitignore b/.gitignore index 1755acca7e..2bf1816598 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ docs/node_modules docs/modules dist tools-stamp -proto-tools-stamp buf-stamp artifacts diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a10deafb..7e63adfaca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,18 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements +- (SDK) [\#7925](https://github.com/cosmos/cosmos-sdk/pull/7925) Updated dependencies to use gRPC v1.33.2 + * Updated gRPC dependency to v1.33.2 + * Updated iavl dependency to v0.15-rc2 + + +## [v0.40.0-rc3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.40.0-rc3) - 2020-11-06 + +### Client Breaking + +* (x/staking) [\#7419](https://github.com/cosmos/cosmos-sdk/pull/7419) The `TmConsPubKey` method on ValidatorI has been removed and replaced instead by `ConsPubKey` (which returns a SDK `cryptotypes.PubKey`) and `TmConsPublicKey` (which returns a Tendermint proto PublicKey). + ### Improvements * (tendermint) [\#7828](https://github.com/cosmos/cosmos-sdk/pull/7828) Update tendermint dependency to v0.34.0-rc6 @@ -59,6 +71,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ * `server/types.AppExporter` requires extra argument: `AppOptions`. * `server.AddCommands` requires extra argument: `addStartFlags types.ModuleInitFlags` * `x/crisis.NewAppModule` has a new attribute: `skipGenesisInvariants`. [PR](https://github.com/cosmos/cosmos-sdk/pull/7764) +* [#7918](https://github.com/cosmos/cosmos-sdk/pull/7918) Add x/capability safety checks: + * All outward facing APIs will now check that capability is not nil and name is not empty before performing any state-machine changes + * `SetIndex` has been renamed to `InitializeIndex` ### Features diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e13dba1b85..bfa080cc90 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -142,11 +142,15 @@ build, in which case we can fall back on `go mod tidy -v`. We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos-SDK. +For determinstic behavior around Protobuf tooling, everything is containerized using Docker. Make sure to have Docker installed on your machine, or head to [Docker's website](https://docs.docker.com/get-docker/) to install it. + For formatting code in `.proto` files, you can run `make proto-format` command. -For linting and checking breaking changes, we use [buf](https://buf.build/). There are two options for linting and to check if your changes will cause a break. The first is that you can install [buf](https://buf.build/docs/installation) locally, the commands for running buf after installing are `make proto-lint` and the breaking changes check will be `make proto-check-breaking`. If you do not want to install buf and have docker installed already then you can use these commands `make proto-lint-docker` and `make proto-check-breaking-docker`. +For linting and checking breaking changes, we use [buf](https://buf.build/). You can use the commands `make proto-lint` and `make proto-check-breaking` to respectively lint your proto files and check for breaking changes. -To generate the protobuf stubs you must have `protoc` and `protoc-gen-gocosmos` installed. To install these tools run `make proto-tools`. After this step you will be able to run `make proto-gen` to generate the protobuf stubs. +To generate the protobuf stubs, you can run `make proto-gen`. + +We also added the `make proto-all` command to run all the above commands sequentially. In order for imports to properly compile in your IDE, you may need to manually set your protobuf path in your IDE's workspace settings/config. @@ -268,8 +272,8 @@ and PRs are merged into `master`, if a contributor wishes the PR to be released - **[Impact]** Explanation of how the bug affects users or developers. - **[Test Case]** section with detailed instructions on how to reproduce the bug. - **[Regression Potential]** section with a discussion how regressions are most likely to manifest, or might - manifest even if it's unlikely, as a result of the change. **It is assumed that any SRU candidate PR is - well-tested before it is merged in and has an overall low risk of regression**. + manifest even if it's unlikely, as a result of the change. **It is assumed that any SRU candidate PR is + well-tested before it is merged in and has an overall low risk of regression**. It is the PR's author's responsibility to fix merge conflicts, update changelog entries, and ensure CI passes. If a PR originates from an external contributor, it may be a core team member's @@ -280,7 +284,7 @@ Finally, when a point release is ready to be made: 1. Create `release/v0.38.N` branch 2. Ensure changelog entries are verified - 2. Be sure changelog entries are added to `RELEASE_CHANGELOG.md` + 1. Be sure changelog entries are added to `RELEASE_CHANGELOG.md` 3. Add release version date to the changelog 4. Push release branch along with the annotated tag: **git tag -a** 5. Create a PR into `master` containing ONLY `CHANGELOG.md` updates diff --git a/Makefile b/Makefile index 5eadb43a7c..1d8164219f 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ BUILDDIR ?= $(CURDIR)/build SIMAPP = ./simapp MOCKS_DIR = $(CURDIR)/tests/mocks HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git -DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf +DOCKER_BUF := docker run -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf export GO111MODULE = on @@ -356,38 +356,30 @@ devdoc-update: ### Protobuf ### ############################################################################### -proto-all: proto-tools proto-gen proto-lint proto-check-breaking proto-swagger-gen proto-format +proto-all: proto-format proto-lint proto-check-breaking proto-gen proto-gen: - @./scripts/protocgen.sh + @echo "Generating Protobuf files" + docker run -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh proto-format: @echo "Formatting Protobuf files" - docker run -v $(shell pwd):/workspace \ + docker run -v $(CURDIR):/workspace \ --workdir /workspace tendermintdev/docker-build-proto \ find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; -.PHONY: proto-format # This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed proto-gen-any: - @./scripts/protocgen-any.sh + docker run -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen-any.sh proto-swagger-gen: @./scripts/protoc-swagger-gen.sh proto-lint: - @buf check lint --error-format=json + @$(DOCKER_BUF) check lint --error-format=json proto-check-breaking: - @buf check breaking --against-input '.git#branch=master' - -proto-lint-docker: - @$(DOCKER_BUF) check lint --error-format=json -.PHONY: proto-lint - -proto-check-breaking-docker: @$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master -.PHONY: proto-check-breaking-ci TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos @@ -440,7 +432,7 @@ proto-update-deps: ## Issue link: https://github.com/confio/ics23/issues/32 @sed -i '4ioption go_package = "github.com/confio/ics23/go";' $(CONFIO_TYPES)/proofs.proto -.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-deps +.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps ############################################################################### ### Localnet ### diff --git a/client/account_retriever.go b/client/account_retriever.go index 51c0a7fa9b..8e2fd14c1f 100644 --- a/client/account_retriever.go +++ b/client/account_retriever.go @@ -1,15 +1,14 @@ package client import ( - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // Account defines a read-only version of the auth module's AccountI. type Account interface { GetAddress() sdk.AccAddress - GetPubKey() crypto.PubKey // can return nil. + GetPubKey() cryptotypes.PubKey // can return nil. GetAccountNumber() uint64 GetSequence() uint64 } diff --git a/client/debug/main.go b/client/debug/main.go index ab9ec0cf8a..54b75e712b 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -8,10 +8,10 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/version" @@ -34,7 +34,7 @@ func Cmd() *cobra.Command { // getPubKeyFromString returns a Tendermint PubKey (PubKeyEd25519) by attempting // to decode the pubkey string from hex, base64, and finally bech32. If all // encodings fail, an error is returned. -func getPubKeyFromString(pkstr string) (crypto.PubKey, error) { +func getPubKeyFromString(pkstr string) (cryptotypes.PubKey, error) { bz, err := hex.DecodeString(pkstr) if err == nil { if len(bz) == ed25519.PubKeySize { diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 06500d7545..0b52dcf194 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -15760,7 +15760,7 @@ paths: } tags: - Query - /ibc/channel/v1beta1/channels: + /ibc/core/channel/v1beta1/channels: get: summary: Channels queries all the IBC channels of a chain. operationId: Channels @@ -16146,7 +16146,7 @@ paths: type: boolean tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}': get: summary: Channel queries an IBC Channel. operationId: Channel @@ -16471,7 +16471,7 @@ paths: type: string tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state': get: summary: >- ChannelClientState queries for the client state for the channel @@ -16909,7 +16909,7 @@ paths: type: string tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/version/{version_number}/height/{version_height}': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/version/{version_number}/height/{version_height}': get: summary: |- ChannelConsensusState queries for the consensus state for the channel @@ -17344,7 +17344,7 @@ paths: format: uint64 tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence': get: summary: >- NextSequenceReceive returns the next receive sequence for a given @@ -17596,7 +17596,7 @@ paths: type: string tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements': get: summary: >- PacketAcknowledgements returns all the packet acknowledgements @@ -17945,7 +17945,7 @@ paths: type: boolean tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}': get: summary: PacketAcknowledgement queries a stored packet acknowledgement hash. operationId: PacketAcknowledgement @@ -18205,7 +18205,7 @@ paths: format: uint64 tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments': get: summary: |- PacketCommitments returns all the packet commitments hashes associated @@ -18552,7 +18552,7 @@ paths: type: boolean tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks': get: summary: >- UnreceivedAcks returns all the unreceived IBC acknowledgements @@ -18814,7 +18814,7 @@ paths: minItems: 1 tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_commitment_sequences}/unreceived_packets': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_commitment_sequences}/unreceived_packets': get: summary: >- UnreceivedPackets returns all the unreceived IBC packets associated with @@ -19076,7 +19076,7 @@ paths: minItems: 1 tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}': get: summary: PacketCommitment queries a stored packet commitment hash. operationId: PacketCommitment @@ -19337,7 +19337,7 @@ paths: format: uint64 tags: - Query - '/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}': + '/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}': get: summary: >- PacketReceipt queries if a given packet sequence has been received on @@ -19599,7 +19599,7 @@ paths: format: uint64 tags: - Query - '/ibc/channel/v1beta1/connections/{connection}/channels': + '/ibc/core/channel/v1beta1/connections/{connection}/channels': get: summary: |- ConnectionChannels queries all the channels associated with a connection @@ -19992,7 +19992,222 @@ paths: type: boolean tags: - Query - /ibc/client/v1beta1/client_states: + /ibc/client/v1beta1/params: + get: + summary: ClientParams queries all parameters of the ibc client. + operationId: ClientParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + allowed_clients: + type: array + items: + type: string + description: >- + allowed_clients defines the list of allowed client state + types. + description: >- + QueryClientParamsResponse is the response type for the + Query/ClientParams RPC method. + default: + description: An unexpected error response. + schema: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of + the serialized + + protocol buffer message. This string must contain at + least + + one "/" character. The last segment of the URL's path + must represent + + the fully qualified name of the type (as in + + `path/google.protobuf.Duration`). The name should be in + a canonical form + + (e.g., leading "." is not accepted). + + + In practice, teams usually precompile into the binary + all types that they + + expect it to use in the context of Any. However, for + URLs which use the + + scheme `http`, `https`, or no scheme, one can optionally + set up a type + + server that maps type URLs to message definitions as + follows: + + + * If no scheme is provided, `https` is assumed. + + * An HTTP GET on the URL must yield a + [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based + on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in + the official + + protobuf release, and it is not used for type URLs + beginning with + + type.googleapis.com. + + + Schemes other than `http`, `https` (or the empty scheme) + might be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. + description: >- + `Any` contains an arbitrary serialized protocol buffer + message along with a + + URL that describes the type of the serialized message. + + + Protobuf library provides support to pack/unpack Any values + in the form + + of utility functions or additional generated methods of the + Any type. + + + Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + + Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := ptypes.MarshalAny(foo) + ... + foo := &pb.Foo{} + if err := ptypes.UnmarshalAny(any, foo); err != nil { + ... + } + + The pack methods provided by protobuf library will by + default use + + 'type.googleapis.com/full.type.name' as the type URL and the + unpack + + methods only use the fully qualified type name after the + last '/' + + in the type URL, for example "foo.bar.com/x/y.z" will yield + type + + name "y.z". + + + + JSON + + ==== + + The JSON representation of an `Any` value uses the regular + + representation of the deserialized, embedded message, with + an + + additional field `@type` which contains the type URL. + Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + + If the embedded message type is well-known and has a custom + JSON + + representation, that representation will be embedded adding + a field + + `value` which holds the custom JSON in addition to the + `@type` + + field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + tags: + - Query + /ibc/core/client/v1beta1/client_states: get: summary: ClientStates queries all the IBC light clients of a chain. operationId: ClientStates @@ -20465,7 +20680,7 @@ paths: type: boolean tags: - Query - '/ibc/client/v1beta1/client_states/{client_id}': + '/ibc/core/client/v1beta1/client_states/{client_id}': get: summary: ClientState queries an IBC light client. operationId: ClientState @@ -20883,7 +21098,7 @@ paths: type: string tags: - Query - '/ibc/client/v1beta1/consensus_states/{client_id}': + '/ibc/core/client/v1beta1/consensus_states/{client_id}': get: summary: |- ConsensusStates queries all the consensus state associated with a given @@ -21383,7 +21598,7 @@ paths: type: boolean tags: - Query - '/ibc/client/v1beta1/consensus_states/{client_id}/version/{version_number}/height/{version_height}': + '/ibc/core/client/v1beta1/consensus_states/{client_id}/version/{version_number}/height/{version_height}': get: summary: >- ConsensusState queries a consensus state associated with a client state @@ -21825,7 +22040,7 @@ paths: type: boolean tags: - Query - '/ibc/connection/v1beta1/client_connections/{client_id}': + '/ibc/core/connection/v1beta1/client_connections/{client_id}': get: summary: |- ClientConnections queries the connection paths associated with a client @@ -22073,7 +22288,7 @@ paths: type: string tags: - Query - /ibc/connection/v1beta1/connections: + /ibc/core/connection/v1beta1/connections: get: summary: Connections queries all the IBC connections of a chain. operationId: Connections @@ -22457,7 +22672,7 @@ paths: type: boolean tags: - Query - '/ibc/connection/v1beta1/connections/{connection_id}': + '/ibc/core/connection/v1beta1/connections/{connection_id}': get: summary: Connection queries an IBC connection end. operationId: Connection @@ -22777,7 +22992,7 @@ paths: type: string tags: - Query - '/ibc/connection/v1beta1/connections/{connection_id}/client_state': + '/ibc/core/connection/v1beta1/connections/{connection_id}/client_state': get: summary: |- ConnectionClientState queries the client state associated with the @@ -23208,7 +23423,7 @@ paths: type: string tags: - Query - '/ibc/connection/v1beta1/connections/{connection_id}/consensus_state/version/{version_number}/height/{version_height}': + '/ibc/core/connection/v1beta1/connections/{connection_id}/consensus_state/version/{version_number}/height/{version_height}': get: summary: |- ConnectionConsensusState queries the consensus state associated with the @@ -23636,7 +23851,7 @@ paths: format: uint64 tags: - Query - /ibc_transfer/v1beta1/denom_traces: + /ibc/applications/transfer/v1beta1/denom_traces: get: summary: DenomTraces queries all denomination traces. operationId: DenomTraces @@ -23761,7 +23976,7 @@ paths: type: boolean tags: - Query - '/ibc_transfer/v1beta1/denom_traces/{hash}': + '/ibc/applications/transfer/v1beta1/denom_traces/{hash}': get: summary: DenomTrace queries a denomination trace information. operationId: DenomTrace @@ -23822,7 +24037,7 @@ paths: type: string tags: - Query - /ibc_transfer/v1beta1/params: + /ibc/applications/transfer/v1beta1/params: get: summary: Params queries all parameters of the ibc-transfer module. operationId: IBCTransferParams @@ -33015,6 +33230,30 @@ definitions: description: >- ConsensusStateWithHeight defines a consensus state with an additional height field. + ibc.core.client.v1.Params: + type: object + properties: + allowed_clients: + type: array + items: + type: string + description: allowed_clients defines the list of allowed client state types. + description: Params defines the set of IBC light client parameters. + ibc.core.client.v1.QueryClientParamsResponse: + type: object + properties: + params: + description: params defines the parameters of the module. + type: object + properties: + allowed_clients: + type: array + items: + type: string + description: allowed_clients defines the list of allowed client state types. + description: >- + QueryClientParamsResponse is the response type for the Query/ClientParams + RPC method. ibc.core.client.v1.QueryClientStateResponse: type: object properties: diff --git a/client/keys/add.go b/client/keys/add.go index b2e267e83e..c91f639c4a 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -9,7 +9,6 @@ import ( bip39 "github.com/cosmos/go-bip39" "github.com/spf13/cobra" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/client" @@ -18,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -152,7 +152,7 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keyring.Keyring, inBuf *buf multisigKeys, _ := cmd.Flags().GetStringSlice(flagMultisig) if len(multisigKeys) != 0 { - var pks []crypto.PubKey + var pks []cryptotypes.PubKey multisigThreshold, _ := cmd.Flags().GetInt(flagMultiSigThreshold) if err := validateMultisigThreshold(multisigThreshold, len(multisigKeys)); err != nil { @@ -247,7 +247,7 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keyring.Keyring, inBuf *buf } if len(mnemonic) == 0 { - // read entropy seed straight from crypto.Rand and convert to mnemonic + // read entropy seed straight from tmcrypto.Rand and convert to mnemonic entropySeed, err := bip39.NewEntropy(mnemonicEntropySize) if err != nil { return err diff --git a/client/keys/keyring-test/00ddf62001f91b9aaf7758fb727bea3932bb236e.address b/client/keys/keyring-test/00ddf62001f91b9aaf7758fb727bea3932bb236e.address deleted file mode 100644 index f53c291b43..0000000000 --- a/client/keys/keyring-test/00ddf62001f91b9aaf7758fb727bea3932bb236e.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMzowNjozOC45MTAzNTggLTA0MDAgRURUIG09KzAuMDUwMTczMjM4IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiT25IN1lscERZSHZUVFFQcCJ9.27X3naS_OL75csQLEIFoPvvCyYb9R4D573z1Z1obm3TRGn4HyPFN_w.GXNcqKAUkxqM537Q.cT169l1KGKeOra6NXHbx3kEOEDw77Lom-42mwKV0bRQ_5WZU3kG5o6Ix14r7LFL1ajjc8rdXkuiUgKQyVXEXVpo-6WkEfk2-D_CQaaUgq0-UErT-9Pj7djI3FZkPPG-yxlVSiQXB1xMk38I_AxYwAakctpwHlEK_YC0-UycFmk25Qjezar_ni69KDRPyuqCYh3dyhimG6LgdpWF4pQHjtZPy5qIqcaE7TR0OeKvf9MtsaKEzpAQOeAvh.WbbZ_Fs8qk9rsN6FuWa2zg \ No newline at end of file diff --git a/client/keys/keyring-test/252b5fe0336e82b269d1c26e379b11b54474f57a.address b/client/keys/keyring-test/252b5fe0336e82b269d1c26e379b11b54474f57a.address deleted file mode 100644 index 4e99364230..0000000000 --- a/client/keys/keyring-test/252b5fe0336e82b269d1c26e379b11b54474f57a.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yMzA4ODggLTA0MDAgRURUIG09KzAuMTYxMTg1Nzk2IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiU3ZNM1hfZU42VHhpSVg3aiJ9.BjL9xqItRueA3u4ujcWPTp4TJjO6w4NeR9G7p32ndo63ADDGJ7j1JQ.8Fd_XM52yxKhF31U.7Cm3SBAmp0u4QffFwBgeueuU3rWT1npSKI5CUROX5COgKbDpqj5CaT54k6UGeZiUxv8itQXglUpAsg7XsF-1LjbbUAfVxXe9H9n1GcfxrLov0L8_Ia-5JadXMXkbvv9jKyjhVg6kSziQXoHcHaeauF1X0_ij3a-UVH87cLqsdAI_OXtptyU8GonVyt_Q0n8mljonjZhj2c_bmXmHARYXZOmCj52dmzSpmkyQ9vqdhlRPco93-JWR5P1V.5J7fb71-1WKJ91g02D0JGg \ No newline at end of file diff --git a/client/keys/keyring-test/43ca6f8e891fd1ef46a28d67c9be33ffecd8a6f8.address b/client/keys/keyring-test/43ca6f8e891fd1ef46a28d67c9be33ffecd8a6f8.address deleted file mode 100644 index d03cbd2cbc..0000000000 --- a/client/keys/keyring-test/43ca6f8e891fd1ef46a28d67c9be33ffecd8a6f8.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MzoyMy4yNjI0NzEgLTA0MDAgRURUIG09KzAuMDc2MzQ4MjA5IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiTE02SnY0RUdZNHBPLTQxWSJ9.wsqaCPHz_PlOH4_B3QlKT_4N9nTEjMzqn_Rqjq2ZM3vzf1dTO1_gjA.WVEaKSvNNWJ3ZaTT.eWrtCGCCplDULPw1QEyijVO_totUT5-6yx-TK4KP_BdKmhdEG8Bm319dXU33BchHthFa2VxDyB4NH_hsUenErJSKIJgJGoVc_AMwqrVZr0Wg0qJaay7jRGh1IRNXc0cuEsNpEek1C31tNaXjD2IuJzkicwdDT3BARFLFFdRhY97LG83YTvX0gVKyJFfjx8TAgUHZgpYyJMI4_vVajnneI-v1SYCY_VMbFTaCqWKFZdYOhu3x-hXfFBww.rxnMJbBz5OU4itr8nuyZgA \ No newline at end of file diff --git a/client/keys/keyring-test/454b29a63587e58ce2487836d90bda016c6fff7c.address b/client/keys/keyring-test/454b29a63587e58ce2487836d90bda016c6fff7c.address deleted file mode 100644 index 12fc44167b..0000000000 --- a/client/keys/keyring-test/454b29a63587e58ce2487836d90bda016c6fff7c.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yNDQwMTEgLTA0MDAgRURUIG09KzAuMTc0MzMxMjAxIiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiYmlQLXR5Mnlvc3U2aHBvLSJ9.3drCmgYTeqS3PohaYKQc7i1fyjtOMuEPu_pDqMpT0UStPNDxG_LUDg.VS6Au9HoIruV0RiE._2BmFif-VbT_x4OD1NfsOCVFdL2MZfsG645SkptEKZAncOwHkKmWnBlKiV_LwnNzRBh-9eGGsCGfyou3zjUQRMDDHJOuW2EaVNmufmBWcAb9UoNO8O5kzPHwIvNqqJo5TQyjOviKCoP2PVcJXAwzttqDOw71B-9OuPwt_Ed4G6u8evwGIe08CzV6CKVImzj-AQg-1UI-uL06yFIEJ6CzB1DMdPR0qDQddP8pSYR_RTHnEUsii7HeKK1O.jqlYm4IZhXqe1k5kBQtguA \ No newline at end of file diff --git a/client/keys/keyring-test/900b3a0b8932e443b60fd6273cc3026aa25116c8.address b/client/keys/keyring-test/900b3a0b8932e443b60fd6273cc3026aa25116c8.address deleted file mode 100644 index 4f49e8bddd..0000000000 --- a/client/keys/keyring-test/900b3a0b8932e443b60fd6273cc3026aa25116c8.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yMDQ1NjYgLTA0MDAgRURUIG09KzAuMTM0ODY0MzE4IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoidjVpMzRMY3NNbXduakEyMiJ9.XTokiwtSrKOIGREG7P7uaSfcV3hEr2ANHVUwaKbvLbuQVlTQO8fALw.bldSMLqfirE4GM9S.kNlvEojt1cavNW-nCaxX-Qk3tNm09xtXbuKppWbmMBUCf-_p-U_TWsnHuKbLon47RH1lxomrc1RpcfXwWhDEsGLwibtsjRdxz_2DGh124jeKOr4-Bl2raoPWdHKimm_cf5Ve17ChFfVy1AOaXwIr97ZdGWSU0FP8hOvv5_z5iUsuMK9T0DLxjz0162-_xSQMWWl4-hLknHz-QdO3oR_FpYo2K2eucNaFKmcN5Rn4s2n8FYLU9dIcopUF.WpNuRheBDoTiv3rK95yNjA \ No newline at end of file diff --git a/client/keys/keyring-test/9a85abde78d0e55e7650f11dcfdbb6bd131038d0.address b/client/keys/keyring-test/9a85abde78d0e55e7650f11dcfdbb6bd131038d0.address deleted file mode 100644 index 9110d23a6b..0000000000 --- a/client/keys/keyring-test/9a85abde78d0e55e7650f11dcfdbb6bd131038d0.address +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yMjAyOSAtMDQwMCBFRFQgbT0rMC4xNTA1ODc4MjYiLCJlbmMiOiJBMjU2R0NNIiwicDJjIjo4MTkyLCJwMnMiOiJJYXRUWEFMVjBfeXV2ZnNMIn0.kCXD6XXDHeBiXR-GqF10fbMWBvy3qe38r16b92Xu3oLpA5c0a6ByMg.ONW9ggBJFhdfIA8M.IWm_ioQqOCLSK3FbSwjAlEVtzRR4AAW7ceIXpKzv_voaCGDNgcr7xSyRR5N-YK-sVYInwUDrme8rb5T14mjcsNgoGdKKB2QXuApY-GcPwpe2Tf7TyiCxFp91VotHnrbjCh1NvWnjDC-SZNm8HDVolkYtiBPkIkk0uFGh35WWprkVpgEYFyNIFQ0PP3XD4D9A58X0UXdGEu5Q8VcJnt1p86XUyI1le_LufJUrWAz3o_89n3xKj-b6sYzQ.KZSIrdNzE97BxrTSNkMkTw \ No newline at end of file diff --git a/client/keys/keyring-test/keyname1.info b/client/keys/keyring-test/keyname1.info deleted file mode 100644 index 6da5735e6e..0000000000 --- a/client/keys/keyring-test/keyname1.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMzowNjozOC45MDMwMjcgLTA0MDAgRURUIG09KzAuMDQyODQyNTY4IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiSjBxN2Zza0pGRUJJR25mYSJ9.W91-I2lpaBfacsUO2Xn2_tCadqztjGX7MjAkA6GKL4uMkqjEHDXyhw.c8uKD9z5w-jpSmq1.XGnt9JaOg0VT1cjg4RAlwC6Bsq9KowSF6wM6Ak1Y16Kq4sV3NnwA4CqJKnluIjAG6D4sfBKEs2FCHy5zux4uaOQ3Y5EJjRxWoTdBP7HahmO2-jsSFX_sPIzr86KIlKIqaYFJAOUqvaObOsQkX3EL_2-vDonSRMz32abg8thFS6mNi7NtM4xGXQ5Knrix-6OgzBmvWbn4Y0v82vNNWh8d4ubKf_RSEBV7CIWfuFg2CxfRq5EbUUmtMINF74eG52F8y8zjTDcn6n3qKLcecdr6s0n1tc7iq-f3s1EHnzPefwROPLFxiq0Zyt7N7vZCSowOElYZtgQWEg0dy6CIyZ274gNPlfLXMHA-kUsZj4Q_3w.sUPc7D8bBR4I3S-njXa4Ww \ No newline at end of file diff --git a/client/keys/keyring-test/keyname2.info b/client/keys/keyring-test/keyname2.info deleted file mode 100644 index bc7b594c5a..0000000000 --- a/client/keys/keyring-test/keyname2.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MzoyMy4yNTg0OTUgLTA0MDAgRURUIG09KzAuMDcyMzcyNTM1IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiTW1XOFlVU0Nia2JUNW9iSSJ9.JyBrlPAvgtgYWwu0rcfTn6k9qvv6DywUotcWxPUiJncCBue2WPC5cQ.CmWeu5wMFFinUfiE.FA9k3Q_W8mBgSuJRkYV8h_U5YR2mDmW595L4DnFzuSFJ19Us0O1SQF9-xPJQAyjh4jli46o5mfFfsmU0ce1h4HwklW7AdrRJXVXZ0reZLjrdiojCbLvzyM9tsWInRXi6izUcwLggv2lNCXP5UIRpjMpUPiEC4GsHiwNH8qN04_feICxHuSWJ4mKLWEDtgKxHTrBqvaHT304UF6gRD-_W9_hWdEIj66-5HE4jlxcJAe22WdoF2Z1c3ujhm4piSfHaNnWYsZHLI5Jy1WhkFC2eULOe31c6eAeik5DyUUdWKvAoSiEk4H0Z9EcSbNzlW2rrU30WIIb-icK1qLID21WYurbxM8zvXl-CvhSM2VRN1g.tu_usvTlCOy3okBKmC6zHg \ No newline at end of file diff --git a/client/keys/keyring-test/keyname4.info b/client/keys/keyring-test/keyname4.info deleted file mode 100644 index 2a198cd917..0000000000 --- a/client/keys/keyring-test/keyname4.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4xOTkwMDUgLTA0MDAgRURUIG09KzAuMTI5MzA0MDMxIiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiYzVYM09VdTBtQmJ4TFd4ayJ9.Pa4p1u-9N9x4E9-5rjUlReLsfH3TvTfAw-Dr1iV8z5ccAfnqLY1UWQ.Q41_cYh4c-C2zi3v.aFna4CwpZeGQBI2_ecOzlJSKypCV0NLCD8PCOnpYvY-k-HqoUFSeouFbuKeN9VaIo12JSZmjzGhfCAupZDBcSJisLVHOvaBAjl5XCOa8k49jb-aSopMI4HXQWatBJcnM65p9Hl1JrYOcnoKPxNKzJ4PiPQnHKv_VgAvWU_CBt6nnSjkwwVJjPMobgvNzeQTEFq-4pyziJNDbDWKUrQSrc-VaO-31JBlhpu6dPOJPFsnOcMyPc76po5cAQQdog-g79d59_Y4vj8s7qd-YPCHnWmoCbgf9w8vbpmJ4Y9evXZQz8A0-c0rFX7F96aZBYtQOeC1ZpRi0BMsbs_WHrpdN678HXej6YpfNDijQmiNYzQ.ayDBvX4W6GiGxAjN3ch8DA \ No newline at end of file diff --git a/client/keys/keyring-test/keyname5.info b/client/keys/keyring-test/keyname5.info deleted file mode 100644 index 5c9bbe4e97..0000000000 --- a/client/keys/keyring-test/keyname5.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yMTYwNTkgLTA0MDAgRURUIG09KzAuMTQ2MzU3MTI5IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoidmNnOXNfXzFvY0N1ZC1YTCJ9.hQ21Z1cXTw925V8Xxm_Gywb05S92rKEX54tnELv16xZvkgV8XiEj9A.4Wnaa4LemIi3bdIT.kEJyzWUvmLof5_bYbDePbrYyfjyqTLuUIOdnom3igOuwfzFDHtPuEb3rSLKjxj7LgJOmZVqZGP_ihW1sJQPXbK7ZuWA4zH_Wf-n5T8CFDmNIUhlUIb6sfd_ze-s45CE58hjKRkp7b5k61xBnMujZ5KC5Vk_JHUOUyZB5SqhTuEUJDjSSCFnMDJ1UYKEp23U__XFwcZonent4IMfM0fWvmA6NC2h0qLAMcKw9hbJ_yyNHt2I3lI5twthsAOsXKxUkjhx7c9Tc7BnttFxq-puD_QyjReExP77DzuueDJ-5KBd8PMgeiQMHoYM8e2NAAJU7MXe7voB-D8Ki2QcEgH7GfHNcr6vP1by3hvV5M32OXg.ifBDbtRjrXBOdH_jEORHgw \ No newline at end of file diff --git a/client/keys/keyring-test/keyname6.info b/client/keys/keyring-test/keyname6.info deleted file mode 100644 index f193785ba6..0000000000 --- a/client/keys/keyring-test/keyname6.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yMjY1OTEgLTA0MDAgRURUIG09KzAuMTU2ODg5MTU0IiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiNUtTSWJtdGhCVHVSUnRjYyJ9.qD2C7cQK5P0EHy2Yr-uQZzMHep6U6n57z2LwWTmgxQp6m7ujLw-C-g.rmsltoJfFO4e56RZ.IDpVmduqe2WgyepT_-paXzcosHQzK6sfKY9JH16lT4QRVJ_lAozQOyZrW3X5MbgefrmtXGsoEIEFYhTDYBtXxrW7IqLaBhSCiA5MVwR403H3C2NkcygdGDdR-uDQGW3_bp7xnOhVL_3ofu0-7MQMMhZyz_wEmVW-aG7F6lN68TPaO5KTIqfnI8vOJyyZsSgB0M0gA3f-P4aar64YDTUdjgXPOSBkyRZr07JIOauGhTFXwmHWsDVBvGo3aIIx9ybAg_Blgo8ZAPqOJ6EYmA3J5RE2_LkfJjgI8dEpIFaviBHeWrG54AAN0klQ7trq9MOCpUGPc7PqySwiwTmxb2g4kFH9fR_yQ-g5g6mjj3JYVA.GRnNxd28SYmRt1I9twptPw \ No newline at end of file diff --git a/client/keys/keyring-test/keyname7.info b/client/keys/keyring-test/keyname7.info deleted file mode 100644 index 7b09ba0a78..0000000000 --- a/client/keys/keyring-test/keyname7.info +++ /dev/null @@ -1 +0,0 @@ -eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyMC0xMC0wOCAxMjo1MDoxOC4yMzg1MTQgLTA0MDAgRURUIG09KzAuMTY4ODExNzMwIiwiZW5jIjoiQTI1NkdDTSIsInAyYyI6ODE5MiwicDJzIjoiUmZDZC0xeGh6OVJ3RzJfViJ9.hMyIYfHwLYAwJs6THPC30rWfhd1SRUl5po4ifTvln5cV_VHyHLW3MQ.ku5jtKB-G5acpq4v.s0oNPaUaRQbFk-X8AL8QitkI_SdBWB2BpBmRRbo2ZMAkq4x81hSC5p7RlSrM3OGTNFZ4yOrRgzdMv43YpCl7ZpJIypF4l7Hyvl_13jTjqzB7o81dEhl_10SI_Fw607VKCnwqq02_VoqD489EpMVuQ05Fg2pUT3M_mJMacGztORYVJrIWwzbyUiHfM4GlnaoUQaKfwbkHS2W2-1wOPTSWTLEBVJlRG1EAZR_upcPJolcAStjl8PY5EfkxXD56c8Xu6SI8LjMrJAXXg7lTqOGNOkt0v8M8UZWd95Gy2zH_KJm3ItYR_YjPoMIHh-_Cb2-0uoXNRyykW4EpGptp08n7QubSYltzXwaw_NgLP9KUmg.67EgfbLDNyvEYCR12Bjoew \ No newline at end of file diff --git a/client/keys/show.go b/client/keys/show.go index 102f29793b..2cb3c457f2 100644 --- a/client/keys/show.go +++ b/client/keys/show.go @@ -5,13 +5,13 @@ import ( "fmt" "github.com/spf13/cobra" - tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/ledger" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -61,7 +61,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) { return fmt.Errorf("%s is not a valid name or address: %v", args[0], err) } } else { - pks := make([]tmcrypto.PubKey, len(args)) + pks := make([]cryptotypes.PubKey, len(args)) for i, keyref := range args { info, err := fetchKey(clientCtx.Keyring, keyref) if err != nil { diff --git a/client/keys/show_test.go b/client/keys/show_test.go index e68107b58b..882a80683a 100644 --- a/client/keys/show_test.go +++ b/client/keys/show_test.go @@ -7,14 +7,13 @@ import ( "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -23,7 +22,7 @@ func Test_multiSigKey_Properties(t *testing.T) { tmpKey1 := secp256k1.GenPrivKeyFromSecret([]byte("mySecret")) pk := multisig.NewLegacyAminoPubKey( 1, - []crypto.PubKey{tmpKey1.PubKey()}, + []cryptotypes.PubKey{tmpKey1.PubKey()}, ) tmp := keyring.NewMultiInfo("myMultisig", pk) diff --git a/client/rpc/validators.go b/client/rpc/validators.go index 591d3354c5..0a15f4bc93 100644 --- a/client/rpc/validators.go +++ b/client/rpc/validators.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" ) @@ -99,7 +100,11 @@ func (rvo ResultValidatorsOutput) String() string { } func bech32ValidatorOutput(validator *tmtypes.Validator) (ValidatorOutput, error) { - bechValPubkey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, validator.PubKey) + pk, err := cryptocodec.FromTmPubKeyInterface(validator.PubKey) + if err != nil { + return ValidatorOutput{}, err + } + bechValPubkey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pk) if err != nil { return ValidatorOutput{}, err } diff --git a/client/test_helpers.go b/client/test_helpers.go index 1140298fda..214184b50f 100644 --- a/client/test_helpers.go +++ b/client/test_helpers.go @@ -3,8 +3,7 @@ package client import ( "fmt" - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -26,7 +25,7 @@ func (t TestAccount) GetAddress() sdk.AccAddress { } // GetPubKey implements client Account.GetPubKey -func (t TestAccount) GetPubKey() crypto.PubKey { +func (t TestAccount) GetPubKey() cryptotypes.PubKey { return nil } diff --git a/client/tx/tx.go b/client/tx/tx.go index fb0e712805..d1814c3635 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -8,13 +8,13 @@ import ( "os" "github.com/spf13/pflag" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/rest" @@ -343,7 +343,7 @@ func PrepareFactory(clientCtx client.Context, txf Factory) (Factory, error) { // corresponding SignatureV2 if the signing is successful. func SignWithPrivKey( signMode signing.SignMode, signerData authsigning.SignerData, - txBuilder client.TxBuilder, priv crypto.PrivKey, txConfig client.TxConfig, + txBuilder client.TxBuilder, priv cryptotypes.PrivKey, txConfig client.TxConfig, accSeq uint64, ) (signing.SignatureV2, error) { var sigV2 signing.SignatureV2 diff --git a/codec/types/any.pb.go b/codec/types/any.pb.go index d084381696..97d9f1c2aa 100644 --- a/codec/types/any.pb.go +++ b/codec/types/any.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: third_party/proto/google/protobuf/any.proto +// source: google/protobuf/any.proto package types @@ -29,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func (m *Any) Reset() { *m = Any{} } func (*Any) ProtoMessage() {} func (*Any) Descriptor() ([]byte, []int) { - return fileDescriptor_cb68f365a8e2bcdc, []int{0} + return fileDescriptor_b53526c13ae22eb4, []int{0} } func (*Any) XXX_WellKnownType() string { return "Any" } func (m *Any) XXX_Unmarshal(b []byte) error { @@ -79,28 +79,25 @@ func (*Any) XXX_MessageName() string { func init() { } -func init() { - proto.RegisterFile("third_party/proto/google/protobuf/any.proto", fileDescriptor_cb68f365a8e2bcdc) -} +func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor_b53526c13ae22eb4) } -var fileDescriptor_cb68f365a8e2bcdc = []byte{ - // 246 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2e, 0xc9, 0xc8, 0x2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2f, 0x5e, 0xc4, 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, - 0xce, 0x1d, 0xa2, 0x34, 0x00, 0xaa, 0x54, 0x2f, 0x3c, 0x35, 0x27, 0xc7, 0x3b, 0x2f, 0xbf, 0x3c, - 0x2f, 0x04, 0xa4, 0x2c, 0x89, 0x0d, 0x6c, 0x86, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x16, 0xc3, - 0x46, 0x5f, 0x32, 0x01, 0x00, 0x00, +var fileDescriptor_b53526c13ae22eb4 = []byte{ + // 235 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f, + 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4, + 0x03, 0x73, 0x84, 0xf8, 0x21, 0x52, 0x7a, 0x30, 0x29, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, + 0x4f, 0x1f, 0xc4, 0x82, 0x48, 0x28, 0xd9, 0x70, 0x31, 0x3b, 0xe6, 0x55, 0x0a, 0x49, 0x72, 0x71, + 0x94, 0x54, 0x16, 0xa4, 0xc6, 0x97, 0x16, 0xe5, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xb1, + 0x83, 0xf8, 0xa1, 0x45, 0x39, 0x42, 0x22, 0x5c, 0xac, 0x65, 0x89, 0x39, 0xa5, 0xa9, 0x12, 0x4c, + 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x10, 0x8e, 0x15, 0xcb, 0x87, 0x85, 0xf2, 0x0c, 0x4e, 0xcd, 0x8c, + 0x37, 0x1e, 0xca, 0x31, 0x7c, 0x78, 0x28, 0xc7, 0xf8, 0xe3, 0xa1, 0x1c, 0x63, 0xc3, 0x23, 0x39, + 0xc6, 0x15, 0x8f, 0xe4, 0x18, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, + 0x39, 0xc6, 0x17, 0x8f, 0xe4, 0x18, 0x3e, 0x80, 0xc4, 0x1f, 0xcb, 0x31, 0x1e, 0x78, 0x2c, 0xc7, + 0x70, 0xe2, 0xb1, 0x1c, 0x23, 0x97, 0x70, 0x72, 0x7e, 0xae, 0x1e, 0x9a, 0xfb, 0x9c, 0x38, 0x1c, + 0xf3, 0x2a, 0x03, 0x40, 0x9c, 0x00, 0xc6, 0x28, 0x56, 0x90, 0xe5, 0xc5, 0x8b, 0x98, 0x98, 0xdd, + 0x03, 0x9c, 0x56, 0x31, 0xc9, 0xb9, 0x43, 0x94, 0x06, 0x40, 0x95, 0xea, 0x85, 0xa7, 0xe6, 0xe4, + 0x78, 0xe7, 0xe5, 0x97, 0xe7, 0x85, 0x80, 0x94, 0x25, 0xb1, 0x81, 0xcd, 0x30, 0x06, 0x04, 0x00, + 0x00, 0xff, 0xff, 0xe6, 0xfb, 0xa0, 0x21, 0x0e, 0x01, 0x00, 0x00, } func (this *Any) Compare(that interface{}) int { diff --git a/codec/unknownproto/regression_test.go b/codec/unknownproto/regression_test.go new file mode 100644 index 0000000000..24c4056fbd --- /dev/null +++ b/codec/unknownproto/regression_test.go @@ -0,0 +1,25 @@ +package unknownproto_test + +import ( + "encoding/hex" + "io" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/simapp" +) + +// Issue #7739: Catch parse errors resulting from unexpected EOF in +// protowire.ConsumeFieldValue. Discovered from fuzzing. +func TestBadBytesPassedIntoDecoder(t *testing.T) { + data, _ := hex.DecodeString("0A9F010A9C200A2D2F6962632E636F72652E636F6E6E656374696F6E2E76312E4D7367436F6E6E656374696F584F75656E496E6974126B0A0D6962637A65726F636C69656E74120B6962637A65726F636F6E6E1A1C0A0C6962636F6E65636C69656E74120A6962636F6E65636F6E6E00002205312E302E302A283235454635364341373935313335453430393336384536444238313130463232413442453035433212080A0612040A0208011A40143342993E25DA936CDDC7BE3D8F603CA6E9661518D536D0C482E18A0154AA096E438A6B9BCADFCFC2F0D689DCCAF55B96399D67A8361B70F5DA13091E2F929") + cfg := simapp.MakeTestEncodingConfig() + decoder := cfg.TxConfig.TxDecoder() + tx, err := decoder(data) + + // TODO: When issue https://github.com/cosmos/cosmos-sdk/issues/7846 + // is addressed, we'll remove this .Contains check. + require.Contains(t, err.Error(), io.ErrUnexpectedEOF.Error()) + require.Nil(t, tx) +} diff --git a/codec/unknownproto/unknown_fields.go b/codec/unknownproto/unknown_fields.go index b2e7a0e069..b9db642962 100644 --- a/codec/unknownproto/unknown_fields.go +++ b/codec/unknownproto/unknown_fields.go @@ -92,6 +92,11 @@ func RejectUnknownFields(bz []byte, msg proto.Message, allowUnknownNonCriticals // Skip over the bytes that store fieldNumber and wireType bytes. bz = bz[m:] n := protowire.ConsumeFieldValue(tagNum, wireType, bz) + if n < 0 { + err = fmt.Errorf("could not consume field value for tagNum: %d, wireType: %q; %w", + tagNum, wireTypeToString(wireType), protowire.ParseError(n)) + return hasUnknownNonCriticals, err + } fieldBytes := bz[:n] bz = bz[n:] diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 69271030fc..2e3741fd85 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -57,14 +57,6 @@ tools-stamp: statik runsim # in a row. touch $@ -proto-tools: proto-tools-stamp -proto-tools-stamp: - bash $(mkfile_dir)/proto-tools-installer.sh - # Create dummy file to satisfy dependency and avoid - # rebuilding when this Makefile target is hit twice - # in a row. - touch $@ - # Install the runsim binary with a temporary workaround of entering an outside # directory as the "go get" command ignores the -mod option and will polute the # go.{mod, sum} files. @@ -87,6 +79,6 @@ $(RUNSIM): tools-clean: rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) - rm -f proto-tools-stamp tools-stamp + rm -f tools-stamp .PHONY: tools-clean statik runsim diff --git a/contrib/devtools/proto-tools-installer.sh b/contrib/devtools/proto-tools-installer.sh deleted file mode 100755 index f8bd2f621b..0000000000 --- a/contrib/devtools/proto-tools-installer.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/bash - -set -ue - -DESTDIR=${DESTDIR:-} -PREFIX=${PREFIX:-/usr/local} -UNAME_S="$(uname -s 2>/dev/null)" -UNAME_M="$(uname -m 2>/dev/null)" -BUF_VERSION=0.11.0 -PROTOC_VERSION=3.13.0 -PROTOC_GRPC_GATEWAY_VERSION=1.14.7 - -f_abort() { - local l_rc=$1 - shift - - echo $@ >&2 - exit ${l_rc} -} - -case "${UNAME_S}" in -Linux) - PROTOC_ZIP="protoc-${PROTOC_VERSION}-linux-x86_64.zip" - PROTOC_GRPC_GATEWAY_BIN="protoc-gen-grpc-gateway-v${PROTOC_GRPC_GATEWAY_VERSION}-linux-x86_64" - ;; -Darwin) - PROTOC_ZIP="protoc-${PROTOC_VERSION}-osx-x86_64.zip" - PROTOC_GRPC_GATEWAY_BIN="protoc-gen-grpc-gateway-v${PROTOC_GRPC_GATEWAY_VERSION}-darwin-x86_64" - ;; -*) - f_abort 1 "Unknown kernel name. Exiting." -esac - -TEMPDIR="$(mktemp -d)" - -trap "rm -rvf ${TEMPDIR}" EXIT - -f_print_installing_with_padding() { - printf "Installing %30s ..." "$1" >&2 -} - -f_print_done() { - echo -e "\tDONE" >&2 -} - -f_ensure_tools() { - ! which curl &>/dev/null && f_abort 2 "couldn't find curl, aborting" || true -} - -f_ensure_dirs() { - mkdir -p "${DESTDIR}/${PREFIX}/bin" - mkdir -p "${DESTDIR}/${PREFIX}/include" -} - -f_needs_install() { - if [ -x $1 ]; then - echo -e "\talready installed. Skipping." >&2 - return 1 - fi - - return 0 -} - -f_install_protoc() { - f_print_installing_with_padding proto_c - f_needs_install "${DESTDIR}/${PREFIX}/bin/protoc" || return 0 - - pushd "${TEMPDIR}" >/dev/null - curl -o "${PROTOC_ZIP}" -sSL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}" - unzip -q -o ${PROTOC_ZIP} -d ${DESTDIR}/${PREFIX} bin/protoc; \ - unzip -q -o ${PROTOC_ZIP} -d ${DESTDIR}/${PREFIX} 'include/*'; \ - rm -f ${PROTOC_ZIP} - popd >/dev/null - f_print_done -} - -f_install_buf() { - f_print_installing_with_padding buf - f_needs_install "${DESTDIR}/${PREFIX}/bin/buf" || return 0 - - curl -sSL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${UNAME_S}-${UNAME_M}" -o "${DESTDIR}/${PREFIX}/bin/buf" - chmod +x "${DESTDIR}/${PREFIX}/bin/buf" - f_print_done -} - -f_install_protoc_gen_gocosmos() { - f_print_installing_with_padding protoc-gen-gocosmos - - if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then - echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder." - return 1 - fi - - go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null - f_print_done -} - -f_install_protoc_gen_grpc_gateway() { - f_print_installing_with_padding protoc-gen-grpc-gateway - f_needs_install "${DESTDIR}/${PREFIX}/bin/protoc-gen-grpc-gateway" || return 0 - - curl -o "${DESTDIR}/${PREFIX}/bin/protoc-gen-grpc-gateway" -sSL "https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v${PROTOC_GRPC_GATEWAY_VERSION}/${PROTOC_GRPC_GATEWAY_BIN}" - f_print_done -} - -f_install_protoc_gen_swagger() { - f_print_installing_with_padding protoc-gen-swagger - f_needs_install "${DESTDIR}/${PREFIX}/bin/protoc-gen-swagger" || return 0 - - if ! which npm &>/dev/null ; then - echo -e "\tNPM is not installed. Skipping." - return 0 - fi - - pushd "${TEMPDIR}" >/dev/null - go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger - npm install -g swagger-combine - popd >/dev/null - f_print_done -} - -f_ensure_tools -f_ensure_dirs -f_install_protoc -f_install_buf -f_install_protoc_gen_gocosmos -f_install_protoc_gen_grpc_gateway -f_install_protoc_gen_swagger diff --git a/cosmovisor/args_test.go b/cosmovisor/args_test.go index c36faacafa..9e0ce3bb04 100644 --- a/cosmovisor/args_test.go +++ b/cosmovisor/args_test.go @@ -5,10 +5,18 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" ) -func TestConfigPaths(t *testing.T) { +type argsTestSuite struct { + suite.Suite +} + +func TestArgsTestSuite(t *testing.T) { + suite.Run(t, new(argsTestSuite)) +} + +func (s *argsTestSuite) TestConfigPaths() { cases := map[string]struct { cfg Config upgradeName string @@ -32,23 +40,21 @@ func TestConfigPaths(t *testing.T) { }, } - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.cfg.Root(), filepath.FromSlash(tc.expectRoot)) - assert.Equal(t, tc.cfg.GenesisBin(), filepath.FromSlash(tc.expectGenesis)) - assert.Equal(t, tc.cfg.UpgradeBin(tc.upgradeName), filepath.FromSlash(tc.expectUpgrade)) - }) + for _, tc := range cases { + s.Require().Equal(tc.cfg.Root(), filepath.FromSlash(tc.expectRoot)) + s.Require().Equal(tc.cfg.GenesisBin(), filepath.FromSlash(tc.expectGenesis)) + s.Require().Equal(tc.cfg.UpgradeBin(tc.upgradeName), filepath.FromSlash(tc.expectUpgrade)) } } // Test validate -func TestValidate(t *testing.T) { +func (s *argsTestSuite) TestValidate() { relPath := filepath.Join("testdata", "validate") absPath, err := filepath.Abs(relPath) - assert.NoError(t, err) + s.Require().NoError(err) testdata, err := filepath.Abs("testdata") - assert.NoError(t, err) + s.Require().NoError(err) cases := map[string]struct { cfg Config @@ -84,28 +90,25 @@ func TestValidate(t *testing.T) { }, } - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - err := tc.cfg.validate() - if tc.valid { - assert.NoError(t, err) - } else { - assert.Error(t, err) - } - }) + for _, tc := range cases { + err := tc.cfg.validate() + if tc.valid { + s.Require().NoError(err) + } else { + s.Require().Error(err) + } } } -func TestEnsureBin(t *testing.T) { +func (s *argsTestSuite) TestEnsureBin() { relPath := filepath.Join("testdata", "validate") absPath, err := filepath.Abs(relPath) - assert.NoError(t, err) + s.Require().NoError(err) cfg := Config{Home: absPath, Name: "dummyd"} - assert.NoError(t, cfg.validate()) + s.Require().NoError(cfg.validate()) - err = EnsureBinary(cfg.GenesisBin()) - assert.NoError(t, err) + s.Require().NoError(EnsureBinary(cfg.GenesisBin())) cases := map[string]struct { upgrade string @@ -117,14 +120,12 @@ func TestEnsureBin(t *testing.T) { "no directory": {"foobarbaz", false}, } - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - err := EnsureBinary(cfg.UpgradeBin(tc.upgrade)) - if tc.hasBin { - assert.NoError(t, err) - } else { - assert.Error(t, err) - } - }) + for _, tc := range cases { + err := EnsureBinary(cfg.UpgradeBin(tc.upgrade)) + if tc.hasBin { + s.Require().NoError(err) + } else { + s.Require().Error(err) + } } } diff --git a/cosmovisor/process.go b/cosmovisor/process.go index 055c4ebfc6..cfd201e2be 100644 --- a/cosmovisor/process.go +++ b/cosmovisor/process.go @@ -4,9 +4,13 @@ import ( "bufio" "fmt" "io" + "log" + "os" "os/exec" + "os/signal" "strings" "sync" + "syscall" ) // LaunchProcess runs a subprocess and returns when the subprocess exits, @@ -39,6 +43,15 @@ func LaunchProcess(cfg *Config, args []string, stdout, stderr io.Writer) (bool, return false, fmt.Errorf("launching process %s %s: %w", bin, strings.Join(args, " "), err) } + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGQUIT, syscall.SIGTERM) + go func() { + sig := <-sigs + if err := cmd.Process.Signal(sig); err != nil { + log.Fatal(err) + } + }() + // three ways to exit - command ends, find regexp in scanOut, find regexp in scanErr upgradeInfo, err := WaitForUpgradeOrExit(cmd, scanOut, scanErr) if err != nil { diff --git a/cosmovisor/process_test.go b/cosmovisor/process_test.go index a8068f49c2..6dc964f21e 100644 --- a/cosmovisor/process_test.go +++ b/cosmovisor/process_test.go @@ -1,110 +1,114 @@ // +build linux -package cosmovisor +package cosmovisor_test import ( "bytes" - "os" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/cosmovisor" ) -// TestLaunchProcess will try running the script a few times and watch upgrades work properly -// and args are passed through -func TestLaunchProcess(t *testing.T) { - home, err := copyTestData("validate") - cfg := &Config{Home: home, Name: "dummyd"} - require.NoError(t, err) - defer os.RemoveAll(home) +type processTestSuite struct { + suite.Suite +} - // should run the genesis binary and produce expected output - var stdout, stderr bytes.Buffer - currentBin, err := cfg.CurrentBin() - require.NoError(t, err) - - require.Equal(t, cfg.GenesisBin(), currentBin) - - args := []string{"foo", "bar", "1234"} - doUpgrade, err := LaunchProcess(cfg, args, &stdout, &stderr) - require.NoError(t, err) - assert.True(t, doUpgrade) - assert.Equal(t, "", stderr.String()) - assert.Equal(t, "Genesis foo bar 1234\nUPGRADE \"chain2\" NEEDED at height: 49: {}\n", stdout.String()) - - // ensure this is upgraded now and produces new output - - currentBin, err = cfg.CurrentBin() - require.NoError(t, err) - require.Equal(t, cfg.UpgradeBin("chain2"), currentBin) - args = []string{"second", "run", "--verbose"} - stdout.Reset() - stderr.Reset() - doUpgrade, err = LaunchProcess(cfg, args, &stdout, &stderr) - require.NoError(t, err) - assert.False(t, doUpgrade) - assert.Equal(t, "", stderr.String()) - assert.Equal(t, "Chain 2 is live!\nArgs: second run --verbose\nFinished successfully\n", stdout.String()) - - // ended without other upgrade - require.Equal(t, cfg.UpgradeBin("chain2"), currentBin) +func TestProcessTestSuite(t *testing.T) { + suite.Run(t, new(processTestSuite)) } // TestLaunchProcess will try running the script a few times and watch upgrades work properly // and args are passed through -func TestLaunchProcessWithDownloads(t *testing.T) { +func (s *processTestSuite) TestLaunchProcess() { + home := copyTestData(s.T(), "validate") + cfg := &cosmovisor.Config{Home: home, Name: "dummyd"} + + // should run the genesis binary and produce expected output + var stdout, stderr bytes.Buffer + currentBin, err := cfg.CurrentBin() + s.Require().NoError(err) + + s.Require().Equal(cfg.GenesisBin(), currentBin) + + args := []string{"foo", "bar", "1234"} + doUpgrade, err := cosmovisor.LaunchProcess(cfg, args, &stdout, &stderr) + s.Require().NoError(err) + s.Require().True(doUpgrade) + s.Require().Equal("", stderr.String()) + s.Require().Equal("Genesis foo bar 1234\nUPGRADE \"chain2\" NEEDED at height: 49: {}\n", stdout.String()) + + // ensure this is upgraded now and produces new output + + currentBin, err = cfg.CurrentBin() + s.Require().NoError(err) + s.Require().Equal(cfg.UpgradeBin("chain2"), currentBin) + args = []string{"second", "run", "--verbose"} + stdout.Reset() + stderr.Reset() + doUpgrade, err = cosmovisor.LaunchProcess(cfg, args, &stdout, &stderr) + s.Require().NoError(err) + s.Require().False(doUpgrade) + s.Require().Equal("", stderr.String()) + s.Require().Equal("Chain 2 is live!\nArgs: second run --verbose\nFinished successfully\n", stdout.String()) + + // ended without other upgrade + s.Require().Equal(cfg.UpgradeBin("chain2"), currentBin) +} + +// TestLaunchProcess will try running the script a few times and watch upgrades work properly +// and args are passed through +func (s *processTestSuite) TestLaunchProcessWithDownloads() { // this is a fun path // genesis -> "chain2" = zip_binary // zip_binary -> "chain3" = ref_zipped -> zip_directory // zip_directory no upgrade - home, err := copyTestData("download") - cfg := &Config{Home: home, Name: "autod", AllowDownloadBinaries: true} - require.NoError(t, err) - defer os.RemoveAll(home) + home := copyTestData(s.T(), "download") + cfg := &cosmovisor.Config{Home: home, Name: "autod", AllowDownloadBinaries: true} // should run the genesis binary and produce expected output var stdout, stderr bytes.Buffer currentBin, err := cfg.CurrentBin() - require.NoError(t, err) + s.Require().NoError(err) - require.Equal(t, cfg.GenesisBin(), currentBin) + s.Require().Equal(cfg.GenesisBin(), currentBin) args := []string{"some", "args"} - doUpgrade, err := LaunchProcess(cfg, args, &stdout, &stderr) - require.NoError(t, err) - assert.True(t, doUpgrade) - assert.Equal(t, "", stderr.String()) - assert.Equal(t, "Preparing auto-download some args\n"+`ERROR: UPGRADE "chain2" NEEDED at height: 49: {"binaries":{"linux/amd64":"https://github.com/cosmos/cosmos-sdk/raw/51249cb93130810033408934454841c98423ed4b/cosmovisor/testdata/repo/zip_binary/autod.zip?checksum=sha256:dc48829b4126ae95bc0db316c66d4e9da5f3db95e212665b6080638cca77e998"}} module=main`+"\n", stdout.String()) + doUpgrade, err := cosmovisor.LaunchProcess(cfg, args, &stdout, &stderr) + s.Require().NoError(err) + s.Require().True(doUpgrade) + s.Require().Equal("", stderr.String()) + s.Require().Equal("Preparing auto-download some args\n"+`ERROR: UPGRADE "chain2" NEEDED at height: 49: {"binaries":{"linux/amd64":"https://github.com/cosmos/cosmos-sdk/raw/51249cb93130810033408934454841c98423ed4b/cosmovisor/testdata/repo/zip_binary/autod.zip?checksum=sha256:dc48829b4126ae95bc0db316c66d4e9da5f3db95e212665b6080638cca77e998"}} module=main`+"\n", stdout.String()) // ensure this is upgraded now and produces new output currentBin, err = cfg.CurrentBin() - require.NoError(t, err) - require.Equal(t, cfg.UpgradeBin("chain2"), currentBin) + s.Require().NoError(err) + s.Require().Equal(cfg.UpgradeBin("chain2"), currentBin) args = []string{"run", "--fast"} stdout.Reset() stderr.Reset() - doUpgrade, err = LaunchProcess(cfg, args, &stdout, &stderr) - require.NoError(t, err) - assert.True(t, doUpgrade) - assert.Equal(t, "", stderr.String()) - assert.Equal(t, "Chain 2 from zipped binary link to referral\nArgs: run --fast\n"+`ERROR: UPGRADE "chain3" NEEDED at height: 936: https://github.com/cosmos/cosmos-sdk/raw/0eae1a50612b8bf803336d35055896fbddaa1ddd/cosmovisor/testdata/repo/ref_zipped?checksum=sha256:0a428575de718ed3cf0771c9687eefaf6f19359977eca4d94a0abd0e11ef8e64 module=main`+"\n", stdout.String()) + doUpgrade, err = cosmovisor.LaunchProcess(cfg, args, &stdout, &stderr) + s.Require().NoError(err) + s.Require().True(doUpgrade) + s.Require().Equal("", stderr.String()) + s.Require().Equal("Chain 2 from zipped binary link to referral\nArgs: run --fast\n"+`ERROR: UPGRADE "chain3" NEEDED at height: 936: https://github.com/cosmos/cosmos-sdk/raw/0eae1a50612b8bf803336d35055896fbddaa1ddd/cosmovisor/testdata/repo/ref_zipped?checksum=sha256:0a428575de718ed3cf0771c9687eefaf6f19359977eca4d94a0abd0e11ef8e64 module=main`+"\n", stdout.String()) // ended with one more upgrade currentBin, err = cfg.CurrentBin() - require.NoError(t, err) - require.Equal(t, cfg.UpgradeBin("chain3"), currentBin) + s.Require().NoError(err) + s.Require().Equal(cfg.UpgradeBin("chain3"), currentBin) // make sure this is the proper binary now.... args = []string{"end", "--halt"} stdout.Reset() stderr.Reset() - doUpgrade, err = LaunchProcess(cfg, args, &stdout, &stderr) - require.NoError(t, err) - assert.False(t, doUpgrade) - assert.Equal(t, "", stderr.String()) - assert.Equal(t, "Chain 2 from zipped directory\nArgs: end --halt\n", stdout.String()) + doUpgrade, err = cosmovisor.LaunchProcess(cfg, args, &stdout, &stderr) + s.Require().NoError(err) + s.Require().False(doUpgrade) + s.Require().Equal("", stderr.String()) + s.Require().Equal("Chain 2 from zipped directory\nArgs: end --halt\n", stdout.String()) // and this doesn't upgrade currentBin, err = cfg.CurrentBin() - require.NoError(t, err) - require.Equal(t, cfg.UpgradeBin("chain3"), currentBin) + s.Require().NoError(err) + s.Require().Equal(cfg.UpgradeBin("chain3"), currentBin) } diff --git a/cosmovisor/scanner_test.go b/cosmovisor/scanner_test.go index a207006fe3..9e42410c7b 100644 --- a/cosmovisor/scanner_test.go +++ b/cosmovisor/scanner_test.go @@ -1,17 +1,19 @@ -package cosmovisor +package cosmovisor_test import ( "bufio" "io" "testing" - "github.com/stretchr/testify/assert" + "github.com/cosmos/cosmos-sdk/cosmovisor" + + "github.com/stretchr/testify/require" ) func TestWaitForInfo(t *testing.T) { cases := map[string]struct { write []string - expectUpgrade *UpgradeInfo + expectUpgrade *cosmovisor.UpgradeInfo expectErr bool }{ "no match": { @@ -19,14 +21,14 @@ func TestWaitForInfo(t *testing.T) { }, "match name with no info": { write: []string{"first line\n", `UPGRADE "myname" NEEDED at height: 123: `, "\nnext line\n"}, - expectUpgrade: &UpgradeInfo{ + expectUpgrade: &cosmovisor.UpgradeInfo{ Name: "myname", Info: "", }, }, "match name with info": { write: []string{"first line\n", `UPGRADE "take2" NEEDED at height: 123: DownloadData here!`, "\nnext line\n"}, - expectUpgrade: &UpgradeInfo{ + expectUpgrade: &cosmovisor.UpgradeInfo{ Name: "take2", Info: "DownloadData", }, @@ -42,20 +44,20 @@ func TestWaitForInfo(t *testing.T) { go func() { for _, line := range tc.write { n, err := w.Write([]byte(line)) - assert.NoError(t, err) - assert.Equal(t, len(line), n) + require.NoError(t, err) + require.Equal(t, len(line), n) } w.Close() }() // now scan the info - info, err := WaitForUpdate(scan) + info, err := cosmovisor.WaitForUpdate(scan) if tc.expectErr { - assert.Error(t, err) + require.Error(t, err) return } - assert.NoError(t, err) - assert.Equal(t, tc.expectUpgrade, info) + require.NoError(t, err) + require.Equal(t, tc.expectUpgrade, info) }) } } diff --git a/cosmovisor/upgrade.go b/cosmovisor/upgrade.go index 38b6c9f81f..3057597f7d 100644 --- a/cosmovisor/upgrade.go +++ b/cosmovisor/upgrade.go @@ -119,12 +119,12 @@ func GetDownloadURL(info *UpgradeInfo) (string, error) { var config UpgradeConfig if err := json.Unmarshal([]byte(doc), &config); err == nil { - url, ok := config.Binaries[osArch()] + url, ok := config.Binaries[OSArch()] if !ok { url, ok = config.Binaries["any"] } if !ok { - return "", fmt.Errorf("cannot find binary for os/arch: neither %s, nor any", osArch()) + return "", fmt.Errorf("cannot find binary for os/arch: neither %s, nor any", OSArch()) } return url, nil @@ -133,7 +133,7 @@ func GetDownloadURL(info *UpgradeInfo) (string, error) { return "", errors.New("upgrade info doesn't contain binary map") } -func osArch() string { +func OSArch() string { return fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) } diff --git a/cosmovisor/upgrade_test.go b/cosmovisor/upgrade_test.go index 3e628bb7ff..2123df8e40 100644 --- a/cosmovisor/upgrade_test.go +++ b/cosmovisor/upgrade_test.go @@ -1,139 +1,138 @@ // +build linux -package cosmovisor +package cosmovisor_test import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" "testing" - copy2 "github.com/otiai10/copy" + "github.com/stretchr/testify/suite" - "github.com/stretchr/testify/assert" + "github.com/otiai10/copy" "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/cosmovisor" ) -func TestCurrentBin(t *testing.T) { - home, err := copyTestData("validate") - require.NoError(t, err) - defer os.RemoveAll(home) +type upgradeTestSuite struct { + suite.Suite +} - cfg := Config{Home: home, Name: "dummyd"} +func TestUpgradeTestSuite(t *testing.T) { + suite.Run(t, new(upgradeTestSuite)) +} + +func (s *upgradeTestSuite) TestCurrentBin() { + home := copyTestData(s.T(), "validate") + cfg := cosmovisor.Config{Home: home, Name: "dummyd"} currentBin, err := cfg.CurrentBin() - require.NoError(t, err) + s.Require().NoError(err) - assert.Equal(t, cfg.GenesisBin(), currentBin) + s.Require().Equal(cfg.GenesisBin(), currentBin) // ensure we cannot set this to an invalid value for _, name := range []string{"missing", "nobin", "noexec"} { - err = cfg.SetCurrentUpgrade(name) - require.Error(t, err, name) + s.Require().Error(cfg.SetCurrentUpgrade(name), name) currentBin, err := cfg.CurrentBin() - require.NoError(t, err) + s.Require().NoError(err) - assert.Equal(t, cfg.GenesisBin(), currentBin, name) + s.Require().Equal(cfg.GenesisBin(), currentBin, name) } // try a few times to make sure this can be reproduced for _, upgrade := range []string{"chain2", "chain3", "chain2"} { // now set it to a valid upgrade and make sure CurrentBin is now set properly err = cfg.SetCurrentUpgrade(upgrade) - require.NoError(t, err) + s.Require().NoError(err) // we should see current point to the new upgrade dir currentBin, err := cfg.CurrentBin() - require.NoError(t, err) + s.Require().NoError(err) - assert.Equal(t, cfg.UpgradeBin(upgrade), currentBin) + s.Require().Equal(cfg.UpgradeBin(upgrade), currentBin) } } -func TestCurrentAlwaysSymlinkToDirectory(t *testing.T) { - home, err := copyTestData("validate") - require.NoError(t, err) - defer os.RemoveAll(home) - - cfg := Config{Home: home, Name: "dummyd"} +func (s *upgradeTestSuite) TestCurrentAlwaysSymlinkToDirectory() { + home := copyTestData(s.T(), "validate") + cfg := cosmovisor.Config{Home: home, Name: "dummyd"} currentBin, err := cfg.CurrentBin() - require.NoError(t, err) - assert.Equal(t, cfg.GenesisBin(), currentBin) - assertCurrentLink(t, cfg, "genesis") + s.Require().NoError(err) + s.Require().Equal(cfg.GenesisBin(), currentBin) + s.assertCurrentLink(cfg, "genesis") err = cfg.SetCurrentUpgrade("chain2") - require.NoError(t, err) + s.Require().NoError(err) currentBin, err = cfg.CurrentBin() - require.NoError(t, err) - assert.Equal(t, cfg.UpgradeBin("chain2"), currentBin) - assertCurrentLink(t, cfg, filepath.Join("upgrades", "chain2")) + s.Require().NoError(err) + s.Require().Equal(cfg.UpgradeBin("chain2"), currentBin) + s.assertCurrentLink(cfg, filepath.Join("upgrades", "chain2")) } -func assertCurrentLink(t *testing.T, cfg Config, target string) { - link := filepath.Join(cfg.Root(), currentLink) +func (s *upgradeTestSuite) assertCurrentLink(cfg cosmovisor.Config, target string) { + link := filepath.Join(cfg.Root(), "current") // ensure this is a symlink info, err := os.Lstat(link) - require.NoError(t, err) - require.Equal(t, os.ModeSymlink, info.Mode()&os.ModeSymlink) + s.Require().NoError(err) + s.Require().Equal(os.ModeSymlink, info.Mode()&os.ModeSymlink) dest, err := os.Readlink(link) - require.NoError(t, err) + s.Require().NoError(err) expected := filepath.Join(cfg.Root(), target) - require.Equal(t, expected, dest) + s.Require().Equal(expected, dest) } // TODO: test with download (and test all download functions) -func TestDoUpgradeNoDownloadUrl(t *testing.T) { - home, err := copyTestData("validate") - require.NoError(t, err) - defer os.RemoveAll(home) - - cfg := &Config{Home: home, Name: "dummyd", AllowDownloadBinaries: true} +func (s *upgradeTestSuite) TestDoUpgradeNoDownloadUrl() { + home := copyTestData(s.T(), "validate") + cfg := &cosmovisor.Config{Home: home, Name: "dummyd", AllowDownloadBinaries: true} currentBin, err := cfg.CurrentBin() - require.NoError(t, err) + s.Require().NoError(err) - assert.Equal(t, cfg.GenesisBin(), currentBin) + s.Require().Equal(cfg.GenesisBin(), currentBin) // do upgrade ignores bad files for _, name := range []string{"missing", "nobin", "noexec"} { - info := &UpgradeInfo{Name: name} - err = DoUpgrade(cfg, info) - require.Error(t, err, name) + info := &cosmovisor.UpgradeInfo{Name: name} + err = cosmovisor.DoUpgrade(cfg, info) + s.Require().Error(err, name) currentBin, err := cfg.CurrentBin() - require.NoError(t, err) - assert.Equal(t, cfg.GenesisBin(), currentBin, name) + s.Require().NoError(err) + s.Require().Equal(cfg.GenesisBin(), currentBin, name) } // make sure it updates a few times for _, upgrade := range []string{"chain2", "chain3"} { // now set it to a valid upgrade and make sure CurrentBin is now set properly - info := &UpgradeInfo{Name: upgrade} - err = DoUpgrade(cfg, info) - require.NoError(t, err) + info := &cosmovisor.UpgradeInfo{Name: upgrade} + err = cosmovisor.DoUpgrade(cfg, info) + s.Require().NoError(err) // we should see current point to the new upgrade dir upgradeBin := cfg.UpgradeBin(upgrade) currentBin, err := cfg.CurrentBin() - require.NoError(t, err) + s.Require().NoError(err) - assert.Equal(t, upgradeBin, currentBin) + s.Require().Equal(upgradeBin, currentBin) } } -func TestOsArch(t *testing.T) { +func (s *upgradeTestSuite) TestOsArch() { // all download tests will fail if we are not on linux... - assert.Equal(t, "linux/amd64", osArch()) + s.Require().Equal("linux/amd64", cosmovisor.OSArch()) } -func TestGetDownloadURL(t *testing.T) { +func (s *upgradeTestSuite) TestGetDownloadURL() { // all download tests will fail if we are not on linux... ref, err := filepath.Abs(filepath.FromSlash("./testdata/repo/ref_zipped")) - require.NoError(t, err) + s.Require().NoError(err) badref, err := filepath.Abs(filepath.FromSlash("./testdata/repo/zip_binary/autod.zip")) - require.NoError(t, err) + s.Require().NoError(err) cases := map[string]struct { info string @@ -173,20 +172,18 @@ func TestGetDownloadURL(t *testing.T) { }, } - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - url, err := GetDownloadURL(&UpgradeInfo{Info: tc.info}) - if tc.isErr { - assert.Error(t, err) - } else { - assert.NoError(t, err) - assert.Equal(t, tc.url, url) - } - }) + for _, tc := range cases { + url, err := cosmovisor.GetDownloadURL(&cosmovisor.UpgradeInfo{Info: tc.info}) + if tc.isErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().Equal(tc.url, url) + } } } -func TestDownloadBinary(t *testing.T) { +func (s *upgradeTestSuite) TestDownloadBinary() { cases := map[string]struct { url string canDownload bool @@ -228,65 +225,55 @@ func TestDownloadBinary(t *testing.T) { }, } - for name, tc := range cases { - t.Run(name, func(t *testing.T) { - // make temp dir - home, err := copyTestData("download") - require.NoError(t, err) - defer os.RemoveAll(home) + for _, tc := range cases { + var err error + // make temp dir + home := copyTestData(s.T(), "download") - cfg := &Config{ - Home: home, - Name: "autod", - AllowDownloadBinaries: true, - } + cfg := &cosmovisor.Config{ + Home: home, + Name: "autod", + AllowDownloadBinaries: true, + } - // if we have a relative path, make it absolute, but don't change eg. https://... urls - url := tc.url - if strings.HasPrefix(url, "./") { - url, err = filepath.Abs(url) - require.NoError(t, err) - } + // if we have a relative path, make it absolute, but don't change eg. https://... urls + url := tc.url + if strings.HasPrefix(url, "./") { + url, err = filepath.Abs(url) + s.Require().NoError(err) + } - upgrade := "amazonas" - info := &UpgradeInfo{ - Name: upgrade, - Info: fmt.Sprintf(`{"binaries":{"%s": "%s"}}`, osArch(), url), - } + upgrade := "amazonas" + info := &cosmovisor.UpgradeInfo{ + Name: upgrade, + Info: fmt.Sprintf(`{"binaries":{"%s": "%s"}}`, cosmovisor.OSArch(), url), + } - err = DownloadBinary(cfg, info) - if !tc.canDownload { - assert.Error(t, err) - return - } - require.NoError(t, err) + err = cosmovisor.DownloadBinary(cfg, info) + if !tc.canDownload { + s.Require().Error(err) + return + } + s.Require().NoError(err) - err = EnsureBinary(cfg.UpgradeBin(upgrade)) - if tc.validBinary { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) + err = cosmovisor.EnsureBinary(cfg.UpgradeBin(upgrade)) + if tc.validBinary { + s.Require().NoError(err) + } else { + s.Require().Error(err) + } } } // copyTestData will make a tempdir and then // "cp -r" a subdirectory under testdata there // returns the directory (which can now be used as Config.Home) and modified safely -func copyTestData(subdir string) (string, error) { - tmpdir, err := ioutil.TempDir("", "upgrade-manager-test") - if err != nil { - return "", fmt.Errorf("couldn't create temporary directory: %w", err) - } +func copyTestData(t *testing.T, subdir string) string { + t.Helper() - src := filepath.Join("testdata", subdir) + tmpdir := t.TempDir() - err = copy2.Copy(src, tmpdir) - if err != nil { - os.RemoveAll(tmpdir) - return "", fmt.Errorf("couldn't copy files: %w", err) - } + require.NoError(t, copy.Copy(filepath.Join("testdata", subdir), tmpdir)) - return tmpdir, nil + return tmpdir } diff --git a/crypto/armor.go b/crypto/armor.go index d0637c709d..3ee472707a 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/legacy" cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -124,7 +125,7 @@ func unarmorBytes(armorStr, blockType string) (bz []byte, header map[string]stri // encrypt/decrypt with armor // Encrypt and armor the private key. -func EncryptArmorPrivKey(privKey crypto.PrivKey, passphrase string, algo string) string { +func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo string) string { saltBytes, encBytes := encryptPrivKey(privKey, passphrase) header := map[string]string{ "kdf": "bcrypt", @@ -143,7 +144,7 @@ func EncryptArmorPrivKey(privKey crypto.PrivKey, passphrase string, algo string) // encrypt the given privKey with the passphrase using a randomly // generated salt and the xsalsa20 cipher. returns the salt and the // encrypted priv key. -func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { +func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { saltBytes = crypto.CRandBytes(16) key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter) @@ -158,7 +159,7 @@ func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte } // UnarmorDecryptPrivKey returns the privkey byte slice, a string of the algo type, and an error -func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey crypto.PrivKey, algo string, err error) { +func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptotypes.PrivKey, algo string, err error) { blockType, header, encBytes, err := armor.DecodeArmor(armorStr) if err != nil { return privKey, "", err @@ -190,7 +191,7 @@ func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey crypto.P return privKey, header[headerType], err } -func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey crypto.PrivKey, err error) { +func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) { key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter) if err != nil { return privKey, sdkerrors.Wrap(err, "error generating bcrypt key from passphrase") diff --git a/crypto/armor_test.go b/crypto/armor_test.go index 3e5f256faa..3267ca98a7 100644 --- a/crypto/armor_test.go +++ b/crypto/armor_test.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" ) @@ -46,7 +47,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) { require.Contains(t, err.Error(), "unrecognized armor type") // armor key manually - encryptPrivKeyFn := func(privKey tmcrypto.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { + encryptPrivKeyFn := func(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { saltBytes = tmcrypto.CRandBytes(16) key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), crypto.BcryptSecurityParameter) require.NoError(t, err) diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 5a98acbac3..5cd61c3dd3 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -1,8 +1,6 @@ package codec import ( - "github.com/tendermint/tendermint/crypto" - tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" @@ -22,16 +20,9 @@ func init() { // RegisterCrypto registers all crypto dependency types with the provided Amino // codec. func RegisterCrypto(cdc *codec.LegacyAmino) { - // TODO We now register both Tendermint's PubKey and our own PubKey. In the - // long-term, we should move away from Tendermint's PubKey, and delete this - // first line. - cdc.RegisterInterface((*crypto.PubKey)(nil), nil) cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil) cdc.RegisterConcrete(sr25519.PubKey{}, sr25519.PubKeyName, nil) - // TODO Same as above, for ED25519 - cdc.RegisterConcrete(tmed25519.PubKey{}, - tmed25519.PubKeyName, nil) cdc.RegisterConcrete(&ed25519.PubKey{}, ed25519.PubKeyName, nil) cdc.RegisterConcrete(&secp256k1.PubKey{}, @@ -39,12 +30,9 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{}, kmultisig.PubKeyAminoRoute, nil) - cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) + cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil) cdc.RegisterConcrete(sr25519.PrivKey{}, sr25519.PrivKeyName, nil) - // TODO Same as above - cdc.RegisterConcrete(tmed25519.PrivKey{}, - tmed25519.PrivKeyName, nil) cdc.RegisterConcrete(&ed25519.PrivKey{}, ed25519.PrivKeyName, nil) cdc.RegisterConcrete(&secp256k1.PrivKey{}, @@ -52,13 +40,13 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { } // PrivKeyFromBytes unmarshals private key bytes and returns a PrivKey -func PrivKeyFromBytes(privKeyBytes []byte) (privKey crypto.PrivKey, err error) { +func PrivKeyFromBytes(privKeyBytes []byte) (privKey cryptotypes.PrivKey, err error) { err = amino.UnmarshalBinaryBare(privKeyBytes, &privKey) return } // PubKeyFromBytes unmarshals public key bytes and returns a PubKey -func PubKeyFromBytes(pubKeyBytes []byte) (pubKey crypto.PubKey, err error) { +func PubKeyFromBytes(pubKeyBytes []byte) (pubKey cryptotypes.PubKey, err error) { err = amino.UnmarshalBinaryBare(pubKeyBytes, &pubKey) return } diff --git a/crypto/codec/proto.go b/crypto/codec/proto.go index 845e60bf82..9c07ca1105 100644 --- a/crypto/codec/proto.go +++ b/crypto/codec/proto.go @@ -1,8 +1,6 @@ package codec import ( - tmcrypto "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" @@ -12,14 +10,6 @@ import ( // RegisterInterfaces registers the sdk.Tx interface. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - // TODO We now register both Tendermint's PubKey and our own PubKey. In the - // long-term, we should move away from Tendermint's PubKey, and delete - // these lines. - registry.RegisterInterface("tendermint.crypto.PubKey", (*tmcrypto.PubKey)(nil)) - registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &ed25519.PubKey{}) - registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &secp256k1.PubKey{}) - registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &multisig.LegacyAminoPubKey{}) - registry.RegisterInterface("cosmos.crypto.PubKey", (*cryptotypes.PubKey)(nil)) registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ed25519.PubKey{}) registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{}) diff --git a/crypto/codec/tm.go b/crypto/codec/tm.go new file mode 100644 index 0000000000..8c841e96b3 --- /dev/null +++ b/crypto/codec/tm.go @@ -0,0 +1,68 @@ +package codec + +import ( + tmcrypto "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/encoding" + tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// FromTmProtoPublicKey converts a TM's tmprotocrypto.PublicKey into our own PubKey. +func FromTmProtoPublicKey(protoPk tmprotocrypto.PublicKey) (cryptotypes.PubKey, error) { + switch protoPk := protoPk.Sum.(type) { + case *tmprotocrypto.PublicKey_Ed25519: + return &ed25519.PubKey{ + Key: protoPk.Ed25519, + }, nil + case *tmprotocrypto.PublicKey_Secp256K1: + return &secp256k1.PubKey{ + Key: protoPk.Secp256K1, + }, nil + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v from Tendermint public key", protoPk) + } +} + +// ToTmProtoPublicKey converts our own PubKey to TM's tmprotocrypto.PublicKey. +func ToTmProtoPublicKey(pk cryptotypes.PubKey) (tmprotocrypto.PublicKey, error) { + switch pk := pk.(type) { + case *ed25519.PubKey: + return tmprotocrypto.PublicKey{ + Sum: &tmprotocrypto.PublicKey_Ed25519{ + Ed25519: pk.Key, + }, + }, nil + case *secp256k1.PubKey: + return tmprotocrypto.PublicKey{ + Sum: &tmprotocrypto.PublicKey_Secp256K1{ + Secp256K1: pk.Key, + }, + }, nil + default: + return tmprotocrypto.PublicKey{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v to Tendermint public key", pk) + } +} + +// FromTmPubKeyInterface converts TM's tmcrypto.PubKey to our own PubKey. +func FromTmPubKeyInterface(tmPk tmcrypto.PubKey) (cryptotypes.PubKey, error) { + tmProtoPk, err := encoding.PubKeyToProto(tmPk) + if err != nil { + return nil, err + } + + return FromTmProtoPublicKey(tmProtoPk) +} + +// ToTmPubKeyInterface converts our own PubKey to TM's tmcrypto.PubKey. +func ToTmPubKeyInterface(pk cryptotypes.PubKey) (tmcrypto.PubKey, error) { + tmProtoPk, err := ToTmProtoPublicKey(pk) + if err != nil { + return nil, err + } + + return encoding.PubKeyFromProto(tmProtoPk) +} diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index 30636c56df..f934ad08ae 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -2,9 +2,9 @@ package hd import ( bip39 "github.com/cosmos/go-bip39" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/types" ) // PubKeyType defines an algorithm to derive key-pairs which can be used for cryptographic signing. @@ -28,11 +28,11 @@ var ( ) type DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) -type GenerateFn func(bz []byte) crypto.PrivKey +type GenerateFn func(bz []byte) types.PrivKey type WalletGenerator interface { Derive(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) - Generate(bz []byte) crypto.PrivKey + Generate(bz []byte) types.PrivKey } type secp256k1Algo struct { @@ -62,7 +62,7 @@ func (s secp256k1Algo) Derive() DeriveFn { // Generate generates a secp256k1 private key from the given bytes. func (s secp256k1Algo) Generate() GenerateFn { - return func(bz []byte) crypto.PrivKey { + return func(bz []byte) types.PrivKey { var bzArr = make([]byte, secp256k1.PrivKeySize) copy(bzArr, bz) diff --git a/crypto/keyring/info.go b/crypto/keyring/info.go index 366e474d22..f05e2f0dde 100644 --- a/crypto/keyring/info.go +++ b/crypto/keyring/info.go @@ -3,11 +3,10 @@ package keyring import ( "fmt" - "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" ) @@ -18,7 +17,7 @@ type Info interface { // Name of the key GetName() string // Public key - GetPubKey() crypto.PubKey + GetPubKey() cryptotypes.PubKey // Address GetAddress() types.AccAddress // Bip44 Path @@ -37,13 +36,13 @@ var ( // localInfo is the public information about a locally stored key // Note: Algo must be last field in struct for backwards amino compatibility type localInfo struct { - Name string `json:"name"` - PubKey crypto.PubKey `json:"pubkey"` - PrivKeyArmor string `json:"privkey.armor"` - Algo hd.PubKeyType `json:"algo"` + Name string `json:"name"` + PubKey cryptotypes.PubKey `json:"pubkey"` + PrivKeyArmor string `json:"privkey.armor"` + Algo hd.PubKeyType `json:"algo"` } -func newLocalInfo(name string, pub crypto.PubKey, privArmor string, algo hd.PubKeyType) Info { +func newLocalInfo(name string, pub cryptotypes.PubKey, privArmor string, algo hd.PubKeyType) Info { return &localInfo{ Name: name, PubKey: pub, @@ -63,7 +62,7 @@ func (i localInfo) GetName() string { } // GetType implements Info interface -func (i localInfo) GetPubKey() crypto.PubKey { +func (i localInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } @@ -85,13 +84,13 @@ func (i localInfo) GetPath() (*hd.BIP44Params, error) { // ledgerInfo is the public information about a Ledger key // Note: Algo must be last field in struct for backwards amino compatibility type ledgerInfo struct { - Name string `json:"name"` - PubKey crypto.PubKey `json:"pubkey"` - Path hd.BIP44Params `json:"path"` - Algo hd.PubKeyType `json:"algo"` + Name string `json:"name"` + PubKey cryptotypes.PubKey `json:"pubkey"` + Path hd.BIP44Params `json:"path"` + Algo hd.PubKeyType `json:"algo"` } -func newLedgerInfo(name string, pub crypto.PubKey, path hd.BIP44Params, algo hd.PubKeyType) Info { +func newLedgerInfo(name string, pub cryptotypes.PubKey, path hd.BIP44Params, algo hd.PubKeyType) Info { return &ledgerInfo{ Name: name, PubKey: pub, @@ -111,7 +110,7 @@ func (i ledgerInfo) GetName() string { } // GetPubKey implements Info interface -func (i ledgerInfo) GetPubKey() crypto.PubKey { +func (i ledgerInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } @@ -134,12 +133,12 @@ func (i ledgerInfo) GetPath() (*hd.BIP44Params, error) { // offlineInfo is the public information about an offline key // Note: Algo must be last field in struct for backwards amino compatibility type offlineInfo struct { - Name string `json:"name"` - PubKey crypto.PubKey `json:"pubkey"` - Algo hd.PubKeyType `json:"algo"` + Name string `json:"name"` + PubKey cryptotypes.PubKey `json:"pubkey"` + Algo hd.PubKeyType `json:"algo"` } -func newOfflineInfo(name string, pub crypto.PubKey, algo hd.PubKeyType) Info { +func newOfflineInfo(name string, pub cryptotypes.PubKey, algo hd.PubKeyType) Info { return &offlineInfo{ Name: name, PubKey: pub, @@ -158,7 +157,7 @@ func (i offlineInfo) GetName() string { } // GetPubKey implements Info interface -func (i offlineInfo) GetPubKey() crypto.PubKey { +func (i offlineInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } @@ -178,20 +177,20 @@ func (i offlineInfo) GetPath() (*hd.BIP44Params, error) { } type multisigPubKeyInfo struct { - PubKey crypto.PubKey `json:"pubkey"` - Weight uint `json:"weight"` + PubKey cryptotypes.PubKey `json:"pubkey"` + Weight uint `json:"weight"` } // multiInfo is the public information about a multisig key type multiInfo struct { Name string `json:"name"` - PubKey crypto.PubKey `json:"pubkey"` + PubKey cryptotypes.PubKey `json:"pubkey"` Threshold uint `json:"threshold"` PubKeys []multisigPubKeyInfo `json:"pubkeys"` } // NewMultiInfo creates a new multiInfo instance -func NewMultiInfo(name string, pub crypto.PubKey) Info { +func NewMultiInfo(name string, pub cryptotypes.PubKey) Info { multiPK := pub.(*multisig.LegacyAminoPubKey) pubKeys := make([]multisigPubKeyInfo, len(multiPK.PubKeys)) @@ -219,7 +218,7 @@ func (i multiInfo) GetName() string { } // GetPubKey implements Info interface -func (i multiInfo) GetPubKey() crypto.PubKey { +func (i multiInfo) GetPubKey() cryptotypes.PubKey { return i.PubKey } diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 0d0e41b7c3..d3220b5b43 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -22,6 +22,7 @@ import ( cryptoamino "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/ledger" + "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -76,10 +77,10 @@ type Keyring interface { SaveLedgerKey(uid string, algo SignatureAlgo, hrp string, coinType, account, index uint32) (Info, error) // SavePubKey stores a public key and returns the persisted Info structure. - SavePubKey(uid string, pubkey tmcrypto.PubKey, algo hd.PubKeyType) (Info, error) + SavePubKey(uid string, pubkey types.PubKey, algo hd.PubKeyType) (Info, error) // SaveMultisig stores and returns a new multsig (offline) key reference. - SaveMultisig(uid string, pubkey tmcrypto.PubKey) (Info, error) + SaveMultisig(uid string, pubkey types.PubKey) (Info, error) Signer @@ -90,10 +91,10 @@ type Keyring interface { // Signer is implemented by key stores that want to provide signing capabilities. type Signer interface { // Sign sign byte messages with a user key. - Sign(uid string, msg []byte) ([]byte, tmcrypto.PubKey, error) + Sign(uid string, msg []byte) ([]byte, types.PubKey, error) // SignByAddress sign byte messages with a user key providing the address. - SignByAddress(address sdk.Address, msg []byte) ([]byte, tmcrypto.PubKey, error) + SignByAddress(address sdk.Address, msg []byte) ([]byte, types.PubKey, error) } // Importer is implemented by key stores that support import of public and private keys. @@ -224,13 +225,13 @@ func (ks keystore) ExportPrivKeyArmor(uid, encryptPassphrase string) (armor stri } // ExportPrivateKeyObject exports an armored private key object. -func (ks keystore) ExportPrivateKeyObject(uid string) (tmcrypto.PrivKey, error) { +func (ks keystore) ExportPrivateKeyObject(uid string) (types.PrivKey, error) { info, err := ks.Key(uid) if err != nil { return nil, err } - var priv tmcrypto.PrivKey + var priv types.PrivKey switch linfo := info.(type) { case localInfo: @@ -301,13 +302,13 @@ func (ks keystore) ImportPubKey(uid string, armor string) error { return nil } -func (ks keystore) Sign(uid string, msg []byte) ([]byte, tmcrypto.PubKey, error) { +func (ks keystore) Sign(uid string, msg []byte) ([]byte, types.PubKey, error) { info, err := ks.Key(uid) if err != nil { return nil, nil, err } - var priv tmcrypto.PrivKey + var priv types.PrivKey switch i := info.(type) { case localInfo: @@ -335,7 +336,7 @@ func (ks keystore) Sign(uid string, msg []byte) ([]byte, tmcrypto.PubKey, error) return sig, priv.PubKey(), nil } -func (ks keystore) SignByAddress(address sdk.Address, msg []byte) ([]byte, tmcrypto.PubKey, error) { +func (ks keystore) SignByAddress(address sdk.Address, msg []byte) ([]byte, types.PubKey, error) { key, err := ks.KeyByAddress(address) if err != nil { return nil, nil, err @@ -359,7 +360,7 @@ func (ks keystore) SaveLedgerKey(uid string, algo SignatureAlgo, hrp string, coi return ks.writeLedgerKey(uid, priv.PubKey(), *hdPath, algo.Name()) } -func (ks keystore) writeLedgerKey(name string, pub tmcrypto.PubKey, path hd.BIP44Params, algo hd.PubKeyType) (Info, error) { +func (ks keystore) writeLedgerKey(name string, pub types.PubKey, path hd.BIP44Params, algo hd.PubKeyType) (Info, error) { info := newLedgerInfo(name, pub, path, algo) if err := ks.writeInfo(info); err != nil { return nil, err @@ -368,11 +369,11 @@ func (ks keystore) writeLedgerKey(name string, pub tmcrypto.PubKey, path hd.BIP4 return info, nil } -func (ks keystore) SaveMultisig(uid string, pubkey tmcrypto.PubKey) (Info, error) { +func (ks keystore) SaveMultisig(uid string, pubkey types.PubKey) (Info, error) { return ks.writeMultisigKey(uid, pubkey) } -func (ks keystore) SavePubKey(uid string, pubkey tmcrypto.PubKey, algo hd.PubKeyType) (Info, error) { +func (ks keystore) SavePubKey(uid string, pubkey types.PubKey, algo hd.PubKeyType) (Info, error) { return ks.writeOfflineKey(uid, pubkey, algo) } @@ -533,7 +534,7 @@ func (ks keystore) SupportedAlgorithms() (SigningAlgoList, SigningAlgoList) { // SignWithLedger signs a binary message with the ledger device referenced by an Info object // and returns the signed bytes and the public key. It returns an error if the device could // not be queried or it returned an error. -func SignWithLedger(info Info, msg []byte) (sig []byte, pub tmcrypto.PubKey, err error) { +func SignWithLedger(info Info, msg []byte) (sig []byte, pub types.PubKey, err error) { switch info.(type) { case *ledgerInfo, ledgerInfo: default: @@ -691,7 +692,7 @@ func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) { } } -func (ks keystore) writeLocalKey(name string, priv tmcrypto.PrivKey, algo hd.PubKeyType) (Info, error) { +func (ks keystore) writeLocalKey(name string, priv types.PrivKey, algo hd.PubKeyType) (Info, error) { // encrypt private key using keyring pub := priv.PubKey() @@ -753,7 +754,7 @@ func (ks keystore) existsInDb(info Info) (bool, error) { return false, nil } -func (ks keystore) writeOfflineKey(name string, pub tmcrypto.PubKey, algo hd.PubKeyType) (Info, error) { +func (ks keystore) writeOfflineKey(name string, pub types.PubKey, algo hd.PubKeyType) (Info, error) { info := newOfflineInfo(name, pub, algo) err := ks.writeInfo(info) if err != nil { @@ -763,7 +764,7 @@ func (ks keystore) writeOfflineKey(name string, pub tmcrypto.PubKey, algo hd.Pub return info, nil } -func (ks keystore) writeMultisigKey(name string, pub tmcrypto.PubKey) (Info, error) { +func (ks keystore) writeMultisigKey(name string, pub types.PubKey) (Info, error) { info := NewMultiInfo(name, pub) err := ks.writeInfo(info) if err != nil { diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 0cd75c9b44..540ea57bf3 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -8,13 +8,13 @@ import ( "github.com/99designs/keyring" bip39 "github.com/cosmos/go-bip39" "github.com/stretchr/testify/require" - tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -166,7 +166,7 @@ func TestSignVerifyKeyRing(t *testing.T) { // let's try to validate and make sure it only works when everything is proper cases := []struct { - key tmcrypto.PubKey + key types.PubKey data []byte sig []byte valid bool @@ -380,7 +380,7 @@ func TestInMemoryCreateMultisig(t *testing.T) { kb, err := New("keybasename", "memory", "", nil) require.NoError(t, err) multi := multisig.NewLegacyAminoPubKey( - 1, []tmcrypto.PubKey{ + 1, []types.PubKey{ secp256k1.GenPrivKey().PubKey(), }, ) @@ -521,7 +521,7 @@ func TestInMemorySignVerify(t *testing.T) { // let's try to validate and make sure it only works when everything is proper cases := []struct { - key tmcrypto.PubKey + key types.PubKey data []byte sig []byte valid bool @@ -947,7 +947,7 @@ func TestAltKeyring_SaveMultisig(t *testing.T) { key := "multi" pub := multisig.NewLegacyAminoPubKey( 2, - []tmcrypto.PubKey{ + []types.PubKey{ &secp256k1.PubKey{Key: mnemonic1.GetPubKey().Bytes()}, &secp256k1.PubKey{Key: mnemonic2.GetPubKey().Bytes()}, }, diff --git a/crypto/keyring/legacy.go b/crypto/keyring/legacy.go index 2332266d45..59bdc3fc5d 100644 --- a/crypto/keyring/legacy.go +++ b/crypto/keyring/legacy.go @@ -6,11 +6,11 @@ import ( "strings" "github.com/pkg/errors" - tmcrypto "github.com/tendermint/tendermint/crypto" tmos "github.com/tendermint/tendermint/libs/os" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/crypto" + "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -101,13 +101,13 @@ func (kb dbKeybase) Get(name string) (Info, error) { // ExportPrivateKeyObject returns a PrivKey object given the key name and // passphrase. An error is returned if the key does not exist or if the Info for // the key is invalid. -func (kb dbKeybase) ExportPrivateKeyObject(name string, passphrase string) (tmcrypto.PrivKey, error) { +func (kb dbKeybase) ExportPrivateKeyObject(name string, passphrase string) (types.PrivKey, error) { info, err := kb.Get(name) if err != nil { return nil, err } - var priv tmcrypto.PrivKey + var priv types.PrivKey switch i := info.(type) { case localInfo: diff --git a/crypto/keyring/output_test.go b/crypto/keyring/output_test.go index dc98ad62bc..c43b36bf7c 100644 --- a/crypto/keyring/output_test.go +++ b/crypto/keyring/output_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -16,7 +16,7 @@ func TestBech32KeysOutput(t *testing.T) { bechTmpKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, tmpKey) tmpAddr := sdk.AccAddress(tmpKey.Address().Bytes()) - multisigPks := kmultisig.NewLegacyAminoPubKey(1, []crypto.PubKey{tmpKey}) + multisigPks := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey}) multiInfo := NewMultiInfo("multisig", multisigPks) accAddr := sdk.AccAddress(multiInfo.GetPubKey().Address().Bytes()) bechPubKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, multiInfo.GetPubKey()) diff --git a/crypto/keyring/types.go b/crypto/keyring/types.go index 443896d785..0b893ea4cc 100644 --- a/crypto/keyring/types.go +++ b/crypto/keyring/types.go @@ -1,9 +1,8 @@ package keyring import ( - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/hd" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) // Language is a language to create the BIP 39 mnemonic in. @@ -68,5 +67,5 @@ type ( // DeriveKeyFunc defines the function to derive a new key from a seed and hd path DeriveKeyFunc func(mnemonic string, bip39Passphrase, hdPath string, algo hd.PubKeyType) ([]byte, error) // PrivKeyGenFunc defines the function to convert derived key bytes to a tendermint private key - PrivKeyGenFunc func(bz []byte, algo hd.PubKeyType) (crypto.PrivKey, error) + PrivKeyGenFunc func(bz []byte, algo hd.PubKeyType) (cryptotypes.PrivKey, error) ) diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index 4c935a0760..17368c4b12 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -7,7 +7,6 @@ import ( "io" "github.com/tendermint/tendermint/crypto" - tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto/tmhash" "github.com/cosmos/cosmos-sdk/codec" @@ -18,8 +17,8 @@ import ( //------------------------------------- const ( - PrivKeyName = "cosmos/PrivKeyEd25519" - PubKeyName = "cosmos/PubKeyEd25519" + PrivKeyName = "tendermint/PrivKeyEd25519" + PubKeyName = "tendermint/PubKeyEd25519" // PubKeySize is is the size, in bytes, of public keys as used in this package. PubKeySize = 32 // PrivKeySize is the size, in bytes, of private keys as used in this package. @@ -56,7 +55,7 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { // PubKey gets the corresponding public key from the private key. // // Panics if the private key is not initialized. -func (privKey *PrivKey) PubKey() crypto.PubKey { +func (privKey *PrivKey) PubKey() cryptotypes.PubKey { // If the latter 32 bytes of the privkey are all zero, privkey is not // initialized. initialized := false @@ -78,7 +77,7 @@ func (privKey *PrivKey) PubKey() crypto.PubKey { // Equals - you probably don't need to use this. // Runs in constant time based on length of the keys. -func (privKey *PrivKey) Equals(other crypto.PrivKey) bool { +func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { if privKey.Type() != other.Type() { return false } @@ -150,7 +149,6 @@ func GenPrivKeyFromSecret(secret []byte) *PrivKey { var _ cryptotypes.PubKey = &PubKey{} var _ codec.AminoMarshaler = &PubKey{} -var _ cryptotypes.IntoTmPubKey = &PubKey{} // Address is the SHA256-20 of the raw pubkey bytes. func (pubKey *PubKey) Address() crypto.Address { @@ -182,7 +180,7 @@ func (pubKey *PubKey) Type() string { return keyType } -func (pubKey *PubKey) Equals(other crypto.PubKey) bool { +func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { if pubKey.Type() != other.Type() { return false } @@ -216,19 +214,3 @@ func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) { func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error { return pubKey.UnmarshalAmino(bz) } - -// AsTmPubKey converts our own PubKey into a Tendermint ED25519 pubkey. -func (pubKey *PubKey) AsTmPubKey() crypto.PubKey { - return tmed25519.PubKey(pubKey.Key) -} - -// FromTmEd25519 converts a Tendermint ED25519 pubkey into our own ED25519 -// PubKey. -func FromTmEd25519(pubKey crypto.PubKey) (*PubKey, error) { - tmPk, ok := pubKey.(tmed25519.PubKey) - if !ok { - return nil, fmt.Errorf("expected %T, got %T", tmed25519.PubKey{}, pubKey) - } - - return &PubKey{Key: []byte(tmPk)}, nil -} diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 6b2ad36dc4..59cce4066a 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" ed25519 "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) @@ -51,7 +51,7 @@ func TestPubKeyEquals(t *testing.T) { testCases := []struct { msg string pubKey cryptotypes.PubKey - other crypto.PubKey + other cryptotypes.PubKey expectEq bool }{ { @@ -71,7 +71,7 @@ func TestPubKeyEquals(t *testing.T) { { "different types", ed25519PubKey, - sr25519.GenPrivKey().PubKey(), + secp256k1.GenPrivKey().PubKey(), false, }, } @@ -90,7 +90,7 @@ func TestPrivKeyEquals(t *testing.T) { testCases := []struct { msg string privKey cryptotypes.PrivKey - other crypto.PrivKey + other cryptotypes.PrivKey expectEq bool }{ { @@ -110,7 +110,7 @@ func TestPrivKeyEquals(t *testing.T) { { "different types", ed25519PrivKey, - sr25519.GenPrivKey(), + secp256k1.GenPrivKey(), false, }, } diff --git a/crypto/keys/internal/benchmarking/bench.go b/crypto/keys/internal/benchmarking/bench.go index b74b901db9..a789da91f9 100644 --- a/crypto/keys/internal/benchmarking/bench.go +++ b/crypto/keys/internal/benchmarking/bench.go @@ -4,7 +4,7 @@ import ( "io" "testing" - "github.com/tendermint/tendermint/crypto" + "github.com/cosmos/cosmos-sdk/crypto/types" ) // The code in this file is adapted from agl/ed25519. @@ -24,7 +24,7 @@ func (zeroReader) Read(buf []byte) (int, error) { // BenchmarkKeyGeneration benchmarks the given key generation algorithm using // a dummy reader. -func BenchmarkKeyGeneration(b *testing.B, generateKey func(reader io.Reader) crypto.PrivKey) { +func BenchmarkKeyGeneration(b *testing.B, generateKey func(reader io.Reader) types.PrivKey) { var zero zeroReader for i := 0; i < b.N; i++ { generateKey(zero) @@ -33,7 +33,7 @@ func BenchmarkKeyGeneration(b *testing.B, generateKey func(reader io.Reader) cry // BenchmarkSigning benchmarks the given signing algorithm using // the provided privkey. -func BenchmarkSigning(b *testing.B, priv crypto.PrivKey) { +func BenchmarkSigning(b *testing.B, priv types.PrivKey) { message := []byte("Hello, world!") b.ResetTimer() for i := 0; i < b.N; i++ { @@ -47,7 +47,7 @@ func BenchmarkSigning(b *testing.B, priv crypto.PrivKey) { // BenchmarkVerification benchmarks the given verification algorithm using // the provided privkey on a constant message. -func BenchmarkVerification(b *testing.B, priv crypto.PrivKey) { +func BenchmarkVerification(b *testing.B, priv types.PrivKey) { pub := priv.PubKey() // use a short message, so this time doesn't get dominated by hashing. message := []byte("Hello, world!") diff --git a/crypto/keys/multisig/codec.go b/crypto/keys/multisig/codec.go index c282d01227..b92576e4f3 100644 --- a/crypto/keys/multisig/codec.go +++ b/crypto/keys/multisig/codec.go @@ -1,7 +1,6 @@ package multisig import ( - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" @@ -19,10 +18,6 @@ const ( var AminoCdc = codec.NewLegacyAmino() func init() { - // TODO We now register both Tendermint's PubKey and our own PubKey. In the - // long-term, we should move away from Tendermint's PubKey, and delete this - // first line. - AminoCdc.RegisterInterface((*crypto.PubKey)(nil), nil) AminoCdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil) AminoCdc.RegisterConcrete(ed25519.PubKey{}, ed25519.PubKeyName, nil) diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 836eadbe16..590e5ba110 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -5,10 +5,8 @@ import ( tmcrypto "github.com/tendermint/tendermint/crypto" - proto "github.com/gogo/protobuf/proto" - "github.com/cosmos/cosmos-sdk/codec/types" - crypto "github.com/cosmos/cosmos-sdk/crypto/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" multisigtypes "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) @@ -18,7 +16,7 @@ var _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. // Panics if len(pubKeys) < k or 0 >= k. -func NewLegacyAminoPubKey(k int, pubKeys []tmcrypto.PubKey) *LegacyAminoPubKey { +func NewLegacyAminoPubKey(k int, pubKeys []cryptotypes.PubKey) *LegacyAminoPubKey { if k <= 0 { panic("threshold k of n multisignature: k <= 0") } @@ -32,8 +30,8 @@ func NewLegacyAminoPubKey(k int, pubKeys []tmcrypto.PubKey) *LegacyAminoPubKey { return &LegacyAminoPubKey{Threshold: uint32(k), PubKeys: anyPubKeys} } -// Address implements crypto.PubKey Address method -func (m *LegacyAminoPubKey) Address() tmcrypto.Address { +// Address implements cryptotypes.PubKey Address method +func (m *LegacyAminoPubKey) Address() cryptotypes.Address { return tmcrypto.AddressHash(m.Bytes()) } @@ -91,7 +89,7 @@ func (m *LegacyAminoPubKey) VerifyMultisignature(getSignBytes multisigtypes.GetS return nil } -// VerifySignature implements crypto.PubKey VerifySignature method, +// VerifySignature implements cryptotypes.PubKey VerifySignature method, // it panics because it can't handle MultiSignatureData // cf. https://github.com/cosmos/cosmos-sdk/issues/7109#issuecomment-686329936 func (m *LegacyAminoPubKey) VerifySignature(msg []byte, sig []byte) bool { @@ -99,11 +97,11 @@ func (m *LegacyAminoPubKey) VerifySignature(msg []byte, sig []byte) bool { } // GetPubKeys implements the PubKey.GetPubKeys method -func (m *LegacyAminoPubKey) GetPubKeys() []tmcrypto.PubKey { +func (m *LegacyAminoPubKey) GetPubKeys() []cryptotypes.PubKey { if m != nil { - pubKeys := make([]tmcrypto.PubKey, len(m.PubKeys)) + pubKeys := make([]cryptotypes.PubKey, len(m.PubKeys)) for i := 0; i < len(m.PubKeys); i++ { - pubKeys[i] = m.PubKeys[i].GetCachedValue().(tmcrypto.PubKey) + pubKeys[i] = m.PubKeys[i].GetCachedValue().(cryptotypes.PubKey) } return pubKeys } @@ -113,7 +111,7 @@ func (m *LegacyAminoPubKey) GetPubKeys() []tmcrypto.PubKey { // Equals returns true if m and other both have the same number of keys, and // all constituent keys are the same, and in the same order. -func (m *LegacyAminoPubKey) Equals(key tmcrypto.PubKey) bool { +func (m *LegacyAminoPubKey) Equals(key cryptotypes.PubKey) bool { otherKey, ok := key.(multisigtypes.PubKey) if !ok { return false @@ -145,7 +143,7 @@ func (m *LegacyAminoPubKey) Type() string { // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { for _, any := range m.PubKeys { - var pk crypto.PubKey + var pk cryptotypes.PubKey err := unpacker.UnpackAny(any, &pk) if err != nil { return err @@ -154,11 +152,11 @@ func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { return nil } -func packPubKeys(pubKeys []tmcrypto.PubKey) ([]*types.Any, error) { +func packPubKeys(pubKeys []cryptotypes.PubKey) ([]*types.Any, error) { anyPubKeys := make([]*types.Any, len(pubKeys)) for i := 0; i < len(pubKeys); i++ { - any, err := types.NewAnyWithValue(pubKeys[i].(proto.Message)) + any, err := types.NewAnyWithValue(pubKeys[i]) if err != nil { return nil, err } diff --git a/crypto/keys/multisig/multisig_test.go b/crypto/keys/multisig/multisig_test.go index 9c18c97d06..2b91e74eb6 100644 --- a/crypto/keys/multisig/multisig_test.go +++ b/crypto/keys/multisig/multisig_test.go @@ -3,19 +3,16 @@ package multisig_test import ( "testing" - tmcrypto "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/codec/types" - crypto "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/crypto/types/multisig" - "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" - "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" ) func TestAddress(t *testing.T) { @@ -30,12 +27,12 @@ func TestEquals(t *testing.T) { pubKey1 := secp256k1.GenPrivKey().PubKey() pubKey2 := secp256k1.GenPrivKey().PubKey() - multisigKey := kmultisig.NewLegacyAminoPubKey(1, []tmcrypto.PubKey{pubKey1, pubKey2}) - otherMultisigKey := kmultisig.NewLegacyAminoPubKey(1, []tmcrypto.PubKey{pubKey1, multisigKey}) + multisigKey := kmultisig.NewLegacyAminoPubKey(1, []cryptotypes.PubKey{pubKey1, pubKey2}) + otherMultisigKey := kmultisig.NewLegacyAminoPubKey(1, []cryptotypes.PubKey{pubKey1, multisigKey}) testCases := []struct { msg string - other tmcrypto.PubKey + other cryptotypes.PubKey expectEq bool }{ { @@ -255,8 +252,8 @@ func TestPubKeyMultisigThresholdAminoToIface(t *testing.T) { ab, err := kmultisig.AminoCdc.MarshalBinaryLengthPrefixed(multisigKey) require.NoError(t, err) - // like other crypto.Pubkey implementations (e.g. ed25519.PubKey), - // LegacyAminoPubKey should be deserializable into a crypto.LegacyAminoPubKey: + // like other cryptotypes.Pubkey implementations (e.g. ed25519.PubKey), + // LegacyAminoPubKey should be deserializable into a cryptotypes.LegacyAminoPubKey: var pubKey kmultisig.LegacyAminoPubKey err = kmultisig.AminoCdc.UnmarshalBinaryLengthPrefixed(ab, &pubKey) require.NoError(t, err) @@ -264,8 +261,8 @@ func TestPubKeyMultisigThresholdAminoToIface(t *testing.T) { require.Equal(t, multisigKey.Equals(&pubKey), true) } -func generatePubKeysAndSignatures(n int, msg []byte) (pubKeys []tmcrypto.PubKey, signatures []signing.SignatureData) { - pubKeys = make([]tmcrypto.PubKey, n) +func generatePubKeysAndSignatures(n int, msg []byte) (pubKeys []cryptotypes.PubKey, signatures []signing.SignatureData) { + pubKeys = make([]cryptotypes.PubKey, n) signatures = make([]signing.SignatureData, n) for i := 0; i < n; i++ { @@ -279,12 +276,12 @@ func generatePubKeysAndSignatures(n int, msg []byte) (pubKeys []tmcrypto.PubKey, } func generateNestedMultiSignature(n int, msg []byte) (multisig.PubKey, *signing.MultiSignatureData) { - pubKeys := make([]tmcrypto.PubKey, n) + pubKeys := make([]cryptotypes.PubKey, n) signatures := make([]signing.SignatureData, n) - bitArray := crypto.NewCompactBitArray(n) + bitArray := cryptotypes.NewCompactBitArray(n) for i := 0; i < n; i++ { nestedPks, nestedSigs := generatePubKeysAndSignatures(5, msg) - nestedBitArray := crypto.NewCompactBitArray(5) + nestedBitArray := cryptotypes.NewCompactBitArray(5) for j := 0; j < 5; j++ { nestedBitArray.SetIndex(j, true) } diff --git a/crypto/keys/secp256k1/bench_test.go b/crypto/keys/secp256k1/bench_test.go index e36f2df4b6..423f7a5a52 100644 --- a/crypto/keys/secp256k1/bench_test.go +++ b/crypto/keys/secp256k1/bench_test.go @@ -4,13 +4,12 @@ import ( "io" "testing" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" + "github.com/cosmos/cosmos-sdk/crypto/types" ) func BenchmarkKeyGeneration(b *testing.B) { - benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { + benchmarkKeygenWrapper := func(reader io.Reader) types.PrivKey { priv := genPrivKey(reader) return &PrivKey{Key: priv} } diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index 77d546812c..eebe72a452 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -34,7 +34,7 @@ func (privKey *PrivKey) Bytes() []byte { // PubKey performs the point-scalar multiplication from the privKey on the // generator point to get the pubkey. -func (privKey *PrivKey) PubKey() crypto.PubKey { +func (privKey *PrivKey) PubKey() cryptotypes.PubKey { _, pubkeyObject := secp256k1.PrivKeyFromBytes(secp256k1.S256(), privKey.Key) pk := pubkeyObject.SerializeCompressed() return &PubKey{Key: pk} @@ -42,7 +42,7 @@ func (privKey *PrivKey) PubKey() crypto.PubKey { // Equals - you probably don't need to use this. // Runs in constant time based on length of the -func (privKey *PrivKey) Equals(other crypto.PrivKey) bool { +func (privKey *PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool { return privKey.Type() == other.Type() && subtle.ConstantTimeCompare(privKey.Bytes(), other.Bytes()) == 1 } @@ -173,7 +173,7 @@ func (pubKey *PubKey) Type() string { return keyType } -func (pubKey *PubKey) Equals(other crypto.PubKey) bool { +func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool { return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes()) } diff --git a/crypto/keys/secp256k1/secp256k1_test.go b/crypto/keys/secp256k1/secp256k1_test.go index 0133d68509..56c67f594b 100644 --- a/crypto/keys/secp256k1/secp256k1_test.go +++ b/crypto/keys/secp256k1/secp256k1_test.go @@ -12,9 +12,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/sr25519" + tmsecp256k1 "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) @@ -143,7 +144,7 @@ func TestPubKeyEquals(t *testing.T) { testCases := []struct { msg string pubKey cryptotypes.PubKey - other crypto.PubKey + other cryptotypes.PubKey expectEq bool }{ { @@ -163,7 +164,7 @@ func TestPubKeyEquals(t *testing.T) { { "different types", secp256K1PubKey, - sr25519.GenPrivKey().PubKey(), + ed25519.GenPrivKey().PubKey(), false, }, } @@ -182,7 +183,7 @@ func TestPrivKeyEquals(t *testing.T) { testCases := []struct { msg string privKey cryptotypes.PrivKey - other crypto.PrivKey + other cryptotypes.PrivKey expectEq bool }{ { @@ -202,7 +203,7 @@ func TestPrivKeyEquals(t *testing.T) { { "different types", secp256K1PrivKey, - sr25519.GenPrivKey(), + ed25519.GenPrivKey(), false, }, } @@ -267,3 +268,56 @@ func TestMarshalAmino(t *testing.T) { }) } } + +func TestMarshalAmino_BackwardsCompatibility(t *testing.T) { + aminoCdc := codec.NewLegacyAmino() + // Create Tendermint keys. + tmPrivKey := tmsecp256k1.GenPrivKey() + tmPubKey := tmPrivKey.PubKey() + // Create our own keys, with the same private key as Tendermint's. + privKey := &secp256k1.PrivKey{Key: []byte(tmPrivKey)} + pubKey := privKey.PubKey().(*secp256k1.PubKey) + + testCases := []struct { + desc string + tmKey interface{} + ourKey interface{} + marshalFn func(o interface{}) ([]byte, error) + }{ + { + "secp256k1 private key, binary", + tmPrivKey, + privKey, + aminoCdc.MarshalBinaryBare, + }, + { + "secp256k1 private key, JSON", + tmPrivKey, + privKey, + aminoCdc.MarshalJSON, + }, + { + "secp256k1 public key, binary", + tmPubKey, + pubKey, + aminoCdc.MarshalBinaryBare, + }, + { + "secp256k1 public key, JSON", + tmPubKey, + pubKey, + aminoCdc.MarshalJSON, + }, + } + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + // Make sure Amino encoding override is not breaking backwards compatibility. + bz1, err := tc.marshalFn(tc.tmKey) + require.NoError(t, err) + bz2, err := tc.marshalFn(tc.ourKey) + require.NoError(t, err) + require.Equal(t, bz1, bz2) + }) + } +} diff --git a/crypto/ledger/encode_test.go b/crypto/ledger/encode_test.go index 6e0cf99f52..447891fde7 100644 --- a/crypto/ledger/encode_test.go +++ b/crypto/ledger/encode_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - tcrypto "github.com/tendermint/tendermint/crypto" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) type byter interface { @@ -51,12 +51,12 @@ func TestNilEncodings(t *testing.T) { require.EqualValues(t, a, b) // Check nil PubKey. - var c, d tcrypto.PubKey + var c, d cryptotypes.PubKey checkAminoJSON(t, &c, &d, true) require.EqualValues(t, c, d) // Check nil PrivKey. - var e, f tcrypto.PrivKey + var e, f cryptotypes.PrivKey checkAminoJSON(t, &e, &f, true) require.EqualValues(t, e, f) diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index 3afdbac5f3..659181d306 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -8,10 +8,10 @@ import ( "github.com/pkg/errors" tmbtcec "github.com/tendermint/btcd/btcec" - tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/types" ) var ( @@ -43,7 +43,7 @@ type ( // CachedPubKey should be private, but we want to encode it via // go-amino so we can view the address later, even without having the // ledger attached. - CachedPubKey tmcrypto.PubKey + CachedPubKey types.PubKey Path hd.BIP44Params } ) @@ -53,7 +53,7 @@ type ( // This function is marked as unsafe as it will retrieve a pubkey without user verification. // It can only be used to verify a pubkey but never to create new accounts/keys. In that case, // please refer to NewPrivKeySecp256k1 -func NewPrivKeySecp256k1Unsafe(path hd.BIP44Params) (tmcrypto.PrivKey, error) { +func NewPrivKeySecp256k1Unsafe(path hd.BIP44Params) (types.LedgerPrivKey, error) { device, err := getDevice() if err != nil { return nil, err @@ -70,7 +70,7 @@ func NewPrivKeySecp256k1Unsafe(path hd.BIP44Params) (tmcrypto.PrivKey, error) { // NewPrivKeySecp256k1 will generate a new key and store the public key for later use. // The request will require user confirmation and will show account and index in the device -func NewPrivKeySecp256k1(path hd.BIP44Params, hrp string) (tmcrypto.PrivKey, string, error) { +func NewPrivKeySecp256k1(path hd.BIP44Params, hrp string) (types.LedgerPrivKey, string, error) { device, err := getDevice() if err != nil { return nil, "", err @@ -86,7 +86,7 @@ func NewPrivKeySecp256k1(path hd.BIP44Params, hrp string) (tmcrypto.PrivKey, str } // PubKey returns the cached public key. -func (pkl PrivKeyLedgerSecp256k1) PubKey() tmcrypto.PubKey { +func (pkl PrivKeyLedgerSecp256k1) PubKey() types.PubKey { return pkl.CachedPubKey } @@ -102,7 +102,7 @@ func (pkl PrivKeyLedgerSecp256k1) Sign(message []byte) ([]byte, error) { } // ShowAddress triggers a ledger device to show the corresponding address. -func ShowAddress(path hd.BIP44Params, expectedPubKey tmcrypto.PubKey, +func ShowAddress(path hd.BIP44Params, expectedPubKey types.PubKey, accountAddressPrefix string) error { device, err := getDevice() if err != nil { @@ -154,7 +154,7 @@ func (pkl PrivKeyLedgerSecp256k1) Bytes() []byte { // Equals implements the PrivKey interface. It makes sure two private keys // refer to the same public key. -func (pkl PrivKeyLedgerSecp256k1) Equals(other tmcrypto.PrivKey) bool { +func (pkl PrivKeyLedgerSecp256k1) Equals(other types.LedgerPrivKey) bool { if otherKey, ok := other.(PrivKeyLedgerSecp256k1); ok { return pkl.CachedPubKey.Equals(otherKey.CachedPubKey) } @@ -234,7 +234,7 @@ func sign(device SECP256K1, pkl PrivKeyLedgerSecp256k1, msg []byte) ([]byte, err // // since this involves IO, it may return an error, which is not exposed // in the PubKey interface, so this function allows better error handling -func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (tmcrypto.PubKey, error) { +func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (types.PubKey, error) { publicKey, err := device.GetPublicKeySECP256K1(path.DerivationPath()) if err != nil { return nil, fmt.Errorf("please open Cosmos app on the Ledger device - error: %v", err) @@ -258,7 +258,7 @@ func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (tmcrypto.PubKey, er // // Since this involves IO, it may return an error, which is not exposed // in the PubKey interface, so this function allows better error handling. -func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (tmcrypto.PubKey, string, error) { +func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (types.PubKey, string, error) { publicKey, addr, err := device.GetAddressPubKeySECP256K1(path.DerivationPath(), hrp) if err != nil { return nil, "", fmt.Errorf("address %s rejected", addr) diff --git a/crypto/ledger/ledger_test.go b/crypto/ledger/ledger_test.go index 9b21e464bc..bc85b2feba 100644 --- a/crypto/ledger/ledger_test.go +++ b/crypto/ledger/ledger_test.go @@ -6,10 +6,9 @@ import ( "github.com/stretchr/testify/require" - tmcrypto "github.com/tendermint/tendermint/crypto" - cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -58,7 +57,7 @@ func TestPublicKeyUnsafeHDPath(t *testing.T) { const numIters = 10 - privKeys := make([]tmcrypto.PrivKey, numIters) + privKeys := make([]types.LedgerPrivKey, numIters) // Check with device for i := uint32(0); i < 10; i++ { @@ -70,8 +69,8 @@ func TestPublicKeyUnsafeHDPath(t *testing.T) { require.NotNil(t, priv) // Check other methods - require.NoError(t, priv.(PrivKeyLedgerSecp256k1).ValidateKey()) tmp := priv.(PrivKeyLedgerSecp256k1) + require.NoError(t, tmp.ValidateKey()) (&tmp).AssertIsPrivKeyInner() pubKeyAddr, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, priv.PubKey()) @@ -151,7 +150,7 @@ func TestPublicKeyHDPath(t *testing.T) { const numIters = 10 - privKeys := make([]tmcrypto.PrivKey, numIters) + privKeys := make([]types.LedgerPrivKey, numIters) // Check with device for i := uint32(0); i < 10; i++ { @@ -170,8 +169,8 @@ func TestPublicKeyHDPath(t *testing.T) { "Is your device using test mnemonic: %s ?", testutil.TestMnemonic) // Check other methods - require.NoError(t, priv.(PrivKeyLedgerSecp256k1).ValidateKey()) tmp := priv.(PrivKeyLedgerSecp256k1) + require.NoError(t, tmp.ValidateKey()) (&tmp).AssertIsPrivKeyInner() pubKeyAddr, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, priv.PubKey()) diff --git a/crypto/types/multisig/multisignature.go b/crypto/types/multisig/multisignature.go index b13072e280..20e3ef1129 100644 --- a/crypto/types/multisig/multisignature.go +++ b/crypto/types/multisig/multisignature.go @@ -4,8 +4,6 @@ import ( "fmt" "strings" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) @@ -27,7 +25,7 @@ func NewMultisig(n int) *signing.MultiSignatureData { } // GetIndex returns the index of pk in keys. Returns -1 if not found -func getIndex(pk crypto.PubKey, keys []crypto.PubKey) int { +func getIndex(pk types.PubKey, keys []types.PubKey) int { for i := 0; i < len(keys); i++ { if pk.Equals(keys[i]) { return i @@ -60,7 +58,7 @@ func AddSignature(mSig *signing.MultiSignatureData, sig signing.SignatureData, i // AddSignatureFromPubKey adds a signature to the multisig, at the index in // keys corresponding to the provided pubkey. -func AddSignatureFromPubKey(mSig *signing.MultiSignatureData, sig signing.SignatureData, pubkey crypto.PubKey, keys []crypto.PubKey) error { +func AddSignatureFromPubKey(mSig *signing.MultiSignatureData, sig signing.SignatureData, pubkey types.PubKey, keys []types.PubKey) error { if mSig == nil { return fmt.Errorf("value of mSig is nil %v", mSig) } @@ -85,6 +83,6 @@ func AddSignatureFromPubKey(mSig *signing.MultiSignatureData, sig signing.Signat return nil } -func AddSignatureV2(mSig *signing.MultiSignatureData, sig signing.SignatureV2, keys []crypto.PubKey) error { +func AddSignatureV2(mSig *signing.MultiSignatureData, sig signing.SignatureV2, keys []types.PubKey) error { return AddSignatureFromPubKey(mSig, sig.Data, sig.PubKey, keys) } diff --git a/crypto/types/multisig/pubkey.go b/crypto/types/multisig/pubkey.go index 51d432f59c..2e778bae6f 100644 --- a/crypto/types/multisig/pubkey.go +++ b/crypto/types/multisig/pubkey.go @@ -1,22 +1,21 @@ package multisig import ( - "github.com/tendermint/tendermint/crypto" - + "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) // PubKey defines a type which supports multi-signature verification via MultiSignatureData // which supports multiple SignMode's. type PubKey interface { - crypto.PubKey + types.PubKey // VerifyMultisignature verifies the provide multi-signature represented by MultiSignatureData // using getSignBytes to retrieve the sign bytes to verify against for the provided mode. VerifyMultisignature(getSignBytes GetSignBytesFunc, sig *signing.MultiSignatureData) error - // GetPubKeys returns the crypto.PubKey's nested within the multi-sig PubKey - GetPubKeys() []crypto.PubKey + // GetPubKeys returns the types.PubKey's nested within the multi-sig PubKey + GetPubKeys() []types.PubKey // GetThreshold returns the threshold number of signatures that must be obtained to verify a signature. GetThreshold() uint diff --git a/crypto/types/types.go b/crypto/types/types.go index bce35d716d..eccdba7381 100644 --- a/crypto/types/types.go +++ b/crypto/types/types.go @@ -5,26 +5,39 @@ import ( tmcrypto "github.com/tendermint/tendermint/crypto" ) -// PubKey interface extends proto.Message -// and tendermint crypto.PubKey +// PubKey defines a public key and extends proto.Message. type PubKey interface { proto.Message - tmcrypto.PubKey + + Address() Address + Bytes() []byte + VerifySignature(msg []byte, sig []byte) bool + Equals(PubKey) bool + Type() string } -// PrivKey interface extends proto.Message -// and tendermint crypto.PrivKey +// LedgerPrivKey defines a private key that is not a proto message. For now, +// LedgerSecp256k1 keys are not converted to proto.Message yet, this is why +// they use LedgerPrivKey instead of PrivKey. All other keys must use PrivKey +// instead of LedgerPrivKey. +// TODO https://github.com/cosmos/cosmos-sdk/issues/7357. +type LedgerPrivKey interface { + Bytes() []byte + Sign(msg []byte) ([]byte, error) + PubKey() PubKey + Equals(LedgerPrivKey) bool + Type() string +} + +// PrivKey defines a private key and extends proto.Message. For now, it extends +// LedgerPrivKey (see godoc for LedgerPrivKey). Ultimately, we should remove +// LedgerPrivKey and add its methods here directly. +// TODO https://github.com/cosmos/cosmos-sdk/issues/7357. type PrivKey interface { proto.Message - tmcrypto.PrivKey + LedgerPrivKey } type ( Address = tmcrypto.Address ) - -// IntoTmPubKey allows our own PubKey types be converted into Tendermint's -// pubkey types. -type IntoTmPubKey interface { - AsTmPubKey() tmcrypto.PubKey -} diff --git a/docs/architecture/README.md b/docs/architecture/README.md index d9a52d3898..d3ff033688 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -72,3 +72,4 @@ Read about the [PROCESS](./PROCESS.md). - [ADR 031: Protobuf Msg Services](./adr-031-msg-service.md) - [ADR 032: Typed Events](./adr-032-typed-events.md) - [ADR 035: Rosetta API Support](./adr-035-rosetta-api-support.md) +- [ADR 037: Governance Split Votes](./adr-037-gov-split-vote.md) \ No newline at end of file diff --git a/docs/architecture/adr-037-gov-split-vote.md b/docs/architecture/adr-037-gov-split-vote.md new file mode 100644 index 0000000000..af9cd8d6f6 --- /dev/null +++ b/docs/architecture/adr-037-gov-split-vote.md @@ -0,0 +1,104 @@ +# ADR 037: Governance split votes + +## Changelog + +- 2020/10/28: Intial draft + +## Status + +Proposed + +## Abstract + +This ADR defines a modification to the the governance module that would allow a staker to split their votes into several voting options. For example, it could use 70% of its voting power to vote Yes and 30% of its voting power to vote No. + +## Context + +Currently, an address can cast a vote with only one options (Yes/No/Abstain/NoWithVeto) and use their full voting power behind that choice. + +However, often times the entity owning that address might not be a single individual. For example, a company might have different stakeholders who want to vote differently, and so it makes sense to allow them to split their voting power. Another example use case is exchanges. Many centralized exchanges often stake a portion of their users' tokens in their custody. Currently, it is not possible for them to do "passthrough voting" and giving their users voting rights over their tokens. However, with this system, exchanges can poll their users for voting preferences, and then vote on-chain proportionally to the results of the poll. + +## Decision + +We modify the vote structs to be + +``` +type WeightedVoteOption struct { + Option string + Weight sdk.Dec +} + +type Vote struct { + ProposalID int64 + Voter sdk.Address + Options []WeightedVoteOption +} +``` + +And for backwards compatibility, we introduce `MsgWeightedVote` while keeping `MsgVote`. +``` +type MsgVote struct { + ProposalID int64 + Voter sdk.Address + Option Option +} + +type MsgWeightedVote struct { + ProposalID int64 + Voter sdk.Address + Options []WeightedVoteOption +} +``` + +The `ValidateBasic` of a `MsgWeightedVote` struct would require that +1. The sum of all the Rates is equal to 1.0 +2. No Option is repeated + +The governance tally function will iterate over all the options in a vote and add to the tally the result of the voter's voting power * the rate for that option. + +``` +tally() { + results := map[types.VoteOption]sdk.Dec + + for _, vote := range votes { + for i, weightedOption := range vote.Options { + results[weightedOption.Option] += getVotingPower(vote.voter) * weightedOption.Weight + } + } +} +``` + +The CLI command for creating a multi-option vote would be as such: +```sh +simd tx gov vote 1 "yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05" --from mykey +``` + +To create a single-option vote a user can do either +``` +simd tx gov vote 1 "yes=1" --from mykey +``` + +or + +```sh +simd tx gov vote 1 yes --from mykey +``` + +to maintain backwards compatibility. + + +## Consequences + +### Backwards Compatibility +- Previous VoteMsg types will remain the same and so clients will not have to update their procedure unless they want to support the WeightedVoteMsg feature. +- When querying a Vote struct from state, its structure will be different, and so clients wanting to display all voters and their respective votes will have to handle the new format and the fact that a single voter can have split votes. +- The result of querying the tally function should have the same API for clients. + +### Positive +- Can make the voting process more accurate for addresses representing multiple stakeholders, often some of the largest addresses. + +### Negative +- Is more complex than simple voting, and so may be harder to explain to users. However, this is mostly mitigated because the feature is opt-in. + +### Neutral +- Relatively minor change to governance tally function. diff --git a/docs/versions b/docs/versions index e55af2fb71..8df09cc782 100644 --- a/docs/versions +++ b/docs/versions @@ -1,3 +1,2 @@ master master -v0.40.x v0.40 launchpad/backports v0.39 \ No newline at end of file diff --git a/go.mod b/go.mod index 004cb69e0b..7049f591ab 100644 --- a/go.mod +++ b/go.mod @@ -11,9 +11,8 @@ require ( github.com/btcsuite/btcutil v1.0.2 github.com/confio/ics23/go v0.6.3 github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d - github.com/cosmos/iavl v0.15.0-rc4 + github.com/cosmos/iavl v0.15.0-rc5 github.com/cosmos/ledger-cosmos-go v0.11.1 - github.com/dgraph-io/badger/v2 v2.2007.2 // indirect github.com/dgraph-io/ristretto v0.0.3 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25 @@ -24,7 +23,7 @@ require ( github.com/golang/snappy v0.0.2 // indirect github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 - github.com/grpc-ecosystem/grpc-gateway v1.15.2 + github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.4 github.com/magiconair/properties v1.8.4 github.com/mattn/go-isatty v0.0.12 @@ -46,11 +45,11 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 github.com/tendermint/tendermint v0.34.0-rc6 - github.com/tendermint/tm-db v0.6.2 - golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee + github.com/tendermint/tm-db v0.6.3 + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 // indirect - google.golang.org/genproto v0.0.0-20201014134559-03b6142f0dc9 - google.golang.org/grpc v1.33.0 + google.golang.org/genproto v0.0.0-20201111145450-ac7456db90a6 + google.golang.org/grpc v1.33.2 google.golang.org/protobuf v1.25.0 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index 6b5e5ed526..db70ba9caf 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE= -github.com/cosmos/iavl v0.15.0-rc4 h1:P1wmET7BueqCzfxsn+BzVkDWDLY9ij2JNwkbIdM7RG8= -github.com/cosmos/iavl v0.15.0-rc4/go.mod h1:5CsecJdh44Uj4vZ6WSPeWq84hNW5BwRI36ZsAbfJvRw= +github.com/cosmos/iavl v0.15.0-rc5 h1:AMKgaAjXwGANWv56NL4q4hV+a0puSkLYD6cCQAv3i44= +github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -284,8 +284,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU= -github.com/grpc-ecosystem/grpc-gateway v1.15.2 h1:HC+hWRWf+v5zTMPyoaYTKIJih+4sd4XRWmj0qlG87Co= -github.com/grpc-ecosystem/grpc-gateway v1.15.2/go.mod h1:vO11I9oWA+KsxmfFQPhLnnIb1VDE24M+pdxZFiuZcA8= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= @@ -595,12 +595,12 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tendermint/tendermint v0.34.0-rc4/go.mod h1:yotsojf2C1QBOw4dZrTcxbyxmPUrT4hNuOQWX9XUwB4= -github.com/tendermint/tendermint v0.34.0-rc5 h1:2bnQfWyOMfTCbol5pwB8CgM2nxi6/Kz6zqlS6Udm/Cg= -github.com/tendermint/tendermint v0.34.0-rc5/go.mod h1:yotsojf2C1QBOw4dZrTcxbyxmPUrT4hNuOQWX9XUwB4= github.com/tendermint/tendermint v0.34.0-rc6 h1:SVuKGvvE22KxfuK8QUHctUrmOWJsncZSYXIYtcnoKN0= github.com/tendermint/tendermint v0.34.0-rc6/go.mod h1:ugzyZO5foutZImv0Iyx/gOFCX6mjJTgbLHTwi17VDVg= github.com/tendermint/tm-db v0.6.2 h1:DOn8jwCdjJblrCFJbtonEIPD1IuJWpbRUUdR8GWE4RM= github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs+yAcLvGI= +github.com/tendermint/tm-db v0.6.3 h1:ZkhQcKnB8/2jr5EaZwGndN4owkPsGezW2fSisS9zGbg= +github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -645,8 +645,8 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee h1:4yd7jl+vXjalO5ztz6Vc1VADv+S/80LGJmyl1ROJ2AI= -golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -694,6 +694,7 @@ golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 h1:YfxMZzv3PjGonQYNUaeU2+DhAdqOxerQ30JFB6WgAXo= golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -810,8 +811,8 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201014134559-03b6142f0dc9 h1:fG84H9C3EXfuDlzkG+VEPDYHHExklP6scH1QZ5gQTqU= -google.golang.org/genproto v0.0.0-20201014134559-03b6142f0dc9/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201111145450-ac7456db90a6 h1:iRN4+t0lvZX/l9gH14ARF9i58tsVa5a97k6aH95rC3Y= +google.golang.org/genproto v0.0.0-20201111145450-ac7456db90a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -830,8 +831,9 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.0 h1:IBKSUNL2uBS2DkJBncPP+TwT0sp9tgA8A75NjHt6umg= -google.golang.org/grpc v1.33.0/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 0caa123829..72e1d9ec28 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -17,8 +17,9 @@ message BaseAccount { option (cosmos_proto.implements_interface) = "AccountI"; - string address = 1; - google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; + string address = 1; + google.protobuf.Any pub_key = 2 + [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; uint64 sequence = 4; } @@ -29,9 +30,9 @@ message ModuleAccount { option (gogoproto.goproto_stringer) = false; option (cosmos_proto.implements_interface) = "ModuleAccountI"; - BaseAccount base_account = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""]; - string name = 2; - repeated string permissions = 3; + BaseAccount base_account = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""]; + string name = 2; + repeated string permissions = 3; } // Params defines the parameters for the auth module. diff --git a/proto/cosmos/bank/v1beta1/tx.proto b/proto/cosmos/bank/v1beta1/tx.proto index 0216ad665e..26b2ab41f4 100644 --- a/proto/cosmos/bank/v1beta1/tx.proto +++ b/proto/cosmos/bank/v1beta1/tx.proto @@ -28,15 +28,15 @@ message MsgSend { } // MsgSendResponse defines the Msg/Send response type. -message MsgSendResponse { } +message MsgSendResponse {} // MsgMultiSend represents an arbitrary multi-in, multi-out send message. message MsgMultiSend { option (gogoproto.equal) = false; - repeated Input inputs = 1 [(gogoproto.nullable) = false]; + repeated Input inputs = 1 [(gogoproto.nullable) = false]; repeated Output outputs = 2 [(gogoproto.nullable) = false]; } // MsgMultiSendResponse defines the Msg/MultiSend response type. -message MsgMultiSendResponse { } +message MsgMultiSendResponse {} diff --git a/proto/cosmos/base/abci/v1beta1/abci.proto b/proto/cosmos/base/abci/v1beta1/abci.proto index 9d7edbbbbd..72da2aacc3 100644 --- a/proto/cosmos/base/abci/v1beta1/abci.proto +++ b/proto/cosmos/base/abci/v1beta1/abci.proto @@ -58,7 +58,7 @@ message ABCIMessageLog { message StringEvent { option (gogoproto.stringer) = true; - string type = 1; + string type = 1; repeated Attribute attributes = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/cosmos/base/store/v1beta1/commit_info.proto b/proto/cosmos/base/store/v1beta1/commit_info.proto index 3bc23af84e..98a33d30e7 100644 --- a/proto/cosmos/base/store/v1beta1/commit_info.proto +++ b/proto/cosmos/base/store/v1beta1/commit_info.proto @@ -8,7 +8,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/store/types"; // CommitInfo defines commit information used by the multi-store when committing // a version/height. message CommitInfo { - int64 version = 1; + int64 version = 1; repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/cosmos/crisis/v1beta1/tx.proto b/proto/cosmos/crisis/v1beta1/tx.proto index c6156b8a72..26457ad6d5 100644 --- a/proto/cosmos/crisis/v1beta1/tx.proto +++ b/proto/cosmos/crisis/v1beta1/tx.proto @@ -22,4 +22,4 @@ message MsgVerifyInvariant { } // MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. -message MsgVerifyInvariantResponse { } +message MsgVerifyInvariantResponse {} diff --git a/proto/cosmos/crypto/ed25519/keys.proto b/proto/cosmos/crypto/ed25519/keys.proto index 3f667a0b21..bed9c29cc7 100644 --- a/proto/cosmos/crypto/ed25519/keys.proto +++ b/proto/cosmos/crypto/ed25519/keys.proto @@ -11,12 +11,12 @@ option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"; // the x-coordinate. Otherwise the first byte is a 0x03. // This prefix is followed with the x-coordinate. message PubKey { - option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_stringer) = false; - bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"]; + bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"]; } // PrivKey defines a ed25519 private key. message PrivKey { - bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"]; + bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"]; } diff --git a/proto/cosmos/distribution/v1beta1/tx.proto b/proto/cosmos/distribution/v1beta1/tx.proto index 783f06d1d7..e6ce478bcd 100644 --- a/proto/cosmos/distribution/v1beta1/tx.proto +++ b/proto/cosmos/distribution/v1beta1/tx.proto @@ -9,7 +9,7 @@ import "cosmos/base/v1beta1/coin.proto"; // Msg defines the distribution Msg service. service Msg { - // SetWithdrawAddress defines a method to change the withdraw address + // SetWithdrawAddress defines a method to change the withdraw address // for a delegator (or validator self-delegation). rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse); @@ -17,7 +17,7 @@ service Msg { // from a single validator. rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward) returns (MsgWithdrawDelegatorRewardResponse); - // WithdrawValidatorCommission defines a method to withdraw the + // WithdrawValidatorCommission defines a method to withdraw the // full commission to the validator address. rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); @@ -37,7 +37,7 @@ message MsgSetWithdrawAddress { } // MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. -message MsgSetWithdrawAddressResponse { } +message MsgSetWithdrawAddressResponse {} // MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator // from a single validator. @@ -50,7 +50,7 @@ message MsgWithdrawDelegatorReward { } // MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. -message MsgWithdrawDelegatorRewardResponse { } +message MsgWithdrawDelegatorRewardResponse {} // MsgWithdrawValidatorCommission withdraws the full commission to the validator // address. @@ -62,7 +62,7 @@ message MsgWithdrawValidatorCommission { } // MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. -message MsgWithdrawValidatorCommissionResponse { } +message MsgWithdrawValidatorCommissionResponse {} // MsgFundCommunityPool allows an account to directly // fund the community pool. @@ -76,4 +76,4 @@ message MsgFundCommunityPool { } // MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. -message MsgFundCommunityPoolResponse { } +message MsgFundCommunityPoolResponse {} diff --git a/proto/cosmos/gov/v1beta1/tx.proto b/proto/cosmos/gov/v1beta1/tx.proto index 0d8cbc03ce..f5e1b5f1bf 100644 --- a/proto/cosmos/gov/v1beta1/tx.proto +++ b/proto/cosmos/gov/v1beta1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; // Msg defines the bank Msg service. service Msg { @@ -27,7 +27,7 @@ service Msg { // MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary // proposal Content. message MsgSubmitProposal { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_stringer) = false; option (gogoproto.stringer) = false; option (gogoproto.goproto_getters) = false; @@ -43,12 +43,12 @@ message MsgSubmitProposal { // MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. message MsgSubmitProposalResponse { - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; } // MsgVote defines a message to cast a vote. message MsgVote { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_stringer) = false; option (gogoproto.stringer) = false; option (gogoproto.goproto_getters) = false; @@ -78,7 +78,7 @@ message MsgWeightedVoteResponse {} // MsgDeposit defines a message to submit a deposit to an existing proposal. message MsgDeposit { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_stringer) = false; option (gogoproto.stringer) = false; option (gogoproto.goproto_getters) = false; diff --git a/proto/cosmos/params/v1beta1/params.proto b/proto/cosmos/params/v1beta1/params.proto index 5b47261b19..5382fd7999 100644 --- a/proto/cosmos/params/v1beta1/params.proto +++ b/proto/cosmos/params/v1beta1/params.proto @@ -11,9 +11,9 @@ message ParameterChangeProposal { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - string title = 1; - string description = 2; - repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; + string title = 1; + string description = 2; + repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; } // ParamChange defines an individual parameter change, for use in diff --git a/proto/cosmos/staking/v1beta1/staking.proto b/proto/cosmos/staking/v1beta1/staking.proto index ac68af05f4..eadc86e9d1 100644 --- a/proto/cosmos/staking/v1beta1/staking.proto +++ b/proto/cosmos/staking/v1beta1/staking.proto @@ -18,7 +18,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; // (`n` is set by the staking module's `historical_entries` parameter). message HistoricalInfo { tendermint.types.Header header = 1 [(gogoproto.nullable) = false]; - repeated Validator valset = 2 [(gogoproto.nullable) = false]; + repeated Validator valset = 2 [(gogoproto.nullable) = false]; } // CommissionRates defines the initial commission rates to be used for creating @@ -75,13 +75,12 @@ message Validator { option (gogoproto.goproto_stringer) = false; option (gogoproto.goproto_getters) = false; - string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; - google.protobuf.Any consensus_pubkey = 2 [ - (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", - (gogoproto.moretags) = "yaml:\"consensus_pubkey\""]; - bool jailed = 3; - BondStatus status = 4; - string tokens = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; + google.protobuf.Any consensus_pubkey = 2 + [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", (gogoproto.moretags) = "yaml:\"consensus_pubkey\""]; + bool jailed = 3; + BondStatus status = 4; + string tokens = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; string delegator_shares = 6 [ (gogoproto.moretags) = "yaml:\"delegator_shares\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", @@ -177,8 +176,8 @@ message UnbondingDelegation { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; repeated UnbondingDelegationEntry entries = 3 [(gogoproto.nullable) = false]; // unbonding delegation entries } @@ -222,10 +221,10 @@ message Redelegation { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; - string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; - string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; - repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; + repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries } // Params defines the parameters for the staking module. @@ -268,8 +267,8 @@ message RedelegationEntryResponse { message RedelegationResponse { option (gogoproto.equal) = false; - Redelegation redelegation = 1 [(gogoproto.nullable) = false]; - repeated RedelegationEntryResponse entries = 2 [(gogoproto.nullable) = false]; + Redelegation redelegation = 1 [(gogoproto.nullable) = false]; + repeated RedelegationEntryResponse entries = 2 [(gogoproto.nullable) = false]; } // Pool is used for tracking bonded and not-bonded token supply of the bond diff --git a/proto/cosmos/staking/v1beta1/tx.proto b/proto/cosmos/staking/v1beta1/tx.proto index 389957091d..ffcd74b2d9 100644 --- a/proto/cosmos/staking/v1beta1/tx.proto +++ b/proto/cosmos/staking/v1beta1/tx.proto @@ -51,7 +51,7 @@ message MsgCreateValidator { } // MsgCreateValidatorResponse defines the Msg/CreateValidator response type. -message MsgCreateValidatorResponse { } +message MsgCreateValidatorResponse {} // MsgEditValidator defines a SDK message for editing an existing validator. message MsgEditValidator { @@ -77,7 +77,7 @@ message MsgEditValidator { } // MsgEditValidatorResponse defines the Msg/EditValidator response type. -message MsgEditValidatorResponse { } +message MsgEditValidatorResponse {} // MsgDelegate defines a SDK message for performing a delegation of coins // from a delegator to a validator. @@ -91,7 +91,7 @@ message MsgDelegate { } // MsgDelegateResponse defines the Msg/Delegate response type. -message MsgDelegateResponse { } +message MsgDelegateResponse {} // MsgBeginRedelegate defines a SDK message for performing a redelegation // of coins from a delegator and source validator to a destination validator. diff --git a/proto/cosmos/tx/signing/v1beta1/signing.proto b/proto/cosmos/tx/signing/v1beta1/signing.proto index 73c8596483..4c1be40594 100644 --- a/proto/cosmos/tx/signing/v1beta1/signing.proto +++ b/proto/cosmos/tx/signing/v1beta1/signing.proto @@ -37,43 +37,43 @@ message SignatureDescriptors { // signature itself. It is primarily used for coordinating signatures between // clients. message SignatureDescriptor { - // public_key is the public key of the signer - google.protobuf.Any public_key = 1; + // public_key is the public key of the signer + google.protobuf.Any public_key = 1; - Data data = 2; + Data data = 2; - // sequence is the sequence of the account, which describes the - // number of committed transactions signed by a given address. It is used to prevent - // replay attacks. - uint64 sequence = 3; + // sequence is the sequence of the account, which describes the + // number of committed transactions signed by a given address. It is used to prevent + // replay attacks. + uint64 sequence = 3; - // Data represents signature data - message Data { - // sum is the oneof that specifies whether this represents single or multi-signature data - oneof sum { - // single represents a single signer - Single single = 1; + // Data represents signature data + message Data { + // sum is the oneof that specifies whether this represents single or multi-signature data + oneof sum { + // single represents a single signer + Single single = 1; - // multi represents a multisig signer - Multi multi = 2; - } - - // Single is the signature data for a single signer - message Single { - // mode is the signing mode of the single signer - SignMode mode = 1; - - // signature is the raw signature bytes - bytes signature = 2; - } - - // Multi is the signature data for a multisig public key - message Multi { - // bitarray specifies which keys within the multisig are signing - cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1; - - // signatures is the signatures of the multi-signature - repeated Data signatures = 2; - } + // multi represents a multisig signer + Multi multi = 2; } + + // Single is the signature data for a single signer + message Single { + // mode is the signing mode of the single signer + SignMode mode = 1; + + // signature is the raw signature bytes + bytes signature = 2; + } + + // Multi is the signature data for a multisig public key + message Multi { + // bitarray specifies which keys within the multisig are signing + cosmos.crypto.multisig.v1beta1.CompactBitArray bitarray = 1; + + // signatures is the signatures of the multi-signature + repeated Data signatures = 2; + } + } } diff --git a/proto/cosmos/tx/v1beta1/service.proto b/proto/cosmos/tx/v1beta1/service.proto index eb7784001c..d78216d031 100644 --- a/proto/cosmos/tx/v1beta1/service.proto +++ b/proto/cosmos/tx/v1beta1/service.proto @@ -4,46 +4,74 @@ package cosmos.tx.v1beta1; import "google/api/annotations.proto"; import "cosmos/base/abci/v1beta1/abci.proto"; import "cosmos/tx/v1beta1/tx.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; // Service defines a gRPC service for interacting with transactions. service Service { - // Simulate simulates executing a transaction for estimating gas usage. - rpc Simulate(SimulateRequest) returns (SimulateResponse) { - option (google.api.http).post = "/cosmos/tx/v1beta1/simulate"; - } - // GetTx fetches a tx by hash. - rpc GetTx(GetTxRequest) returns (GetTxResponse) { - option (google.api.http).get = "/cosmos/tx/v1beta1/tx/{hash}"; - } + // Simulate simulates executing a transaction for estimating gas usage. + rpc Simulate(SimulateRequest) returns (SimulateResponse) { + option (google.api.http).post = "/cosmos/tx/v1beta1/simulate"; + } + // GetTx fetches a tx by hash. + rpc GetTx(GetTxRequest) returns (GetTxResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/tx/{hash}"; + } + + // GetTxsEvent fetches txs by event. + rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/txs"; + } +} + +// GetTxsEventRequest is the request type for the Service.TxsByEvents +// RPC method. +message GetTxsEventRequest { + // event is the transaction event type. + string event = 1; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// GetTxsEventResponse is the response type for the Service.TxsByEvents +// RPC method. +message GetTxsEventResponse { + // txs is the list of queried transactions. + repeated cosmos.tx.v1beta1.Tx txs = 1; + // tx_responses is the list of queried TxResponses. + repeated cosmos.base.abci.v1beta1.TxResponse tx_responses = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; } // SimulateRequest is the request type for the Service.Simulate // RPC method. message SimulateRequest { - // tx is the transaction to simulate. - cosmos.tx.v1beta1.Tx tx = 1; + // tx is the transaction to simulate. + cosmos.tx.v1beta1.Tx tx = 1; } - + // SimulateResponse is the response type for the // Service.SimulateRPC method. message SimulateResponse { - // gas_info is the information about gas used in the simulation. - cosmos.base.abci.v1beta1.GasInfo gas_info = 1; - // result is the result of the simulation. - cosmos.base.abci.v1beta1.Result result = 2; + // gas_info is the information about gas used in the simulation. + cosmos.base.abci.v1beta1.GasInfo gas_info = 1; + // result is the result of the simulation. + cosmos.base.abci.v1beta1.Result result = 2; } -// GetTx is the request type for the Service.GetTx +// GetTxRequest is the request type for the Service.GetTx // RPC method. message GetTxRequest { - // hash is the tx hash to query, encoded as a hex string. - string hash = 1; + // hash is the tx hash to query, encoded as a hex string. + string hash = 1; } - + // GetTxResponse is the response type for the Service.GetTx method. message GetTxResponse { - // tx is the queried transaction. - cosmos.tx.v1beta1.Tx tx = 1; -} + // tx is the queried transaction. + cosmos.tx.v1beta1.Tx tx = 1; + // tx_response is the queried TxResponses. + cosmos.base.abci.v1beta1.TxResponse tx_response = 2; +} \ No newline at end of file diff --git a/proto/cosmos/upgrade/v1beta1/upgrade.proto b/proto/cosmos/upgrade/v1beta1/upgrade.proto index 858634b2b2..826440e5d7 100644 --- a/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ b/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -39,7 +39,8 @@ message Plan { // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the // previous version of the chain. // This will allow IBC connections to persist smoothly across planned chain upgrades - google.protobuf.Any upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""];; + google.protobuf.Any upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; + ; } // SoftwareUpgradeProposal is a gov Content type for initiating a software diff --git a/proto/cosmos/vesting/v1beta1/tx.proto b/proto/cosmos/vesting/v1beta1/tx.proto index 41873315c0..c49be802a7 100644 --- a/proto/cosmos/vesting/v1beta1/tx.proto +++ b/proto/cosmos/vesting/v1beta1/tx.proto @@ -6,7 +6,6 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; - // Msg defines the bank Msg service. service Msg { // CreateVestingAccount defines a method that enables creating a vesting @@ -14,7 +13,6 @@ service Msg { rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); } - // MsgCreateVestingAccount defines a message that enables creating a vesting // account. message MsgCreateVestingAccount { @@ -30,4 +28,4 @@ message MsgCreateVestingAccount { } // MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. -message MsgCreateVestingAccountResponse { } \ No newline at end of file +message MsgCreateVestingAccountResponse {} \ No newline at end of file diff --git a/proto/ibc/applications/transfer/v1/query.proto b/proto/ibc/applications/transfer/v1/query.proto index 98dd02f759..e9cbd02a31 100644 --- a/proto/ibc/applications/transfer/v1/query.proto +++ b/proto/ibc/applications/transfer/v1/query.proto @@ -12,17 +12,17 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/ty service Query { // DenomTrace queries a denomination trace information. rpc DenomTrace(QueryDenomTraceRequest) returns (QueryDenomTraceResponse) { - option (google.api.http).get = "/ibc_transfer/v1beta1/denom_traces/{hash}"; + option (google.api.http).get = "/ibc/applications/transfer/v1beta1/denom_traces/{hash}"; } // DenomTraces queries all denomination traces. rpc DenomTraces(QueryDenomTracesRequest) returns (QueryDenomTracesResponse) { - option (google.api.http).get = "/ibc_transfer/v1beta1/denom_traces"; + option (google.api.http).get = "/ibc/applications/transfer/v1beta1/denom_traces"; } // Params queries all parameters of the ibc-transfer module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/ibc_transfer/v1beta1/params"; + option (google.api.http).get = "/ibc/applications/transfer/v1beta1/params"; } } diff --git a/proto/ibc/applications/transfer/v1/tx.proto b/proto/ibc/applications/transfer/v1/tx.proto index eb2e12e5df..a0f0827aaf 100644 --- a/proto/ibc/applications/transfer/v1/tx.proto +++ b/proto/ibc/applications/transfer/v1/tx.proto @@ -40,4 +40,4 @@ message MsgTransfer { } // MsgTransferResponse defines the Msg/Transfer response type. -message MsgTransferResponse { } +message MsgTransferResponse {} diff --git a/proto/ibc/core/channel/v1/genesis.proto b/proto/ibc/core/channel/v1/genesis.proto index 98a7e630aa..a89e69c7dd 100644 --- a/proto/ibc/core/channel/v1/genesis.proto +++ b/proto/ibc/core/channel/v1/genesis.proto @@ -8,11 +8,11 @@ import "ibc/core/channel/v1/channel.proto"; // GenesisState defines the ibc channel submodule's genesis state. message GenesisState { - repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; - repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; - repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; - repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; - repeated PacketSequence send_sequences = 5 + repeated IdentifiedChannel channels = 1 [(gogoproto.casttype) = "IdentifiedChannel", (gogoproto.nullable) = false]; + repeated PacketState acknowledgements = 2 [(gogoproto.nullable) = false]; + repeated PacketState commitments = 3 [(gogoproto.nullable) = false]; + repeated PacketState receipts = 4 [(gogoproto.nullable) = false]; + repeated PacketSequence send_sequences = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"send_sequences\""]; repeated PacketSequence recv_sequences = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"recv_sequences\""]; diff --git a/proto/ibc/core/channel/v1/query.proto b/proto/ibc/core/channel/v1/query.proto index dcff04f7f4..4121096240 100644 --- a/proto/ibc/core/channel/v1/query.proto +++ b/proto/ibc/core/channel/v1/query.proto @@ -14,79 +14,82 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"; service Query { // Channel queries an IBC Channel. rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}"; + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}"; } // Channels queries all the IBC channels of a chain. rpc Channels(QueryChannelsRequest) returns (QueryChannelsResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels"; + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels"; } // ConnectionChannels queries all the channels associated with a connection // end. rpc ConnectionChannels(QueryConnectionChannelsRequest) returns (QueryConnectionChannelsResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/connections/{connection}/channels"; + option (google.api.http).get = "/ibc/core/channel/v1beta1/connections/{connection}/channels"; } // ChannelClientState queries for the client state for the channel associated // with the provided channel identifiers. rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state"; + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/client_state"; } // ChannelConsensusState queries for the consensus state for the channel // associated with the provided channel identifiers. rpc ChannelConsensusState(QueryChannelConsensusStateRequest) returns (QueryChannelConsensusStateResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/version/" - "{version_number}/height/{version_height}"; + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/consensus_state/version/" + "{version_number}/height/{version_height}"; } // PacketCommitment queries a stored packet commitment hash. rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) { option (google.api.http).get = - "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}"; + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence}"; } // PacketCommitments returns all the packet commitments hashes associated // with a channel. rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments"; + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments"; } // PacketReceipt queries if a given packet sequence has been received on the queried chain rpc PacketReceipt(QueryPacketReceiptRequest) returns (QueryPacketReceiptResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}"; + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence}"; } // PacketAcknowledgement queries a stored packet acknowledgement hash. rpc PacketAcknowledgement(QueryPacketAcknowledgementRequest) returns (QueryPacketAcknowledgementResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}"; + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}"; } // PacketAcknowledgements returns all the packet acknowledgements associated // with a channel. rpc PacketAcknowledgements(QueryPacketAcknowledgementsRequest) returns (QueryPacketAcknowledgementsResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements"; + option (google.api.http).get = + "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements"; } - // UnreceivedPackets returns all the unreceived IBC packets associated with a // channel and sequences. rpc UnreceivedPackets(QueryUnreceivedPacketsRequest) returns (QueryUnreceivedPacketsResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" "{packet_commitment_sequences}/unreceived_packets"; } // UnreceivedAcks returns all the unreceived IBC acknowledgements associated with a // channel and sequences. rpc UnreceivedAcks(QueryUnreceivedAcksRequest) returns (QueryUnreceivedAcksResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/packet_commitments/" "{packet_ack_sequences}/unreceived_acks"; } // NextSequenceReceive returns the next receive sequence for a given channel. rpc NextSequenceReceive(QueryNextSequenceReceiveRequest) returns (QueryNextSequenceReceiveResponse) { - option (google.api.http).get = "/ibc/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence"; + option (google.api.http).get = "/ibc/core/channel/v1beta1/channels/{channel_id}/ports/{port_id}/next_sequence"; } } diff --git a/proto/ibc/core/channel/v1/tx.proto b/proto/ibc/core/channel/v1/tx.proto index 0426c741b9..c60ecc4363 100644 --- a/proto/ibc/core/channel/v1/tx.proto +++ b/proto/ibc/core/channel/v1/tx.proto @@ -148,7 +148,7 @@ message MsgRecvPacket { option (gogoproto.goproto_getters) = false; Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof = 2; + bytes proof_commitment = 2 [(gogoproto.moretags) = "yaml:\"proof_commitment\""]; ibc.core.client.v1.Height proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; string signer = 4; @@ -163,7 +163,7 @@ message MsgTimeout { option (gogoproto.goproto_getters) = false; Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof = 2; + bytes proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""]; ibc.core.client.v1.Height proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""]; @@ -179,7 +179,7 @@ message MsgTimeoutOnClose { option (gogoproto.goproto_getters) = false; Packet packet = 1 [(gogoproto.nullable) = false]; - bytes proof = 2; + bytes proof_unreceived = 2 [(gogoproto.moretags) = "yaml:\"proof_unreceived\""]; bytes proof_close = 3 [(gogoproto.moretags) = "yaml:\"proof_close\""]; ibc.core.client.v1.Height proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; @@ -197,7 +197,7 @@ message MsgAcknowledgement { Packet packet = 1 [(gogoproto.nullable) = false]; bytes acknowledgement = 2; - bytes proof = 3; + bytes proof_acked = 3 [(gogoproto.moretags) = "yaml:\"proof_acked\""]; ibc.core.client.v1.Height proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; string signer = 5; diff --git a/proto/ibc/core/client/v1/client.proto b/proto/ibc/core/client/v1/client.proto index 118318c246..a5d2b0f19e 100644 --- a/proto/ibc/core/client/v1/client.proto +++ b/proto/ibc/core/client/v1/client.proto @@ -6,91 +6,6 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; -// Msg defines the ibc/client Msg service. -service Msg { - // CreateClient defines a rpc handler method for MsgCreateClient. - rpc CreateClient(MsgCreateClient) returns (MsgCreateClientResponse); - - // UpdateClient defines a rpc handler method for MsgUpdateClient. - rpc UpdateClient(MsgUpdateClient) returns (MsgUpdateClientResponse); - - // UpgradeClient defines a rpc handler method for MsgUpgradeClient. - rpc UpgradeClient(MsgUpgradeClient) returns (MsgUpgradeClientResponse); - - // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. - rpc SubmitMisbehaviour(MsgSubmitMisbehaviour) returns (MsgSubmitMisbehaviourResponse); -} - -// MsgCreateClient defines a message to create an IBC client -message MsgCreateClient { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // light client state - google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; - // consensus state associated with the client that corresponds to a given - // height. - google.protobuf.Any consensus_state = 3 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; - // signer address - string signer = 4; -} - -// MsgCreateClientResponse defines the Msg/CreateClient response type. -message MsgCreateClientResponse { } - -// MsgUpdateClient defines an sdk.Msg to update a IBC client state using -// the given header. -message MsgUpdateClient { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // header to update the light client - google.protobuf.Any header = 2; - // signer address - string signer = 3; -} - -// MsgUpdateClientResponse defines the Msg/UpdateClient response type. -message MsgUpdateClientResponse { } - -// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state -message MsgUpgradeClient { - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // upgraded client state - google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; - // height at which old chain halts and upgrades (i.e last block executed) - Height upgrade_height = 3 [(gogoproto.moretags) = "yaml:\"upgrade_height\""]; - // proof that old chain committed to new client - bytes proof_upgrade = 4 [(gogoproto.moretags) = "yaml:\"proof_upgrade\""]; - // signer address - string signer = 5; -} - -// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. -message MsgUpgradeClientResponse { } - -// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for -// light client misbehaviour. -message MsgSubmitMisbehaviour { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - // client unique identifier - string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - // misbehaviour used for freezing the light client - google.protobuf.Any misbehaviour = 2; - // signer address - string signer = 3; -} - -// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. -message MsgSubmitMisbehaviourResponse { } - // IdentifiedClientState defines a client state with an additional client // identifier field. message IdentifiedClientState { @@ -151,3 +66,9 @@ message Height { // the height within the given version uint64 version_height = 2 [(gogoproto.moretags) = "yaml:\"version_height\""]; } + +// Params defines the set of IBC light client parameters. +message Params { + // allowed_clients defines the list of allowed client state types. + repeated string allowed_clients = 1 [(gogoproto.moretags) = "yaml:\"allowed_clients\""]; +} diff --git a/proto/ibc/core/client/v1/genesis.proto b/proto/ibc/core/client/v1/genesis.proto index 1041ca9448..b1c4247c94 100644 --- a/proto/ibc/core/client/v1/genesis.proto +++ b/proto/ibc/core/client/v1/genesis.proto @@ -9,13 +9,15 @@ import "gogoproto/gogo.proto"; // GenesisState defines the ibc client submodule's genesis state. message GenesisState { // client states with their corresponding identifiers - repeated IdentifiedClientState clients = 1 [(gogoproto.nullable) = false]; + repeated IdentifiedClientState clients = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"]; // consensus states from each client repeated ClientConsensusStates clients_consensus = 2 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "ClientsConsensusStates", (gogoproto.moretags) = "yaml:\"clients_consensus\"" ]; + Params params = 3 [(gogoproto.nullable) = false]; // create localhost on initialization - bool create_localhost = 3 [(gogoproto.moretags) = "yaml:\"create_localhost\""]; + bool create_localhost = 4 [(gogoproto.moretags) = "yaml:\"create_localhost\""]; } diff --git a/proto/ibc/core/client/v1/query.proto b/proto/ibc/core/client/v1/query.proto index a40fed843e..7a1bf50538 100644 --- a/proto/ibc/core/client/v1/query.proto +++ b/proto/ibc/core/client/v1/query.proto @@ -13,25 +13,30 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; service Query { // ClientState queries an IBC light client. rpc ClientState(QueryClientStateRequest) returns (QueryClientStateResponse) { - option (google.api.http).get = "/ibc/client/v1beta1/client_states/{client_id}"; + option (google.api.http).get = "/ibc/core/client/v1beta1/client_states/{client_id}"; } // ClientStates queries all the IBC light clients of a chain. rpc ClientStates(QueryClientStatesRequest) returns (QueryClientStatesResponse) { - option (google.api.http).get = "/ibc/client/v1beta1/client_states"; + option (google.api.http).get = "/ibc/core/client/v1beta1/client_states"; } // ConsensusState queries a consensus state associated with a client state at // a given height. rpc ConsensusState(QueryConsensusStateRequest) returns (QueryConsensusStateResponse) { - option (google.api.http).get = "/ibc/client/v1beta1/consensus_states/{client_id}/version/{version_number}/" + option (google.api.http).get = "/ibc/core/client/v1beta1/consensus_states/{client_id}/version/{version_number}/" "height/{version_height}"; } // ConsensusStates queries all the consensus state associated with a given // client. rpc ConsensusStates(QueryConsensusStatesRequest) returns (QueryConsensusStatesResponse) { - option (google.api.http).get = "/ibc/client/v1beta1/consensus_states/{client_id}"; + option (google.api.http).get = "/ibc/core/client/v1beta1/consensus_states/{client_id}"; + } + + // ClientParams queries all parameters of the ibc client. + rpc ClientParams(QueryClientParamsRequest) returns (QueryClientParamsResponse) { + option (google.api.http).get = "/ibc/client/v1beta1/params"; } } @@ -65,7 +70,8 @@ message QueryClientStatesRequest { // method. message QueryClientStatesResponse { // list of stored ClientStates of the chain. - repeated IdentifiedClientState client_states = 1; + repeated IdentifiedClientState client_states = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "IdentifiedClientStates"]; // pagination response cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -113,3 +119,12 @@ message QueryConsensusStatesResponse { // pagination response cosmos.base.query.v1beta1.PageResponse pagination = 2; } + +// QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. +message QueryClientParamsRequest {} + +// QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. +message QueryClientParamsResponse { + // params defines the parameters of the module. + Params params = 1; +} diff --git a/proto/ibc/core/client/v1/tx.proto b/proto/ibc/core/client/v1/tx.proto new file mode 100644 index 0000000000..fd54a92108 --- /dev/null +++ b/proto/ibc/core/client/v1/tx.proto @@ -0,0 +1,93 @@ +syntax = "proto3"; +package ibc.core.client.v1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "ibc/core/client/v1/client.proto"; + +// Msg defines the ibc/client Msg service. +service Msg { + // CreateClient defines a rpc handler method for MsgCreateClient. + rpc CreateClient(MsgCreateClient) returns (MsgCreateClientResponse); + + // UpdateClient defines a rpc handler method for MsgUpdateClient. + rpc UpdateClient(MsgUpdateClient) returns (MsgUpdateClientResponse); + + // UpgradeClient defines a rpc handler method for MsgUpgradeClient. + rpc UpgradeClient(MsgUpgradeClient) returns (MsgUpgradeClientResponse); + + // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. + rpc SubmitMisbehaviour(MsgSubmitMisbehaviour) returns (MsgSubmitMisbehaviourResponse); +} + +// MsgCreateClient defines a message to create an IBC client +message MsgCreateClient { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // light client state + google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; + // consensus state associated with the client that corresponds to a given + // height. + google.protobuf.Any consensus_state = 3 [(gogoproto.moretags) = "yaml:\"consensus_state\""]; + // signer address + string signer = 4; +} + +// MsgCreateClientResponse defines the Msg/CreateClient response type. +message MsgCreateClientResponse {} + +// MsgUpdateClient defines an sdk.Msg to update a IBC client state using +// the given header. +message MsgUpdateClient { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // header to update the light client + google.protobuf.Any header = 2; + // signer address + string signer = 3; +} + +// MsgUpdateClientResponse defines the Msg/UpdateClient response type. +message MsgUpdateClientResponse {} + +// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state +message MsgUpgradeClient { + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // upgraded client state + google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""]; + // height at which old chain halts and upgrades (i.e last block executed) + Height upgrade_height = 3 [(gogoproto.moretags) = "yaml:\"upgrade_height\""]; + // proof that old chain committed to new client + bytes proof_upgrade = 4 [(gogoproto.moretags) = "yaml:\"proof_upgrade\""]; + // signer address + string signer = 5; +} + +// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. +message MsgUpgradeClientResponse {} + +// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for +// light client misbehaviour. +message MsgSubmitMisbehaviour { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // client unique identifier + string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; + // misbehaviour used for freezing the light client + google.protobuf.Any misbehaviour = 2; + // signer address + string signer = 3; +} + +// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. +message MsgSubmitMisbehaviourResponse {} diff --git a/proto/ibc/core/commitment/v1/commitment.proto b/proto/ibc/core/commitment/v1/commitment.proto index 0ed6be0f25..51c1027316 100644 --- a/proto/ibc/core/commitment/v1/commitment.proto +++ b/proto/ibc/core/commitment/v1/commitment.proto @@ -4,7 +4,7 @@ package ibc.core.commitment.v1; option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types"; import "gogoproto/gogo.proto"; -import "tendermint/crypto/proof.proto"; +import "confio/proofs.proto"; // MerkleRoot defines a merkle root hash. // In the Cosmos SDK, the AppHash of a block header becomes the root. @@ -23,42 +23,18 @@ message MerklePrefix { // MerklePath is the path used to verify commitment proofs, which can be an // arbitrary structured object (defined by a commitment type). +// MerklePath is represented from root-to-leaf message MerklePath { option (gogoproto.goproto_stringer) = false; - KeyPath key_path = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"key_path\""]; + repeated string key_path = 1 [(gogoproto.moretags) = "yaml:\"key_path\""]; } -// MerkleProof is a wrapper type that contains a merkle proof. +// MerkleProof is a wrapper type over a chain of CommitmentProofs. // It demonstrates membership or non-membership for an element or set of // elements, verifiable in conjunction with a known commitment root. Proofs // should be succinct. +// MerkleProofs are ordered from leaf-to-root message MerkleProof { - tendermint.crypto.ProofOps proof = 1; -} - -// KeyPath defines a slice of keys -message KeyPath { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.goproto_getters) = false; - - repeated Key keys = 1; -} - -// Key defines a proof Key -message Key { - option (gogoproto.goproto_getters) = false; - - bytes name = 1; - KeyEncoding enc = 2; -} - -// KeyEncoding defines the encoding format of a key's bytes. -enum KeyEncoding { - option (gogoproto.goproto_enum_prefix) = false; - - // URL encoding - KEY_ENCODING_URL_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "URL"]; - // Hex encoding - KEY_ENCODING_HEX = 1 [(gogoproto.enumvalue_customname) = "HEX"]; -} + repeated ics23.CommitmentProof proofs = 1; +} \ No newline at end of file diff --git a/proto/ibc/core/connection/v1/query.proto b/proto/ibc/core/connection/v1/query.proto index c2666ee28a..9e5b068804 100644 --- a/proto/ibc/core/connection/v1/query.proto +++ b/proto/ibc/core/connection/v1/query.proto @@ -14,30 +14,30 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types service Query { // Connection queries an IBC connection end. rpc Connection(QueryConnectionRequest) returns (QueryConnectionResponse) { - option (google.api.http).get = "/ibc/connection/v1beta1/connections/{connection_id}"; + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}"; } // Connections queries all the IBC connections of a chain. rpc Connections(QueryConnectionsRequest) returns (QueryConnectionsResponse) { - option (google.api.http).get = "/ibc/connection/v1beta1/connections"; + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections"; } // ClientConnections queries the connection paths associated with a client // state. rpc ClientConnections(QueryClientConnectionsRequest) returns (QueryClientConnectionsResponse) { - option (google.api.http).get = "/ibc/connection/v1beta1/client_connections/{client_id}"; + option (google.api.http).get = "/ibc/core/connection/v1beta1/client_connections/{client_id}"; } // ConnectionClientState queries the client state associated with the // connection. rpc ConnectionClientState(QueryConnectionClientStateRequest) returns (QueryConnectionClientStateResponse) { - option (google.api.http).get = "/ibc/connection/v1beta1/connections/{connection_id}/client_state"; + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}/client_state"; } // ConnectionConsensusState queries the consensus state associated with the // connection. rpc ConnectionConsensusState(QueryConnectionConsensusStateRequest) returns (QueryConnectionConsensusStateResponse) { - option (google.api.http).get = "/ibc/connection/v1beta1/connections/{connection_id}/consensus_state/" + option (google.api.http).get = "/ibc/core/connection/v1beta1/connections/{connection_id}/consensus_state/" "version/{version_number}/height/{version_height}"; } } diff --git a/proto/ibc/core/connection/v1/tx.proto b/proto/ibc/core/connection/v1/tx.proto index 8de521886b..02a12b0e31 100644 --- a/proto/ibc/core/connection/v1/tx.proto +++ b/proto/ibc/core/connection/v1/tx.proto @@ -18,7 +18,7 @@ service Msg { // ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. rpc ConnectionOpenAck(MsgConnectionOpenAck) returns (MsgConnectionOpenAckResponse); - + // ConnectionOpenConfirm defines a rpc handler method for MsgConnectionOpenConfirm. rpc ConnectionOpenConfirm(MsgConnectionOpenConfirm) returns (MsgConnectionOpenConfirmResponse); } @@ -37,7 +37,7 @@ message MsgConnectionOpenInit { } // MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response type. -message MsgConnectionOpenInitResponse { } +message MsgConnectionOpenInitResponse {} // MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a // connection on Chain B. @@ -48,9 +48,9 @@ message MsgConnectionOpenTry { string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; string desired_connection_id = 2 [(gogoproto.moretags) = "yaml:\"desired_connection_id\""]; string counterparty_chosen_connection_id = 3 [(gogoproto.moretags) = "yaml:\"counterparty_chosen_connection_id\""]; - google.protobuf.Any client_state = 4 [(gogoproto.moretags) = "yaml:\"client_state\""]; - Counterparty counterparty = 5 [(gogoproto.nullable) = false]; - repeated Version counterparty_versions = 6 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""]; + google.protobuf.Any client_state = 4 [(gogoproto.moretags) = "yaml:\"client_state\""]; + Counterparty counterparty = 5 [(gogoproto.nullable) = false]; + repeated Version counterparty_versions = 6 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""]; ibc.core.client.v1.Height proof_height = 7 [(gogoproto.moretags) = "yaml:\"proof_height\"", (gogoproto.nullable) = false]; // proof of the initialization the connection on Chain A: `UNITIALIZED -> @@ -66,7 +66,7 @@ message MsgConnectionOpenTry { } // MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. -message MsgConnectionOpenTryResponse { } +message MsgConnectionOpenTryResponse {} // MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to // acknowledge the change of connection state to TRYOPEN on Chain B. @@ -93,7 +93,7 @@ message MsgConnectionOpenAck { } // MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. -message MsgConnectionOpenAckResponse { } +message MsgConnectionOpenAckResponse {} // MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to // acknowledge the change of connection state to OPEN on Chain A. @@ -110,4 +110,4 @@ message MsgConnectionOpenConfirm { } // MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm response type. -message MsgConnectionOpenConfirmResponse { } +message MsgConnectionOpenConfirmResponse {} diff --git a/proto/ibc/lightclients/solomachine/v1/solomachine.proto b/proto/ibc/lightclients/solomachine/v1/solomachine.proto index 5903b1b651..738217fa6c 100644 --- a/proto/ibc/lightclients/solomachine/v1/solomachine.proto +++ b/proto/ibc/lightclients/solomachine/v1/solomachine.proto @@ -49,7 +49,6 @@ message Header { // of a sequence and two signatures over different messages at that sequence. message Misbehaviour { option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; uint64 sequence = 2; SignatureAndData signature_one = 3 [(gogoproto.moretags) = "yaml:\"signature_one\""]; diff --git a/proto/ibc/lightclients/tendermint/v1/tendermint.proto b/proto/ibc/lightclients/tendermint/v1/tendermint.proto index c592a9b5da..6f9285c057 100644 --- a/proto/ibc/lightclients/tendermint/v1/tendermint.proto +++ b/proto/ibc/lightclients/tendermint/v1/tendermint.proto @@ -5,7 +5,6 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tenderm import "tendermint/types/validator.proto"; import "tendermint/types/types.proto"; -import "tendermint/abci/types.proto"; import "confio/proofs.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; @@ -40,21 +39,18 @@ message ClientState { ibc.core.client.v1.Height latest_height = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"latest_height\""]; - // Consensus params of the chain - .tendermint.abci.ConsensusParams consensus_params = 8 [(gogoproto.moretags) = "yaml:\"consensus_params\""]; - // Proof specifications used in verifying counterparty state - repeated ics23.ProofSpec proof_specs = 9 [(gogoproto.moretags) = "yaml:\"proof_specs\""]; + repeated ics23.ProofSpec proof_specs = 8 [(gogoproto.moretags) = "yaml:\"proof_specs\""]; // Path at which next upgraded client will be committed - string upgrade_path = 10 [(gogoproto.moretags) = "yaml:\"upgrade_path\""]; + string upgrade_path = 9 [(gogoproto.moretags) = "yaml:\"upgrade_path\""]; // This flag, when set to true, will allow governance to recover a client // which has expired - bool allow_update_after_expiry = 11 [(gogoproto.moretags) = "yaml:\"allow_update_after_expiry\""]; + bool allow_update_after_expiry = 10 [(gogoproto.moretags) = "yaml:\"allow_update_after_expiry\""]; // This flag, when set to true, will allow governance to unfreeze a client // whose chain has experienced a misbehaviour event - bool allow_update_after_misbehaviour = 12 [(gogoproto.moretags) = "yaml:\"allow_update_after_misbehaviour\""]; + bool allow_update_after_misbehaviour = 11 [(gogoproto.moretags) = "yaml:\"allow_update_after_misbehaviour\""]; } // ConsensusState defines the consensus state from Tendermint. @@ -76,12 +72,10 @@ message ConsensusState { // that implements Misbehaviour interface expected by ICS-02 message Misbehaviour { option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; string client_id = 1 [(gogoproto.moretags) = "yaml:\"client_id\""]; - string chain_id = 2 [(gogoproto.moretags) = "yaml:\"chain_id\""]; - Header header_1 = 3 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; - Header header_2 = 4 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; + Header header_1 = 2 [(gogoproto.customname) = "Header1", (gogoproto.moretags) = "yaml:\"header_1\""]; + Header header_2 = 3 [(gogoproto.customname) = "Header2", (gogoproto.moretags) = "yaml:\"header_2\""]; } // Header defines the Tendermint client consensus Header. @@ -106,8 +100,8 @@ message Header { .tendermint.types.ValidatorSet trusted_validators = 4 [(gogoproto.moretags) = "yaml:\"trusted_validators\""]; } -// Fraction defines the protobuf message type for tmmath.Fraction +// Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. message Fraction { - int64 numerator = 1; - int64 denominator = 2; + uint64 numerator = 1; + uint64 denominator = 2; } diff --git a/scripts/protocgen-any.sh b/scripts/protocgen-any.sh index 5622a91eea..2a094265d3 100755 --- a/scripts/protocgen-any.sh +++ b/scripts/protocgen-any.sh @@ -8,8 +8,8 @@ set -eo pipefail go install github.com/gogo/protobuf/protoc-gen-gogotypes -protoc -I. --gogotypes_out=./codec/types third_party/proto/google/protobuf/any.proto -mv codec/types/third_party/proto/google/protobuf/any.pb.go codec/types +buf protoc -I "third_party/proto" --gogotypes_out=./codec/types third_party/proto/google/protobuf/any.proto +mv codec/types/google/protobuf/any.pb.go codec/types rm -rf codec/types/third_party # This removes the call to RegisterType in the custom generated Any wrapper diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index e1592aa780..32baafe977 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -2,9 +2,20 @@ set -eo pipefail +protoc_gen_gocosmos() { + if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then + echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder." + return 1 + fi + + go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null +} + +protoc_gen_gocosmos + proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) for dir in $proto_dirs; do - protoc \ + buf protoc \ -I "proto" \ -I "third_party/proto" \ --gocosmos_out=plugins=interfacetype+grpc,\ @@ -12,7 +23,7 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ $(find "${dir}" -maxdepth 1 -name '*.proto') # command to generate gRPC gateway (*.pb.gw.go in respective modules) files - protoc \ + buf protoc \ -I "proto" \ -I "third_party/proto" \ --grpc-gateway_out=logtostderr=true:. \ @@ -21,7 +32,7 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ done # generate codec/testdata proto code -protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\ +buf protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./testutil/testdata/*.proto # move proto files to the right places diff --git a/server/export.go b/server/export.go index 280d62da32..150add98e7 100644 --- a/server/export.go +++ b/server/export.go @@ -113,7 +113,7 @@ func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Com cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") cmd.Flags().Int64(FlagHeight, -1, "Export state from a particular height (-1 means latest height)") cmd.Flags().Bool(FlagForZeroHeight, false, "Export state to start at height zero (perform preproccessing)") - cmd.Flags().StringSlice(FlagJailAllowedAddrs, []string{}, "List of validators to not jail state export") + cmd.Flags().StringSlice(FlagJailAllowedAddrs, []string{}, "Comma-separated list of operator addresses of jailed validators to unjail") return cmd } diff --git a/server/start.go b/server/start.go index 2a2a1af886..b8565a87a3 100644 --- a/server/start.go +++ b/server/start.go @@ -252,12 +252,20 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App } ctx.Logger.Debug("Initialization: tmNode started") - // Add the tx service to the gRPC router. - app.RegisterTxService(clientCtx) + config := config.GetConfig(ctx.Viper) + + // Add the tx service to the gRPC router. We only need to register this + // service if API or gRPC is enabled, and avoid doing so in the general + // case, because it spawns a new local tendermint RPC client. + if config.API.Enable || config.GRPC.Enable { + clientCtx = clientCtx. + WithClient(local.New(tmNode)) + + app.RegisterTxService(clientCtx) + } var apiSrv *api.Server - config := config.GetConfig(ctx.Viper) if config.API.Enable { genDoc, err := genDocProvider() if err != nil { @@ -266,8 +274,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App clientCtx := clientCtx. WithHomeDir(home). - WithChainID(genDoc.ChainID). - WithClient(local.New(tmNode)) + WithChainID(genDoc.ChainID) apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server")) app.RegisterAPIRoutes(apiSrv, config.API) diff --git a/server/tm_cmds.go b/server/tm_cmds.go index abea9c116f..b05a88f797 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -39,7 +39,7 @@ func ShowNodeIDCmd() *cobra.Command { } } -// ShowValidator - ported from Tendermint, show this node's validator info +// ShowValidatorCmd - ported from Tendermint, show this node's validator info func ShowValidatorCmd() *cobra.Command { cmd := cobra.Command{ Use: "show-validator", @@ -59,12 +59,16 @@ func ShowValidatorCmd() *cobra.Command { return printlnJSON(valPubKey) } - pubkey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, valPubKey) + pubkey, err := cryptocodec.FromTmPubKeyInterface(valPubKey) + if err != nil { + return err + } + pubkeyBech32, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pubkey) if err != nil { return err } - fmt.Println(pubkey) + fmt.Println(pubkeyBech32) return nil }, } diff --git a/simapp/app.go b/simapp/app.go index a8c9e584be..8aaa007327 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -279,7 +279,7 @@ func NewSimApp( // Create IBC Keeper app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibchost.StoreKey], app.StakingKeeper, scopedIBCKeeper, + appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, scopedIBCKeeper, ) // register the proposal types @@ -609,6 +609,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(ibchost.ModuleName) return paramsKeeper } diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 9e8a4d9714..9ccecbd976 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -4,9 +4,8 @@ import ( "math/rand" "time" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/client" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -20,7 +19,7 @@ const ( ) // GenTx generates a signed mock transaction. -func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...crypto.PrivKey) (sdk.Tx, error) { +func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index d17e57fb95..3355c04b4e 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -12,7 +12,6 @@ import ( "github.com/spf13/cobra" tmconfig "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/crypto" tmos "github.com/tendermint/tendermint/libs/os" tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/types" @@ -23,6 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" sdk "github.com/cosmos/cosmos-sdk/types" @@ -116,7 +116,7 @@ func InitTestnet( } nodeIDs := make([]string, numValidators) - valPubKeys := make([]crypto.PubKey, numValidators) + valPubKeys := make([]cryptotypes.PubKey, numValidators) simappConfig := srvconfig.DefaultConfig() simappConfig.MinGasPrices = minGasPrices @@ -311,7 +311,7 @@ func initGenFiles( func collectGenFiles( clientCtx client.Context, nodeConfig *tmconfig.Config, chainID string, - nodeIDs []string, valPubKeys []crypto.PubKey, numValidators int, + nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, ) error { diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 6624c1df3f..22df884fbb 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" @@ -20,7 +19,9 @@ import ( bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp/helpers" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" @@ -92,10 +93,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs bondAmt := sdk.NewInt(1000000) for _, val := range valSet.Validators { - // Currently validator requires tmcrypto.ed25519 keys, which don't support - // our Marshaling interfaces, so we need to pack them into our version of ed25519. - // There is ongoing work to add secp256k1 keys (https://github.com/cosmos/cosmos-sdk/pull/7604). - pk, err := ed25519.FromTmEd25519(val.PubKey) + pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) require.NoError(t, err) pkAny, err := codectypes.PackAny(pk) require.NoError(t, err) @@ -230,7 +228,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress { } // AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys. -func AddTestAddrsFromPubKeys(app *SimApp, ctx sdk.Context, pubKeys []crypto.PubKey, accAmt sdk.Int) { +func AddTestAddrsFromPubKeys(app *SimApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int) { initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt)) setTotalSupply(app, ctx, accAmt, len(pubKeys)) @@ -328,7 +326,7 @@ func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.C // returned. func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, - chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...crypto.PrivKey, + chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { tx, err := helpers.GenTx( @@ -377,7 +375,7 @@ func SignCheckDeliver( // GenSequenceOfTxs generates a set of signed transactions of messages, such // that they differ only by having the sequence numbers incremented between // every transaction. -func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) ([]sdk.Tx, error) { +func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...cryptotypes.PrivKey) ([]sdk.Tx, error) { txs := make([]sdk.Tx, numToGenerate) var err error for i := 0; i < numToGenerate; i++ { @@ -407,8 +405,8 @@ func incrementAllSequenceNumbers(initSeqNums []uint64) { } // CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. -func CreateTestPubKeys(numPubKeys int) []crypto.PubKey { - var publicKeys []crypto.PubKey +func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { + var publicKeys []cryptotypes.PubKey var buffer bytes.Buffer // start at 10 to avoid changing 1 to 01, 2 to 02, etc @@ -424,7 +422,7 @@ func CreateTestPubKeys(numPubKeys int) []crypto.PubKey { } // NewPubKeyFromHex returns a PubKey from a hex string. -func NewPubKeyFromHex(pk string) (res crypto.PubKey) { +func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { pkBytes, err := hex.DecodeString(pk) if err != nil { panic(err) diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 90633a9220..72238cbb1e 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -315,7 +315,9 @@ func (rs *Store) TracingEnabled() bool { // LastCommitID implements Committer/CommitStore. func (rs *Store) LastCommitID() types.CommitID { if rs.lastCommitInfo == nil { - return types.CommitID{} + return types.CommitID{ + Version: getLatestVersion(rs.db), + } } return rs.lastCommitInfo.CommitID() diff --git a/tests/mocks/account_retriever.go b/tests/mocks/account_retriever.go index 23b02b7dce..37fa1aa64d 100644 --- a/tests/mocks/account_retriever.go +++ b/tests/mocks/account_retriever.go @@ -6,9 +6,9 @@ package mocks import ( client "github.com/cosmos/cosmos-sdk/client" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" types "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" - crypto "github.com/tendermint/tendermint/crypto" reflect "reflect" ) @@ -50,10 +50,10 @@ func (mr *MockAccountMockRecorder) GetAddress() *gomock.Call { } // GetPubKey mocks base method -func (m *MockAccount) GetPubKey() crypto.PubKey { +func (m *MockAccount) GetPubKey() cryptotypes.PubKey { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetPubKey") - ret0, _ := ret[0].(crypto.PubKey) + ret0, _ := ret[0].(cryptotypes.PubKey) return ret0 } diff --git a/testutil/network/network.go b/testutil/network/network.go index 1ee11f8c93..a50c6fa935 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -16,7 +16,6 @@ import ( "github.com/stretchr/testify/require" tmcfg "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/crypto" tmflags "github.com/tendermint/tendermint/libs/cli/flags" "github.com/tendermint/tendermint/libs/log" tmrand "github.com/tendermint/tendermint/libs/rand" @@ -32,6 +31,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" srvconfig "github.com/cosmos/cosmos-sdk/server/config" @@ -148,7 +148,7 @@ type ( Ctx *server.Context Dir string NodeID string - PubKey crypto.PubKey + PubKey cryptotypes.PubKey Moniker string APIAddress string RPCAddress string @@ -184,7 +184,7 @@ func New(t *testing.T, cfg Config) *Network { monikers := make([]string, cfg.NumValidators) nodeIDs := make([]string, cfg.NumValidators) - valPubKeys := make([]crypto.PubKey, cfg.NumValidators) + valPubKeys := make([]cryptotypes.PubKey, cfg.NumValidators) var ( genAccounts []authtypes.GenesisAccount diff --git a/testutil/testdata/query.proto b/testutil/testdata/query.proto index 0090b4fca8..3a60acaad1 100644 --- a/testutil/testdata/query.proto +++ b/testutil/testdata/query.proto @@ -9,31 +9,31 @@ option go_package = "github.com/cosmos/cosmos-sdk/testutil/testdata"; // Query tests the protobuf Query service as defined in // https://github.com/cosmos/cosmos-sdk/issues/5921. service Query { - rpc Echo(EchoRequest) returns (EchoResponse); - rpc SayHello(SayHelloRequest) returns (SayHelloResponse); - rpc TestAny(TestAnyRequest) returns (TestAnyResponse); + rpc Echo(EchoRequest) returns (EchoResponse); + rpc SayHello(SayHelloRequest) returns (SayHelloResponse); + rpc TestAny(TestAnyRequest) returns (TestAnyResponse); } message EchoRequest { - string message = 1; + string message = 1; } message EchoResponse { - string message = 1; + string message = 1; } message SayHelloRequest { - string name = 1; + string name = 1; } message SayHelloResponse { - string greeting = 1; + string greeting = 1; } message TestAnyRequest { - google.protobuf.Any any_animal = 1; + google.protobuf.Any any_animal = 1; } message TestAnyResponse { - testdata.HasAnimal has_animal = 1; + testdata.HasAnimal has_animal = 1; } diff --git a/testutil/testdata/tx.go b/testutil/testdata/tx.go index 09e1e365f1..1538460830 100644 --- a/testutil/testdata/tx.go +++ b/testutil/testdata/tx.go @@ -3,14 +3,13 @@ package testdata import ( "encoding/json" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // KeyTestPubAddr generates a new secp256k1 keypair. -func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { +func KeyTestPubAddr() (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) { key := secp256k1.GenPrivKey() pub := key.PubKey() addr := sdk.AccAddress(pub.Address()) diff --git a/testutil/testdata/tx.proto b/testutil/testdata/tx.proto index 8f670fc50e..eaeb9580e5 100644 --- a/testutil/testdata/tx.proto +++ b/testutil/testdata/tx.proto @@ -9,20 +9,20 @@ option go_package = "github.com/cosmos/cosmos-sdk/testutil/testdata"; // Msg tests the Protobuf message service as defined in // https://github.com/cosmos/cosmos-sdk/issues/7500. service Msg { - rpc CreateDog(MsgCreateDog) returns (MsgCreateDogResponse); + rpc CreateDog(MsgCreateDog) returns (MsgCreateDogResponse); } message MsgCreateDog { - testdata.Dog dog = 1; + testdata.Dog dog = 1; } message MsgCreateDogResponse { - string name = 1; + string name = 1; } // TestMsg is msg type for testing protobuf message using any, as defined in // https://github.com/cosmos/cosmos-sdk/issues/6213. message TestMsg { - option (gogoproto.goproto_getters) = false; - repeated string signers = 1; + option (gogoproto.goproto_getters) = false; + repeated string signers = 1; } diff --git a/testutil/testdata/unknonwnproto.proto b/testutil/testdata/unknonwnproto.proto index a11773f92e..7bf1ce6bba 100644 --- a/testutil/testdata/unknonwnproto.proto +++ b/testutil/testdata/unknonwnproto.proto @@ -42,8 +42,8 @@ message Nested4A { } message Nested3A { - int32 id = 1; - string name = 2; + int32 id = 1; + string name = 2; repeated Nested4A a4 = 4; map index = 5; } @@ -66,10 +66,10 @@ message Nested4B { } message Nested3B { - int32 id = 1; - int32 age = 2; - string name = 3; - repeated Nested4B b4 = 4; + int32 id = 1; + int32 age = 2; + string name = 3; + repeated Nested4B b4 = 4; } message Nested2B { @@ -101,32 +101,32 @@ message Customer3 { } message TestVersion1 { - int64 x = 1; - TestVersion1 a = 2; - TestVersion1 b = 3; // [(gogoproto.nullable) = false] generates invalid recursive structs; + int64 x = 1; + TestVersion1 a = 2; + TestVersion1 b = 3; // [(gogoproto.nullable) = false] generates invalid recursive structs; repeated TestVersion1 c = 4; repeated TestVersion1 d = 5 [(gogoproto.nullable) = false]; oneof sum { int32 e = 6; TestVersion1 f = 7; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; // [(gogoproto.castrepeated) = "TestVersion1"]; // google.protobuf.Timestamp i = 10; // google.protobuf.Timestamp j = 11; // [(gogoproto.stdtime) = true]; Customer1 k = 12 [(gogoproto.embed) = true]; } message TestVersion2 { - int64 x = 1; - TestVersion2 a = 2; - TestVersion2 b = 3; // [(gogoproto.nullable) = false]; + int64 x = 1; + TestVersion2 a = 2; + TestVersion2 b = 3; // [(gogoproto.nullable) = false]; repeated TestVersion2 c = 4; repeated TestVersion2 d = 5; // [(gogoproto.nullable) = false]; oneof sum { int32 e = 6; TestVersion2 f = 7; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; // [(gogoproto.castrepeated) = "TestVersion1"]; // google.protobuf.Timestamp i = 10; // google.protobuf.Timestamp j = 11; // [(gogoproto.stdtime) = true]; @@ -134,16 +134,16 @@ message TestVersion2 { uint64 new_field = 25; } message TestVersion3 { - int64 x = 1; - TestVersion3 a = 2; - TestVersion3 b = 3; // [(gogoproto.nullable) = false]; + int64 x = 1; + TestVersion3 a = 2; + TestVersion3 b = 3; // [(gogoproto.nullable) = false]; repeated TestVersion3 c = 4; repeated TestVersion3 d = 5; // [(gogoproto.nullable) = false]; oneof sum { int32 e = 6; TestVersion3 f = 7; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; //[(gogoproto.castrepeated) = "TestVersion1"]; // google.protobuf.Timestamp i = 10; // google.protobuf.Timestamp j = 11; // [(gogoproto.stdtime) = true]; @@ -152,15 +152,15 @@ message TestVersion3 { } message TestVersion3LoneOneOfValue { - int64 x = 1; - TestVersion3 a = 2; - TestVersion3 b = 3; // [(gogoproto.nullable) = false]; + int64 x = 1; + TestVersion3 a = 2; + TestVersion3 b = 3; // [(gogoproto.nullable) = false]; repeated TestVersion3 c = 4; repeated TestVersion3 d = 5; // [(gogoproto.nullable) = false]; oneof sum { int32 e = 6; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; //[(gogoproto.castrepeated) = "TestVersion1"]; // google.protobuf.Timestamp i = 10; // google.protobuf.Timestamp j = 11; // [(gogoproto.stdtime) = true]; @@ -169,15 +169,15 @@ message TestVersion3LoneOneOfValue { } message TestVersion3LoneNesting { - int64 x = 1; - TestVersion3 a = 2; - TestVersion3 b = 3; // [(gogoproto.nullable) = false]; + int64 x = 1; + TestVersion3 a = 2; + TestVersion3 b = 3; // [(gogoproto.nullable) = false]; repeated TestVersion3 c = 4; repeated TestVersion3 d = 5; // [(gogoproto.nullable) = false]; oneof sum { TestVersion3LoneNesting f = 7; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; //[(gogoproto.castrepeated) = "TestVersion1"]; // google.protobuf.Timestamp i = 10; // google.protobuf.Timestamp j = 11; // [(gogoproto.stdtime) = true]; @@ -210,15 +210,15 @@ message TestVersion3LoneNesting { } message TestVersion4LoneNesting { - int64 x = 1; - TestVersion3 a = 2; - TestVersion3 b = 3; // [(gogoproto.nullable) = false]; + int64 x = 1; + TestVersion3 a = 2; + TestVersion3 b = 3; // [(gogoproto.nullable) = false]; repeated TestVersion3 c = 4; repeated TestVersion3 d = 5; // [(gogoproto.nullable) = false]; oneof sum { TestVersion3LoneNesting f = 7; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; //[(gogoproto.castrepeated) = "TestVersion1"]; // google.protobuf.Timestamp i = 10; // google.protobuf.Timestamp j = 11; // [(gogoproto.stdtime) = true]; @@ -257,7 +257,7 @@ message TestVersionFD1 { int32 e = 6; TestVersion1 f = 7; } - google.protobuf.Any g = 8; + google.protobuf.Any g = 8; repeated TestVersion1 h = 9; // [(gogoproto.castrepeated) = "TestVersion1"]; } @@ -268,7 +268,7 @@ message TestVersionFD1WithExtraAny { int32 e = 6; TestVersion1 f = 7; } - AnyWithExtra g = 8; + AnyWithExtra g = 8; repeated TestVersion1 h = 9; // [(gogoproto.castrepeated) = "TestVersion1"]; } @@ -279,11 +279,11 @@ message AnyWithExtra { } message TestUpdatedTxRaw { - bytes body_bytes = 1; - bytes auth_info_bytes = 2; - repeated bytes signatures = 3; - bytes new_field_5 = 5; - bytes new_field_1024 = 1024; + bytes body_bytes = 1; + bytes auth_info_bytes = 2; + repeated bytes signatures = 3; + bytes new_field_5 = 5; + bytes new_field_1024 = 1024; } message TestUpdatedTxBody { diff --git a/types/address.go b/types/address.go index 345c44fa8e..a6d65e7a70 100644 --- a/types/address.go +++ b/types/address.go @@ -8,16 +8,12 @@ import ( "fmt" "strings" - "github.com/tendermint/tendermint/crypto" - tmed25519 "github.com/tendermint/tendermint/crypto/ed25519" yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec/legacy" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/bech32" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) const ( @@ -452,7 +448,7 @@ func ConsAddressFromBech32(address string) (addr ConsAddress, err error) { } // get ConsAddress from pubkey -func GetConsAddress(pubkey crypto.PubKey) ConsAddress { +func GetConsAddress(pubkey cryptotypes.PubKey) ConsAddress { return ConsAddress(pubkey.Address()) } @@ -616,7 +612,8 @@ const ( // Bech32ifyPubKey returns a Bech32 encoded string containing the appropriate // prefix based on the key type provided for a given PublicKey. -func Bech32ifyPubKey(pkt Bech32PubKeyType, pubkey crypto.PubKey) (string, error) { +// TODO: Remove Bech32ifyPubKey and all usages (cosmos/cosmos-sdk/issues/#7357) +func Bech32ifyPubKey(pkt Bech32PubKeyType, pubkey cryptotypes.PubKey) (string, error) { var bech32Prefix string switch pkt { @@ -631,22 +628,11 @@ func Bech32ifyPubKey(pkt Bech32PubKeyType, pubkey crypto.PubKey) (string, error) } - // This piece of code is to keep backwards-compatibility. - // For ed25519 keys, our own ed25519 is registered in Amino under a - // different name than TM's ed25519. But since users are already using - // TM's ed25519 bech32 encoding, we explicitly say to bech32-encode our own - // ed25519 the same way as TM's ed25519. - // TODO: Remove Bech32ifyPubKey and all usages (cosmos/cosmos-sdk/issues/#7357) - pkToMarshal := pubkey - if ed25519Pk, ok := pubkey.(*ed25519.PubKey); ok { - pkToMarshal = ed25519Pk.AsTmPubKey() - } - - return bech32.ConvertAndEncode(bech32Prefix, legacy.Cdc.MustMarshalBinaryBare(pkToMarshal)) + return bech32.ConvertAndEncode(bech32Prefix, legacy.Cdc.MustMarshalBinaryBare(pubkey)) } // MustBech32ifyPubKey calls Bech32ifyPubKey except it panics on error. -func MustBech32ifyPubKey(pkt Bech32PubKeyType, pubkey crypto.PubKey) string { +func MustBech32ifyPubKey(pkt Bech32PubKeyType, pubkey cryptotypes.PubKey) string { res, err := Bech32ifyPubKey(pkt, pubkey) if err != nil { panic(err) @@ -657,7 +643,7 @@ func MustBech32ifyPubKey(pkt Bech32PubKeyType, pubkey crypto.PubKey) string { // GetPubKeyFromBech32 returns a PublicKey from a bech32-encoded PublicKey with // a given key type. -func GetPubKeyFromBech32(pkt Bech32PubKeyType, pubkeyStr string) (crypto.PubKey, error) { +func GetPubKeyFromBech32(pkt Bech32PubKeyType, pubkeyStr string) (cryptotypes.PubKey, error) { var bech32Prefix string switch pkt { @@ -677,36 +663,11 @@ func GetPubKeyFromBech32(pkt Bech32PubKeyType, pubkeyStr string) (crypto.PubKey, return nil, err } - aminoPk, err := cryptocodec.PubKeyFromBytes(bz) - if err != nil { - return nil, err - } - - var protoPk crypto.PubKey - switch aminoPk.(type) { - - // We are bech32ifying some secp256k1 keys in tests. - case *secp256k1.PubKey: - protoPk = aminoPk - case *ed25519.PubKey: - protoPk = aminoPk - - // Real-life case. - case tmed25519.PubKey: - protoPk = &ed25519.PubKey{ - Key: aminoPk.Bytes(), - } - - default: - // We only allow ed25519 pubkeys to be bech32-ed right now. - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "bech32 pubkey does not support %T", aminoPk) - } - - return protoPk, nil + return cryptocodec.PubKeyFromBytes(bz) } // MustGetPubKeyFromBech32 calls GetPubKeyFromBech32 except it panics on error. -func MustGetPubKeyFromBech32(pkt Bech32PubKeyType, pubkeyStr string) crypto.PubKey { +func MustGetPubKeyFromBech32(pkt Bech32PubKeyType, pubkeyStr string) cryptotypes.PubKey { res, err := GetPubKeyFromBech32(pkt, pubkeyStr) if err != nil { panic(err) diff --git a/types/address_test.go b/types/address_test.go index 9de4bea4f3..5796c891ac 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -10,11 +10,11 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto" "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" ) @@ -509,7 +509,7 @@ func (s *addressTestSuite) TestGetConsAddress() { pk := secp256k1.GenPrivKey().PubKey() s.Require().NotEqual(types.GetConsAddress(pk), pk.Address()) s.Require().True(bytes.Equal(types.GetConsAddress(pk).Bytes(), pk.Address().Bytes())) - s.Require().Panics(func() { types.GetConsAddress(crypto.PubKey(nil)) }) + s.Require().Panics(func() { types.GetConsAddress(cryptotypes.PubKey(nil)) }) } func (s *addressTestSuite) TestGetFromBech32() { diff --git a/types/query/filtered_pagination.go b/types/query/filtered_pagination.go index fe8a905a68..0ab29a4acd 100644 --- a/types/query/filtered_pagination.go +++ b/types/query/filtered_pagination.go @@ -35,7 +35,7 @@ func FilteredPaginate( } if limit == 0 { - limit = defaultLimit + limit = DefaultLimit // count total results when the limit is zero/not supplied countTotal = true diff --git a/types/query/pagination.go b/types/query/pagination.go index b263a1ba4a..3963add364 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/store/types" ) -// defaultLimit is the default `limit` for queries -// if the `limit` is not supplied, paginate will use `defaultLimit` -const defaultLimit = 100 +// DefaultLimit is the default `limit` for queries +// if the `limit` is not supplied, paginate will use `DefaultLimit` +const DefaultLimit = 100 // Paginate does pagination of all the results in the PrefixStore based on the // provided PageRequest. onResult should be used to do actual unmarshaling. @@ -33,7 +33,7 @@ func Paginate( } if limit == 0 { - limit = defaultLimit + limit = DefaultLimit // count total results when the limit is zero/not supplied countTotal = true diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index b4bf386117..0a3e16b29d 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -12,13 +12,13 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" @@ -176,15 +176,15 @@ func TestParseQueryHeight(t *testing.T) { func TestProcessPostResponse(t *testing.T) { // mock account // PubKey field ensures amino encoding is used first since standard - // JSON encoding will panic on crypto.PubKey + // JSON encoding will panic on cryptotypes.PubKey t.Parallel() type mockAccount struct { - Address types.AccAddress `json:"address"` - Coins types.Coins `json:"coins"` - PubKey crypto.PubKey `json:"public_key"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` + Address types.AccAddress `json:"address"` + Coins types.Coins `json:"coins"` + PubKey cryptotypes.PubKey `json:"public_key"` + AccountNumber uint64 `json:"account_number"` + Sequence uint64 `json:"sequence"` } // setup diff --git a/types/simulation/account.go b/types/simulation/account.go index b0c6b7bd68..e031b5a9eb 100644 --- a/types/simulation/account.go +++ b/types/simulation/account.go @@ -3,10 +3,9 @@ package simulation import ( "math/rand" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -14,10 +13,10 @@ import ( // eventually more useful data can be placed in here. // (e.g. number of coins) type Account struct { - PrivKey crypto.PrivKey - PubKey crypto.PubKey + PrivKey cryptotypes.PrivKey + PubKey cryptotypes.PubKey Address sdk.AccAddress - ConsKey crypto.PrivKey + ConsKey cryptotypes.PrivKey } // Equals returns true if two accounts are equal diff --git a/types/tx/service.pb.go b/types/tx/service.pb.go index ae691fd627..2302593c5c 100644 --- a/types/tx/service.pb.go +++ b/types/tx/service.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/types" + query "github.com/cosmos/cosmos-sdk/types/query" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -29,6 +30,127 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// GetTxsEventRequest is the request type for the Service.TxsByEvents +// RPC method. +type GetTxsEventRequest struct { + // event is the transaction event type. + Event string `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"` + // pagination defines an pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *GetTxsEventRequest) Reset() { *m = GetTxsEventRequest{} } +func (m *GetTxsEventRequest) String() string { return proto.CompactTextString(m) } +func (*GetTxsEventRequest) ProtoMessage() {} +func (*GetTxsEventRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e0b00a618705eca7, []int{0} +} +func (m *GetTxsEventRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetTxsEventRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetTxsEventRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetTxsEventRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTxsEventRequest.Merge(m, src) +} +func (m *GetTxsEventRequest) XXX_Size() int { + return m.Size() +} +func (m *GetTxsEventRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetTxsEventRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTxsEventRequest proto.InternalMessageInfo + +func (m *GetTxsEventRequest) GetEvent() string { + if m != nil { + return m.Event + } + return "" +} + +func (m *GetTxsEventRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// GetTxsEventResponse is the response type for the Service.TxsByEvents +// RPC method. +type GetTxsEventResponse struct { + // txs is the list of queried transactions. + Txs []*Tx `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` + // tx_responses is the list of queried TxResponses. + TxResponses []*types.TxResponse `protobuf:"bytes,2,rep,name=tx_responses,json=txResponses,proto3" json:"tx_responses,omitempty"` + // pagination defines an pagination for the response. + Pagination *query.PageResponse `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *GetTxsEventResponse) Reset() { *m = GetTxsEventResponse{} } +func (m *GetTxsEventResponse) String() string { return proto.CompactTextString(m) } +func (*GetTxsEventResponse) ProtoMessage() {} +func (*GetTxsEventResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e0b00a618705eca7, []int{1} +} +func (m *GetTxsEventResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetTxsEventResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetTxsEventResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetTxsEventResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTxsEventResponse.Merge(m, src) +} +func (m *GetTxsEventResponse) XXX_Size() int { + return m.Size() +} +func (m *GetTxsEventResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetTxsEventResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTxsEventResponse proto.InternalMessageInfo + +func (m *GetTxsEventResponse) GetTxs() []*Tx { + if m != nil { + return m.Txs + } + return nil +} + +func (m *GetTxsEventResponse) GetTxResponses() []*types.TxResponse { + if m != nil { + return m.TxResponses + } + return nil +} + +func (m *GetTxsEventResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // SimulateRequest is the request type for the Service.Simulate // RPC method. type SimulateRequest struct { @@ -40,7 +162,7 @@ func (m *SimulateRequest) Reset() { *m = SimulateRequest{} } func (m *SimulateRequest) String() string { return proto.CompactTextString(m) } func (*SimulateRequest) ProtoMessage() {} func (*SimulateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e0b00a618705eca7, []int{0} + return fileDescriptor_e0b00a618705eca7, []int{2} } func (m *SimulateRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -89,7 +211,7 @@ func (m *SimulateResponse) Reset() { *m = SimulateResponse{} } func (m *SimulateResponse) String() string { return proto.CompactTextString(m) } func (*SimulateResponse) ProtoMessage() {} func (*SimulateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e0b00a618705eca7, []int{1} + return fileDescriptor_e0b00a618705eca7, []int{3} } func (m *SimulateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -132,7 +254,7 @@ func (m *SimulateResponse) GetResult() *types.Result { return nil } -// GetTx is the request type for the Service.GetTx +// GetTxRequest is the request type for the Service.GetTx // RPC method. type GetTxRequest struct { // hash is the tx hash to query, encoded as a hex string. @@ -143,7 +265,7 @@ func (m *GetTxRequest) Reset() { *m = GetTxRequest{} } func (m *GetTxRequest) String() string { return proto.CompactTextString(m) } func (*GetTxRequest) ProtoMessage() {} func (*GetTxRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e0b00a618705eca7, []int{2} + return fileDescriptor_e0b00a618705eca7, []int{4} } func (m *GetTxRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -183,13 +305,15 @@ func (m *GetTxRequest) GetHash() string { type GetTxResponse struct { // tx is the queried transaction. Tx *Tx `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` + // tx_response is the queried TxResponses. + TxResponse *types.TxResponse `protobuf:"bytes,2,opt,name=tx_response,json=txResponse,proto3" json:"tx_response,omitempty"` } func (m *GetTxResponse) Reset() { *m = GetTxResponse{} } func (m *GetTxResponse) String() string { return proto.CompactTextString(m) } func (*GetTxResponse) ProtoMessage() {} func (*GetTxResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e0b00a618705eca7, []int{3} + return fileDescriptor_e0b00a618705eca7, []int{5} } func (m *GetTxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -225,7 +349,16 @@ func (m *GetTxResponse) GetTx() *Tx { return nil } +func (m *GetTxResponse) GetTxResponse() *types.TxResponse { + if m != nil { + return m.TxResponse + } + return nil +} + func init() { + proto.RegisterType((*GetTxsEventRequest)(nil), "cosmos.tx.v1beta1.GetTxsEventRequest") + proto.RegisterType((*GetTxsEventResponse)(nil), "cosmos.tx.v1beta1.GetTxsEventResponse") proto.RegisterType((*SimulateRequest)(nil), "cosmos.tx.v1beta1.SimulateRequest") proto.RegisterType((*SimulateResponse)(nil), "cosmos.tx.v1beta1.SimulateResponse") proto.RegisterType((*GetTxRequest)(nil), "cosmos.tx.v1beta1.GetTxRequest") @@ -235,33 +368,43 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/service.proto", fileDescriptor_e0b00a618705eca7) } var fileDescriptor_e0b00a618705eca7 = []byte{ - // 404 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x31, 0x6b, 0xdb, 0x40, - 0x1c, 0xc5, 0x2d, 0xd1, 0xda, 0xee, 0xb5, 0xa5, 0xed, 0x41, 0xc1, 0xa8, 0xae, 0xec, 0x9e, 0x6b, - 0xe8, 0x52, 0x1d, 0x76, 0xa1, 0x78, 0x08, 0x04, 0xb2, 0x98, 0xac, 0xb2, 0xa7, 0x2c, 0xe1, 0xa4, - 0x9c, 0x65, 0x11, 0x5b, 0xa7, 0xf8, 0x4e, 0xe6, 0x42, 0xc8, 0x92, 0x31, 0x53, 0x20, 0x5f, 0x2a, - 0xa3, 0x21, 0x4b, 0xc6, 0x60, 0xe7, 0x2b, 0x64, 0x0f, 0x3a, 0x9d, 0x92, 0x10, 0xcb, 0x21, 0x93, - 0x4e, 0xe8, 0xbd, 0xdf, 0xff, 0xbd, 0xd3, 0x1f, 0x34, 0x7c, 0xc6, 0xa7, 0x8c, 0x63, 0x21, 0xf1, - 0xbc, 0xe3, 0x51, 0x41, 0x3a, 0x98, 0xd3, 0xd9, 0x3c, 0xf4, 0xa9, 0x13, 0xcf, 0x98, 0x60, 0xf0, - 0x5b, 0x26, 0x70, 0x84, 0x74, 0xb4, 0xc0, 0xaa, 0x07, 0x8c, 0x05, 0x13, 0x8a, 0x49, 0x1c, 0x62, - 0x12, 0x45, 0x4c, 0x10, 0x11, 0xb2, 0x88, 0x67, 0x06, 0xab, 0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 0x90, 0xcf, 0xbb, 0x5b, 0xcd, 0xcd, 0x02, 0x3d, 0xf0, 0xb7, 0x1a, 0x68, 0xc3, 0x3a, 0x2e, 0xda, - 0x0c, 0x7c, 0x92, 0x5e, 0xd7, 0xe9, 0xce, 0xf6, 0xd5, 0xd2, 0x36, 0x16, 0x4b, 0xdb, 0xb8, 0x5d, - 0xda, 0xc6, 0xc5, 0xca, 0x2e, 0x2d, 0x56, 0x76, 0xe9, 0x66, 0x65, 0x97, 0xf6, 0xda, 0x41, 0x28, - 0xc6, 0x89, 0xe7, 0xf8, 0x6c, 0x9a, 0x13, 0xb2, 0xc7, 0x5f, 0x7e, 0x70, 0x88, 0xc5, 0x71, 0x4c, - 0x53, 0xa4, 0x57, 0x56, 0x2b, 0xf6, 0xef, 0x21, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x4c, 0x40, 0xff, - 0xf7, 0x02, 0x00, 0x00, + // 563 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xae, 0x1d, 0xfa, 0xc3, 0xa4, 0x08, 0x58, 0x7e, 0x14, 0x99, 0xe2, 0x06, 0xa7, 0x69, 0x23, + 0x24, 0xbc, 0x6a, 0xb8, 0xf4, 0x80, 0x84, 0x84, 0x54, 0x22, 0x6e, 0xc8, 0xed, 0x89, 0x4b, 0xb5, + 0x09, 0x5b, 0xc7, 0x22, 0xf1, 0xba, 0xde, 0x4d, 0xb4, 0x15, 0xf4, 0xc2, 0x91, 0x13, 0x12, 0x2f, + 0xc5, 0x31, 0x12, 0x17, 0x8e, 0x28, 0xe1, 0x0d, 0x78, 0x01, 0xe4, 0xf5, 0x3a, 0x71, 0xa8, 0x4d, + 0x7b, 0xf2, 0xae, 0xfc, 0xfd, 0xcc, 0x37, 0xe3, 0x31, 0x6c, 0xf7, 0x18, 0x1f, 0x32, 0x8e,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95, 0x23, 0x6a, 0xb0, 0x57, 0x15, 0xf3, 0x73, 0x22, 0x94, + 0x4f, 0x54, 0x51, 0x89, 0xf6, 0xae, 0x4c, 0xa4, 0x95, 0xf2, 0x91, 0x0e, 0xe0, 0xf6, 0x51, 0x30, + 0x1c, 0x0d, 0x88, 0xc8, 0x12, 0xa3, 0x26, 0x98, 0x42, 0xaa, 0x06, 0x96, 0x86, 0x31, 0x85, 0x74, + 0xbe, 0x18, 0x70, 0x67, 0x41, 0xd5, 0x9d, 0x78, 0x01, 0x1b, 0x3e, 0xe1, 0x27, 0x41, 0x78, 0xca, + 0xb4, 0xc2, 0x93, 0xf2, 0x70, 0x1d, 0xc2, 0xdf, 0x84, 0xa7, 0xcc, 0x5b, 0xf7, 0xd3, 0x03, 0x3a, + 0x80, 0xb5, 0x98, 0xf2, 0xd1, 0x40, 0xe8, 0x19, 0xd5, 0xcb, 0xb9, 0x9e, 0xc2, 0x79, 0x1a, 0xef, + 0x38, 0xb0, 0xa9, 0x06, 0x93, 0x65, 0x40, 0x70, 0xa3, 0x4f, 0x78, 0x5f, 0x7f, 0x06, 0xea, 0xec, + 0x5c, 0xc0, 0x2d, 0x8d, 0xd1, 0xc5, 0x5e, 0x2f, 0x28, 0x3a, 0x84, 0x6a, 0x6e, 0x68, 0xba, 0xb4, + 0xeb, 0xcd, 0x0c, 0x16, 0x33, 0x6b, 0xff, 0x31, 0x61, 0xfd, 0x28, 0x5d, 0x30, 0x24, 0x61, 0x23, + 0x6b, 0x1d, 0x72, 0x0a, 0x9c, 0xff, 0x19, 0x89, 0xd5, 0xf8, 0x2f, 0x26, 0x35, 0x70, 0x1a, 0x9f, + 0x7f, 0xfc, 0xfe, 0x66, 0x3e, 0x76, 0x1e, 0xe1, 0x82, 0xcd, 0xce, 0xdc, 0x22, 0x58, 0x55, 0x4d, + 0x40, 0xdb, 0x05, 0x92, 0xf9, 0x16, 0x5a, 0xf5, 0x72, 0x80, 0x36, 0xdc, 0x51, 0x86, 0x36, 0xda, + 0xc2, 0x45, 0x3b, 0x8d, 0x3f, 0x26, 0x5d, 0xbf, 0x40, 0x9f, 0xa0, 0x9a, 0xdb, 0x19, 0xd4, 0x2c, + 0x93, 0x5d, 0x5a, 0x64, 0x6b, 0xf7, 0x2a, 0x98, 0xae, 0xc1, 0x56, 0x35, 0xd4, 0xd0, 0xc3, 0xc2, + 0x1a, 0xf8, 0xab, 0x97, 0xdf, 0xa7, 0xb6, 0x31, 0x99, 0xda, 0xc6, 0xaf, 0xa9, 0x6d, 0x7c, 0x9d, + 0xd9, 0x2b, 0x93, 0x99, 0xbd, 0xf2, 0x73, 0x66, 0xaf, 0xbc, 0x6b, 0xfa, 0x81, 0xe8, 0x8f, 0xba, + 0x6e, 0x8f, 0x0d, 0x33, 0x6e, 0xfa, 0x78, 0xc6, 0xdf, 0x7f, 0xc0, 0xe2, 0x3c, 0xa2, 0x89, 0x58, + 0x77, 0x4d, 0xfd, 0x6e, 0x9e, 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xae, 0x63, 0xf9, 0x38, 0x2f, + 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -280,6 +423,8 @@ type ServiceClient interface { Simulate(ctx context.Context, in *SimulateRequest, opts ...grpc.CallOption) (*SimulateResponse, error) // GetTx fetches a tx by hash. GetTx(ctx context.Context, in *GetTxRequest, opts ...grpc.CallOption) (*GetTxResponse, error) + // GetTxsEvent fetches txs by event. + GetTxsEvent(ctx context.Context, in *GetTxsEventRequest, opts ...grpc.CallOption) (*GetTxsEventResponse, error) } type serviceClient struct { @@ -308,12 +453,23 @@ func (c *serviceClient) GetTx(ctx context.Context, in *GetTxRequest, opts ...grp return out, nil } +func (c *serviceClient) GetTxsEvent(ctx context.Context, in *GetTxsEventRequest, opts ...grpc.CallOption) (*GetTxsEventResponse, error) { + out := new(GetTxsEventResponse) + err := c.cc.Invoke(ctx, "/cosmos.tx.v1beta1.Service/GetTxsEvent", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ServiceServer is the server API for Service service. type ServiceServer interface { // Simulate simulates executing a transaction for estimating gas usage. Simulate(context.Context, *SimulateRequest) (*SimulateResponse, error) // GetTx fetches a tx by hash. GetTx(context.Context, *GetTxRequest) (*GetTxResponse, error) + // GetTxsEvent fetches txs by event. + GetTxsEvent(context.Context, *GetTxsEventRequest) (*GetTxsEventResponse, error) } // UnimplementedServiceServer can be embedded to have forward compatible implementations. @@ -326,6 +482,9 @@ func (*UnimplementedServiceServer) Simulate(ctx context.Context, req *SimulateRe func (*UnimplementedServiceServer) GetTx(ctx context.Context, req *GetTxRequest) (*GetTxResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetTx not implemented") } +func (*UnimplementedServiceServer) GetTxsEvent(ctx context.Context, req *GetTxsEventRequest) (*GetTxsEventResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTxsEvent not implemented") +} func RegisterServiceServer(s grpc1.Server, srv ServiceServer) { s.RegisterService(&_Service_serviceDesc, srv) @@ -367,6 +526,24 @@ func _Service_GetTx_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Service_GetTxsEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTxsEventRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).GetTxsEvent(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.tx.v1beta1.Service/GetTxsEvent", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).GetTxsEvent(ctx, req.(*GetTxsEventRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Service_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.tx.v1beta1.Service", HandlerType: (*ServiceServer)(nil), @@ -379,11 +556,120 @@ var _Service_serviceDesc = grpc.ServiceDesc{ MethodName: "GetTx", Handler: _Service_GetTx_Handler, }, + { + MethodName: "GetTxsEvent", + Handler: _Service_GetTxsEvent_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/tx/v1beta1/service.proto", } +func (m *GetTxsEventRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetTxsEventRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetTxsEventRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Event) > 0 { + i -= len(m.Event) + copy(dAtA[i:], m.Event) + i = encodeVarintService(dAtA, i, uint64(len(m.Event))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetTxsEventResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetTxsEventResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetTxsEventResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.TxResponses) > 0 { + for iNdEx := len(m.TxResponses) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TxResponses[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Txs) > 0 { + for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Txs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *SimulateRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -516,6 +802,18 @@ func (m *GetTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TxResponse != nil { + { + size, err := m.TxResponse.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintService(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } if m.Tx != nil { { size, err := m.Tx.MarshalToSizedBuffer(dAtA[:i]) @@ -542,6 +840,48 @@ func encodeVarintService(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *GetTxsEventRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Event) + if l > 0 { + n += 1 + l + sovService(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovService(uint64(l)) + } + return n +} + +func (m *GetTxsEventResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Txs) > 0 { + for _, e := range m.Txs { + l = e.Size() + n += 1 + l + sovService(uint64(l)) + } + } + if len(m.TxResponses) > 0 { + for _, e := range m.TxResponses { + l = e.Size() + n += 1 + l + sovService(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovService(uint64(l)) + } + return n +} + func (m *SimulateRequest) Size() (n int) { if m == nil { return 0 @@ -595,6 +935,10 @@ func (m *GetTxResponse) Size() (n int) { l = m.Tx.Size() n += 1 + l + sovService(uint64(l)) } + if m.TxResponse != nil { + l = m.TxResponse.Size() + n += 1 + l + sovService(uint64(l)) + } return n } @@ -604,6 +948,284 @@ func sovService(x uint64) (n int) { func sozService(x uint64) (n int) { return sovService(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *GetTxsEventRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetTxsEventRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetTxsEventRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Event", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Event = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetTxsEventResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetTxsEventResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetTxsEventResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Txs = append(m.Txs, &Tx{}) + if err := m.Txs[len(m.Txs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxResponses", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxResponses = append(m.TxResponses, &types.TxResponse{}) + if err := m.TxResponses[len(m.TxResponses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *SimulateRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -968,6 +1590,42 @@ func (m *GetTxResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxResponse", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthService + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TxResponse == nil { + m.TxResponse = &types.TxResponse{} + } + if err := m.TxResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipService(dAtA[iNdEx:]) diff --git a/types/tx/service.pb.gw.go b/types/tx/service.pb.gw.go index 270036363a..a7d5b56c5e 100644 --- a/types/tx/service.pb.gw.go +++ b/types/tx/service.pb.gw.go @@ -121,6 +121,42 @@ func local_request_Service_GetTx_0(ctx context.Context, marshaler runtime.Marsha } +var ( + filter_Service_GetTxsEvent_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Service_GetTxsEvent_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTxsEventRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_GetTxsEvent_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetTxsEvent(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Service_GetTxsEvent_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetTxsEventRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_GetTxsEvent_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetTxsEvent(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterServiceHandlerServer registers the http handlers for service Service to "mux". // UnaryRPC :call ServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -167,6 +203,26 @@ func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, se }) + mux.Handle("GET", pattern_Service_GetTxsEvent_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Service_GetTxsEvent_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Service_GetTxsEvent_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -248,6 +304,26 @@ func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl }) + mux.Handle("GET", pattern_Service_GetTxsEvent_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Service_GetTxsEvent_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Service_GetTxsEvent_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -255,10 +331,14 @@ var ( pattern_Service_Simulate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "simulate"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Service_GetTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 1, 1, 0, 4, 1, 5, 3}, []string{"cosmos", "tx", "v1beta1", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Service_GetTxsEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "txs"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Service_Simulate_0 = runtime.ForwardResponseMessage forward_Service_GetTx_0 = runtime.ForwardResponseMessage + + forward_Service_GetTxsEvent_0 = runtime.ForwardResponseMessage ) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index 0966cc06f7..1323543f02 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,9 +3,8 @@ package signing import ( "fmt" - "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) // SignatureV2 is a convenience type that is easier to use in application logic @@ -15,7 +14,7 @@ import ( // signatures. type SignatureV2 struct { // PubKey is the public key to use for verifying the signature - PubKey crypto.PubKey + PubKey cryptotypes.PubKey // Data is the actual data of the signature which includes SignMode's and // the signatures themselves for either single or multi-signatures. @@ -104,5 +103,5 @@ func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacke // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (sd *SignatureDescriptor) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return unpacker.UnpackAny(sd.PublicKey, new(crypto.PubKey)) + return unpacker.UnpackAny(sd.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx/types.go b/types/tx/types.go index 436f2cd9bc..c572d448a8 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -4,9 +4,8 @@ import ( "fmt" "strings" - "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -180,7 +179,7 @@ func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (m *SignerInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return unpacker.UnpackAny(m.PublicKey, new(crypto.PubKey)) + return unpacker.UnpackAny(m.PublicKey, new(cryptotypes.PubKey)) } // RegisterInterfaces registers the sdk.Tx interface. diff --git a/types/tx_msg.go b/types/tx_msg.go index e75b7b6ae6..ddc07fa16b 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -1,9 +1,8 @@ package types import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/gogo/protobuf/proto" - - "github.com/tendermint/tendermint/crypto" ) type ( @@ -42,7 +41,7 @@ type ( // Signature defines an interface for an application application-defined // concrete transaction type to be able to set and return transaction signatures. Signature interface { - GetPubKey() crypto.PubKey + GetPubKey() cryptotypes.PubKey GetSignature() []byte } diff --git a/version/command.go b/version/command.go index 9291c0a824..bb632aea5b 100644 --- a/version/command.go +++ b/version/command.go @@ -17,6 +17,7 @@ func NewVersionCommand() *cobra.Command { Short: "Print the application binary version information", RunE: func(cmd *cobra.Command, _ []string) error { verInfo := NewInfo() + cmd.SetOut(cmd.OutOrStdout()) if long, _ := cmd.Flags().GetBool(flagLong); !long { cmd.Println(verInfo.Version) diff --git a/version/version.go b/version/version.go index 1e40d483db..25995932fc 100644 --- a/version/version.go +++ b/version/version.go @@ -17,8 +17,10 @@ package version import ( + "encoding/json" "fmt" "runtime" + "runtime/debug" ) var ( @@ -36,12 +38,13 @@ var ( // Info defines the application version information. type Info struct { - Name string `json:"name" yaml:"name"` - AppName string `json:"server_name" yaml:"server_name"` - Version string `json:"version" yaml:"version"` - GitCommit string `json:"commit" yaml:"commit"` - BuildTags string `json:"build_tags" yaml:"build_tags"` - GoVersion string `json:"go" yaml:"go"` + Name string `json:"name" yaml:"name"` + AppName string `json:"server_name" yaml:"server_name"` + Version string `json:"version" yaml:"version"` + GitCommit string `json:"commit" yaml:"commit"` + BuildTags string `json:"build_tags" yaml:"build_tags"` + GoVersion string `json:"go" yaml:"go"` + BuildDeps []buildDep `json:"build_deps" yaml:"build_deps"` } func NewInfo() Info { @@ -52,6 +55,7 @@ func NewInfo() Info { GitCommit: Commit, BuildTags: BuildTags, GoVersion: fmt.Sprintf("go version %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH), + BuildDeps: depsFromBuildInfo(), } } @@ -63,3 +67,24 @@ build tags: %s vi.Name, vi.Version, vi.GitCommit, vi.BuildTags, vi.GoVersion, ) } + +func depsFromBuildInfo() (deps []buildDep) { + buildInfo, ok := debug.ReadBuildInfo() + if !ok { + return nil + } + + for _, dep := range buildInfo.Deps { + deps = append(deps, buildDep{dep}) + } + + return +} + +type buildDep struct { + *debug.Module +} + +func (d buildDep) String() string { return fmt.Sprintf("%s@%s", d.Path, d.Version) } +func (d buildDep) MarshalJSON() ([]byte, error) { return json.Marshal(d.String()) } +func (d buildDep) MarshalYAML() (interface{}, error) { return d.String(), nil } diff --git a/version/version_test.go b/version/version_test.go index ef44f8d317..87608cfdbb 100644 --- a/version/version_test.go +++ b/version/version_test.go @@ -1,4 +1,4 @@ -package version +package version_test import ( "encoding/json" @@ -11,10 +11,11 @@ import ( "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/testutil" + "github.com/cosmos/cosmos-sdk/version" ) func TestNewInfo(t *testing.T) { - info := NewInfo() + info := version.NewInfo() want := fmt.Sprintf(`: git commit: build tags: @@ -23,7 +24,7 @@ build tags: } func TestInfo_String(t *testing.T) { - info := Info{ + info := version.Info{ Name: "testapp", AppName: "testappd", Version: "1.0.0", @@ -39,12 +40,12 @@ go version go1.14 linux/amd64` } func Test_runVersionCmd(t *testing.T) { - cmd := NewVersionCommand() + cmd := version.NewVersionCommand() _, mockOut := testutil.ApplyMockIO(cmd) cmd.SetArgs([]string{ fmt.Sprintf("--%s=''", cli.OutputFlag), - fmt.Sprintf("--%s=false", flagLong), + "--long=false", }) require.NoError(t, cmd.Execute()) @@ -52,11 +53,10 @@ func Test_runVersionCmd(t *testing.T) { mockOut.Reset() cmd.SetArgs([]string{ - fmt.Sprintf("--%s=json", cli.OutputFlag), - fmt.Sprintf("--%s=true", flagLong), + fmt.Sprintf("--%s=json", cli.OutputFlag), "--long=true", }) - info := NewInfo() + info := version.NewInfo() stringInfo, err := json.Marshal(info) require.NoError(t, err) require.NoError(t, cmd.Execute()) diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 0d9ef82f44..7659f3e104 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -8,11 +8,11 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -35,7 +35,7 @@ func (suite *AnteTestSuite) TestSimulateGasCost() { feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() accSeqs := []uint64{0, 0, 0} - privs := []crypto.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv} + privs := []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv} accNums := []uint64{0, 1, 2} testCases := []TestCase{ @@ -91,7 +91,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { // Variable data per test case var ( - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accNums []uint64 accSeqs []uint64 ) @@ -100,7 +100,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "check no signatures fails", func() { - privs, accNums, accSeqs = []crypto.PrivKey{}, []uint64{}, []uint64{} + privs, accNums, accSeqs = []cryptotypes.PrivKey{}, []uint64{}, []uint64{} // Create tx manually to test the tx's signers suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) @@ -117,7 +117,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "num sigs dont match GetSigners", func() { - privs, accNums, accSeqs = []crypto.PrivKey{priv0}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} }, false, false, @@ -126,7 +126,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "unrecognized account", func() { - privs, accNums, accSeqs = []crypto.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} }, false, false, @@ -169,7 +169,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { var ( accNums []uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -180,7 +180,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, @@ -189,7 +189,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { { "new tx from wrong account number", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} }, false, false, @@ -198,7 +198,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { { "new tx from correct account number", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} }, false, true, @@ -210,7 +210,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { msg1 := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) msg2 := testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg1, msg2} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} }, false, false, @@ -219,7 +219,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { { "new tx with correct account numbers", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{2, 0} }, false, true, @@ -251,7 +251,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { var ( accNums []uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -262,7 +262,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, @@ -271,7 +271,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { { "new tx from wrong account number", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} }, false, false, @@ -280,7 +280,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { { "new tx from correct account number", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} }, false, true, @@ -293,7 +293,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { msg2 := testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg1, msg2} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} }, false, false, @@ -303,7 +303,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { "new tx with another signer and correct account numbers", func() { // Note that accNums is [0,0] at block 0. - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 0}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 0}, []uint64{2, 0} }, false, true, @@ -334,7 +334,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { var ( accNums []uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -345,7 +345,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, @@ -354,7 +354,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { { "test sending it again fails (replay protection)", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, false, @@ -363,7 +363,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { { "fix sequence, should pass", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} }, false, true, @@ -376,7 +376,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { msg2 := testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg1, msg2} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{2, 0, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{2, 0, 0} }, false, true, @@ -394,7 +394,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { func() { msg := testdata.NewTestMsg(accounts[1].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} }, false, false, @@ -415,7 +415,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{3, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{3, 2} }, false, true, @@ -445,7 +445,7 @@ func (suite *AnteTestSuite) TestAnteHandlerFees() { msgs := []sdk.Msg{testdata.NewTestMsg(addr0)} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - privs, accNums, accSeqs := []crypto.PrivKey{priv0}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} testCases := []struct { desc string @@ -517,7 +517,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { // Same data for every test cases accounts := suite.CreateTestAccounts(1) msgs := []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} - privs, accNums, accSeqs := []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} // Variable data per test case var ( @@ -596,7 +596,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { var ( accNums []uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -605,7 +605,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "signers in order", func() { msgs = []sdk.Msg{msg1, msg2, msg3} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} suite.txBuilder.SetMemo("Check signers are in expected order and different account numbers works") }, false, @@ -616,7 +616,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "change sequence numbers (only accounts 0 and 1 sign)", func() { msgs = []sdk.Msg{msg1} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{1, 1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{1, 1} }, false, true, @@ -626,7 +626,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "change sequence numbers (only accounts 1 and 2 sign)", func() { msgs = []sdk.Msg{msg2} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[2].priv, accounts[0].priv}, []uint64{2, 0}, []uint64{1, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[2].priv, accounts[0].priv}, []uint64{2, 0}, []uint64{1, 2} }, false, true, @@ -636,7 +636,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "everyone signs again", func() { msgs = []sdk.Msg{msg1, msg2, msg3} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{3, 2, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{3, 2, 2} }, false, true, @@ -668,7 +668,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { feeAmount sdk.Coins gasLimit uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -680,7 +680,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() msgs = []sdk.Msg{msg0} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, @@ -752,7 +752,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { func() { feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() - privs, accNums, accSeqs = []crypto.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} }, false, false, @@ -762,7 +762,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { "test wrong signer if public doesn't exist", func() { msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{0} }, false, false, @@ -792,7 +792,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { var ( accNums []uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -800,7 +800,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { { "test good tx", func() { - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} msgs = []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} }, false, @@ -835,7 +835,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { acc1 := suite.app.AccountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) suite.Require().Nil(acc1.GetPubKey()) - privs, accNums, accSeqs = []crypto.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} suite.txBuilder.SetMsgs(msgs...) suite.txBuilder.SetFeeAmount(feeAmount) @@ -858,7 +858,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { suite.Require().Nil(acc1.GetPubKey()) // Set incorrect accSeq, to generate incorrect signature. - privs, accNums, accSeqs = []crypto.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{1} }, false, false, @@ -888,11 +888,11 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { } } -func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []crypto.PubKey, signatures [][]byte) { - pubkeys = make([]crypto.PubKey, n) +func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []cryptotypes.PubKey, signatures [][]byte) { + pubkeys = make([]cryptotypes.PubKey, n) signatures = make([][]byte, n) for i := 0; i < n; i++ { - var privkey crypto.PrivKey + var privkey cryptotypes.PrivKey privkey = secp256k1.GenPrivKey() // TODO: also generate ed25519 keys as below when ed25519 keys are @@ -910,7 +910,7 @@ func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []crypto.P return } -func expectedGasCostByKeys(pubkeys []crypto.PubKey) uint64 { +func expectedGasCostByKeys(pubkeys []cryptotypes.PubKey) uint64 { cost := uint64(0) for _, pubkey := range pubkeys { pubkeyType := strings.ToLower(fmt.Sprintf("%T", pubkey)) @@ -927,8 +927,8 @@ func expectedGasCostByKeys(pubkeys []crypto.PubKey) uint64 { } func TestCountSubkeys(t *testing.T) { - genPubKeys := func(n int) []crypto.PubKey { - var ret []crypto.PubKey + genPubKeys := func(n int) []cryptotypes.PubKey { + var ret []cryptotypes.PubKey for i := 0; i < n; i++ { ret = append(ret, secp256k1.GenPrivKey().PubKey()) } @@ -938,10 +938,10 @@ func TestCountSubkeys(t *testing.T) { singleLevelMultiKey := kmultisig.NewLegacyAminoPubKey(4, genPubKeys(5)) multiLevelSubKey1 := kmultisig.NewLegacyAminoPubKey(4, genPubKeys(5)) multiLevelSubKey2 := kmultisig.NewLegacyAminoPubKey(4, genPubKeys(5)) - multiLevelMultiKey := kmultisig.NewLegacyAminoPubKey(2, []crypto.PubKey{ + multiLevelMultiKey := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{ multiLevelSubKey1, multiLevelSubKey2, secp256k1.GenPrivKey().PubKey()}) type args struct { - pub crypto.PubKey + pub cryptotypes.PubKey } testCases := []struct { name string @@ -965,7 +965,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigLimitExceeded() { // Same data for every test cases accounts := suite.CreateTestAccounts(8) var addrs []sdk.AccAddress - var privs []crypto.PrivKey + var privs []cryptotypes.PrivKey for i := 0; i < 8; i++ { addrs = append(addrs, accounts[i].acc.GetAddress()) privs = append(privs, accounts[i].priv) @@ -1019,7 +1019,7 @@ func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { var ( accNums []uint64 msgs []sdk.Msg - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -1028,7 +1028,7 @@ func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { "verify that an secp256k1 account gets rejected", func() { msgs = []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} - privs, accNums, accSeqs = []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, false, @@ -1067,7 +1067,7 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() { suite.txBuilder.SetMemo("thisisatestmemo") // test that operations skipped on recheck do not run - privs, accNums, accSeqs := []crypto.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index f722e51a04..7ed834ebaa 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -1,10 +1,9 @@ package ante import ( - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -110,7 +109,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim continue } - var pubkey crypto.PubKey + var pubkey cryptotypes.PubKey acc := cgts.ak.GetAccount(ctx, signer) diff --git a/x/auth/ante/basic_test.go b/x/auth/ante/basic_test.go index 8b304d180e..0856734885 100644 --- a/x/auth/ante/basic_test.go +++ b/x/auth/ante/basic_test.go @@ -3,13 +3,11 @@ package ante_test import ( "strings" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" ) @@ -28,7 +26,7 @@ func (suite *AnteTestSuite) TestValidateBasic() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{}, []uint64{}, []uint64{} + privs, accNums, accSeqs := []cryptotypes.PrivKey{}, []uint64{}, []uint64{} invalidTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -38,7 +36,7 @@ func (suite *AnteTestSuite) TestValidateBasic() { suite.Require().NotNil(err, "Did not error on invalid tx") - privs, accNums, accSeqs = []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} validTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -69,7 +67,7 @@ func (suite *AnteTestSuite) TestValidateMemo() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} suite.txBuilder.SetMemo(strings.Repeat("01234567890", 500)) invalidTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -120,7 +118,7 @@ func (suite *AnteTestSuite) TestConsumeGasForTxSize() { suite.txBuilder.SetGasLimit(gasLimit) suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -214,7 +212,7 @@ func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() { suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) suite.txBuilder.SetTimeoutHeight(tc.timeout) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) diff --git a/x/auth/ante/fee_test.go b/x/auth/ante/fee_test.go index 4264baf399..84e5adb60d 100644 --- a/x/auth/ante/fee_test.go +++ b/x/auth/ante/fee_test.go @@ -1,10 +1,9 @@ package ante_test import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" - "github.com/tendermint/tendermint/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/ante" ) @@ -27,7 +26,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -76,7 +75,7 @@ func (suite *AnteTestSuite) TestDeductFees() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) diff --git a/x/auth/ante/setup_test.go b/x/auth/ante/setup_test.go index 8454ec26a1..4942665cac 100644 --- a/x/auth/ante/setup_test.go +++ b/x/auth/ante/setup_test.go @@ -1,10 +1,8 @@ package ante_test import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" - - "github.com/tendermint/tendermint/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" @@ -25,7 +23,7 @@ func (suite *AnteTestSuite) TestSetup() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -60,7 +58,7 @@ func (suite *AnteTestSuite) TestRecoverPanic() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 80ea9317e1..79fbbcdc67 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -5,11 +5,10 @@ import ( "encoding/hex" "fmt" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -424,7 +423,7 @@ func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (types } // CountSubKeys counts the total number of keys for a multi-sig public key. -func CountSubKeys(pub crypto.PubKey) int { +func CountSubKeys(pub cryptotypes.PubKey) int { v, ok := pub.(*kmultisig.LegacyAminoPubKey) if !ok { return 1 diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 2eb235b2f1..337618fab5 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -3,13 +3,12 @@ package ante_test import ( "fmt" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -30,7 +29,7 @@ func (suite *AnteTestSuite) TestSetPubKey() { priv3, pub3, addr3 := testdata.KeyTestPubAddr() addrs := []sdk.AccAddress{addr1, addr2, addr3} - pubs := []crypto.PubKey{pub1, pub2, pub3} + pubs := []cryptotypes.PubKey{pub1, pub2, pub3} msgs := make([]sdk.Msg, len(addrs)) // set accounts and create msg for each address @@ -47,7 +46,7 @@ func (suite *AnteTestSuite) TestSetPubKey() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) @@ -85,7 +84,7 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { type args struct { meter sdk.GasMeter sig signing.SignatureData - pubkey crypto.PubKey + pubkey cryptotypes.PubKey params types.Params } tests := []struct { @@ -148,20 +147,20 @@ func (suite *AnteTestSuite) TestSigVerification() { type testCase struct { name string - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accNums []uint64 accSeqs []uint64 recheck bool shouldErr bool } testCases := []testCase{ - {"no signers", []crypto.PrivKey{}, []uint64{}, []uint64{}, false, true}, - {"not enough signers", []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, - {"wrong order signers", []crypto.PrivKey{priv3, priv2, priv1}, []uint64{2, 1, 0}, []uint64{0, 0, 0}, false, true}, - {"wrong accnums", []crypto.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, - {"wrong sequences", []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{3, 4, 5}, false, true}, - {"valid tx", []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, - {"no err on recheck", []crypto.PrivKey{}, []uint64{}, []uint64{}, true, false}, + {"no signers", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, false, true}, + {"not enough signers", []cryptotypes.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, + {"wrong order signers", []cryptotypes.PrivKey{priv3, priv2, priv1}, []uint64{2, 1, 0}, []uint64{0, 0, 0}, false, true}, + {"wrong accnums", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, + {"wrong sequences", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{3, 4, 5}, false, true}, + {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, + {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck) @@ -233,20 +232,20 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { type testCase struct { name string - privs []crypto.PrivKey + privs []cryptotypes.PrivKey accNums []uint64 accSeqs []uint64 recheck bool shouldErr bool } testCases := []testCase{ - {"no signers", []crypto.PrivKey{}, []uint64{}, []uint64{}, false, true}, - {"not enough signers", []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, - {"wrong order signers", []crypto.PrivKey{priv3, priv2, priv1}, []uint64{2, 1, 0}, []uint64{0, 0, 0}, false, true}, - {"wrong accnums", []crypto.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, - {"wrong sequences", []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{3, 4, 5}, false, true}, - {"valid tx", []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, - {"no err on recheck", []crypto.PrivKey{}, []uint64{}, []uint64{}, true, false}, + {"no signers", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, false, true}, + {"not enough signers", []cryptotypes.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, + {"wrong order signers", []cryptotypes.PrivKey{priv3, priv2, priv1}, []uint64{2, 1, 0}, []uint64{0, 0, 0}, false, true}, + {"wrong accnums", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, + {"wrong sequences", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{3, 4, 5}, false, true}, + {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, + {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck) @@ -270,7 +269,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { func (suite *AnteTestSuite) TestSigIntegration() { // generate private keys - privs := []crypto.PrivKey{ + privs := []cryptotypes.PrivKey{ secp256k1.GenPrivKey(), secp256k1.GenPrivKey(), secp256k1.GenPrivKey(), @@ -288,7 +287,7 @@ func (suite *AnteTestSuite) TestSigIntegration() { suite.Require().Equal(initialSigCost*uint64(len(privs)), doubleCost-initialCost) } -func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs ...crypto.PrivKey) (sdk.Gas, error) { +func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs ...cryptotypes.PrivKey) (sdk.Gas, error) { suite.SetupTest(true) // setup suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() @@ -343,7 +342,7 @@ func (suite *AnteTestSuite) TestIncrementSequenceDecorator() { msgs := []sdk.Msg{testdata.NewTestMsg(addr)} suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) - privs := []crypto.PrivKey{priv} + privs := []cryptotypes.PrivKey{priv} accNums := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetAccountNumber()} accSeqs := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetSequence()} feeAmount := testdata.NewTestFeeAmount() diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 9d8924eea7..5a1cfc4ec4 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -6,11 +6,11 @@ import ( "testing" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +24,7 @@ import ( // TestAccount represents an account used in the tests in x/auth/ante. type TestAccount struct { acc types.AccountI - priv crypto.PrivKey + priv cryptotypes.PrivKey } // AnteTestSuite is a test suite to be used with ante handler tests. @@ -86,7 +86,7 @@ func (suite *AnteTestSuite) CreateTestAccounts(numAccs int) []TestAccount { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (suite *AnteTestSuite) CreateTestTx(privs []crypto.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. var sigsV2 []signing.SignatureV2 @@ -142,7 +142,7 @@ type TestCase struct { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (suite *AnteTestSuite) RunTestCase(privs []crypto.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) { +func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) { suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) suite.txBuilder.SetFeeAmount(feeAmount) diff --git a/x/auth/client/cli/cli_test.go b/x/auth/client/cli/cli_test.go index 4961e91c37..4ba383139c 100644 --- a/x/auth/client/cli/cli_test.go +++ b/x/auth/client/cli/cli_test.go @@ -1,5 +1,3 @@ -// +build norace - package cli_test import ( @@ -12,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - tmcrypto "github.com/tendermint/tendermint/crypto" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/client" @@ -22,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" @@ -63,7 +61,7 @@ func (s *IntegrationTestSuite) SetupSuite() { account2, _, err := kb.NewMnemonic("newAccount2", keyring.English, sdk.FullFundraiserPath, hd.Secp256k1) s.Require().NoError(err) - multi := kmultisig.NewLegacyAminoPubKey(2, []tmcrypto.PubKey{account1.GetPubKey(), account2.GetPubKey()}) + multi := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{account1.GetPubKey(), account2.GetPubKey()}) _, err = kb.SaveMultisig("multi", multi) s.Require().NoError(err) diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 86189b62a2..75724f7d3c 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -4,10 +4,10 @@ import ( "fmt" gogotypes "github.com/gogo/protobuf/types" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -35,7 +35,7 @@ type AccountKeeperI interface { IterateAccounts(sdk.Context, func(types.AccountI) bool) // Fetch the public key of an account at a specified address - GetPubKey(sdk.Context, sdk.AccAddress) (crypto.PubKey, error) + GetPubKey(sdk.Context, sdk.AccAddress) (cryptotypes.PubKey, error) // Fetch the sequence of an account at a specified address. GetSequence(sdk.Context, sdk.AccAddress) (uint64, error) @@ -90,7 +90,7 @@ func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger { } // GetPubKey Returns the PubKey of the account at address -func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, error) { +func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) { acc := ak.GetAccount(ctx, addr) if acc == nil { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", addr) diff --git a/x/auth/legacy/legacytx/stdsign.go b/x/auth/legacy/legacytx/stdsign.go index 49792d3a21..2ba194dad8 100644 --- a/x/auth/legacy/legacytx/stdsign.go +++ b/x/auth/legacy/legacytx/stdsign.go @@ -3,11 +3,10 @@ package legacytx import ( "encoding/json" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -57,8 +56,8 @@ func StdSignBytes(chainID string, accnum, sequence, timeout uint64, fee StdFee, // Deprecated: StdSignature represents a sig type StdSignature struct { - crypto.PubKey `json:"pub_key" yaml:"pub_key"` // optional - Signature []byte `json:"signature" yaml:"signature"` + cryptotypes.PubKey `json:"pub_key" yaml:"pub_key"` // optional + Signature []byte `json:"signature" yaml:"signature"` } // StdSignatureToSignatureV2 converts a StdSignature to a SignatureV2 @@ -75,7 +74,7 @@ func StdSignatureToSignatureV2(cdc *codec.LegacyAmino, sig StdSignature) (signin }, nil } -func pubKeySigToSigData(cdc *codec.LegacyAmino, key crypto.PubKey, sig []byte) (signing.SignatureData, error) { +func pubKeySigToSigData(cdc *codec.LegacyAmino, key cryptotypes.PubKey, sig []byte) (signing.SignatureData, error) { multiPK, ok := key.(multisig.PubKey) if !ok { return &signing.SingleSignatureData{ diff --git a/x/auth/legacy/legacytx/stdtx.go b/x/auth/legacy/legacytx/stdtx.go index 270a8d727a..ba3215010e 100644 --- a/x/auth/legacy/legacytx/stdtx.go +++ b/x/auth/legacy/legacytx/stdtx.go @@ -3,11 +3,11 @@ package legacytx import ( "fmt" - "github.com/tendermint/tendermint/crypto" "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" txtypes "github.com/cosmos/cosmos-sdk/types/tx" @@ -73,7 +73,7 @@ func (fee StdFee) GasPrices() sdk.DecCoins { } // Deprecated -func NewStdSignature(pk crypto.PubKey, sig []byte) StdSignature { +func NewStdSignature(pk cryptotypes.PubKey, sig []byte) StdSignature { return StdSignature{PubKey: pk, Signature: sig} } @@ -82,9 +82,9 @@ func (ss StdSignature) GetSignature() []byte { return ss.Signature } -// GetPubKey returns the public key of a signature as a crypto.PubKey using the +// GetPubKey returns the public key of a signature as a cryptotypes.PubKey using the // Amino codec. -func (ss StdSignature) GetPubKey() crypto.PubKey { +func (ss StdSignature) GetPubKey() cryptotypes.PubKey { return ss.PubKey } @@ -238,8 +238,8 @@ func (tx StdTx) GetSignaturesV2() ([]signing.SignatureV2, error) { // GetPubkeys returns the pubkeys of signers if the pubkey is included in the signature // If pubkey is not included in the signature, then nil is in the slice instead -func (tx StdTx) GetPubKeys() []crypto.PubKey { - pks := make([]crypto.PubKey, len(tx.Signatures)) +func (tx StdTx) GetPubKeys() []cryptotypes.PubKey { + pks := make([]cryptotypes.PubKey, len(tx.Signatures)) for i, stdSig := range tx.Signatures { pks[i] = stdSig.GetPubKey() diff --git a/x/auth/legacy/legacytx/stdtx_test.go b/x/auth/legacy/legacytx/stdtx_test.go index 96460f5382..a702a82841 100644 --- a/x/auth/legacy/legacytx/stdtx_test.go +++ b/x/auth/legacy/legacytx/stdtx_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" yaml "gopkg.in/yaml.v2" @@ -15,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -39,7 +39,7 @@ func NewTestStdFee() StdFee { } // Deprecated, use TxBuilder. -func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { +func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], timeout, fee, msgs, "") @@ -126,7 +126,7 @@ func TestTxValidateBasic(t *testing.T) { require.Equal(t, sdkerrors.ErrInsufficientFee.ABCICode(), code) // require to fail validation when no signatures exist - privs, accNums, seqs := []crypto.PrivKey{}, []uint64{}, []uint64{} + privs, accNums, seqs := []cryptotypes.PrivKey{}, []uint64{}, []uint64{} tx = NewTestTx(ctx, msgs, privs, accNums, seqs, 0, fee) err = tx.ValidateBasic() @@ -135,7 +135,7 @@ func TestTxValidateBasic(t *testing.T) { require.Equal(t, sdkerrors.ErrNoSignatures.ABCICode(), code) // require to fail validation when signatures do not match expected signers - privs, accNums, seqs = []crypto.PrivKey{priv1}, []uint64{0, 1}, []uint64{0, 0} + privs, accNums, seqs = []cryptotypes.PrivKey{priv1}, []uint64{0, 1}, []uint64{0, 0} tx = NewTestTx(ctx, msgs, privs, accNums, seqs, 0, fee) err = tx.ValidateBasic() @@ -154,7 +154,7 @@ func TestTxValidateBasic(t *testing.T) { require.Equal(t, sdkerrors.ErrInvalidRequest.ABCICode(), code) // require to pass when above criteria are matched - privs, accNums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0} + privs, accNums, seqs = []cryptotypes.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0} tx = NewTestTx(ctx, msgs, privs, accNums, seqs, 0, fee) err = tx.ValidateBasic() @@ -231,7 +231,7 @@ func TestSignatureV2Conversions(t *testing.T) { // multisigs _, pubKey2, _ := testdata.KeyTestPubAddr() - multiPK := kmultisig.NewLegacyAminoPubKey(1, []crypto.PubKey{ + multiPK := kmultisig.NewLegacyAminoPubKey(1, []cryptotypes.PubKey{ pubKey, pubKey2, }) dummy2 := []byte("dummySig2") diff --git a/x/auth/legacy/v038/types.go b/x/auth/legacy/v038/types.go index aeb554eeea..e9977c1d29 100644 --- a/x/auth/legacy/v038/types.go +++ b/x/auth/legacy/v038/types.go @@ -11,9 +11,11 @@ import ( "sort" "strings" - "github.com/tendermint/tendermint/crypto" + tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/codec" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" v034auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v034" ) @@ -45,11 +47,11 @@ type ( } BaseAccount struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey crypto.PubKey `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` + PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` } baseAccountPretty struct { @@ -127,7 +129,7 @@ func NewBaseAccountWithAddress(addr sdk.AccAddress) BaseAccount { } func NewBaseAccount( - address sdk.AccAddress, coins sdk.Coins, pk crypto.PubKey, accountNumber, sequence uint64, + address sdk.AccAddress, coins sdk.Coins, pk cryptotypes.PubKey, accountNumber, sequence uint64, ) *BaseAccount { return &BaseAccount{ @@ -259,7 +261,7 @@ func (bva *BaseVestingAccount) UnmarshalJSON(bz []byte) error { } var ( - pk crypto.PubKey + pk cryptotypes.PubKey err error ) @@ -328,7 +330,7 @@ func (cva *ContinuousVestingAccount) UnmarshalJSON(bz []byte) error { } var ( - pk crypto.PubKey + pk cryptotypes.PubKey err error ) @@ -394,7 +396,7 @@ func (dva *DelayedVestingAccount) UnmarshalJSON(bz []byte) error { } var ( - pk crypto.PubKey + pk cryptotypes.PubKey err error ) @@ -417,7 +419,7 @@ func (dva *DelayedVestingAccount) UnmarshalJSON(bz []byte) error { } func NewModuleAddress(name string) sdk.AccAddress { - return sdk.AccAddress(crypto.AddressHash([]byte(name))) + return sdk.AccAddress(tmcrypto.AddressHash([]byte(name))) } func NewModuleAccount(baseAccount *BaseAccount, name string, permissions ...string) *ModuleAccount { @@ -437,7 +439,7 @@ func (ma ModuleAccount) Validate() error { return errors.New("module account name cannot be blank") } - if !ma.Address.Equals(sdk.AccAddress(crypto.AddressHash([]byte(ma.Name)))) { + if !ma.Address.Equals(sdk.AccAddress(tmcrypto.AddressHash([]byte(ma.Name)))) { return fmt.Errorf("address %s cannot be derived from the module name '%s'", ma.Address, ma.Name) } @@ -517,6 +519,7 @@ func ValidateGenAccounts(genAccounts GenesisAccounts) error { } func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cryptocodec.RegisterCrypto(cdc) cdc.RegisterInterface((*GenesisAccount)(nil), nil) cdc.RegisterInterface((*Account)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) diff --git a/x/auth/legacy/v039/migrate_test.go b/x/auth/legacy/v039/migrate_test.go new file mode 100644 index 0000000000..6972789c00 --- /dev/null +++ b/x/auth/legacy/v039/migrate_test.go @@ -0,0 +1,104 @@ +package v039_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" + v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v038" + v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039" +) + +func TestMigrate(t *testing.T) { + aminoCdc := codec.NewLegacyAmino() + v039auth.RegisterLegacyAminoCodec(aminoCdc) + + pub1 := ed25519.GenPrivKeyFromSecret([]byte("acc1")).PubKey() + pub2 := secp256k1.GenPrivKeyFromSecret([]byte("acc2")).PubKey() + + acc1 := v038auth.BaseAccount{ + Address: sdk.AccAddress(pub1.Address()), + Coins: sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)), + Sequence: 1, + AccountNumber: 1, + PubKey: pub1, + } + acc2 := v038auth.BaseAccount{ + Address: sdk.AccAddress(pub2.Address()), + Coins: sdk.NewCoins(sdk.NewInt64Coin("stake", 400000)), + Sequence: 2, + AccountNumber: 2, + PubKey: pub2, + } + + migrated := v039auth.Migrate( + v038auth.GenesisState{ + Accounts: v038auth.GenesisAccounts{&acc1, &acc2}, + }, + ) + + expectedAcc1 := v039auth.NewBaseAccount(acc1.Address, acc1.Coins, acc1.PubKey, acc1.AccountNumber, acc1.Sequence) + expectedAcc2 := v039auth.NewBaseAccount(acc2.Address, acc2.Coins, acc2.PubKey, acc2.AccountNumber, acc2.Sequence) + + require.Equal( + t, migrated, v039auth.GenesisState{ + Accounts: v038auth.GenesisAccounts{expectedAcc1, expectedAcc2}, + }, + ) + + json, err := aminoCdc.MarshalJSONIndent(migrated, "", " ") + require.NoError(t, err) + + expectedJSON := `{ + "params": { + "max_memo_characters": "0", + "tx_sig_limit": "0", + "tx_size_cost_per_byte": "0", + "sig_verify_cost_ed25519": "0", + "sig_verify_cost_secp256k1": "0" + }, + "accounts": [ + { + "type": "cosmos-sdk/Account", + "value": { + "address": "cosmos1j7skdhh9raxdmfhmcy2gxz8hgn0jnhfmujjsfe", + "coins": [ + { + "denom": "stake", + "amount": "400000" + } + ], + "public_key": { + "type": "tendermint/PubKeyEd25519", + "value": "eB0AcLMLKFRNFfh4XAAMstexfAIUQQCDnfjLZ2KJg+A=" + }, + "account_number": "1", + "sequence": "1" + } + }, + { + "type": "cosmos-sdk/Account", + "value": { + "address": "cosmos1v57fx2l2rt6ehujuu99u2fw05779m5e2ux4z2h", + "coins": [ + { + "denom": "stake", + "amount": "400000" + } + ], + "public_key": { + "type": "tendermint/PubKeySecp256k1", + "value": "AruDygh5HprMOpHOEato85dLgAsybMJVyxBGUa3KuWCr" + }, + "account_number": "2", + "sequence": "2" + } + } + ] +}` + require.Equal(t, expectedJSON, string(json)) +} diff --git a/x/auth/legacy/v039/types.go b/x/auth/legacy/v039/types.go index a75bc74a69..55c3014eb7 100644 --- a/x/auth/legacy/v039/types.go +++ b/x/auth/legacy/v039/types.go @@ -9,10 +9,12 @@ import ( "fmt" "strings" - "github.com/tendermint/tendermint/crypto" + tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" v034auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v034" v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v038" @@ -29,11 +31,11 @@ type ( } BaseAccount struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey crypto.PubKey `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` + PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` } BaseVestingAccount struct { @@ -47,15 +49,15 @@ type ( } vestingAccountJSON struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins"` - PubKey crypto.PubKey `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` - DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` - DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` - EndTime int64 `json:"end_time" yaml:"end_time"` + Address sdk.AccAddress `json:"address" yaml:"address"` + Coins sdk.Coins `json:"coins,omitempty" yaml:"coins"` + PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"` + AccountNumber uint64 `json:"account_number" yaml:"account_number"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` + DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` + DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` + EndTime int64 `json:"end_time" yaml:"end_time"` // custom fields based on concrete vesting type which can be omitted StartTime int64 `json:"start_time,omitempty" yaml:"start_time,omitempty"` @@ -117,7 +119,7 @@ func NewBaseAccountWithAddress(addr sdk.AccAddress) BaseAccount { } func NewBaseAccount( - address sdk.AccAddress, coins sdk.Coins, pk crypto.PubKey, accountNumber, sequence uint64, + address sdk.AccAddress, coins sdk.Coins, pk cryptotypes.PubKey, accountNumber, sequence uint64, ) *BaseAccount { return &BaseAccount{ @@ -380,7 +382,7 @@ func (ma ModuleAccount) Validate() error { return errors.New("module account name cannot be blank") } - if x := sdk.AccAddress(crypto.AddressHash([]byte(ma.Name))); !ma.Address.Equals(x) { + if x := sdk.AccAddress(tmcrypto.AddressHash([]byte(ma.Name))); !ma.Address.Equals(x) { return fmt.Errorf("address %s cannot be derived from the module name '%s'; expected: %s", ma.Address, ma.Name, x) } @@ -415,6 +417,7 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { } func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cryptocodec.RegisterCrypto(cdc) cdc.RegisterInterface((*v038auth.GenesisAccount)(nil), nil) cdc.RegisterInterface((*v038auth.Account)(nil), nil) cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) diff --git a/x/auth/signing/sig_verifiable_tx.go b/x/auth/signing/sig_verifiable_tx.go index 6621d3fcb0..8381ad491a 100644 --- a/x/auth/signing/sig_verifiable_tx.go +++ b/x/auth/signing/sig_verifiable_tx.go @@ -1,8 +1,7 @@ package signing import ( - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) @@ -12,7 +11,7 @@ import ( type SigVerifiableTx interface { types.Tx GetSigners() []types.AccAddress - GetPubKeys() []crypto.PubKey // If signer already has pubkey in context, this list will have nil in its place + GetPubKeys() []cryptotypes.PubKey // If signer already has pubkey in context, this list will have nil in its place GetSignaturesV2() ([]signing.SignatureV2, error) } diff --git a/x/auth/signing/verify.go b/x/auth/signing/verify.go index 0e66f026fa..5a5395de69 100644 --- a/x/auth/signing/verify.go +++ b/x/auth/signing/verify.go @@ -3,8 +3,7 @@ package signing import ( "fmt" - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -12,7 +11,7 @@ import ( // VerifySignature verifies a transaction signature contained in SignatureData abstracting over different signing modes // and single vs multi-signatures. -func VerifySignature(pubKey crypto.PubKey, signerData SignerData, sigData signing.SignatureData, handler SignModeHandler, tx sdk.Tx) error { +func VerifySignature(pubKey cryptotypes.PubKey, signerData SignerData, sigData signing.SignatureData, handler SignModeHandler, tx sdk.Tx) error { switch data := sigData.(type) { case *signing.SingleSignatureData: signBytes, err := handler.GetSignBytes(data.SignMode, signerData, tx) diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index f0929c76cc..7e842d1353 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -4,11 +4,11 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -65,7 +65,7 @@ func TestVerifySignature(t *testing.T) { err = signing.VerifySignature(pubKey, signerData, sigV2.Data, handler, stdTx) require.NoError(t, err) - pkSet := []crypto.PubKey{pubKey, pubKey1} + pkSet := []cryptotypes.PubKey{pubKey, pubKey1} multisigKey := kmultisig.NewLegacyAminoPubKey(2, pkSet) multisignature := multisig.NewMultisig(2) msgs = []sdk.Msg{testdata.NewTestMsg(addr, addr1)} diff --git a/x/auth/testutil/suite.go b/x/auth/testutil/suite.go index 518e502de1..f8002e68e4 100644 --- a/x/auth/testutil/suite.go +++ b/x/auth/testutil/suite.go @@ -4,10 +4,10 @@ import ( "bytes" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -81,7 +81,7 @@ func (s *TxConfigTestSuite) TestTxBuilderSetMsgs() { func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() { privKey, pubkey, addr := testdata.KeyTestPubAddr() privKey2, pubkey2, _ := testdata.KeyTestPubAddr() - multisigPk := kmultisig.NewLegacyAminoPubKey(2, []crypto.PubKey{pubkey, pubkey2}) + multisigPk := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{pubkey, pubkey2}) txBuilder := s.TxConfig.NewTxBuilder() @@ -268,7 +268,7 @@ func (s *TxConfigTestSuite) TestTxEncodeDecode() { tx3Sigs, err := tx3.GetSignaturesV2() s.Require().NoError(err) s.Require().Equal([]signingtypes.SignatureV2{sig}, tx3Sigs) - s.Require().Equal([]crypto.PubKey{pubkey}, tx3.GetPubKeys()) + s.Require().Equal([]cryptotypes.PubKey{pubkey}, tx3.GetPubKeys()) log("JSON encode transaction") jsonTxBytes, err := s.TxConfig.TxJSONEncoder()(tx) @@ -287,7 +287,7 @@ func (s *TxConfigTestSuite) TestTxEncodeDecode() { tx3Sigs, err = tx3.GetSignaturesV2() s.Require().NoError(err) s.Require().Equal([]signingtypes.SignatureV2{sig}, tx3Sigs) - s.Require().Equal([]crypto.PubKey{pubkey}, tx3.GetPubKeys()) + s.Require().Equal([]cryptotypes.PubKey{pubkey}, tx3.GetPubKeys()) } func (s *TxConfigTestSuite) TestWrapTxBuilder() { diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index b3697e70b2..4c76d529a9 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -1,15 +1,12 @@ package tx import ( - "fmt" - "github.com/gogo/protobuf/proto" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" @@ -103,9 +100,9 @@ func (w *wrapper) GetSigners() []sdk.AccAddress { return w.tx.GetSigners() } -func (w *wrapper) GetPubKeys() []crypto.PubKey { +func (w *wrapper) GetPubKeys() []cryptotypes.PubKey { signerInfos := w.tx.AuthInfo.SignerInfos - pks := make([]crypto.PubKey, len(signerInfos)) + pks := make([]cryptotypes.PubKey, len(signerInfos)) for i, si := range signerInfos { // NOTE: it is okay to leave this nil if there is no PubKey in the SignerInfo. @@ -114,7 +111,7 @@ func (w *wrapper) GetPubKeys() []crypto.PubKey { continue } - pk, ok := si.PublicKey.GetCachedValue().(crypto.PubKey) + pk, ok := si.PublicKey.GetCachedValue().(cryptotypes.PubKey) if ok { pks[i] = pk } @@ -366,11 +363,7 @@ func (w *wrapper) SetNonCriticalExtensionOptions(extOpts ...*codectypes.Any) { w.bodyBz = nil } -// PubKeyToAny converts a crypto.PubKey to a proto Any. -func PubKeyToAny(key crypto.PubKey) (*codectypes.Any, error) { - protoMsg, ok := key.(proto.Message) - if !ok { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, fmt.Sprintf("can't proto encode %T", protoMsg)) - } - return codectypes.NewAnyWithValue(protoMsg) +// PubKeyToAny converts a cryptotypes.PubKey to a proto Any. +func PubKeyToAny(key cryptotypes.PubKey) (*codectypes.Any, error) { + return codectypes.NewAnyWithValue(key) } diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index d430dc2b0a..b12808a164 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -3,16 +3,22 @@ package tx import ( "context" "encoding/hex" + "fmt" + "strings" gogogrpc "github.com/gogo/protobuf/grpc" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + abci "github.com/tendermint/tendermint/abci/types" + tmtypes "github.com/tendermint/tendermint/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + pagination "github.com/cosmos/cosmos-sdk/types/query" txtypes "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -37,6 +43,89 @@ func NewTxServer(clientCtx client.Context, simulate baseAppSimulateFn, interface var _ txtypes.ServiceServer = txServer{} +const ( + eventFormat = "{eventType}.{eventAttribute}={value}" +) + +// TxsByEvents implements the ServiceServer.TxsByEvents RPC method. +func (s txServer) GetTxsEvent(ctx context.Context, req *txtypes.GetTxsEventRequest) (*txtypes.GetTxsEventResponse, error) { + offset := int(req.Pagination.Offset) + limit := int(req.Pagination.Limit) + if offset < 0 { + return nil, status.Error(codes.InvalidArgument, "offset must greater than 0") + } + if len(req.Event) == 0 { + return nil, status.Error(codes.InvalidArgument, "must declare at least one event to search") + } + + if limit < 0 { + return nil, status.Error(codes.InvalidArgument, "limit must greater than 0") + } else if limit == 0 { + limit = pagination.DefaultLimit + } + + page := offset/limit + 1 + + var events []string + + if strings.Contains(req.Event, "&") { + events = strings.Split(req.Event, "&") + } else { + events = append(events, req.Event) + } + tmEvents := make([]string, len(events)) + for i, event := range events { + if !strings.Contains(event, "=") { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid event; event %s should be of the format: %s", event, eventFormat)) + } else if strings.Count(event, "=") > 1 { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("invalid event; event %s should be of the format: %s", event, eventFormat)) + } + + tokens := strings.Split(event, "=") + if tokens[0] == tmtypes.TxHeightKey { + event = fmt.Sprintf("%s=%s", tokens[0], tokens[1]) + } else { + event = fmt.Sprintf("%s='%s'", tokens[0], tokens[1]) + } + + tmEvents[i] = event + } + + query := strings.Join(tmEvents, " AND ") + + result, err := s.clientCtx.Client.TxSearch(ctx, query, false, &page, &limit, "") + if err != nil { + return nil, err + } + + // Create a proto codec, we need it to unmarshal the tx bytes. + cdc := codec.NewProtoCodec(s.clientCtx.InterfaceRegistry) + txRespList := make([]*sdk.TxResponse, len(result.Txs)) + txsList := make([]*txtypes.Tx, len(result.Txs)) + + for i, tx := range result.Txs { + txResp := txResultToTxResponse(&tx.TxResult) + txResp.Height = tx.Height + txResp.TxHash = tx.Hash.String() + txRespList[i] = txResp + + var protoTx txtypes.Tx + if err := cdc.UnmarshalBinaryBare(tx.Tx, &protoTx); err != nil { + return nil, err + } + txsList[i] = &protoTx + } + + return &txtypes.GetTxsEventResponse{ + Txs: txsList, + TxResponses: txRespList, + Pagination: &pagination.PageResponse{ + Total: uint64(result.TotalCount), + }, + }, nil + +} + // Simulate implements the ServiceServer.Simulate RPC method. func (s txServer) Simulate(ctx context.Context, req *txtypes.SimulateRequest) (*txtypes.SimulateResponse, error) { if req.Tx == nil { @@ -80,14 +169,19 @@ func (s txServer) GetTx(ctx context.Context, req *txtypes.GetTxRequest) (*txtype // Create a proto codec, we need it to unmarshal the tx bytes. cdc := codec.NewProtoCodec(s.clientCtx.InterfaceRegistry) - var protoTx txtypes.Tx + var protoTx txtypes.Tx if err := cdc.UnmarshalBinaryBare(result.Tx, &protoTx); err != nil { return nil, err } + txResp := txResultToTxResponse(&result.TxResult) + txResp.Height = result.Height + txResp.TxHash = result.Hash.String() + return &txtypes.GetTxResponse{ - Tx: &protoTx, + Tx: &protoTx, + TxResponse: txResp, }, nil } @@ -109,3 +203,15 @@ func RegisterTxService( func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) { txtypes.RegisterServiceHandlerClient(context.Background(), mux, txtypes.NewServiceClient(clientConn)) } + +func txResultToTxResponse(respTx *abci.ResponseDeliverTx) *sdk.TxResponse { + logs, _ := sdk.ParseABCILogs(respTx.Log) + return &sdk.TxResponse{ + Code: respTx.Code, + Codespace: respTx.Codespace, + GasUsed: respTx.GasUsed, + GasWanted: respTx.GasWanted, + Info: respTx.Info, + Logs: logs, + } +} diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index ec51cf0e2b..a1bacb55cb 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + query "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -99,6 +100,55 @@ func (s IntegrationTestSuite) TestSimulate() { s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. } +func (s IntegrationTestSuite) TestGetTxEvents() { + val := s.network.Validators[0] + + // Create a new MsgSend tx from val to itself. + out, err := bankcli.MsgSendExec( + val.ClientCtx, + val.Address, + val.Address, + sdk.NewCoins( + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--gas=%d", flags.DefaultGasLimit), + fmt.Sprintf("--%s=foobar", flags.FlagMemo), + ) + s.Require().NoError(err) + var txRes sdk.TxResponse + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(out.Bytes(), &txRes)) + s.Require().Equal(uint32(0), txRes.Code) + + s.Require().NoError(s.network.WaitForNextBlock()) + + // Query the tx via gRPC. + grpcRes, err := s.queryClient.GetTxsEvent( + context.Background(), + &tx.GetTxsEventRequest{Event: "message.action=send", + Pagination: &query.PageRequest{ + CountTotal: false, + Offset: 0, + Limit: 1, + }, + }, + ) + s.Require().NoError(err) + s.Require().Equal(len(grpcRes.Txs), 1) + s.Require().Equal("foobar", grpcRes.Txs[0].Body.Memo) + + // Query the tx via grpc-gateway. + restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/txs?event=%s&pagination.offset=%d&pagination.limit=%d", val.APIAddress, "message.action=send", 0, 1)) + s.Require().NoError(err) + var getTxRes tx.GetTxsEventResponse + s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &getTxRes)) + s.Require().Equal(len(grpcRes.Txs), 1) + s.Require().Equal("foobar", getTxRes.Txs[0].Body.Memo) + s.Require().NotZero(grpcRes.TxResponses[0].Height) +} + func (s IntegrationTestSuite) TestGetTx() { val := s.network.Validators[0] @@ -130,13 +180,15 @@ func (s IntegrationTestSuite) TestGetTx() { ) s.Require().NoError(err) s.Require().Equal("foobar", grpcRes.Tx.Body.Memo) + s.Require().NotZero(grpcRes.TxResponse.Height) // Query the tx via grpc-gateway. restRes, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/tx/v1beta1/tx/%s", val.APIAddress, txRes.TxHash)) s.Require().NoError(err) var getTxRes tx.GetTxResponse s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(restRes, &getTxRes)) - s.Require().Equal("foobar", getTxRes.Tx.Body.Memo) + s.Require().Equal("foobar", grpcRes.Tx.Body.Memo) + s.Require().NotZero(grpcRes.TxResponse.Height) } func TestIntegrationTestSuite(t *testing.T) { diff --git a/x/auth/tx/sigs.go b/x/auth/tx/sigs.go index d0e43ede75..b40935b4b8 100644 --- a/x/auth/tx/sigs.go +++ b/x/auth/tx/sigs.go @@ -3,10 +3,8 @@ package tx import ( "fmt" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) @@ -33,7 +31,7 @@ func SignatureDataToModeInfoAndSig(data signing.SignatureData) (*tx.ModeInfo, [] modeInfos[i], sigs[i] = SignatureDataToModeInfoAndSig(d) } - multisig := types.MultiSignature{ + multisig := cryptotypes.MultiSignature{ Signatures: sigs, } sig, err := multisig.Marshal() @@ -92,7 +90,7 @@ func ModeInfoAndSigToSignatureData(modeInfo *tx.ModeInfo, sig []byte) (signing.S // decodeMultisignatures safely decodes the the raw bytes as a MultiSignature protobuf message func decodeMultisignatures(bz []byte) ([][]byte, error) { - multisig := types.MultiSignature{} + multisig := cryptotypes.MultiSignature{} err := multisig.Unmarshal(bz) if err != nil { return nil, err @@ -137,7 +135,7 @@ func (g config) UnmarshalSignatureJSON(bz []byte) ([]signing.SignatureV2, error) sigs := make([]signing.SignatureV2, len(sigDescs.Signatures)) for i, desc := range sigDescs.Signatures { - pubKey, _ := desc.PublicKey.GetCachedValue().(crypto.PubKey) + pubKey, _ := desc.PublicKey.GetCachedValue().(cryptotypes.PubKey) data := signing.SignatureDataFromProto(desc.Data) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 476e607c42..532b80d307 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -26,7 +27,7 @@ var ( // NewBaseAccount creates a new BaseAccount object //nolint:interfacer -func NewBaseAccount(address sdk.AccAddress, pubKey crypto.PubKey, accountNumber, sequence uint64) *BaseAccount { +func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount { acc := &BaseAccount{ Address: address.String(), AccountNumber: accountNumber, @@ -70,11 +71,11 @@ func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error { } // GetPubKey - Implements sdk.AccountI. -func (acc BaseAccount) GetPubKey() (pk crypto.PubKey) { +func (acc BaseAccount) GetPubKey() (pk cryptotypes.PubKey) { if acc.PubKey == nil { return nil } - content, ok := acc.PubKey.GetCachedValue().(crypto.PubKey) + content, ok := acc.PubKey.GetCachedValue().(cryptotypes.PubKey) if !ok { return nil } @@ -82,7 +83,7 @@ func (acc BaseAccount) GetPubKey() (pk crypto.PubKey) { } // SetPubKey - Implements sdk.AccountI. -func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error { +func (acc *BaseAccount) SetPubKey(pubKey cryptotypes.PubKey) error { any, err := codectypes.PackAny(pubKey) if err != nil { return err @@ -150,7 +151,7 @@ func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if acc.PubKey == nil { return nil } - var pubKey crypto.PubKey + var pubKey cryptotypes.PubKey return unpacker.UnpackAny(acc.PubKey, &pubKey) } @@ -209,7 +210,7 @@ func (ma ModuleAccount) GetPermissions() []string { } // SetPubKey - Implements AccountI -func (ma ModuleAccount) SetPubKey(pubKey crypto.PubKey) error { +func (ma ModuleAccount) SetPubKey(pubKey cryptotypes.PubKey) error { return fmt.Errorf("not supported for module accounts") } @@ -311,8 +312,8 @@ type AccountI interface { GetAddress() sdk.AccAddress SetAddress(sdk.AccAddress) error // errors if already set. - GetPubKey() crypto.PubKey // can return nil. - SetPubKey(crypto.PubKey) error + GetPubKey() cryptotypes.PubKey // can return nil. + SetPubKey(cryptotypes.PubKey) error GetAccountNumber() uint64 SetAccountNumber(uint64) error diff --git a/x/auth/vesting/types/test_common.go b/x/auth/vesting/types/test_common.go index 347faba046..0e22ea2352 100644 --- a/x/auth/vesting/types/test_common.go +++ b/x/auth/vesting/types/test_common.go @@ -1,9 +1,8 @@ package types import ( - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -22,7 +21,7 @@ func NewTestCoins() sdk.Coins { } // KeyTestPubAddr generates a test key pair -func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.AccAddress) { +func KeyTestPubAddr() (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) { key := secp256k1.GenPrivKey() pub := key.PubKey() addr := sdk.AccAddress(pub.Address()) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 713aa0999b..82d898b090 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -28,7 +28,7 @@ type ( msgs []sdk.Msg accNums []uint64 accSeqs []uint64 - privKeys []crypto.PrivKey + privKeys []cryptotypes.PrivKey expectedBalances []expectedBalance } ) @@ -228,7 +228,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { accSeqs: []uint64{0}, expSimPass: true, expPass: true, - privKeys: []crypto.PrivKey{priv1}, + privKeys: []cryptotypes.PrivKey{priv1}, expectedBalances: []expectedBalance{ {addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 57)}}, {addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}}, @@ -241,7 +241,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { accSeqs: []uint64{1}, expSimPass: true, // doesn't check signature expPass: false, - privKeys: []crypto.PrivKey{priv1}, + privKeys: []cryptotypes.PrivKey{priv1}, }, { desc: "wrong accSeq should not pass Simulate", @@ -250,7 +250,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { accSeqs: []uint64{0}, // wrong account sequence expSimPass: false, expPass: false, - privKeys: []crypto.PrivKey{priv1}, + privKeys: []cryptotypes.PrivKey{priv1}, }, } @@ -297,7 +297,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { accSeqs: []uint64{0}, expSimPass: true, expPass: true, - privKeys: []crypto.PrivKey{priv1}, + privKeys: []cryptotypes.PrivKey{priv1}, expectedBalances: []expectedBalance{ {addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 32)}}, {addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 47)}}, @@ -351,7 +351,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { accSeqs: []uint64{0, 0}, expSimPass: true, expPass: true, - privKeys: []crypto.PrivKey{priv1, priv4}, + privKeys: []cryptotypes.PrivKey{priv1, priv4}, expectedBalances: []expectedBalance{ {addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 32)}}, {addr4, sdk.Coins{sdk.NewInt64Coin("foocoin", 32)}}, @@ -395,7 +395,7 @@ func TestMsgMultiSendDependent(t *testing.T) { accSeqs: []uint64{0}, expSimPass: true, expPass: true, - privKeys: []crypto.PrivKey{priv1}, + privKeys: []cryptotypes.PrivKey{priv1}, expectedBalances: []expectedBalance{ {addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 32)}}, {addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}}, @@ -407,7 +407,7 @@ func TestMsgMultiSendDependent(t *testing.T) { accSeqs: []uint64{0}, expSimPass: true, expPass: true, - privKeys: []crypto.PrivKey{priv2}, + privKeys: []cryptotypes.PrivKey{priv2}, expectedBalances: []expectedBalance{ {addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 42)}}, }, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index c1e64d80d5..9fcc80f0fe 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -3,10 +3,9 @@ package simulation import ( "math/rand" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp/helpers" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" @@ -72,7 +71,7 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio msg := types.NewMsgSend(simAccount.Address, toSimAcc.Address, coins) - err := sendMsgSend(r, app, bk, ak, msg, ctx, chainID, []crypto.PrivKey{simAccount.PrivKey}) + err := sendMsgSend(r, app, bk, ak, msg, ctx, chainID, []cryptotypes.PrivKey{simAccount.PrivKey}) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "invalid transfers"), nil, err } @@ -85,7 +84,7 @@ func SimulateMsgSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operatio // nolint: interfacer func sendMsgSend( r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, - msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, + msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { var ( @@ -144,7 +143,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope outputs := make([]types.Output, r.Intn(3)+1) // collect signer privKeys - privs := make([]crypto.PrivKey, len(inputs)) + privs := make([]cryptotypes.PrivKey, len(inputs)) // use map to check if address already exists as input usedAddrs := make(map[string]bool) @@ -227,7 +226,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope // nolint: interfacer func sendMsgMultiSend( r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, - msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []crypto.PrivKey, + msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { accountNumbers := make([]uint64, len(msg.Inputs)) diff --git a/x/capability/genesis.go b/x/capability/genesis.go index 07bf6df7ef..ba8e09dcd3 100644 --- a/x/capability/genesis.go +++ b/x/capability/genesis.go @@ -9,7 +9,9 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - k.SetIndex(ctx, genState.Index) + if err := k.InitializeIndex(ctx, genState.Index); err != nil { + panic(err) + } // set owners for each index and initialize capability for _, genOwner := range genState.Owners { diff --git a/x/capability/keeper/keeper.go b/x/capability/keeper/keeper.go index cb4d31df0b..61de033899 100644 --- a/x/capability/keeper/keeper.go +++ b/x/capability/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "strings" "github.com/tendermint/tendermint/libs/log" @@ -49,6 +50,8 @@ type ( } ) +// NewKeeper constructs a new CapabilityKeeper instance and initializes maps +// for capability map and scopedModules map. func NewKeeper(cdc codec.BinaryMarshaler, storeKey, memKey sdk.StoreKey) *Keeper { return &Keeper{ cdc: cdc, @@ -67,6 +70,9 @@ func (k *Keeper) ScopeToModule(moduleName string) ScopedKeeper { if k.sealed { panic("cannot scope to module via a sealed capability keeper") } + if strings.TrimSpace(moduleName) == "" { + panic("cannot scope to an empty module name") + } if _, ok := k.scopedModules[moduleName]; ok { panic(fmt.Sprintf("cannot create multiple scoped keepers for the same module name: %s", moduleName)) @@ -117,12 +123,22 @@ func (k *Keeper) InitializeAndSeal(ctx sdk.Context) { k.sealed = true } -// SetIndex sets the index to one in InitChain -// Since it is an exported function, we check that index is indeed unset, before initializing -func (k Keeper) SetIndex(ctx sdk.Context, index uint64) { +// InitializeIndex sets the index to one (or greater) in InitChain according +// to the GenesisState. It must only be called once. +// It will panic if the provided index is 0, or if the index is already set. +func (k Keeper) InitializeIndex(ctx sdk.Context, index uint64) error { + if index == 0 { + panic("SetIndex requires index > 0") + } + latest := k.GetLatestIndex(ctx) + if latest > 0 { + panic("SetIndex requires index to not be set") + } + // set the global index to the passed index store := ctx.KVStore(k.storeKey) store.Set(types.KeyIndex, types.IndexToKey(index)) + return nil } // GetLatestIndex returns the latest index of the CapabilityKeeper @@ -156,7 +172,8 @@ func (k Keeper) GetOwners(ctx sdk.Context, index uint64) (types.CapabilityOwners } // InitializeCapability takes in an index and an owners array. It creates the capability in memory -// and sets the fwd and reverse keys for each owner in the memstore +// and sets the fwd and reverse keys for each owner in the memstore. +// It is used during initialization from genesis. func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types.CapabilityOwners) { memStore := ctx.KVStore(k.memKey) @@ -189,6 +206,9 @@ func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types // Note, namespacing is completely local, which is safe since records are prefixed // with the module name and no two ScopedKeeper can have the same module name. func (sk ScopedKeeper) NewCapability(ctx sdk.Context, name string) (*types.Capability, error) { + if strings.TrimSpace(name) == "" { + return nil, sdkerrors.Wrap(types.ErrInvalidCapabilityName, "capability name cannot be empty") + } store := ctx.KVStore(sk.storeKey) if _, ok := sk.GetCapability(ctx, name); ok { @@ -236,6 +256,9 @@ func (sk ScopedKeeper) NewCapability(ctx sdk.Context, name string) (*types.Capab // Note, the capability's forward mapping is indexed by a string which should // contain its unique memory reference. func (sk ScopedKeeper) AuthenticateCapability(ctx sdk.Context, cap *types.Capability, name string) bool { + if strings.TrimSpace(name) == "" || cap == nil { + return false + } return sk.GetCapabilityName(ctx, cap) == name } @@ -245,6 +268,12 @@ func (sk ScopedKeeper) AuthenticateCapability(ctx sdk.Context, cap *types.Capabi // index. If the owner already exists, it will return an error. Otherwise, it will // also set a forward and reverse index for the capability and capability name. func (sk ScopedKeeper) ClaimCapability(ctx sdk.Context, cap *types.Capability, name string) error { + if cap == nil { + return sdkerrors.Wrap(types.ErrNilCapability, "cannot claim nil capability") + } + if strings.TrimSpace(name) == "" { + return sdkerrors.Wrap(types.ErrInvalidCapabilityName, "capability name cannot be empty") + } // update capability owner set if err := sk.addOwner(ctx, cap, name); err != nil { return err @@ -271,6 +300,9 @@ func (sk ScopedKeeper) ClaimCapability(ctx sdk.Context, cap *types.Capability, n // previously claimed or created. After releasing the capability, if no more // owners exist, the capability will be globally removed. func (sk ScopedKeeper) ReleaseCapability(ctx sdk.Context, cap *types.Capability) error { + if cap == nil { + return sdkerrors.Wrap(types.ErrNilCapability, "cannot release nil capability") + } name := sk.GetCapabilityName(ctx, cap) if len(name) == 0 { return sdkerrors.Wrap(types.ErrCapabilityNotOwned, sk.module) @@ -278,14 +310,12 @@ func (sk ScopedKeeper) ReleaseCapability(ctx sdk.Context, cap *types.Capability) memStore := ctx.KVStore(sk.memKey) - // Set the forward mapping between the module and capability tuple and the + // Delete the forward mapping between the module and capability tuple and the // capability name in the memKVStore memStore.Delete(types.FwdCapabilityKey(sk.module, cap)) - // Set the reverse mapping between the module and capability name and the - // index in the in-memory store. Since marshalling and unmarshalling into a store - // will change memory address of capability, we simply store index as value here - // and retrieve the in-memory pointer to the capability from our map + // Delete the reverse mapping between the module and capability name and the + // index in the in-memory store. memStore.Delete(types.RevCapabilityKey(sk.module, name)) // remove owner @@ -298,7 +328,7 @@ func (sk ScopedKeeper) ReleaseCapability(ctx sdk.Context, cap *types.Capability) if len(capOwners.Owners) == 0 { // remove capability owner set prefixStore.Delete(indexKey) - // since no one ones capability, we can delete capability from map + // since no one owns capability, we can delete capability from map delete(sk.capMap, cap.GetIndex()) } else { // update capability owner set @@ -312,6 +342,9 @@ func (sk ScopedKeeper) ReleaseCapability(ctx sdk.Context, cap *types.Capability) // by name. The module is not allowed to retrieve capabilities which it does not // own. func (sk ScopedKeeper) GetCapability(ctx sdk.Context, name string) (*types.Capability, bool) { + if strings.TrimSpace(name) == "" { + return nil, false + } memStore := ctx.KVStore(sk.memKey) key := types.RevCapabilityKey(sk.module, name) @@ -323,15 +356,14 @@ func (sk ScopedKeeper) GetCapability(ctx sdk.Context, name string) (*types.Capab // to still have the capability in the go map since changes to // go map do not automatically get reverted on tx failure, // so we delete here to remove unnecessary values in map - delete(sk.capMap, index) + // TODO: Delete index correctly from capMap by storing some reverse lookup + // in-memory map. Issue: https://github.com/cosmos/cosmos-sdk/issues/7805 return nil, false } cap := sk.capMap[index] if cap == nil { - // delete key from store to remove unnecessary mapping - memStore.Delete(key) - return nil, false + panic("capability found in memstore is missing from map") } return cap, true @@ -340,14 +372,20 @@ func (sk ScopedKeeper) GetCapability(ctx sdk.Context, name string) (*types.Capab // GetCapabilityName allows a module to retrieve the name under which it stored a given // capability given the capability func (sk ScopedKeeper) GetCapabilityName(ctx sdk.Context, cap *types.Capability) string { + if cap == nil { + return "" + } memStore := ctx.KVStore(sk.memKey) return string(memStore.Get(types.FwdCapabilityKey(sk.module, cap))) } -// Get all the Owners that own the capability associated with the name this ScopedKeeper uses +// GetOwners all the Owners that own the capability associated with the name this ScopedKeeper uses // to refer to the capability func (sk ScopedKeeper) GetOwners(ctx sdk.Context, name string) (*types.CapabilityOwners, bool) { + if strings.TrimSpace(name) == "" { + return nil, false + } cap, ok := sk.GetCapability(ctx, name) if !ok { return nil, false @@ -370,9 +408,12 @@ func (sk ScopedKeeper) GetOwners(ctx sdk.Context, name string) (*types.Capabilit // LookupModules returns all the module owners for a given capability // as a string array and the capability itself. -// The method returns an errors if either the capability or the owners cannot be +// The method returns an error if either the capability or the owners cannot be // retreived from the memstore. func (sk ScopedKeeper) LookupModules(ctx sdk.Context, name string) ([]string, *types.Capability, error) { + if strings.TrimSpace(name) == "" { + return nil, nil, sdkerrors.Wrap(types.ErrInvalidCapabilityName, "cannot lookup modules with empty capability name") + } cap, ok := sk.GetCapability(ctx, name) if !ok { return nil, nil, sdkerrors.Wrap(types.ErrCapabilityNotFound, name) @@ -413,16 +454,13 @@ func (sk ScopedKeeper) getOwners(ctx sdk.Context, cap *types.Capability) *types. bz := prefixStore.Get(indexKey) - var owners *types.CapabilityOwners if len(bz) == 0 { - owners = types.NewCapabilityOwners() - } else { - var capOwners types.CapabilityOwners - sk.cdc.MustUnmarshalBinaryBare(bz, &capOwners) - owners = &capOwners + return types.NewCapabilityOwners() } - return owners + var capOwners types.CapabilityOwners + sk.cdc.MustUnmarshalBinaryBare(bz, &capOwners) + return &capOwners } func logger(ctx sdk.Context) log.Logger { diff --git a/x/capability/keeper/keeper_test.go b/x/capability/keeper/keeper_test.go index fdd7953410..e62176a724 100644 --- a/x/capability/keeper/keeper_test.go +++ b/x/capability/keeper/keeper_test.go @@ -38,6 +38,9 @@ func (suite *KeeperTestSuite) SetupTest() { func (suite *KeeperTestSuite) TestInitializeAndSeal() { sk := suite.keeper.ScopeToModule(banktypes.ModuleName) + suite.Require().Panics(func() { + suite.keeper.ScopeToModule(" ") + }) caps := make([]*types.Capability, 5) // Get Latest Index before creating new ones to sychronize indices correctly @@ -75,11 +78,15 @@ func (suite *KeeperTestSuite) TestInitializeAndSeal() { func (suite *KeeperTestSuite) TestNewCapability() { sk := suite.keeper.ScopeToModule(banktypes.ModuleName) + got, ok := sk.GetCapability(suite.ctx, "transfer") + suite.Require().False(ok) + suite.Require().Nil(got) + cap, err := sk.NewCapability(suite.ctx, "transfer") suite.Require().NoError(err) suite.Require().NotNil(cap) - got, ok := sk.GetCapability(suite.ctx, "transfer") + got, ok = sk.GetCapability(suite.ctx, "transfer") suite.Require().True(ok) suite.Require().Equal(cap, got) suite.Require().True(cap == got, "expected memory addresses to be equal") @@ -88,7 +95,21 @@ func (suite *KeeperTestSuite) TestNewCapability() { suite.Require().False(ok) suite.Require().Nil(got) - cap, err = sk.NewCapability(suite.ctx, "transfer") + got, ok = sk.GetCapability(suite.ctx, "transfer") + suite.Require().True(ok) + suite.Require().Equal(cap, got) + suite.Require().True(cap == got, "expected memory addresses to be equal") + + cap2, err := sk.NewCapability(suite.ctx, "transfer") + suite.Require().Error(err) + suite.Require().Nil(cap2) + + got, ok = sk.GetCapability(suite.ctx, "transfer") + suite.Require().True(ok) + suite.Require().Equal(cap, got) + suite.Require().True(cap == got, "expected memory addresses to be equal") + + cap, err = sk.NewCapability(suite.ctx, " ") suite.Require().Error(err) suite.Require().Nil(cap) } @@ -111,7 +132,8 @@ func (suite *KeeperTestSuite) TestAuthenticateCapability() { suite.Require().NoError(err) suite.Require().NotNil(cap1) - forgedCap := types.NewCapability(0) // index should be the same index as the first capability + forgedCap := types.NewCapability(cap1.Index) // index should be the same index as the first capability + suite.Require().False(sk1.AuthenticateCapability(suite.ctx, forgedCap, "transfer")) suite.Require().False(sk2.AuthenticateCapability(suite.ctx, forgedCap, "transfer")) cap2, err := sk2.NewCapability(suite.ctx, "bond") @@ -136,11 +158,15 @@ func (suite *KeeperTestSuite) TestAuthenticateCapability() { badCap := types.NewCapability(100) suite.Require().False(sk1.AuthenticateCapability(suite.ctx, badCap, "transfer")) suite.Require().False(sk2.AuthenticateCapability(suite.ctx, badCap, "bond")) + + suite.Require().False(sk1.AuthenticateCapability(suite.ctx, cap1, " ")) + suite.Require().False(sk1.AuthenticateCapability(suite.ctx, nil, "transfer")) } func (suite *KeeperTestSuite) TestClaimCapability() { sk1 := suite.keeper.ScopeToModule(banktypes.ModuleName) sk2 := suite.keeper.ScopeToModule(stakingtypes.ModuleName) + sk3 := suite.keeper.ScopeToModule("foo") cap, err := sk1.NewCapability(suite.ctx, "transfer") suite.Require().NoError(err) @@ -156,6 +182,9 @@ func (suite *KeeperTestSuite) TestClaimCapability() { got, ok = sk2.GetCapability(suite.ctx, "transfer") suite.Require().True(ok) suite.Require().Equal(cap, got) + + suite.Require().Error(sk3.ClaimCapability(suite.ctx, cap, " ")) + suite.Require().Error(sk3.ClaimCapability(suite.ctx, nil, "transfer")) } func (suite *KeeperTestSuite) TestGetOwners() { @@ -176,14 +205,15 @@ func (suite *KeeperTestSuite) TestGetOwners() { // Ensure all scoped keepers can get owners for _, sk := range sks { owners, ok := sk.GetOwners(suite.ctx, "transfer") - mods, cap, err := sk.LookupModules(suite.ctx, "transfer") + mods, gotCap, err := sk.LookupModules(suite.ctx, "transfer") suite.Require().True(ok, "could not retrieve owners") suite.Require().NotNil(owners, "owners is nil") suite.Require().NoError(err, "could not retrieve modules") - suite.Require().NotNil(cap, "capability is nil") + suite.Require().NotNil(gotCap, "capability is nil") suite.Require().NotNil(mods, "modules is nil") + suite.Require().Equal(cap, gotCap, "caps not equal") suite.Require().Equal(len(expectedOrder), len(owners.Owners), "length of owners is unexpected") for i, o := range owners.Owners { @@ -221,6 +251,8 @@ func (suite *KeeperTestSuite) TestGetOwners() { } } + _, ok := sk1.GetOwners(suite.ctx, " ") + suite.Require().False(ok, "got owners from empty capability name") } func (suite *KeeperTestSuite) TestReleaseCapability() { @@ -248,6 +280,8 @@ func (suite *KeeperTestSuite) TestReleaseCapability() { got, ok = sk1.GetCapability(suite.ctx, "transfer") suite.Require().False(ok) suite.Require().Nil(got) + + suite.Require().Error(sk1.ReleaseCapability(suite.ctx, nil)) } func (suite KeeperTestSuite) TestRevertCapability() { diff --git a/x/capability/types/errors.go b/x/capability/types/errors.go index 93f1854260..7c582ccbb0 100644 --- a/x/capability/types/errors.go +++ b/x/capability/types/errors.go @@ -8,9 +8,11 @@ import ( // x/capability module sentinel errors var ( - ErrCapabilityTaken = sdkerrors.Register(ModuleName, 2, "capability name already taken") - ErrOwnerClaimed = sdkerrors.Register(ModuleName, 3, "given owner already claimed capability") - ErrCapabilityNotOwned = sdkerrors.Register(ModuleName, 4, "capability not owned by module") - ErrCapabilityNotFound = sdkerrors.Register(ModuleName, 5, "capability not found") - ErrCapabilityOwnersNotFound = sdkerrors.Register(ModuleName, 6, "owners not found for capability") + ErrInvalidCapabilityName = sdkerrors.Register(ModuleName, 2, "capability name not valid") + ErrNilCapability = sdkerrors.Register(ModuleName, 3, "provided capability is nil") + ErrCapabilityTaken = sdkerrors.Register(ModuleName, 4, "capability name already taken") + ErrOwnerClaimed = sdkerrors.Register(ModuleName, 5, "given owner already claimed capability") + ErrCapabilityNotOwned = sdkerrors.Register(ModuleName, 6, "capability not owned by module") + ErrCapabilityNotFound = sdkerrors.Register(ModuleName, 7, "capability not found") + ErrCapabilityOwnersNotFound = sdkerrors.Register(ModuleName, 8, "owners not found for capability") ) diff --git a/x/distribution/types/common_test.go b/x/distribution/types/common_test.go index a8301b4e42..4e6ef6b012 100644 --- a/x/distribution/types/common_test.go +++ b/x/distribution/types/common_test.go @@ -1,9 +1,8 @@ package types import ( - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -25,5 +24,5 @@ var ( valAddr3 = sdk.ValAddress(valPk3.Address()) emptyValAddr sdk.ValAddress - emptyPubkey crypto.PubKey + emptyPubkey cryptotypes.PubKey ) diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 65e52b30ed..9165730466 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -6,11 +6,11 @@ import ( "time" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -22,7 +22,7 @@ import ( ) var ( - pubkeys = []crypto.PubKey{ + pubkeys = []cryptotypes.PubKey{ newPubKey("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AFB50"), newPubKey("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AFB51"), newPubKey("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AFB52"), @@ -38,7 +38,7 @@ var ( initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt)) ) -func newPubKey(pk string) (res crypto.PubKey) { +func newPubKey(pk string) (res cryptotypes.PubKey) { pkBytes, err := hex.DecodeString(pk) if err != nil { panic(err) diff --git a/x/evidence/types/expected_keepers.go b/x/evidence/types/expected_keepers.go index 23c9b40bdc..0f1d87774c 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -3,8 +3,7 @@ package types import ( "time" - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -19,7 +18,7 @@ type ( // SlashingKeeper defines the slashing module interface contract needed by the // evidence module. SlashingKeeper interface { - GetPubkey(sdk.Context, crypto.Address) (crypto.PubKey, error) + GetPubkey(sdk.Context, cryptotypes.Address) (cryptotypes.PubKey, error) IsTombstoned(sdk.Context, sdk.ConsAddress) bool HasValidatorSigningInfo(sdk.Context, sdk.ConsAddress) bool Tombstone(sdk.Context, sdk.ConsAddress) diff --git a/x/genutil/legacy/v038/migrate.go b/x/genutil/legacy/v038/migrate.go index cd71f57b11..374092298a 100644 --- a/x/genutil/legacy/v038/migrate.go +++ b/x/genutil/legacy/v038/migrate.go @@ -3,7 +3,6 @@ package v038 import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" v036auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v036" v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v038" v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v036" @@ -18,12 +17,10 @@ import ( // Migrate migrates exported state from v0.36/v0.37 to a v0.38 genesis state. func Migrate(appState types.AppMap, _ client.Context) types.AppMap { v036Codec := codec.NewLegacyAmino() - cryptocodec.RegisterCrypto(v036Codec) v036gov.RegisterLegacyAminoCodec(v036Codec) v036distr.RegisterLegacyAminoCodec(v036Codec) v038Codec := codec.NewLegacyAmino() - cryptocodec.RegisterCrypto(v038Codec) v038auth.RegisterLegacyAminoCodec(v038Codec) v036gov.RegisterLegacyAminoCodec(v038Codec) v036distr.RegisterLegacyAminoCodec(v038Codec) diff --git a/x/genutil/legacy/v039/migrate.go b/x/genutil/legacy/v039/migrate.go index bf112c1526..97442e9380 100644 --- a/x/genutil/legacy/v039/migrate.go +++ b/x/genutil/legacy/v039/migrate.go @@ -3,7 +3,6 @@ package v039 import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v038" v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v039" v036distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v036" @@ -17,13 +16,11 @@ import ( // serialization of accounts do change. func Migrate(appState types.AppMap, _ client.Context) types.AppMap { v038Codec := codec.NewLegacyAmino() - cryptocodec.RegisterCrypto(v038Codec) v038auth.RegisterLegacyAminoCodec(v038Codec) v036gov.RegisterLegacyAminoCodec(v038Codec) v036distr.RegisterLegacyAminoCodec(v038Codec) v039Codec := codec.NewLegacyAmino() - cryptocodec.RegisterCrypto(v039Codec) v039auth.RegisterLegacyAminoCodec(v039Codec) v036gov.RegisterLegacyAminoCodec(v039Codec) v036distr.RegisterLegacyAminoCodec(v039Codec) diff --git a/x/genutil/types/types.go b/x/genutil/types/types.go index d902d8ccb3..694eebdbe3 100644 --- a/x/genutil/types/types.go +++ b/x/genutil/types/types.go @@ -3,9 +3,8 @@ package types import ( "encoding/json" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/client" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) // DONTCOVER @@ -32,11 +31,11 @@ type InitConfig struct { ChainID string GenTxsDir string NodeID string - ValPubKey crypto.PubKey + ValPubKey cryptotypes.PubKey } // NewInitConfig creates a new InitConfig object -func NewInitConfig(chainID, genTxsDir, nodeID string, valPubKey crypto.PubKey) InitConfig { +func NewInitConfig(chainID, genTxsDir, nodeID string, valPubKey cryptotypes.PubKey) InitConfig { return InitConfig{ ChainID: chainID, GenTxsDir: genTxsDir, diff --git a/x/genutil/utils.go b/x/genutil/utils.go index 5eea117187..14ac11f533 100644 --- a/x/genutil/utils.go +++ b/x/genutil/utils.go @@ -6,13 +6,13 @@ import ( "time" cfg "github.com/tendermint/tendermint/config" - "github.com/tendermint/tendermint/crypto" tmos "github.com/tendermint/tendermint/libs/os" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/privval" tmtypes "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) // ExportGenesisFile creates and writes the genesis configuration to disk. An @@ -47,7 +47,7 @@ func ExportGenesisFileWithTime( } // InitializeNodeValidatorFiles creates private validator and p2p configuration files. -func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey crypto.PubKey, err error) { +func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey cryptotypes.PubKey, err error) { nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { return "", nil, err @@ -70,7 +70,7 @@ func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey return "", nil, err } - valPubKey, err = ed25519.FromTmEd25519(tmValPubKey) + valPubKey, err = cryptocodec.FromTmPubKeyInterface(tmValPubKey) if err != nil { return "", nil, err } diff --git a/x/gov/common_test.go b/x/gov/common_test.go index d8648b478a..5ef50ea5db 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -71,7 +71,7 @@ func SortByteArrays(src [][]byte) [][]byte { const contextKeyBadProposal = "contextKeyBadProposal" var ( - pubkeys = []crypto.PubKey{ + pubkeys = []cryptotypes.PubKey{ ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey(), diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 63ff8e171b..89e4a7c2bf 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -410,9 +410,9 @@ func TestTallyJailedValidator(t *testing.T) { _ = staking.EndBlocker(ctx, app.StakingKeeper) - consKey, err := val2.TmConsPubKey() + consAddr, err := val2.GetConsAddr() require.NoError(t, err) - app.StakingKeeper.Jail(ctx, sdk.ConsAddress(consKey.Address())) + app.StakingKeeper.Jail(ctx, sdk.ConsAddress(consAddr.Bytes())) tp := TestProposal proposal, err := app.GovKeeper.SubmitProposal(ctx, tp) diff --git a/x/ibc/applications/transfer/client/cli/cli.go b/x/ibc/applications/transfer/client/cli/cli.go index 9686afaa18..d3ca8341e9 100644 --- a/x/ibc/applications/transfer/client/cli/cli.go +++ b/x/ibc/applications/transfer/client/cli/cli.go @@ -18,6 +18,7 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( GetCmdQueryDenomTrace(), GetCmdQueryDenomTraces(), + GetCmdParams(), ) return queryCmd diff --git a/x/ibc/applications/transfer/client/cli/query.go b/x/ibc/applications/transfer/client/cli/query.go index c0953d7ca6..3d158ed59a 100644 --- a/x/ibc/applications/transfer/client/cli/query.go +++ b/x/ibc/applications/transfer/client/cli/query.go @@ -86,8 +86,8 @@ func GetCmdQueryDenomTraces() *cobra.Command { return cmd } -// QueryParamsCmd returns the command handler for ibc-transfer parameter querying. -func QueryParamsCmd() *cobra.Command { +// GetCmdParams returns the command handler for ibc-transfer parameter querying. +func GetCmdParams() *cobra.Command { cmd := &cobra.Command{ Use: "params", Short: "Query the current ibc-transfer parameters", diff --git a/x/ibc/applications/transfer/handler_test.go b/x/ibc/applications/transfer/handler_test.go index fd6b686fe2..b1ee24f2ed 100644 --- a/x/ibc/applications/transfer/handler_test.go +++ b/x/ibc/applications/transfer/handler_test.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -31,7 +32,7 @@ func (suite *TransferTestSuite) SetupTest() { // constructs a send from chainA to chainB on the established channel/connection // and sends the same coin back from chainB to chainA. func (suite *TransferTestSuite) TestHandleMsgTransfer() { - clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) originalBalance := suite.chainA.App.BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), sdk.DefaultBondDenom) timeoutHeight := clienttypes.NewHeight(0, 110) diff --git a/x/ibc/applications/transfer/keeper/relay.go b/x/ibc/applications/transfer/keeper/relay.go index c9bc4470d3..d26e71e984 100644 --- a/x/ibc/applications/transfer/keeper/relay.go +++ b/x/ibc/applications/transfer/keeper/relay.go @@ -361,7 +361,9 @@ func (k Keeper) refundPacketToken(ctx sdk.Context, packet channeltypes.Packet, d // DenomPathFromHash returns the full denomination path prefix from an ibc denom with a hash // component. func (k Keeper) DenomPathFromHash(ctx sdk.Context, denom string) (string, error) { - hexHash := denom[4:] + // trim the denomination prefix, by default "ibc/" + hexHash := denom[len(types.DenomPrefix+"/"):] + hash, err := types.ParseHexHash(hexHash) if err != nil { return "", sdkerrors.Wrap(types.ErrInvalidDenomForTransfer, err.Error()) diff --git a/x/ibc/applications/transfer/keeper/relay_test.go b/x/ibc/applications/transfer/keeper/relay_test.go index 5bb7993f9c..7878c59357 100644 --- a/x/ibc/applications/transfer/keeper/relay_test.go +++ b/x/ibc/applications/transfer/keeper/relay_test.go @@ -8,6 +8,7 @@ import ( clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -28,28 +29,28 @@ func (suite *KeeperTestSuite) TestSendTransfer() { }{ {"successful transfer from source chain", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) }, true, true}, {"successful transfer with coin from counterparty chain", func() { // send coin from chainA back to chainB - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) amount = types.GetTransferCoin(channelA.PortID, channelA.ID, sdk.DefaultBondDenom, 100) }, false, true}, {"source channel not found", func() { // channel references wrong ID - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) channelA.ID = ibctesting.InvalidID amount = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) }, true, false}, {"next seq send not found", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA = connA.NextTestChannel(ibctesting.TransferPort) channelB = connB.NextTestChannel(ibctesting.TransferPort) // manually create channel so next seq send is never set @@ -66,20 +67,20 @@ func (suite *KeeperTestSuite) TestSendTransfer() { // - source chain {"send coin failed", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) amount = sdk.NewCoin("randomdenom", sdk.NewInt(100)) }, true, false}, // - receiving chain {"send from module account failed", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) amount = types.GetTransferCoin(channelA.PortID, channelA.ID, " randomdenom", 100) }, false, false}, {"channel capability not found", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) cap := suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) @@ -109,7 +110,7 @@ func (suite *KeeperTestSuite) TestSendTransfer() { packet := channeltypes.NewPacket(fungibleTokenPacket.GetBytes(), 1, channelB.PortID, channelB.ID, channelA.PortID, channelA.ID, clienttypes.NewHeight(0, 110), 0) // get proof of packet commitment from chainB - packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetKey) recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) @@ -177,7 +178,7 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) receiver = suite.chainB.SenderAccount.GetAddress().String() // must be explicitly changed in malleate @@ -365,7 +366,7 @@ func (suite *KeeperTestSuite) TestOnTimeoutPacket() { suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { suite.SetupTest() // reset - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB = suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, channeltypes.UNORDERED) amount = sdk.NewInt(100) // must be explicitly changed sender = suite.chainA.SenderAccount.GetAddress().String() diff --git a/x/ibc/applications/transfer/module_test.go b/x/ibc/applications/transfer/module_test.go index 7f3cec0bde..b0d0fd10e4 100644 --- a/x/ibc/applications/transfer/module_test.go +++ b/x/ibc/applications/transfer/module_test.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -54,7 +55,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { suite.Run(tc.name, func() { suite.SetupTest() // reset - _, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) testChannel = connA.NextTestChannel(ibctesting.TransferPort) counterparty := channeltypes.NewCounterparty(testChannel.PortID, testChannel.ID) channel = &channeltypes.Channel{ @@ -142,7 +143,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { suite.Run(tc.name, func() { suite.SetupTest() // reset - _, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) testChannel = connA.NextTestChannel(ibctesting.TransferPort) counterparty := channeltypes.NewCounterparty(testChannel.PortID, testChannel.ID) channel = &channeltypes.Channel{ @@ -208,7 +209,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() { suite.Run(tc.name, func() { suite.SetupTest() // reset - _, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) testChannel = connA.NextTestChannel(ibctesting.TransferPort) counterpartyVersion = types.Version diff --git a/x/ibc/applications/transfer/spec/01_concepts.md b/x/ibc/applications/transfer/spec/01_concepts.md index a9e1a30ccb..96f05f12a7 100644 --- a/x/ibc/applications/transfer/spec/01_concepts.md +++ b/x/ibc/applications/transfer/spec/01_concepts.md @@ -9,7 +9,109 @@ order: 1 ICS20 uses the recommended acknowledgement format as specified by [ICS 04](https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope). A successful receive of a transfer packet will result in a Result Acknowledgement being written -with the value `[]byte(byte(1))` in the `Response` field. +with the value `[]byte(byte(1))` in the `Response` field. An unsuccessful receive of a transfer packet will result in an Error Acknowledgement being written -with the error message in the `Response` field. +with the error message in the `Response` field. + +## Denomination Trace + +The denomination trace corresponds to the information that allows a token to be traced back to its +origin chain. It contains a sequence of port and channel identifiers ordered from the most recent to +the oldest in the timeline of transfers. + +This information is included on the token denomination field in the form of a hash to prevent an +unbounded denomination length. For example, the token `transfer/channelToA/uatom` will be displayed +as `ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2`. + +Each send to any chain other than the one it was previously received from is a movement forwards in +the token's timeline. This causes trace to be added to the token's history and the destination port +and destination channel to be prefixed to the denomination. In these instances the sender chain is +acting as the "source zone". When the token is sent back to the chain it previously received from, the +prefix is removed. This is a backwards movement in the token's timeline and the sender chain is +acting as the "sink zone". + +It is strongly recommended to read the full details of [ADR 001: Coin Source Tracing](./../../../../../docs/architecture/adr-001-coin-source-tracing.md) to understand the implications and context of the IBC token representations. + +### UX suggestions for clients + +For clients (wallets, exchanges, applications, block explorers, etc) that want to display the source of the token, it is recommended to use the following +alternatives for each of the cases below: + +#### Direct connection + +If the denomination trace contains a single identifier prefix pair (as in the example above), then +the easiest way to retrieve the chain and light client identifier is to map the trace information +directly. In summary, this requires querying the channel from the denomination trace identifiers, +and then the counterparty client state using the counterparty port and channel identifiers from the +retrieved channel. + +A general pseudo algorithm would look like the following: + +1. Query the full denomination trace. +2. Query the channel with the `portID/channelID` pair, which corresponds to the first destination of the + token. +3. Query the client state using the identifiers pair. Note that this query will return a `"Not + Found"` response if the current chain is not connected to this channel. +4. Retrieve the the client identifier or chain identifier from the client state (eg: on + Tendermint clients) and store it locally. + +Using the gRPC gataway client service the steps above would be, with a given IBC token `ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2` stored on `chainB`: + +1. `GET /ibc_transfer/v1beta1/denom_traces/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2` -> `{"path": "transfer/channelToA", "base_denom": "uatom"}` +2. `GET /ibc/channel/v1beta1/channels/channelToA/ports/transfer/client_state"` -> `{"client_id": "clientA", "chain-id": "chainA", ...}` +3. `GET /ibc/channel/v1beta1/channels/channelToA/ports/transfer"` -> `{"channel_id": "channelToA", port_id": "transfer", counterparty: {"channel_id": "channelToB", port_id": "transfer"}, ...}` +4. `GET /ibc/channel/v1beta1/channels/channelToB/ports/transfer/client_state" -> {"client_id": "clientB", "chain-id": "chainB", ...}` + +Then, the token transfer chain path for the `uatom` denomination would be: `chainA` -> `chainB`. + +### Multiple hops + +The multiple channel hops case applies when the token has passed through multiple chains between the original source and final destination chains. + +The IBC protocol doesn't know the topology of the overall network (i.e connections between chains and identifier names between them). For this reason, in the the multiple hops case, a particular chain in the timeline of the individual transfers can't query the chain and client identifiers of the other chains. + +Take for example the following sequence of transfers `A -> B -> C` for an IBC token, with a final prefix path (trace info) of `transfer/channelChainC/transfer/channelChainB`. What the paragraph above means is that is that even in the case that chain `C` is directly connected to chain `A`, querying the port and channel identifiers that chain `B` uses to connect to chain `A` (eg: `transfer/channelChainA`) can be completely different from the one that chain `C` uses to connect to chain `A` (eg: `transfer/channelToChainA`). + +Thus the proposed solution for clients that the IBC team recommends are the following: + +- **Connect to all chains**: Connecting to all the chains in the timeline would allow clients to + perform the queries outlined in the [direct connection](#direct-connection) section to each + relevant chain. By repeatedly following the port and channel denomination trace transfer timeline, + clients should always be able to find all the relevant identifiers. This comes at the tradeoff + that the client must connect to nodes on each of the chains in order to perform the queries. +- **Relayer as a Service (RaaS)**: A longer term solution is to use/create a relayer service that + could map the denomination trace to the chain path timeline for each token (i.e `origin chain -> + chain #1 -> ... -> chain #(n-1) -> final chain`). These services could provide merkle proofs in + order to allow clients to optionally verify the path timeline correctness for themselves by + running light clients. If the proofs are not verified, they should be considered as trusted third + parties services. Additionally, client would be advised in the future to use RaaS that support the + largest number of connections between chains in the ecosystem. Unfortunately, none of the existing + public relayers (in [Golang](https://github.com/cosmos/relayer) and + [Rust](https://github.com/informalsystems/ibc-rs)), provide this service to clients. + +::: tip +The only viable alternative for clients (at the time of writing) to tokens with multiple connection hops, is to connect to all chains directly and perform relevant queries to each of them in the sequence. +::: + +## Locked Funds + +In some [exceptional cases](./../../../../../docs/architecture/adr-026-ibc-client-recovery-mechanisms.md#exceptional-cases), a client state associated with a given channel cannot be updated. This causes that funds from fungible tokens in that channel will be permanently locked and thus can no longer be transferred. + +To mitigate this, a client update governance proposal can be submitted to update the frozen client +with a new valid header. Once the proposal passes the client state will be unfrozen and the funds +from the associated channels will then be unlocked. This mechanism only applies to clients that +allow updates via governance, such as Tendermint clients. + +In addition to this, it's important to mention that a token must be sent back along the exact route +that it took originally un order to return it to its original form on the source chain (eg: the +Cosmos Hub for the `uatom`). Sending a token back to the same chain across a different channel will +**not** move the token back across its timeline. If a channel in the chain history closes before the +token can be sent back across that channel, then the token will not be returnable to its original +form. + + +## Security Considerations + +For safety, no other module must be capable of minting tokens with the `ibc/` prefix. The IBC +transfer module needs a subset of the denomination space that only it can create tokens in. diff --git a/x/ibc/applications/transfer/spec/02_state.md b/x/ibc/applications/transfer/spec/02_state.md index b57ac80f2a..9cab8d677f 100644 --- a/x/ibc/applications/transfer/spec/02_state.md +++ b/x/ibc/applications/transfer/spec/02_state.md @@ -3,3 +3,8 @@ order: 2 --> # State + +The transfer IBC application module keeps state of the port to which the module is binded and the denomination trace information as outlined in [ADR 01](./../../../../../docs/architecture/adr-001-coin-source-tracing.md). + +- `Port`: `0x01 -> ProtocolBuffer(string)` +- `DenomTrace`: `0x02 | []bytes(traceHash) -> ProtocolBuffer(DenomTrace)` diff --git a/x/ibc/applications/transfer/spec/03_state_transitions.md b/x/ibc/applications/transfer/spec/03_state_transitions.md index 4782e38a43..9090da5434 100644 --- a/x/ibc/applications/transfer/spec/03_state_transitions.md +++ b/x/ibc/applications/transfer/spec/03_state_transitions.md @@ -3,3 +3,34 @@ order: 3 --> # State Transitions + +## Send Fungible Tokens + +A successful fungible token send has two state transitions depending if the +transfer is a movement forward or backwards in the token's timeline: + +1. Sender chain is the source chain, *i.e* a transfer to any chain other than the one it was previously received from is a movement forwards in the token's timeline. This results in the following state transitions: + +- The coins are transferred to an escrow address (i.e locked) on the sender chain +- The coins are transferred to the receiving chain through IBC TAO logic. + +2. Sender chain is the sink chain, *i.e* the token is sent back to the chain it previously received from. This is a backwards movement in the token's timeline. This results in the following state transitions: + +- The coins (vouchers) are burned on the sender chain +- The coins transferred to the receiving chain though IBC TAO logic. + +## Receive Fungible Tokens + +A successful fungible token receive has two state transitions depending if the +transfer is a movement forward or backwards in the token's timeline: + +1. Receiver chain is the source chain. This is a backwards movement in the token's timeline. This results in the following state transitions: + +- The leftmost port and channel identifier pair is removed from the token denomination prefix. +- The tokens are unescrowed and sent to the receiving address. + +2. Receiver chain is the sink chain. This is a movement forwards in the token's timeline. This results in the following state transitions: + +- Token vouchers are minted by prefixing the destination port and channel identifiers to the trace information. +- The receiving chain stores the new trace information in the store (if not set already). +- The vouchers are sent to the receiving address. diff --git a/x/ibc/applications/transfer/spec/04_messages.md b/x/ibc/applications/transfer/spec/04_messages.md index dfd17d07f3..9da7673eb3 100644 --- a/x/ibc/applications/transfer/spec/04_messages.md +++ b/x/ibc/applications/transfer/spec/04_messages.md @@ -13,7 +13,7 @@ type MsgTransfer struct { SourcePort string SourceChannel string Token sdk.Coin - Sender sdk.AccAddress + Sender string Receiver string TimeoutHeight ibcexported.Height TimeoutTimestamp uint64 @@ -29,7 +29,7 @@ This message is expected to fail if: - `Sender` is empty - `Receiver` is empty - `TimeoutHeight` and `TimeoutTimestamp` are both zero -- `Token.Denom` is not a valid IBC denomination as per [ADR 001 - Coin Source Tracing](./../../../docs/architecture/adr-001-coin-source-tracing.md). +- `Token.Denom` is not a valid IBC denomination as per [ADR 001 - Coin Source Tracing](./../../../../../docs/architecture/adr-001-coin-source-tracing.md). This message will send a fungible token to the counterparty chain represented by the counterparty Channel End connected to the Channel End with the identifiers diff --git a/x/ibc/applications/transfer/spec/06_metrics.md b/x/ibc/applications/transfer/spec/06_metrics.md new file mode 100644 index 0000000000..21bb51c0a1 --- /dev/null +++ b/x/ibc/applications/transfer/spec/06_metrics.md @@ -0,0 +1,14 @@ + + +# Metrics + +The transfer IBC application module exposes the following set of [metrics](./../../../../../docs/core/telemetry.md). + +| Metric | Description | Unit | Type | +|:--------------------------------|:------------------------------------------------------------------------------------------|:----------------|:--------| +| `tx_msg_ibc_transfer` | The total amount of tokens transferred via IBC in a `MsgTransfer` (source or sink chain) | token | gauge | +| `ibc_transfer_packet_receive` | The total amount of tokens received in a `FungibleTokenPacketData` (source or sink chain) | token | gauge | +| `ibc_transfer_send` | Total number of IBC transfers sent from a chain (source or sink) | transfer | counter | +| `ibc_transfer_receive` | Total number of IBC transfers received to a chain (source or sink) | transfer | counter | diff --git a/x/ibc/applications/transfer/spec/06_params.md b/x/ibc/applications/transfer/spec/07_params.md similarity index 78% rename from x/ibc/applications/transfer/spec/06_params.md rename to x/ibc/applications/transfer/spec/07_params.md index e6c7e7ff1f..8d2b97c580 100644 --- a/x/ibc/applications/transfer/spec/06_params.md +++ b/x/ibc/applications/transfer/spec/07_params.md @@ -1,5 +1,5 @@ # Parameters @@ -17,7 +17,7 @@ The transfers enabled parameter controls send cross-chain transfer capabilities tokens. To prevent a single token from being transferred from the chain, set the `SendEnabled` parameter to `true` and -then set the bank module's [`SendEnabled` parameter](./../../bank/spec/05_params.md#sendenabled) for +then set the bank module's [`SendEnabled` parameter](./../../../../bank/spec/05_params.md#sendenabled) for the denomination to `false`. ## ReceiveEnabled @@ -26,5 +26,5 @@ The transfers enabled parameter controls receive cross-chain transfer capabiliti tokens. To prevent a single token from being transferred to the chain, set the `ReceiveEnabled` parameter to `true` and -then set the bank module's [`SendEnabled` parameter](./../../bank/spec/05_params.md#sendenabled) for +then set the bank module's [`SendEnabled` parameter](./../../../../bank/spec/05_params.md#sendenabled) for the denomination to `false`. diff --git a/x/ibc/applications/transfer/spec/README.md b/x/ibc/applications/transfer/spec/README.md index 963110e7a2..5230fdde41 100644 --- a/x/ibc/applications/transfer/spec/README.md +++ b/x/ibc/applications/transfer/spec/README.md @@ -20,4 +20,5 @@ For the general specification please refer to the [ICS20 Specification](https:// 3. **[State Transitions](03_state_transitions.md)** 4. **[Messages](04_messages.md)** 5. **[Events](05_events.md)** -6. **[Parameters](06_params.md)** +6. **[Metrics](06_metrics.md)** +7. **[Parameters](07_params.md)** diff --git a/x/ibc/applications/transfer/types/keys.go b/x/ibc/applications/transfer/types/keys.go index b9d4b3085e..f1fbffd951 100644 --- a/x/ibc/applications/transfer/types/keys.go +++ b/x/ibc/applications/transfer/types/keys.go @@ -25,6 +25,9 @@ const ( // QuerierRoute is the querier route for IBC transfer QuerierRoute = ModuleName + + // DenomPrefix is the prefix used for internal SDK coin representation. + DenomPrefix = "ibc" ) var ( diff --git a/x/ibc/applications/transfer/types/query.pb.go b/x/ibc/applications/transfer/types/query.pb.go index 27e1556325..ee069d3501 100644 --- a/x/ibc/applications/transfer/types/query.pb.go +++ b/x/ibc/applications/transfer/types/query.pb.go @@ -324,41 +324,40 @@ func init() { } var fileDescriptor_a638e2800a01538c = []byte{ - // 532 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0xaf, 0x37, 0xa8, 0xc4, 0x2b, 0xe2, 0x60, 0x26, 0xa8, 0xa2, 0x2a, 0x9b, 0xa2, 0x0a, 0xca, - 0x06, 0x36, 0x19, 0x7f, 0x4e, 0x88, 0xc3, 0x84, 0x40, 0xdc, 0x46, 0xe1, 0x80, 0xe0, 0x30, 0x39, - 0xa9, 0x49, 0x23, 0xd6, 0x38, 0x8b, 0xdd, 0x8a, 0x09, 0x71, 0xe1, 0x13, 0x20, 0xed, 0x4b, 0x20, - 0xc4, 0x87, 0xe0, 0xb8, 0xe3, 0x24, 0x2e, 0x9c, 0x00, 0xb5, 0x7c, 0x07, 0xae, 0x28, 0xb6, 0xb3, - 0xa6, 0xea, 0xe8, 0x96, 0x53, 0xad, 0xd7, 0xf7, 0x7b, 0xbf, 0x3f, 0xcf, 0x31, 0x74, 0xe2, 0x20, - 0xa4, 0x2c, 0x4d, 0x77, 0xe3, 0x90, 0xa9, 0x58, 0x24, 0x92, 0xaa, 0x8c, 0x25, 0xf2, 0x0d, 0xcf, - 0xe8, 0xc8, 0xa7, 0x7b, 0x43, 0x9e, 0xed, 0x93, 0x34, 0x13, 0x4a, 0xe0, 0x56, 0x1c, 0x84, 0xa4, - 0xdc, 0x49, 0x8a, 0x4e, 0x32, 0xf2, 0x9d, 0x95, 0x48, 0x44, 0x42, 0x37, 0xd2, 0xfc, 0x64, 0x30, - 0xce, 0x7a, 0x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6, 0x53, - 0x2e, 0x83, 0xba, 0x7e, 0x7f, 0xee, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x19, 0x46, 0xdf, 0x94, - 0x56, 0x05, 0x00, 0x00, + // 528 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x95, 0x12, 0x89, 0x17, 0xc4, 0x70, 0x54, 0x10, 0x59, 0x95, 0x5b, 0x59, 0x08, 0x02, + 0x85, 0x3b, 0x5c, 0xa0, 0x30, 0xa0, 0x0e, 0x15, 0x02, 0xb1, 0x95, 0xc0, 0x80, 0x60, 0x40, 0x67, + 0xe7, 0x70, 0x2c, 0x1a, 0x9f, 0xeb, 0xbb, 0x44, 0x54, 0x88, 0x85, 0x4f, 0x80, 0xc4, 0x8e, 0x98, + 0xd9, 0x19, 0xd8, 0x18, 0x3b, 0x56, 0x62, 0x61, 0x02, 0x94, 0xf0, 0x41, 0x90, 0xef, 0xce, 0x8d, + 0xa3, 0x20, 0x13, 0x4f, 0x39, 0x5d, 0xde, 0xef, 0xfd, 0xfe, 0xbc, 0xe7, 0x83, 0x4e, 0x1c, 0x84, + 0x94, 0xa5, 0xe9, 0x5e, 0x1c, 0x32, 0x15, 0x8b, 0x44, 0x52, 0x95, 0xb1, 0x44, 0xbe, 0xe4, 0x19, + 0x1d, 0xf9, 0x74, 0x7f, 0xc8, 0xb3, 0x03, 0x92, 0x66, 0x42, 0x09, 0xbc, 0x1a, 0x07, 0x21, 0x29, + 0x57, 0x92, 0xa2, 0x92, 0x8c, 0x7c, 0x67, 0x25, 0x12, 0x91, 0xd0, 0x85, 0x34, 0x3f, 0x19, 0x8c, + 0x73, 0x25, 0x14, 0x72, 0x20, 0x24, 0x0d, 0x98, 0xe4, 0xa6, 0x19, 0x1d, 0xf9, 0x01, 0x57, 0xcc, + 0xa7, 0x29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7d, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ibc/applications/transfer/types/query.pb.gw.go b/x/ibc/applications/transfer/types/query.pb.gw.go index 0e1dfd25ce..99a7f19063 100644 --- a/x/ibc/applications/transfer/types/query.pb.gw.go +++ b/x/ibc/applications/transfer/types/query.pb.gw.go @@ -310,11 +310,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_DenomTrace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"ibc_transfer", "v1beta1", "denom_traces", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_DenomTrace_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "applications", "transfer", "v1beta1", "denom_traces", "hash"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_DenomTraces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"ibc_transfer", "v1beta1", "denom_traces"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_DenomTraces_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "applications", "transfer", "v1beta1", "denom_traces"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"ibc_transfer", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "applications", "transfer", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/x/ibc/applications/transfer/types/trace.go b/x/ibc/applications/transfer/types/trace.go index 2e6ccded90..b4527d668f 100644 --- a/x/ibc/applications/transfer/types/trace.go +++ b/x/ibc/applications/transfer/types/trace.go @@ -54,7 +54,7 @@ func (dt DenomTrace) GetPrefix() string { // 'ibc/{hash(tracePath + baseDenom)}'. If the trace is empty, it will return the base denomination. func (dt DenomTrace) IBCDenom() string { if dt.Path != "" { - return fmt.Sprintf("ibc/%s", dt.Hash()) + return fmt.Sprintf("%s/%s", DenomPrefix, dt.Hash()) } return dt.BaseDenom } @@ -164,16 +164,20 @@ func ValidatePrefixedDenom(denom string) error { // - A valid base denomination (eg: 'uatom') // - A valid fungible token representation (i.e 'ibc/{hash}') per ADR 001 https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-001-coin-source-tracing.md func ValidateIBCDenom(denom string) error { + if err := sdk.ValidateDenom(denom); err != nil { + return err + } + denomSplit := strings.SplitN(denom, "/", 2) switch { case strings.TrimSpace(denom) == "", - len(denomSplit) == 1 && denomSplit[0] == "ibc", - len(denomSplit) == 2 && (denomSplit[0] != "ibc" || strings.TrimSpace(denomSplit[1]) == ""): + len(denomSplit) == 1 && denomSplit[0] == DenomPrefix, + len(denomSplit) == 2 && (denomSplit[0] != DenomPrefix || strings.TrimSpace(denomSplit[1]) == ""): return sdkerrors.Wrapf(ErrInvalidDenomForTransfer, "denomination should be prefixed with the format 'ibc/{hash(trace + \"/\" + %s)}'", denom) case denomSplit[0] == denom && strings.TrimSpace(denom) != "": - return sdk.ValidateDenom(denom) + return nil } if _, err := ParseHexHash(denomSplit[1]); err != nil { diff --git a/x/ibc/core/02-client/client/cli/cli.go b/x/ibc/core/02-client/client/cli/cli.go index 32aafc82c7..375d8f6369 100644 --- a/x/ibc/core/02-client/client/cli/cli.go +++ b/x/ibc/core/02-client/client/cli/cli.go @@ -24,6 +24,7 @@ func GetQueryCmd() *cobra.Command { GetCmdQueryConsensusState(), GetCmdQueryHeader(), GetCmdNodeConsensusState(), + GetCmdParams(), ) return queryCmd diff --git a/x/ibc/core/02-client/client/cli/query.go b/x/ibc/core/02-client/client/cli/query.go index 9d4ad4c19d..0140cb7850 100644 --- a/x/ibc/core/02-client/client/cli/query.go +++ b/x/ibc/core/02-client/client/cli/query.go @@ -250,3 +250,30 @@ func GetCmdNodeConsensusState() *cobra.Command { return cmd } + +// GetCmdParams returns the command handler for ibc client parameter querying. +func GetCmdParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current ibc client parameters", + Long: "Query the current ibc client parameters", + Args: cobra.NoArgs, + Example: fmt.Sprintf("%s query %s %s params", version.AppName, host.ModuleName, types.SubModuleName), + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.ReadQueryCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, _ := queryClient.ClientParams(context.Background(), &types.QueryClientParamsRequest{}) + return clientCtx.PrintOutput(res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/ibc/core/02-client/client/utils/utils.go b/x/ibc/core/02-client/client/utils/utils.go index bcd649ae77..200f6423fd 100644 --- a/x/ibc/core/02-client/client/utils/utils.go +++ b/x/ibc/core/02-client/client/utils/utils.go @@ -38,7 +38,7 @@ func QueryClientState( func QueryClientStateABCI( clientCtx client.Context, clientID string, ) (*types.QueryClientStateResponse, error) { - key := host.FullKeyClientPath(clientID, host.KeyClientState()) + key := host.FullClientStateKey(clientID) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { @@ -91,7 +91,7 @@ func QueryConsensusState( func QueryConsensusStateABCI( clientCtx client.Context, clientID string, height exported.Height, ) (*types.QueryConsensusStateResponse, error) { - key := host.FullKeyClientPath(clientID, host.KeyConsensusState(height)) + key := host.FullConsensusStateKey(clientID, height) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { diff --git a/x/ibc/core/02-client/genesis.go b/x/ibc/core/02-client/genesis.go index cda4f7ed7f..988e297c18 100644 --- a/x/ibc/core/02-client/genesis.go +++ b/x/ibc/core/02-client/genesis.go @@ -13,12 +13,18 @@ import ( // InitGenesis initializes the ibc client submodule's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { + k.SetParams(ctx, gs.Params) + for _, client := range gs.Clients { cs, ok := client.ClientState.GetCachedValue().(exported.ClientState) if !ok { panic("invalid client state") } + if !gs.Params.IsAllowedClient(cs.ClientType()) { + panic(fmt.Sprintf("client state type %s is not registered on the allowlist", cs.ClientType())) + } + k.SetClientState(ctx, client.ClientId, cs) } @@ -49,6 +55,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) { ctx.ChainID(), types.NewHeight(version, uint64(ctx.BlockHeight())), ) + if err := clientState.Validate(); err != nil { + panic(err) + } + if err := k.CreateClient(ctx, exported.Localhost, clientState, nil); err != nil { panic(err) } @@ -61,6 +71,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState { return types.GenesisState{ Clients: k.GetAllGenesisClients(ctx), ClientsConsensus: k.GetAllConsensusStates(ctx), + Params: k.GetParams(ctx), CreateLocalhost: false, } } diff --git a/x/ibc/core/02-client/keeper/client.go b/x/ibc/core/02-client/keeper/client.go index 49e9c62c88..5a6bb78d24 100644 --- a/x/ibc/core/02-client/keeper/client.go +++ b/x/ibc/core/02-client/keeper/client.go @@ -17,6 +17,14 @@ import ( func (k Keeper) CreateClient( ctx sdk.Context, clientID string, clientState exported.ClientState, consensusState exported.ConsensusState, ) error { + params := k.GetParams(ctx) + if !params.IsAllowedClient(clientState.ClientType()) { + return sdkerrors.Wrapf( + types.ErrInvalidClientType, + "client state type %s is not registered in the allowlist", clientState.ClientType(), + ) + } + _, found := k.GetClientState(ctx, clientID) if found { return sdkerrors.Wrapf(types.ErrClientExists, "cannot create client with ID %s", clientID) @@ -110,21 +118,22 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e return sdkerrors.Wrapf(types.ErrClientFrozen, "cannot update client with ID %s", clientID) } - err := clientState.VerifyUpgrade(ctx, k.cdc, k.ClientStore(ctx, clientID), upgradedClient, upgradeHeight, proofUpgrade) + updatedClientState, updatedConsensusState, err := clientState.VerifyUpgradeAndUpdateState(ctx, k.cdc, k.ClientStore(ctx, clientID), upgradedClient, upgradeHeight, proofUpgrade) if err != nil { return sdkerrors.Wrapf(err, "cannot upgrade client with ID %s", clientID) } - k.SetClientState(ctx, clientID, upgradedClient) + k.SetClientState(ctx, clientID, updatedClientState) + k.SetClientConsensusState(ctx, clientID, updatedClientState.GetLatestHeight(), updatedConsensusState) - k.Logger(ctx).Info("client state upgraded", "client-id", clientID, "height", upgradedClient.GetLatestHeight().String()) + k.Logger(ctx).Info("client state upgraded", "client-id", clientID, "height", updatedClientState.GetLatestHeight().String()) defer func() { telemetry.IncrCounterWithLabels( []string{"ibc", "client", "upgrade"}, 1, []metrics.Label{ - telemetry.NewLabel("client-type", clientState.ClientType()), + telemetry.NewLabel("client-type", updatedClientState.ClientType()), telemetry.NewLabel("client-id", clientID), }, ) @@ -135,8 +144,8 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e sdk.NewEvent( types.EventTypeUpgradeClient, sdk.NewAttribute(types.AttributeKeyClientID, clientID), - sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), - sdk.NewAttribute(types.AttributeKeyConsensusHeight, upgradedClient.GetLatestHeight().String()), + sdk.NewAttribute(types.AttributeKeyClientType, updatedClientState.ClientType()), + sdk.NewAttribute(types.AttributeKeyConsensusHeight, updatedClientState.GetLatestHeight().String()), ), ) diff --git a/x/ibc/core/02-client/keeper/client_test.go b/x/ibc/core/02-client/keeper/client_test.go index 31cf5d80fe..c2f5c8144a 100644 --- a/x/ibc/core/02-client/keeper/client_test.go +++ b/x/ibc/core/02-client/keeper/client_test.go @@ -6,7 +6,6 @@ import ( tmtypes "github.com/tendermint/tendermint/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" @@ -34,11 +33,11 @@ func (suite *KeeperTestSuite) TestCreateClient() { i := i if tc.expPanic { suite.Require().Panics(func() { - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) suite.keeper.CreateClient(suite.ctx, tc.clientID, clientState, suite.consensusState) }, "Msg %d didn't panic: %s", i, tc.msg) } else { - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) if tc.expPass { suite.Require().NotNil(clientState, "valid test case %d failed: %s", i, tc.msg) } @@ -81,7 +80,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { expPass bool }{ {"valid update", func() error { - clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) // store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height @@ -99,7 +98,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { return err }, true}, {"valid past update", func() error { - clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) suite.Require().NoError(err) @@ -132,7 +131,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { return nil }, false}, {"consensus state not found", func() error { - clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) suite.keeper.SetClientState(suite.ctx, testClientID, clientState) updateHeader = createFutureUpdateFn(suite) @@ -146,7 +145,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { return nil }, false}, {"valid past update before client was frozen", func() error { - clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) clientState.FrozenHeight = types.NewHeight(0, testClientHeight.VersionHeight-1) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) suite.Require().NoError(err) @@ -166,7 +165,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { return nil }, true}, {"invalid header", func() error { - clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState = ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) suite.Require().NoError(err) updateHeader = createPastUpdateFn(suite) @@ -251,7 +250,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { name: "successful upgrade", setup: func() { - upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -262,7 +261,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -276,7 +275,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { name: "client state not found", setup: func() { - upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -287,7 +286,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -303,7 +302,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { name: "client state frozen", setup: func() { - upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -314,7 +313,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -334,7 +333,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { name: "tendermint client VerifyUpgrade fails", setup: func() { - upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -343,10 +342,10 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) // change upgradedClient client-specified parameters - upgradedClient = ibctmtypes.NewClientState("wrongchainID", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, true, true) + upgradedClient = ibctmtypes.NewClientState("wrongchainID", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, true, true) suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -360,7 +359,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { for _, tc := range testCases { tc := tc - clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) tc.setup() @@ -379,7 +378,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { altPrivVal := ibctestingmock.NewPV() altPubKey, err := altPrivVal.GetPubKey() suite.Require().NoError(err) - altVal := tmtypes.NewValidator(altPubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 4) + altVal := tmtypes.NewValidator(altPubKey, 4) // Set valSet here with suite.valSet so it doesn't get reset on each testcase valSet := suite.valSet @@ -414,12 +413,11 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeight, altTime, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeight, suite.ctx.BlockTime(), bothValSet, bothValSet, bothSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { suite.consensusState.NextValidatorsHash = bothValsHash - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) return err @@ -431,12 +429,11 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), testClientHeight, altTime, bothValSet, valSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), testClientHeight, suite.ctx.BlockTime(), bothValSet, valSet, bothSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { suite.consensusState.NextValidatorsHash = valsHash - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) // store intermediate consensus state to check that trustedHeight does not need to be highest consensus state before header height @@ -458,12 +455,11 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), testClientHeight, altTime, bothValSet, valSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), heightPlus3, suite.ctx.BlockTime(), bothValSet, bothValSet, bothSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { suite.consensusState.NextValidatorsHash = valsHash - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) // store trusted consensus state for Header2 @@ -485,12 +481,11 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), heightPlus3, altTime, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), testClientHeight, suite.ctx.BlockTime(), bothValSet, valSet, bothSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { suite.consensusState.NextValidatorsHash = valsHash - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) // intermediate consensus state at height + 3 is not created return err @@ -502,12 +497,11 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), testClientHeight, altTime, bothValSet, valSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(heightPlus5.VersionHeight), heightPlus3, suite.ctx.BlockTime(), bothValSet, bothValSet, bothSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { suite.consensusState.NextValidatorsHash = valsHash - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) // intermediate consensus state at height + 3 is not created return err @@ -525,12 +519,11 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeight, altTime, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeight, suite.ctx.BlockTime(), bothValSet, bothValSet, bothSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { suite.consensusState.NextValidatorsHash = bothValsHash - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) err := suite.keeper.CreateClient(suite.ctx, testClientID, clientState, suite.consensusState) clientState.FrozenHeight = types.NewHeight(0, 1) @@ -545,11 +538,10 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { &ibctmtypes.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeight, altTime, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeight, suite.ctx.BlockTime(), altValSet, bothValSet, altSigners), - ChainId: testChainID, ClientId: testClientID, }, func() error { - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) if err != nil { return err } diff --git a/x/ibc/core/02-client/keeper/grpc_query.go b/x/ibc/core/02-client/keeper/grpc_query.go index eeb3c10b8f..9f4bb6c808 100644 --- a/x/ibc/core/02-client/keeper/grpc_query.go +++ b/x/ibc/core/02-client/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "sort" "strings" "google.golang.org/grpc/codes" @@ -58,7 +59,7 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ ctx := sdk.UnwrapSDKContext(c) - clientStates := []*types.IdentifiedClientState{} + clientStates := types.IdentifiedClientStates{} store := prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyClientStorePrefix) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { @@ -78,7 +79,7 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ } identifiedClient := types.NewIdentifiedClientState(clientID, clientState) - clientStates = append(clientStates, &identifiedClient) + clientStates = append(clientStates, identifiedClient) return nil }) @@ -86,6 +87,8 @@ func (q Keeper) ClientStates(c context.Context, req *types.QueryClientStatesRequ return nil, err } + sort.Sort(clientStates) + return &types.QueryClientStatesResponse{ ClientStates: clientStates, Pagination: pageRes, @@ -152,7 +155,7 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat ctx := sdk.UnwrapSDKContext(c) consensusStates := []types.ConsensusStateWithHeight{} - store := prefix.NewStore(ctx.KVStore(q.storeKey), host.FullKeyClientPath(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatesPrefix)))) + store := prefix.NewStore(ctx.KVStore(q.storeKey), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { height, err := types.ParseHeight(string(key)) @@ -178,3 +181,13 @@ func (q Keeper) ConsensusStates(c context.Context, req *types.QueryConsensusStat Pagination: pageRes, }, nil } + +// ClientParams implements the Query/ClientParams gRPC method +func (q Keeper) ClientParams(c context.Context, _ *types.QueryClientParamsRequest) (*types.QueryClientParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + params := q.GetParams(ctx) + + return &types.QueryClientParamsResponse{ + Params: ¶ms, + }, nil +} diff --git a/x/ibc/core/02-client/keeper/grpc_query_test.go b/x/ibc/core/02-client/keeper/grpc_query_test.go index b99d290f84..a252005fc9 100644 --- a/x/ibc/core/02-client/keeper/grpc_query_test.go +++ b/x/ibc/core/02-client/keeper/grpc_query_test.go @@ -43,7 +43,7 @@ func (suite *KeeperTestSuite) TestQueryClientState() { { "success", func() { - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) suite.keeper.SetClientState(suite.ctx, testClientID, clientState) var err error @@ -82,7 +82,7 @@ func (suite *KeeperTestSuite) TestQueryClientState() { func (suite *KeeperTestSuite) TestQueryClientStates() { var ( req *types.QueryClientStatesRequest - expClientStates = []*types.IdentifiedClientState(nil) + expClientStates = types.IdentifiedClientStates{} ) testCases := []struct { @@ -112,8 +112,8 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { { "success", func() { - clientA1, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) - clientA2, _ := suite.coordinator.CreateClient(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA1, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) + clientA2, _ := suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint) clientStateA1 := suite.chainA.GetClientState(clientA1) clientStateA2 := suite.chainA.GetClientState(clientA2) @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { idcs2 := types.NewIdentifiedClientState(clientA2, clientStateA2) // order is sorted by client id, localhost is last - expClientStates = []*types.IdentifiedClientState{&idcs, &idcs2} + expClientStates = types.IdentifiedClientStates{idcs, idcs2}.Sort() req = &types.QueryClientStatesRequest{ Pagination: &query.PageRequest{ Limit: 7, @@ -144,7 +144,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { // always add localhost which is created by default in init genesis localhostClientState := suite.chainA.GetClientState(exported.Localhost) identifiedLocalhost := types.NewIdentifiedClientState(exported.Localhost, localhostClientState) - expClientStates = append(expClientStates, &identifiedLocalhost) + expClientStates = append(expClientStates, identifiedLocalhost) ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) @@ -153,12 +153,7 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(len(expClientStates), len(res.ClientStates)) - for i := range expClientStates { - suite.Require().Equal(expClientStates[i].ClientId, res.ClientStates[i].ClientId) - suite.Require().NotNil(res.ClientStates[i].ClientState) - suite.Require().Equal(expClientStates[i].ClientState, res.ClientStates[i].ClientState) - } + suite.Require().Equal(expClientStates.Sort(), res.ClientStates) } else { suite.Require().Error(err) } @@ -209,7 +204,7 @@ func (suite *KeeperTestSuite) TestQueryConsensusState() { { "success latest height", func() { - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) cs := ibctmtypes.NewConsensusState( suite.consensusState.Timestamp, commitmenttypes.NewMerkleRoot([]byte("hash1")), nil, ) @@ -364,3 +359,10 @@ func (suite *KeeperTestSuite) TestQueryConsensusStates() { }) } } + +func (suite *KeeperTestSuite) TestQueryParams() { + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + expParams := types.DefaultParams() + res, _ := suite.queryClient.ClientParams(ctx, &types.QueryClientParamsRequest{}) + suite.Require().Equal(&expParams, res.Params) +} diff --git a/x/ibc/core/02-client/keeper/keeper.go b/x/ibc/core/02-client/keeper/keeper.go index 8af73dd75a..d3465e7669 100644 --- a/x/ibc/core/02-client/keeper/keeper.go +++ b/x/ibc/core/02-client/keeper/keeper.go @@ -18,6 +18,7 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -26,14 +27,21 @@ import ( type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryMarshaler + paramSpace paramtypes.Subspace stakingKeeper types.StakingKeeper } // NewKeeper creates a new NewKeeper instance -func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, sk types.StakingKeeper) Keeper { +func NewKeeper(cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace, sk types.StakingKeeper) Keeper { + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + return Keeper{ storeKey: key, cdc: cdc, + paramSpace: paramSpace, stakingKeeper: sk, } } @@ -46,7 +54,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // GetClientState gets a particular client from the store func (k Keeper) GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool) { store := k.ClientStore(ctx, clientID) - bz := store.Get(host.KeyClientState()) + bz := store.Get(host.ClientStateKey()) if bz == nil { return nil, false } @@ -58,13 +66,13 @@ func (k Keeper) GetClientState(ctx sdk.Context, clientID string) (exported.Clien // SetClientState sets a particular Client to the store func (k Keeper) SetClientState(ctx sdk.Context, clientID string, clientState exported.ClientState) { store := k.ClientStore(ctx, clientID) - store.Set(host.KeyClientState(), k.MustMarshalClientState(clientState)) + store.Set(host.ClientStateKey(), k.MustMarshalClientState(clientState)) } // GetClientConsensusState gets the stored consensus state from a client at a given height. func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) { store := k.ClientStore(ctx, clientID) - bz := store.Get(host.KeyConsensusState(height)) + bz := store.Get(host.ConsensusStateKey(height)) if bz == nil { return nil, false } @@ -77,7 +85,7 @@ func (k Keeper) GetClientConsensusState(ctx sdk.Context, clientID string, height // height func (k Keeper) SetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height, consensusState exported.ConsensusState) { store := k.ClientStore(ctx, clientID) - store.Set(host.KeyConsensusState(height), k.MustMarshalConsensusState(consensusState)) + store.Set(host.ConsensusStateKey(height), k.MustMarshalConsensusState(consensusState)) } // IterateConsensusStates provides an iterator over all stored consensus states. @@ -91,7 +99,7 @@ func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") // consensus key is in the format "clients//consensusStates/" - if len(keySplit) != 4 || keySplit[2] != string(host.KeyConsensusStatesPrefix) { + if len(keySplit) != 4 || keySplit[2] != string(host.KeyConsensusStatePrefix) { continue } clientID := keySplit[1] @@ -107,12 +115,14 @@ func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, } // GetAllGenesisClients returns all the clients in state with their client ids returned as IdentifiedClientState -func (k Keeper) GetAllGenesisClients(ctx sdk.Context) (genClients []types.IdentifiedClientState) { +func (k Keeper) GetAllGenesisClients(ctx sdk.Context) types.IdentifiedClientStates { + var genClients types.IdentifiedClientStates k.IterateClients(ctx, func(clientID string, cs exported.ClientState) bool { genClients = append(genClients, types.NewIdentifiedClientState(clientID, cs)) return false }) - return + + return genClients.Sort() } // GetAllConsensusStates returns all stored client consensus states. @@ -144,7 +154,7 @@ func (k Keeper) GetAllConsensusStates(ctx sdk.Context) types.ClientsConsensusSta // client at the given height func (k Keeper) HasClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) bool { store := k.ClientStore(ctx, clientID) - return store.Has(host.KeyConsensusState(height)) + return store.Has(host.ConsensusStateKey(height)) } // GetLatestClientConsensusState gets the latest ConsensusState stored for a given client @@ -215,13 +225,6 @@ func (k Keeper) ValidateSelfClient(ctx sdk.Context, clientState exported.ClientS tmClient.LatestHeight, ctx.BlockHeight()) } - // consensus params must match consensus params on executing chain - expectedConsensusParams := ctx.ConsensusParams() - if !reflect.DeepEqual(expectedConsensusParams, tmClient.ConsensusParams) { - return sdkerrors.Wrapf(types.ErrInvalidClient, "client has invalid consensus params, expected: %v got: %v", - expectedConsensusParams, tmClient.ConsensusParams) - } - expectedProofSpecs := commitmenttypes.GetSDKSpecs() if !reflect.DeepEqual(expectedProofSpecs, tmClient.ProofSpecs) { return sdkerrors.Wrapf(types.ErrInvalidClient, "client has invalid proof specs. expected: %v got: %v", @@ -266,7 +269,7 @@ func (k Keeper) IterateClients(ctx sdk.Context, cb func(clientID string, cs expo defer iterator.Close() for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - if keySplit[len(keySplit)-1] != "clientState" { + if keySplit[len(keySplit)-1] != host.KeyClientState { continue } clientState := k.MustUnmarshalClientState(iterator.Value()) @@ -291,8 +294,6 @@ func (k Keeper) GetAllClients(ctx sdk.Context) (states []exported.ClientState) { // ClientStore returns isolated prefix store for each client so they can read/write in separate // namespace without being able to read/write other client's data func (k Keeper) ClientStore(ctx sdk.Context, clientID string) sdk.KVStore { - // append here is safe, appends within a function won't cause - // weird side effects when its singlethreaded - clientPrefix := append([]byte("clients/"+clientID), '/') + clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID)) return prefix.NewStore(ctx.KVStore(k.storeKey), clientPrefix) } diff --git a/x/ibc/core/02-client/keeper/keeper_test.go b/x/ibc/core/02-client/keeper/keeper_test.go index 24675f4e9a..2ed2b2f032 100644 --- a/x/ibc/core/02-client/keeper/keeper_test.go +++ b/x/ibc/core/02-client/keeper/keeper_test.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/keeper" @@ -91,7 +91,7 @@ func (suite *KeeperTestSuite) SetupTest() { testClientHeightMinus1 := types.NewHeight(0, height-1) - validator := tmtypes.NewValidator(pubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 1) + validator := tmtypes.NewValidator(pubKey, 1) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) suite.valSetHash = suite.valSet.Hash() suite.header = suite.chainA.CreateTMClientHeader(testChainID, int64(testClientHeight.VersionHeight), testClientHeightMinus1, now2, suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) @@ -100,7 +100,9 @@ func (suite *KeeperTestSuite) SetupTest() { var validators stakingtypes.Validators for i := 1; i < 11; i++ { privVal := ibctestingmock.NewPV() - pk, err := privVal.GetPubKey() + tmPk, err := privVal.GetPubKey() + suite.Require().NoError(err) + pk, err := cryptocodec.FromTmPubKeyInterface(tmPk) suite.Require().NoError(err) val, err := stakingtypes.NewValidator(sdk.ValAddress(pk.Address()), pk, stakingtypes.Description{}) suite.Require().NoError(err) @@ -130,7 +132,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestSetClientState() { - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) suite.keeper.SetClientState(suite.ctx, testClientID, clientState) retrievedState, found := suite.keeper.GetClientState(suite.ctx, testClientID) @@ -150,8 +152,6 @@ func (suite *KeeperTestSuite) TestSetClientConsensusState() { } func (suite *KeeperTestSuite) TestValidateSelfClient() { - invalidConsensusParams := suite.chainA.GetContext().ConsensusParams() - invalidConsensusParams.Evidence.MaxAgeDuration++ testClientHeight := types.NewHeight(0, uint64(suite.chainA.GetContext().BlockHeight())) testCases := []struct { @@ -161,12 +161,12 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() { }{ { "success", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), true, }, { "success with nil UpgradePath", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), "", false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), "", false, false), true, }, { @@ -176,57 +176,47 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() { }, { "frozen client", - &ibctmtypes.ClientState{suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false}, + &ibctmtypes.ClientState{suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false}, false, }, { "incorrect chainID", - ibctmtypes.NewClientState("gaiatestnet", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState("gaiatestnet", ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), false, }, { "invalid client height", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.NewHeight(0, testClientHeight.VersionHeight+10), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.NewHeight(0, testClientHeight.VersionHeight+10), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), false, }, { "invalid client version", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeightVersion1, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeightVersion1, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), false, }, { "invalid proof specs", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, nil, ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, nil, ibctesting.UpgradePath, false, false), false, }, { "invalid trust level", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.Fraction{0, 1}, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.Fraction{0, 1}, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), false, }, { "invalid unbonding period", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+10, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod+10, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), false, }, { "invalid trusting period", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ubdPeriod+10, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ubdPeriod+10, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), false, }, { "invalid upgrade path", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), "bad/upgrade/path", false, false), - false, - }, - { - "invalid consensus params", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, invalidConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), - false, - }, - { - "nil consensus params", - ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, nil, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), "bad/upgrade/path", false, false), false, }, } @@ -241,41 +231,17 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() { } } -func (suite KeeperTestSuite) TestGetAllClients() { - clientIDs := []string{ - testClientID2, testClientID3, testClientID, - } - expClients := []exported.ClientState{ - ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), - ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), - ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), - } - - for i := range expClients { - suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientIDs[i], expClients[i]) - } - - // add localhost client - localHostClient, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), exported.Localhost) - suite.Require().True(found) - expClients = append(expClients, localHostClient) - - clients := suite.chainA.App.IBCKeeper.ClientKeeper.GetAllClients(suite.chainA.GetContext()) - suite.Require().Len(clients, len(expClients)) - suite.Require().Equal(expClients, clients) -} - func (suite KeeperTestSuite) TestGetAllGenesisClients() { clientIDs := []string{ testClientID2, testClientID3, testClientID, } expClients := []exported.ClientState{ - ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), - ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), - ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, types.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), } - expGenClients := make([]types.IdentifiedClientState, len(expClients)) + expGenClients := make(types.IdentifiedClientStates, len(expClients)) for i := range expClients { suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientIDs[i], expClients[i]) @@ -289,7 +255,7 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() { genClients := suite.chainA.App.IBCKeeper.ClientKeeper.GetAllGenesisClients(suite.chainA.GetContext()) - suite.Require().Equal(expGenClients, genClients) + suite.Require().Equal(expGenClients.Sort(), genClients) } func (suite KeeperTestSuite) TestGetConsensusState() { @@ -320,7 +286,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() { func (suite KeeperTestSuite) TestConsensusStateHelpers() { // initial setup - clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) suite.keeper.SetClientState(suite.ctx, testClientID, clientState) suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState) @@ -345,7 +311,7 @@ func (suite KeeperTestSuite) TestConsensusStateHelpers() { // 2 clients in total are created on chainA. The first client is updated so it contains an initial consensus state // and a consensus state at the update height. func (suite KeeperTestSuite) TestGetAllConsensusStates() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) expConsensusHeight0 := clientState.GetLatestHeight() @@ -353,7 +319,7 @@ func (suite KeeperTestSuite) TestGetAllConsensusStates() { suite.Require().True(ok) // update client to create a second consensus state - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) clientState = suite.chainA.GetClientState(clientA) @@ -368,7 +334,7 @@ func (suite KeeperTestSuite) TestGetAllConsensusStates() { } // create second client on chainA - clientA2, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA2, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState = suite.chainA.GetClientState(clientA2) expConsensusHeight2 := clientState.GetLatestHeight() diff --git a/x/ibc/core/02-client/keeper/params.go b/x/ibc/core/02-client/keeper/params.go new file mode 100644 index 0000000000..04f4a25637 --- /dev/null +++ b/x/ibc/core/02-client/keeper/params.go @@ -0,0 +1,23 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" +) + +// GetAllowedClients retrieves the receive enabled boolean from the paramstore +func (k Keeper) GetAllowedClients(ctx sdk.Context) []string { + var res []string + k.paramSpace.Get(ctx, types.KeyAllowedClients, &res) + return res +} + +// GetParams returns the total set of ibc-transfer parameters. +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams(k.GetAllowedClients(ctx)...) +} + +// SetParams sets the total set of ibc-transfer parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} diff --git a/x/ibc/core/02-client/keeper/params_test.go b/x/ibc/core/02-client/keeper/params_test.go new file mode 100644 index 0000000000..9df0859710 --- /dev/null +++ b/x/ibc/core/02-client/keeper/params_test.go @@ -0,0 +1,17 @@ +package keeper_test + +import ( + "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" +) + +func (suite *KeeperTestSuite) TestParams() { + expParams := types.DefaultParams() + + params := suite.chainA.App.IBCKeeper.ClientKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Equal(expParams, params) + + expParams.AllowedClients = []string{} + suite.chainA.App.IBCKeeper.ClientKeeper.SetParams(suite.chainA.GetContext(), expParams) + params = suite.chainA.App.IBCKeeper.ClientKeeper.GetParams(suite.chainA.GetContext()) + suite.Require().Empty(expParams.AllowedClients) +} diff --git a/x/ibc/core/02-client/keeper/proposal_test.go b/x/ibc/core/02-client/keeper/proposal_test.go index ea5cd372fa..ada205402b 100644 --- a/x/ibc/core/02-client/keeper/proposal_test.go +++ b/x/ibc/core/02-client/keeper/proposal_test.go @@ -21,7 +21,7 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() { }{ { "valid update client proposal", func() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) tmClientState, ok := clientState.(*ibctmtypes.ClientState) @@ -58,14 +58,14 @@ func (suite *KeeperTestSuite) TestClientUpdateProposal() { }, { "cannot unpack header, header is nil", func() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) content = &clienttypes.ClientUpdateProposal{ibctesting.Title, ibctesting.Description, clientA, nil} }, false, }, { "update fails", func() { header := &ibctmtypes.Header{} - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) content, err = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, clientA, header) suite.Require().NoError(err) }, false, diff --git a/x/ibc/core/02-client/proposal_handler_test.go b/x/ibc/core/02-client/proposal_handler_test.go index 839dd2e532..91c1451b70 100644 --- a/x/ibc/core/02-client/proposal_handler_test.go +++ b/x/ibc/core/02-client/proposal_handler_test.go @@ -6,6 +6,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" client "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -23,7 +24,7 @@ func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() { }{ { "valid update client proposal", func() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) tmClientState, ok := clientState.(*ibctmtypes.ClientState) diff --git a/x/ibc/core/02-client/simulation/decoder.go b/x/ibc/core/02-client/simulation/decoder.go index a5cff11d42..03a803b1b1 100644 --- a/x/ibc/core/02-client/simulation/decoder.go +++ b/x/ibc/core/02-client/simulation/decoder.go @@ -22,12 +22,12 @@ type ClientUnmarshaler interface { // Value to the corresponding client type. func NewDecodeStore(cdc ClientUnmarshaler, kvA, kvB kv.Pair) (string, bool) { switch { - case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyClientState()): + case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, []byte(host.KeyClientState)): clientStateA := cdc.MustUnmarshalClientState(kvA.Value) clientStateB := cdc.MustUnmarshalClientState(kvB.Value) return fmt.Sprintf("ClientState A: %v\nClientState B: %v", clientStateA, clientStateB), true - case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.Contains(kvA.Key, []byte("consensusState")): + case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.Contains(kvA.Key, []byte(host.KeyConsensusStatePrefix)): consensusStateA := cdc.MustUnmarshalConsensusState(kvA.Value) consensusStateB := cdc.MustUnmarshalConsensusState(kvB.Value) return fmt.Sprintf("ConsensusState A: %v\nConsensusState B: %v", consensusStateA, consensusStateB), true diff --git a/x/ibc/core/02-client/simulation/decoder_test.go b/x/ibc/core/02-client/simulation/decoder_test.go index 6ee442eabf..095834ba0d 100644 --- a/x/ibc/core/02-client/simulation/decoder_test.go +++ b/x/ibc/core/02-client/simulation/decoder_test.go @@ -32,11 +32,11 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ { - Key: host.FullKeyClientPath(clientID, host.KeyClientState()), + Key: host.FullClientStateKey(clientID), Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState), }, { - Key: host.FullKeyClientPath(clientID, host.KeyConsensusState(height)), + Key: host.FullConsensusStateKey(clientID, height), Value: app.IBCKeeper.ClientKeeper.MustMarshalConsensusState(consState), }, { diff --git a/x/ibc/core/02-client/types/client.go b/x/ibc/core/02-client/types/client.go index 99fe98e19e..305b07cec4 100644 --- a/x/ibc/core/02-client/types/client.go +++ b/x/ibc/core/02-client/types/client.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "sort" proto "github.com/gogo/protobuf/proto" @@ -37,6 +38,26 @@ func (ics IdentifiedClientState) UnpackInterfaces(unpacker codectypes.AnyUnpacke return unpacker.UnpackAny(ics.ClientState, new(exported.ClientState)) } +var _ sort.Interface = IdentifiedClientStates{} + +// IdentifiedClientStates defines a slice of ClientConsensusStates that supports the sort interface +type IdentifiedClientStates []IdentifiedClientState + +// Len implements sort.Interface +func (ics IdentifiedClientStates) Len() int { return len(ics) } + +// Less implements sort.Interface +func (ics IdentifiedClientStates) Less(i, j int) bool { return ics[i].ClientId < ics[j].ClientId } + +// Swap implements sort.Interface +func (ics IdentifiedClientStates) Swap(i, j int) { ics[i], ics[j] = ics[j], ics[i] } + +// Sort is a helper function to sort the set of IdentifiedClientStates in place +func (ics IdentifiedClientStates) Sort() IdentifiedClientStates { + sort.Sort(ics) + return ics +} + // NewConsensusStateWithHeight creates a new ConsensusStateWithHeight instance func NewConsensusStateWithHeight(height Height, consensusState exported.ConsensusState) ConsensusStateWithHeight { msg, ok := consensusState.(proto.Message) diff --git a/x/ibc/core/02-client/types/client.pb.go b/x/ibc/core/02-client/types/client.pb.go index aa9bd5c3d3..95fc58c339 100644 --- a/x/ibc/core/02-client/types/client.pb.go +++ b/x/ibc/core/02-client/types/client.pb.go @@ -4,15 +4,10 @@ package types import ( - context "context" fmt "fmt" types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" @@ -29,370 +24,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgCreateClient defines a message to create an IBC client -type MsgCreateClient struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - // light client state - ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` - // consensus state associated with the client that corresponds to a given - // height. - ConsensusState *types.Any `protobuf:"bytes,3,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` - // signer address - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgCreateClient) Reset() { *m = MsgCreateClient{} } -func (m *MsgCreateClient) String() string { return proto.CompactTextString(m) } -func (*MsgCreateClient) ProtoMessage() {} -func (*MsgCreateClient) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{0} -} -func (m *MsgCreateClient) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateClient.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgCreateClient) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateClient.Merge(m, src) -} -func (m *MsgCreateClient) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateClient) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateClient.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateClient proto.InternalMessageInfo - -// MsgCreateClientResponse defines the Msg/CreateClient response type. -type MsgCreateClientResponse struct { -} - -func (m *MsgCreateClientResponse) Reset() { *m = MsgCreateClientResponse{} } -func (m *MsgCreateClientResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateClientResponse) ProtoMessage() {} -func (*MsgCreateClientResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{1} -} -func (m *MsgCreateClientResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateClientResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgCreateClientResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateClientResponse.Merge(m, src) -} -func (m *MsgCreateClientResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateClientResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateClientResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateClientResponse proto.InternalMessageInfo - -// MsgUpdateClient defines an sdk.Msg to update a IBC client state using -// the given header. -type MsgUpdateClient struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - // header to update the light client - Header *types.Any `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgUpdateClient) Reset() { *m = MsgUpdateClient{} } -func (m *MsgUpdateClient) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateClient) ProtoMessage() {} -func (*MsgUpdateClient) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{2} -} -func (m *MsgUpdateClient) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateClient.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateClient) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateClient.Merge(m, src) -} -func (m *MsgUpdateClient) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateClient) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateClient.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateClient proto.InternalMessageInfo - -// MsgUpdateClientResponse defines the Msg/UpdateClient response type. -type MsgUpdateClientResponse struct { -} - -func (m *MsgUpdateClientResponse) Reset() { *m = MsgUpdateClientResponse{} } -func (m *MsgUpdateClientResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateClientResponse) ProtoMessage() {} -func (*MsgUpdateClientResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{3} -} -func (m *MsgUpdateClientResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpdateClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpdateClientResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpdateClientResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateClientResponse.Merge(m, src) -} -func (m *MsgUpdateClientResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpdateClientResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateClientResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpdateClientResponse proto.InternalMessageInfo - -// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state -type MsgUpgradeClient struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - // upgraded client state - ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` - // height at which old chain halts and upgrades (i.e last block executed) - UpgradeHeight *Height `protobuf:"bytes,3,opt,name=upgrade_height,json=upgradeHeight,proto3" json:"upgrade_height,omitempty" yaml:"upgrade_height"` - // proof that old chain committed to new client - ProofUpgrade []byte `protobuf:"bytes,4,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty" yaml:"proof_upgrade"` - // signer address - Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgUpgradeClient) Reset() { *m = MsgUpgradeClient{} } -func (m *MsgUpgradeClient) String() string { return proto.CompactTextString(m) } -func (*MsgUpgradeClient) ProtoMessage() {} -func (*MsgUpgradeClient) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{4} -} -func (m *MsgUpgradeClient) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpgradeClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpgradeClient.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpgradeClient) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpgradeClient.Merge(m, src) -} -func (m *MsgUpgradeClient) XXX_Size() int { - return m.Size() -} -func (m *MsgUpgradeClient) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpgradeClient.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpgradeClient proto.InternalMessageInfo - -func (m *MsgUpgradeClient) GetClientId() string { - if m != nil { - return m.ClientId - } - return "" -} - -func (m *MsgUpgradeClient) GetClientState() *types.Any { - if m != nil { - return m.ClientState - } - return nil -} - -func (m *MsgUpgradeClient) GetUpgradeHeight() *Height { - if m != nil { - return m.UpgradeHeight - } - return nil -} - -func (m *MsgUpgradeClient) GetProofUpgrade() []byte { - if m != nil { - return m.ProofUpgrade - } - return nil -} - -func (m *MsgUpgradeClient) GetSigner() string { - if m != nil { - return m.Signer - } - return "" -} - -// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. -type MsgUpgradeClientResponse struct { -} - -func (m *MsgUpgradeClientResponse) Reset() { *m = MsgUpgradeClientResponse{} } -func (m *MsgUpgradeClientResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpgradeClientResponse) ProtoMessage() {} -func (*MsgUpgradeClientResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{5} -} -func (m *MsgUpgradeClientResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgUpgradeClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgUpgradeClientResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgUpgradeClientResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpgradeClientResponse.Merge(m, src) -} -func (m *MsgUpgradeClientResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgUpgradeClientResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpgradeClientResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgUpgradeClientResponse proto.InternalMessageInfo - -// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for -// light client misbehaviour. -type MsgSubmitMisbehaviour struct { - // client unique identifier - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - // misbehaviour used for freezing the light client - Misbehaviour *types.Any `protobuf:"bytes,2,opt,name=misbehaviour,proto3" json:"misbehaviour,omitempty"` - // signer address - Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` -} - -func (m *MsgSubmitMisbehaviour) Reset() { *m = MsgSubmitMisbehaviour{} } -func (m *MsgSubmitMisbehaviour) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitMisbehaviour) ProtoMessage() {} -func (*MsgSubmitMisbehaviour) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{6} -} -func (m *MsgSubmitMisbehaviour) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSubmitMisbehaviour) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSubmitMisbehaviour.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSubmitMisbehaviour) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitMisbehaviour.Merge(m, src) -} -func (m *MsgSubmitMisbehaviour) XXX_Size() int { - return m.Size() -} -func (m *MsgSubmitMisbehaviour) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitMisbehaviour.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSubmitMisbehaviour proto.InternalMessageInfo - -// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. -type MsgSubmitMisbehaviourResponse struct { -} - -func (m *MsgSubmitMisbehaviourResponse) Reset() { *m = MsgSubmitMisbehaviourResponse{} } -func (m *MsgSubmitMisbehaviourResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitMisbehaviourResponse) ProtoMessage() {} -func (*MsgSubmitMisbehaviourResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{7} -} -func (m *MsgSubmitMisbehaviourResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSubmitMisbehaviourResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSubmitMisbehaviourResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSubmitMisbehaviourResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitMisbehaviourResponse.Merge(m, src) -} -func (m *MsgSubmitMisbehaviourResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSubmitMisbehaviourResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitMisbehaviourResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSubmitMisbehaviourResponse proto.InternalMessageInfo - // IdentifiedClientState defines a client state with an additional client // identifier field. type IdentifiedClientState struct { @@ -406,7 +37,7 @@ func (m *IdentifiedClientState) Reset() { *m = IdentifiedClientState{} } func (m *IdentifiedClientState) String() string { return proto.CompactTextString(m) } func (*IdentifiedClientState) ProtoMessage() {} func (*IdentifiedClientState) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{8} + return fileDescriptor_b6bc4c8185546947, []int{0} } func (m *IdentifiedClientState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -461,7 +92,7 @@ func (m *ConsensusStateWithHeight) Reset() { *m = ConsensusStateWithHeig func (m *ConsensusStateWithHeight) String() string { return proto.CompactTextString(m) } func (*ConsensusStateWithHeight) ProtoMessage() {} func (*ConsensusStateWithHeight) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{9} + return fileDescriptor_b6bc4c8185546947, []int{1} } func (m *ConsensusStateWithHeight) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -517,7 +148,7 @@ func (m *ClientConsensusStates) Reset() { *m = ClientConsensusStates{} } func (m *ClientConsensusStates) String() string { return proto.CompactTextString(m) } func (*ClientConsensusStates) ProtoMessage() {} func (*ClientConsensusStates) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{10} + return fileDescriptor_b6bc4c8185546947, []int{2} } func (m *ClientConsensusStates) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -578,7 +209,7 @@ func (m *ClientUpdateProposal) Reset() { *m = ClientUpdateProposal{} } func (m *ClientUpdateProposal) String() string { return proto.CompactTextString(m) } func (*ClientUpdateProposal) ProtoMessage() {} func (*ClientUpdateProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{11} + return fileDescriptor_b6bc4c8185546947, []int{3} } func (m *ClientUpdateProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -626,7 +257,7 @@ type Height struct { func (m *Height) Reset() { *m = Height{} } func (*Height) ProtoMessage() {} func (*Height) Descriptor() ([]byte, []int) { - return fileDescriptor_b6bc4c8185546947, []int{12} + return fileDescriptor_b6bc4c8185546947, []int{4} } func (m *Height) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -655,593 +286,102 @@ func (m *Height) XXX_DiscardUnknown() { var xxx_messageInfo_Height proto.InternalMessageInfo +// Params defines the set of IBC light client parameters. +type Params struct { + // allowed_clients defines the list of allowed client state types. + AllowedClients []string `protobuf:"bytes,1,rep,name=allowed_clients,json=allowedClients,proto3" json:"allowed_clients,omitempty" yaml:"allowed_clients"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_b6bc4c8185546947, []int{5} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetAllowedClients() []string { + if m != nil { + return m.AllowedClients + } + return nil +} + func init() { - proto.RegisterType((*MsgCreateClient)(nil), "ibc.core.client.v1.MsgCreateClient") - proto.RegisterType((*MsgCreateClientResponse)(nil), "ibc.core.client.v1.MsgCreateClientResponse") - proto.RegisterType((*MsgUpdateClient)(nil), "ibc.core.client.v1.MsgUpdateClient") - proto.RegisterType((*MsgUpdateClientResponse)(nil), "ibc.core.client.v1.MsgUpdateClientResponse") - proto.RegisterType((*MsgUpgradeClient)(nil), "ibc.core.client.v1.MsgUpgradeClient") - proto.RegisterType((*MsgUpgradeClientResponse)(nil), "ibc.core.client.v1.MsgUpgradeClientResponse") - proto.RegisterType((*MsgSubmitMisbehaviour)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviour") - proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") proto.RegisterType((*IdentifiedClientState)(nil), "ibc.core.client.v1.IdentifiedClientState") proto.RegisterType((*ConsensusStateWithHeight)(nil), "ibc.core.client.v1.ConsensusStateWithHeight") proto.RegisterType((*ClientConsensusStates)(nil), "ibc.core.client.v1.ClientConsensusStates") proto.RegisterType((*ClientUpdateProposal)(nil), "ibc.core.client.v1.ClientUpdateProposal") proto.RegisterType((*Height)(nil), "ibc.core.client.v1.Height") + proto.RegisterType((*Params)(nil), "ibc.core.client.v1.Params") } func init() { proto.RegisterFile("ibc/core/client/v1/client.proto", fileDescriptor_b6bc4c8185546947) } var fileDescriptor_b6bc4c8185546947 = []byte{ - // 827 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x3f, 0x6f, 0x1a, 0x49, - 0x14, 0x67, 0x01, 0x23, 0x7b, 0x00, 0xdb, 0xda, 0x03, 0x1b, 0xaf, 0x74, 0x2c, 0x9a, 0xbb, 0xc2, - 0xa7, 0xb3, 0x77, 0x0f, 0xae, 0x38, 0xcb, 0xd2, 0x49, 0x77, 0xd0, 0x9c, 0x0b, 0x4e, 0xbe, 0xb5, -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61, 0x63, 0xaf, 0xdd, 0x37, 0x14, 0x93, 0x74, 0x55, - 0x93, 0xd0, 0x2e, 0xa1, 0xfc, 0x67, 0x97, 0x5a, 0x4f, 0xd4, 0x13, 0x35, 0xfc, 0x0f, 0xf7, 0x5b, - 0x6d, 0x97, 0xff, 0x8d, 0xf3, 0x86, 0x3d, 0x44, 0x8d, 0x4c, 0xd0, 0xac, 0xbf, 0x7f, 0x0d, 0x00, - 0x00, 0xff, 0xff, 0x06, 0xa7, 0xa2, 0x16, 0xe6, 0x09, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - // CreateClient defines a rpc handler method for MsgCreateClient. - CreateClient(ctx context.Context, in *MsgCreateClient, opts ...grpc.CallOption) (*MsgCreateClientResponse, error) - // UpdateClient defines a rpc handler method for MsgUpdateClient. - UpdateClient(ctx context.Context, in *MsgUpdateClient, opts ...grpc.CallOption) (*MsgUpdateClientResponse, error) - // UpgradeClient defines a rpc handler method for MsgUpgradeClient. - UpgradeClient(ctx context.Context, in *MsgUpgradeClient, opts ...grpc.CallOption) (*MsgUpgradeClientResponse, error) - // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. - SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) CreateClient(ctx context.Context, in *MsgCreateClient, opts ...grpc.CallOption) (*MsgCreateClientResponse, error) { - out := new(MsgCreateClientResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/CreateClient", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpdateClient(ctx context.Context, in *MsgUpdateClient, opts ...grpc.CallOption) (*MsgUpdateClientResponse, error) { - out := new(MsgUpdateClientResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/UpdateClient", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) UpgradeClient(ctx context.Context, in *MsgUpgradeClient, opts ...grpc.CallOption) (*MsgUpgradeClientResponse, error) { - out := new(MsgUpgradeClientResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/UpgradeClient", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) { - out := new(MsgSubmitMisbehaviourResponse) - err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/SubmitMisbehaviour", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // CreateClient defines a rpc handler method for MsgCreateClient. - CreateClient(context.Context, *MsgCreateClient) (*MsgCreateClientResponse, error) - // UpdateClient defines a rpc handler method for MsgUpdateClient. - UpdateClient(context.Context, *MsgUpdateClient) (*MsgUpdateClientResponse, error) - // UpgradeClient defines a rpc handler method for MsgUpgradeClient. - UpgradeClient(context.Context, *MsgUpgradeClient) (*MsgUpgradeClientResponse, error) - // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. - SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) CreateClient(ctx context.Context, req *MsgCreateClient) (*MsgCreateClientResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateClient not implemented") -} -func (*UnimplementedMsgServer) UpdateClient(ctx context.Context, req *MsgUpdateClient) (*MsgUpdateClientResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateClient not implemented") -} -func (*UnimplementedMsgServer) UpgradeClient(ctx context.Context, req *MsgUpgradeClient) (*MsgUpgradeClientResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpgradeClient not implemented") -} -func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitMisbehaviour not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_CreateClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateClient) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateClient(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Msg/CreateClient", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateClient(ctx, req.(*MsgCreateClient)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpdateClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateClient) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpdateClient(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Msg/UpdateClient", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateClient(ctx, req.(*MsgUpdateClient)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_UpgradeClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpgradeClient) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).UpgradeClient(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Msg/UpgradeClient", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpgradeClient(ctx, req.(*MsgUpgradeClient)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_SubmitMisbehaviour_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSubmitMisbehaviour) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SubmitMisbehaviour(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.core.client.v1.Msg/SubmitMisbehaviour", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SubmitMisbehaviour(ctx, req.(*MsgSubmitMisbehaviour)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ibc.core.client.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateClient", - Handler: _Msg_CreateClient_Handler, - }, - { - MethodName: "UpdateClient", - Handler: _Msg_UpdateClient_Handler, - }, - { - MethodName: "UpgradeClient", - Handler: _Msg_UpgradeClient_Handler, - }, - { - MethodName: "SubmitMisbehaviour", - Handler: _Msg_SubmitMisbehaviour_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "ibc/core/client/v1/client.proto", -} - -func (m *MsgCreateClient) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgCreateClient) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintClient(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x22 - } - if m.ConsensusState != nil { - { - size, err := m.ConsensusState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.ClientState != nil { - { - size, err := m.ClientState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgCreateClientResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgCreateClientResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpdateClient) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateClient) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintClient(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a - } - if m.Header != nil { - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateClientResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpdateClientResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpdateClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgUpgradeClient) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpgradeClient) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpgradeClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintClient(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x2a - } - if len(m.ProofUpgrade) > 0 { - i -= len(m.ProofUpgrade) - copy(dAtA[i:], m.ProofUpgrade) - i = encodeVarintClient(dAtA, i, uint64(len(m.ProofUpgrade))) - i-- - dAtA[i] = 0x22 - } - if m.UpgradeHeight != nil { - { - size, err := m.UpgradeHeight.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.ClientState != nil { - { - size, err := m.ClientState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpgradeClientResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgUpgradeClientResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgUpgradeClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgSubmitMisbehaviour) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSubmitMisbehaviour) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSubmitMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintClient(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x1a - } - if m.Misbehaviour != nil { - { - size, err := m.Misbehaviour.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintClient(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.ClientId) > 0 { - i -= len(m.ClientId) - copy(dAtA[i:], m.ClientId) - i = encodeVarintClient(dAtA, i, uint64(len(m.ClientId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSubmitMisbehaviourResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSubmitMisbehaviourResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSubmitMisbehaviourResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbd, 0x8e, 0xd3, 0x4c, + 0x14, 0xcd, 0x6c, 0xf2, 0x45, 0x9b, 0xc9, 0x47, 0xb2, 0x32, 0x09, 0xeb, 0x4d, 0x61, 0x47, 0x53, + 0xa5, 0xd8, 0xb5, 0x49, 0x28, 0x40, 0xa9, 0xc0, 0x69, 0xd8, 0x02, 0x14, 0x8c, 0x10, 0x88, 0x26, + 0xf2, 0xcf, 0xac, 0x33, 0xc2, 0xf1, 0x44, 0x9e, 0x49, 0xd8, 0xbc, 0x01, 0x25, 0x15, 0xa2, 0xa0, + 0xe0, 0x09, 0xe8, 0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xe3, 0x8c, + 0x72, 0x69, 0xb3, 0xcc, 0x3e, 0xca, 0xd7, 0x91, 0x7d, 0x47, 0x26, 0x9e, 0x67, 0xe7, 0x9b, 0x08, + 0xf2, 0x9e, 0xed, 0xed, 0x42, 0x10, 0xf5, 0x0d, 0x82, 0xe0, 0xd0, 0xdf, 0x4f, 0x49, 0x7d, 0x4e, + 0x89, 0x3d, 0x83, 0xe5, 0xa1, 0x13, 0x3b, 0x13, 0xa6, 0x0c, 0x60, 0xdd, 0x09, 0x43, 0xfa, 0x1e, + 0xfb, 0x23, 0x21, 0x95, 0xa9, 0xa0, 0x5d, 0xec, 0x54, 0xac, 0xd6, 0x3a, 0xd1, 0xef, 0x09, 0xd8, + 0xad, 0x06, 0x64, 0xd7, 0x64, 0x46, 0xec, 0x84, 0x59, 0x2f, 0x2e, 0x96, 0x1a, 0xb8, 0x5c, 0x6a, + 0xe0, 0xd7, 0x52, 0x03, 0x1f, 0x57, 0x5a, 0xe1, 0x72, 0xa5, 0x15, 0x7e, 0xae, 0xb4, 0xc2, 0xdb, + 0x87, 0x01, 0xe1, 0xe3, 0x99, 0x6b, 0x78, 0x74, 0x62, 0x7a, 0x94, 0x4d, 0x28, 0x93, 0x9f, 0x13, + 0xe6, 0xbf, 0x33, 0xcf, 0xcd, 0xeb, 0x57, 0xe5, 0x7e, 0xef, 0x44, 0x3e, 0x2c, 0x7c, 0x31, 0xc5, + 0xcc, 0x2d, 0x67, 0xb6, 0x3e, 0xf8, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x91, 0xd2, 0x2f, 0x3f, 0x78, + 0x04, 0x00, 0x00, } func (m *IdentifiedClientState) Marshal() (dAtA []byte, err error) { @@ -1464,6 +604,38 @@ func (m *Height) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AllowedClients) > 0 { + for iNdEx := len(m.AllowedClients) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedClients[iNdEx]) + copy(dAtA[i:], m.AllowedClients[iNdEx]) + i = encodeVarintClient(dAtA, i, uint64(len(m.AllowedClients[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintClient(dAtA []byte, offset int, v uint64) int { offset -= sovClient(v) base := offset @@ -1475,138 +647,6 @@ func encodeVarintClient(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgCreateClient) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - if m.ClientState != nil { - l = m.ClientState.Size() - n += 1 + l + sovClient(uint64(l)) - } - if m.ConsensusState != nil { - l = m.ConsensusState.Size() - n += 1 + l + sovClient(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - return n -} - -func (m *MsgCreateClientResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpdateClient) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - if m.Header != nil { - l = m.Header.Size() - n += 1 + l + sovClient(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - return n -} - -func (m *MsgUpdateClientResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgUpgradeClient) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - if m.ClientState != nil { - l = m.ClientState.Size() - n += 1 + l + sovClient(uint64(l)) - } - if m.UpgradeHeight != nil { - l = m.UpgradeHeight.Size() - n += 1 + l + sovClient(uint64(l)) - } - l = len(m.ProofUpgrade) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - return n -} - -func (m *MsgUpgradeClientResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgSubmitMisbehaviour) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ClientId) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - if m.Misbehaviour != nil { - l = m.Misbehaviour.Size() - n += 1 + l + sovClient(uint64(l)) - } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovClient(uint64(l)) - } - return n -} - -func (m *MsgSubmitMisbehaviourResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func (m *IdentifiedClientState) Size() (n int) { if m == nil { return 0 @@ -1698,942 +738,27 @@ func (m *Height) Size() (n int) { return n } +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AllowedClients) > 0 { + for _, s := range m.AllowedClients { + l = len(s) + n += 1 + l + sovClient(uint64(l)) + } + } + return n +} + func sovClient(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozClient(x uint64) (n int) { return sovClient(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgCreateClient: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateClient: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ClientState == nil { - m.ClientState = &types.Any{} - } - if err := m.ClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ConsensusState == nil { - m.ConsensusState = &types.Any{} - } - if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgCreateClientResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgCreateClientResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateClient) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateClient: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateClient: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Header == nil { - m.Header = &types.Any{} - } - if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateClientResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateClientResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpgradeClient) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpgradeClient: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpgradeClient: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ClientState == nil { - m.ClientState = &types.Any{} - } - if err := m.ClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpgradeHeight", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.UpgradeHeight == nil { - m.UpgradeHeight = &Height{} - } - if err := m.UpgradeHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProofUpgrade", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProofUpgrade = append(m.ProofUpgrade[:0], dAtA[iNdEx:postIndex]...) - if m.ProofUpgrade == nil { - m.ProofUpgrade = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpgradeClientResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpgradeClientResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpgradeClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSubmitMisbehaviour) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitMisbehaviour: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitMisbehaviour: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClientId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Misbehaviour", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Misbehaviour == nil { - m.Misbehaviour = &types.Any{} - } - if err := m.Misbehaviour.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthClient - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthClient - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSubmitMisbehaviourResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowClient - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitMisbehaviourResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitMisbehaviourResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthClient - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *IdentifiedClientState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3272,6 +1397,91 @@ func (m *Height) Unmarshal(dAtA []byte) error { } return nil } +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedClients", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedClients = append(m.AllowedClients, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipClient(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/core/02-client/types/client_test.go b/x/ibc/core/02-client/types/client_test.go index 3028980b89..409ab53050 100644 --- a/x/ibc/core/02-client/types/client_test.go +++ b/x/ibc/core/02-client/types/client_test.go @@ -2,6 +2,7 @@ package types_test import ( "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -22,7 +23,7 @@ func (suite *TypesTestSuite) TestMarshalConsensusStateWithHeight() { }, { "tendermint client", func() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) consensusState, ok := suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight()) suite.Require().True(ok) diff --git a/x/ibc/core/02-client/types/codec_test.go b/x/ibc/core/02-client/types/codec_test.go index 9ea6642629..75cfc97eb0 100644 --- a/x/ibc/core/02-client/types/codec_test.go +++ b/x/ibc/core/02-client/types/codec_test.go @@ -30,7 +30,7 @@ func (suite *TypesTestSuite) TestPackClientState() { }, { "tendermint client", - ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), true, }, { @@ -175,7 +175,7 @@ func (suite *TypesTestSuite) TestPackMisbehaviour() { }, { "tendermint misbehaviour", - ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.ChainID, suite.chainA.LastHeader, suite.chainA.LastHeader), + ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.LastHeader, suite.chainA.LastHeader), true, }, { diff --git a/x/ibc/core/02-client/types/genesis.go b/x/ibc/core/02-client/types/genesis.go index c9be22f821..fc3ba12d19 100644 --- a/x/ibc/core/02-client/types/genesis.go +++ b/x/ibc/core/02-client/types/genesis.go @@ -66,11 +66,13 @@ func (ccs ClientConsensusStates) UnpackInterfaces(unpacker codectypes.AnyUnpacke // NewGenesisState creates a GenesisState instance. func NewGenesisState( - clients []IdentifiedClientState, clientsConsensus ClientsConsensusStates, createLocalhost bool, + clients []IdentifiedClientState, clientsConsensus ClientsConsensusStates, + params Params, createLocalhost bool, ) GenesisState { return GenesisState{ Clients: clients, ClientsConsensus: clientsConsensus, + Params: params, CreateLocalhost: createLocalhost, } } @@ -80,6 +82,7 @@ func DefaultGenesisState() GenesisState { return GenesisState{ Clients: []IdentifiedClientState{}, ClientsConsensus: ClientsConsensusStates{}, + Params: DefaultParams(), CreateLocalhost: false, } } @@ -133,5 +136,13 @@ func (gs GenesisState) Validate() error { } } + if err := gs.Params.Validate(); err != nil { + return err + } + + if gs.CreateLocalhost && !gs.Params.IsAllowedClient(exported.Localhost) { + return fmt.Errorf("localhost client is not registered on the allowlist") + } + return nil } diff --git a/x/ibc/core/02-client/types/genesis.pb.go b/x/ibc/core/02-client/types/genesis.pb.go index 8d16b4519a..4c72edfe5e 100644 --- a/x/ibc/core/02-client/types/genesis.pb.go +++ b/x/ibc/core/02-client/types/genesis.pb.go @@ -26,11 +26,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the ibc client submodule's genesis state. type GenesisState struct { // client states with their corresponding identifiers - Clients []IdentifiedClientState `protobuf:"bytes,1,rep,name=clients,proto3" json:"clients"` + Clients IdentifiedClientStates `protobuf:"bytes,1,rep,name=clients,proto3,castrepeated=IdentifiedClientStates" json:"clients"` // consensus states from each client ClientsConsensus ClientsConsensusStates `protobuf:"bytes,2,rep,name=clients_consensus,json=clientsConsensus,proto3,castrepeated=ClientsConsensusStates" json:"clients_consensus" yaml:"clients_consensus"` + Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"` // create localhost on initialization - CreateLocalhost bool `protobuf:"varint,3,opt,name=create_localhost,json=createLocalhost,proto3" json:"create_localhost,omitempty" yaml:"create_localhost"` + CreateLocalhost bool `protobuf:"varint,4,opt,name=create_localhost,json=createLocalhost,proto3" json:"create_localhost,omitempty" yaml:"create_localhost"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -66,7 +67,7 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetClients() []IdentifiedClientState { +func (m *GenesisState) GetClients() IdentifiedClientStates { if m != nil { return m.Clients } @@ -80,6 +81,13 @@ func (m *GenesisState) GetClientsConsensus() ClientsConsensusStates { return nil } +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func (m *GenesisState) GetCreateLocalhost() bool { if m != nil { return m.CreateLocalhost @@ -94,28 +102,30 @@ func init() { func init() { proto.RegisterFile("ibc/core/client/v1/genesis.proto", fileDescriptor_bcd0c0f1f2e6a91a) } var fileDescriptor_bcd0c0f1f2e6a91a = []byte{ - // 328 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc8, 0x4c, 0x4a, 0xd6, - 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, - 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xca, 0x4c, - 0x4a, 0xd6, 0x03, 0xa9, 0xd0, 0x83, 0xa8, 0xd0, 0x2b, 0x33, 0x94, 0x92, 0xc7, 0xa2, 0x0b, 0x2a, - 0x0b, 0xd6, 0x24, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x66, 0xea, 0x83, 0x58, 0x10, 0x51, 0xa5, - 0x6d, 0x4c, 0x5c, 0x3c, 0xee, 0x10, 0xc3, 0x83, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0x3c, 0xb9, 0xd8, - 0x21, 0xda, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x34, 0xf5, 0x30, 0x6d, 0xd3, 0xf3, - 0x4c, 0x49, 0xcd, 0x2b, 0xc9, 0x4c, 0xcb, 0x4c, 0x4d, 0x71, 0x06, 0x8b, 0x81, 0xf5, 0x3a, 0xb1, - 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, 0xd3, 0x2f, 0x34, 0x89, 0x91, 0x4b, 0x10, 0xca, 0x8e, 0x4f, - 0xce, 0xcf, 0x2b, 0x4e, 0xcd, 0x2b, 0x2e, 0x2d, 0x96, 0x60, 0xc2, 0x6d, 0x2a, 0xc4, 0x2c, 0x67, - 0x98, 0x52, 0xb0, 0xa1, 0xc5, 0x4e, 0x56, 0x20, 0x53, 0x3f, 0xdd, 0x93, 0x97, 0xa8, 0x4c, 0xcc, - 0xcd, 0xb1, 0x52, 0xc2, 0x30, 0x51, 0x69, 0xd5, 0x7d, 0x79, 0x31, 0x88, 0xd6, 0x62, 0x34, 0xbd, - 0x41, 0x02, 0xc9, 0x68, 0xe2, 0x42, 0x6e, 0x5c, 0x02, 0xc9, 0x45, 0xa9, 0x89, 0x25, 0xa9, 0xf1, - 0x39, 0xf9, 0xc9, 0x89, 0x39, 0x19, 0xf9, 0xc5, 0x25, 0x12, 0xcc, 0x0a, 0x8c, 0x1a, 0x1c, 0x4e, - 0xd2, 0x9f, 0xee, 0xc9, 0x8b, 0x43, 0xed, 0x40, 0x53, 0xa1, 0x14, 0xc4, 0x0f, 0x11, 0xf2, 0x81, - 0x89, 0x38, 0x05, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, - 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x79, 0x7a, - 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x31, - 0x94, 0xd2, 0x2d, 0x4e, 0xc9, 0xd6, 0xaf, 0xd0, 0x87, 0x47, 0x94, 0x81, 0x91, 0x2e, 0x34, 0xae, - 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x51, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0x5b, 0xe3, 0x61, 0x24, 0x01, 0x02, 0x00, 0x00, + // 362 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xc1, 0x4e, 0xea, 0x40, + 0x14, 0x86, 0xdb, 0x0b, 0xe1, 0xde, 0x94, 0x9b, 0x88, 0x8d, 0xd1, 0x06, 0x93, 0xb6, 0xe9, 0x0a, + 0x17, 0xcc, 0x08, 0x2e, 0x34, 0x2c, 0x4b, 0xa2, 0x31, 0x71, 0xa1, 0x75, 0xe7, 0x86, 0xb4, 0xc3, + 0x58, 0x26, 0xb6, 0x1d, 0xd2, 0x33, 0x10, 0x79, 0x05, 0x57, 0xc6, 0xc7, 0xf0, 0x49, 0x58, 0xb2, + 0x74, 0x85, 0x06, 0xde, 0x80, 0x27, 0x30, 0xed, 0x14, 0x17, 0x80, 0xab, 0x39, 0xf9, 0xe7, 0xff, + 0xfe, 0xff, 0x24, 0x47, 0xb3, 0x59, 0x40, 0x30, 0xe1, 0x29, 0xc5, 0x24, 0x62, 0x34, 0x11, 0x78, + 0xdc, 0xc2, 0x21, 0x4d, 0x28, 0x30, 0x40, 0xc3, 0x94, 0x0b, 0xae, 0xeb, 0x2c, 0x20, 0x28, 0x73, + 0x20, 0xe9, 0x40, 0xe3, 0x56, 0xdd, 0xda, 0x41, 0x15, 0xbf, 0x39, 0x54, 0x3f, 0x08, 0x79, 0xc8, + 0xf3, 0x11, 0x67, 0x93, 0x54, 0x9d, 0x97, 0x92, 0xf6, 0xff, 0x4a, 0x86, 0xdf, 0x0b, 0x5f, 0x50, + 0x9d, 0x68, 0x7f, 0x25, 0x06, 0x86, 0x6a, 0x97, 0x1a, 0xd5, 0xf6, 0x09, 0xda, 0x6e, 0x43, 0xd7, + 0x7d, 0x9a, 0x08, 0xf6, 0xc8, 0x68, 0xbf, 0x9b, 0x6b, 0x39, 0xeb, 0x9a, 0xd3, 0xb9, 0xa5, 0xbc, + 0x7f, 0x5a, 0x87, 0x3b, 0xbf, 0xc1, 0x5b, 0x27, 0xeb, 0x6f, 0xaa, 0xb6, 0x5f, 0xcc, 0x3d, 0xc2, + 0x13, 0xa0, 0x09, 0x8c, 0xc0, 0xf8, 0xf3, 0x7b, 0x9f, 0x8c, 0xe9, 0xae, 0xad, 0x32, 0xcf, 0xed, + 0x64, 0x7d, 0xab, 0xb9, 0x65, 0x4c, 0xfc, 0x38, 0xea, 0x38, 0x5b, 0x89, 0x4e, 0xb6, 0x8b, 0x44, + 0x61, 0x83, 0xf5, 0x6a, 0x64, 0x43, 0xd7, 0x2f, 0xb4, 0xca, 0xd0, 0x4f, 0xfd, 0x18, 0x8c, 0x92, + 0xad, 0x36, 0xaa, 0xed, 0xfa, 0xae, 0x45, 0x6e, 0x73, 0x87, 0x5b, 0xce, 0x9a, 0xbd, 0xc2, 0xaf, + 0x5f, 0x6a, 0x35, 0x92, 0x52, 0x5f, 0xd0, 0x5e, 0xc4, 0x89, 0x1f, 0x0d, 0x38, 0x08, 0xa3, 0x6c, + 0xab, 0x8d, 0x7f, 0xee, 0xf1, 0x6a, 0x6e, 0x1d, 0x15, 0xdb, 0x6d, 0x38, 0x1c, 0x6f, 0x4f, 0x4a, + 0x37, 0x6b, 0xc5, 0xbd, 0x9b, 0x2e, 0x4c, 0x75, 0xb6, 0x30, 0xd5, 0xaf, 0x85, 0xa9, 0xbe, 0x2e, + 0x4d, 0x65, 0xb6, 0x34, 0x95, 0x8f, 0xa5, 0xa9, 0x3c, 0x9c, 0x87, 0x4c, 0x0c, 0x46, 0x01, 0x22, + 0x3c, 0xc6, 0x84, 0x43, 0xcc, 0xa1, 0x78, 0x9a, 0xd0, 0x7f, 0xc2, 0xcf, 0xf8, 0xe7, 0xf8, 0xa7, + 0xed, 0x66, 0x71, 0x7f, 0x31, 0x19, 0x52, 0x08, 0x2a, 0xf9, 0x99, 0xcf, 0xbe, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x8d, 0xa4, 0x74, 0xd6, 0x55, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -146,8 +156,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a if len(m.ClientsConsensus) > 0 { for iNdEx := len(m.ClientsConsensus) - 1; iNdEx >= 0; iNdEx-- { { @@ -208,6 +228,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) if m.CreateLocalhost { n += 2 } @@ -318,6 +340,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field CreateLocalhost", wireType) } diff --git a/x/ibc/core/02-client/types/genesis_test.go b/x/ibc/core/02-client/types/genesis_test.go index 1de9103354..d6caca0e68 100644 --- a/x/ibc/core/02-client/types/genesis_test.go +++ b/x/ibc/core/02-client/types/genesis_test.go @@ -5,7 +5,6 @@ import ( tmtypes "github.com/tendermint/tendermint/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" client "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client" "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" @@ -29,7 +28,7 @@ var clientHeight = types.NewHeight(0, 10) func (suite *TypesTestSuite) TestMarshalGenesisState() { cdc := suite.chainA.App.AppCodec() clientA, _, _, _, _, _ := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) genesis := client.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.IBCKeeper.ClientKeeper) @@ -49,7 +48,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { now := time.Now().UTC() - val := tmtypes.NewValidator(pubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 10) + val := tmtypes.NewValidator(pubKey, 10) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) heightMinus1 := types.NewHeight(0, height-1) @@ -66,11 +65,11 @@ func (suite *TypesTestSuite) TestValidateGenesis() { expPass: true, }, { - name: "valid genesis", + name: "valid custom genesis", genState: types.NewGenesisState( []types.IdentifiedClientState{ types.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), types.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight), @@ -89,7 +88,8 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - true, + types.NewParams(exported.Tendermint), + false, ), expPass: true, }, @@ -98,7 +98,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { genState: types.NewGenesisState( []types.IdentifiedClientState{ types.NewIdentifiedClientState( - "/~@$*", ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + "/~@$*", ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), types.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight), @@ -117,7 +117,8 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - true, + types.NewParams(exported.Tendermint), + false, ), expPass: false, }, @@ -126,21 +127,22 @@ func (suite *TypesTestSuite) TestValidateGenesis() { genState: types.NewGenesisState( []types.IdentifiedClientState{ types.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), types.NewIdentifiedClientState(exported.Localhost, localhosttypes.NewClientState("chaindID", types.ZeroHeight())), }, nil, - true, + types.NewParams(exported.Tendermint), + false, ), expPass: false, }, { - name: "invalid consensus state", + name: "invalid consensus state client id", genState: types.NewGenesisState( []types.IdentifiedClientState{ types.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), types.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight), @@ -159,16 +161,17 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, - true, + types.NewParams(exported.Tendermint), + false, ), expPass: false, }, { - name: "invalid consensus state", + name: "invalid consensus state height", genState: types.NewGenesisState( []types.IdentifiedClientState{ types.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), types.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight), @@ -187,6 +190,123 @@ func (suite *TypesTestSuite) TestValidateGenesis() { }, ), }, + types.NewParams(exported.Tendermint), + false, + ), + expPass: false, + }, + { + name: "invalid consensus state", + genState: types.NewGenesisState( + []types.IdentifiedClientState{ + types.NewIdentifiedClientState( + clientID, ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ), + types.NewIdentifiedClientState( + exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight), + ), + }, + []types.ClientConsensusStates{ + types.NewClientConsensusStates( + clientID, + []types.ConsensusStateWithHeight{ + types.NewConsensusStateWithHeight( + types.NewHeight(0, 1), + ibctmtypes.NewConsensusState( + time.Time{}, commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash, + ), + ), + }, + ), + }, + types.NewParams(exported.Tendermint), + false, + ), + expPass: false, + }, + { + name: "invalid params", + genState: types.NewGenesisState( + []types.IdentifiedClientState{ + types.NewIdentifiedClientState( + clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ), + types.NewIdentifiedClientState( + exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight), + ), + }, + []types.ClientConsensusStates{ + types.NewClientConsensusStates( + clientID, + []types.ConsensusStateWithHeight{ + types.NewConsensusStateWithHeight( + header.GetHeight().(types.Height), + ibctmtypes.NewConsensusState( + header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash, + ), + ), + }, + ), + }, + types.NewParams(" "), + false, + ), + expPass: false, + }, + { + name: "invalid param", + genState: types.NewGenesisState( + []types.IdentifiedClientState{ + types.NewIdentifiedClientState( + clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ), + types.NewIdentifiedClientState( + exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight), + ), + }, + []types.ClientConsensusStates{ + types.NewClientConsensusStates( + clientID, + []types.ConsensusStateWithHeight{ + types.NewConsensusStateWithHeight( + header.GetHeight().(types.Height), + ibctmtypes.NewConsensusState( + header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash, + ), + ), + }, + ), + }, + types.NewParams(" "), + true, + ), + expPass: false, + }, + { + name: "localhost client not registered on allowlist", + genState: types.NewGenesisState( + []types.IdentifiedClientState{ + types.NewIdentifiedClientState( + clientID, ibctmtypes.NewClientState(chainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + ), + types.NewIdentifiedClientState( + exported.Localhost, localhosttypes.NewClientState("chainID", clientHeight), + ), + }, + []types.ClientConsensusStates{ + types.NewClientConsensusStates( + clientID, + []types.ConsensusStateWithHeight{ + types.NewConsensusStateWithHeight( + header.GetHeight().(types.Height), + ibctmtypes.NewConsensusState( + header.GetTime(), commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), header.Header.NextValidatorsHash, + ), + ), + }, + ), + }, + types.NewParams(exported.Tendermint), true, ), expPass: false, diff --git a/x/ibc/core/02-client/types/msgs_test.go b/x/ibc/core/02-client/types/msgs_test.go index adaf95cde8..7373205cc5 100644 --- a/x/ibc/core/02-client/types/msgs_test.go +++ b/x/ibc/core/02-client/types/msgs_test.go @@ -56,7 +56,7 @@ func (suite *TypesTestSuite) TestMarshalMsgCreateClient() { }, { "tendermint client", func() { - tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) suite.Require().NoError(err) }, @@ -108,7 +108,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { { "valid - tendermint client", func() { - tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) suite.Require().NoError(err) }, @@ -132,7 +132,7 @@ func (suite *TypesTestSuite) TestMsgCreateClient_ValidateBasic() { { "failed to unpack consensus state", func() { - tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) msg, err = types.NewMsgCreateClient("tendermint", tendermintClient, suite.chainA.CurrentTMClientHeader().ConsensusState(), suite.chainA.SenderAccount.GetAddress()) suite.Require().NoError(err) msg.ConsensusState = nil @@ -348,7 +348,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpgradeClient() { { "client upgrades to new tendermint client", func() { - tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + tendermintClient := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) msg, err = types.NewMsgUpgradeClient("clientid", tendermintClient, newClientHeight, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress()) suite.Require().NoError(err) }, @@ -462,7 +462,7 @@ func (suite *TypesTestSuite) TestMsgUpgradeClient_ValidateBasic() { for _, tc := range cases { tc := tc - clientState := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + clientState := ibctmtypes.NewClientState(suite.chainA.ChainID, ibctesting.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) newClientHeight := types.NewHeight(1, 1) msg, _ := types.NewMsgUpgradeClient("testclientid", clientState, newClientHeight, []byte("proofUpgrade"), suite.chainA.SenderAccount.GetAddress()) @@ -503,7 +503,7 @@ func (suite *TypesTestSuite) TestMarshalMsgSubmitMisbehaviour() { header1 := suite.chainA.CreateTMClientHeader(suite.chainA.ChainID, int64(height.VersionHeight), heightMinus1, suite.chainA.CurrentHeader.Time, suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers) header2 := suite.chainA.CreateTMClientHeader(suite.chainA.ChainID, int64(height.VersionHeight), heightMinus1, suite.chainA.CurrentHeader.Time.Add(time.Minute), suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers) - misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.ChainID, header1, header2) + misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", header1, header2) msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress()) suite.Require().NoError(err) @@ -561,7 +561,7 @@ func (suite *TypesTestSuite) TestMsgSubmitMisbehaviour_ValidateBasic() { header1 := suite.chainA.CreateTMClientHeader(suite.chainA.ChainID, int64(height.VersionHeight), heightMinus1, suite.chainA.CurrentHeader.Time, suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers) header2 := suite.chainA.CreateTMClientHeader(suite.chainA.ChainID, int64(height.VersionHeight), heightMinus1, suite.chainA.CurrentHeader.Time.Add(time.Minute), suite.chainA.Vals, suite.chainA.Vals, suite.chainA.Signers) - misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", suite.chainA.ChainID, header1, header2) + misbehaviour := ibctmtypes.NewMisbehaviour("tendermint", header1, header2) msg, err = types.NewMsgSubmitMisbehaviour("tendermint", misbehaviour, suite.chainA.SenderAccount.GetAddress()) suite.Require().NoError(err) }, diff --git a/x/ibc/core/02-client/types/params.go b/x/ibc/core/02-client/types/params.go new file mode 100644 index 0000000000..6477e3f6f4 --- /dev/null +++ b/x/ibc/core/02-client/types/params.go @@ -0,0 +1,71 @@ +package types + +import ( + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +var ( + // DefaultAllowedClients are "06-solomachine" and "07-tendermint" + DefaultAllowedClients = []string{exported.Solomachine, exported.Tendermint} + + // KeyAllowedClients is store's key for AllowedClients Params + KeyAllowedClients = []byte("AllowedClients") +) + +// ParamKeyTable type declaration for parameters +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new parameter configuration for the ibc transfer module +func NewParams(allowedClients ...string) Params { + return Params{ + AllowedClients: allowedClients, + } +} + +// DefaultParams is the default parameter configuration for the ibc-transfer module +func DefaultParams() Params { + return NewParams(DefaultAllowedClients...) +} + +// Validate all ibc-transfer module parameters +func (p Params) Validate() error { + return validateClients(p.AllowedClients) +} + +// ParamSetPairs implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyAllowedClients, p.AllowedClients, validateClients), + } +} + +// IsAllowedClient checks if the given client type is registered on the allowlist. +func (p Params) IsAllowedClient(clientType string) bool { + for _, allowedClient := range p.AllowedClients { + if allowedClient == clientType { + return true + } + } + return false +} + +func validateClients(i interface{}) error { + clients, ok := i.([]string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + for i, clientType := range clients { + if strings.TrimSpace(clientType) == "" { + return fmt.Errorf("client type %d cannot be blank", i) + } + } + + return nil +} diff --git a/x/ibc/core/02-client/types/params_test.go b/x/ibc/core/02-client/types/params_test.go new file mode 100644 index 0000000000..9484e48b4a --- /dev/null +++ b/x/ibc/core/02-client/types/params_test.go @@ -0,0 +1,29 @@ +package types + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" + "github.com/stretchr/testify/require" +) + +func TestValidateParams(t *testing.T) { + testCases := []struct { + name string + params Params + expPass bool + }{ + {"default params", DefaultParams(), true}, + {"custom params", NewParams(exported.Tendermint), true}, + {"blank client", NewParams(" "), false}, + } + + for _, tc := range testCases { + err := tc.params.Validate() + if tc.expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + } + } +} diff --git a/x/ibc/core/02-client/types/query.pb.go b/x/ibc/core/02-client/types/query.pb.go index fb91ead13c..755d401802 100644 --- a/x/ibc/core/02-client/types/query.pb.go +++ b/x/ibc/core/02-client/types/query.pb.go @@ -195,7 +195,7 @@ func (m *QueryClientStatesRequest) GetPagination() *query.PageRequest { // method. type QueryClientStatesResponse struct { // list of stored ClientStates of the chain. - ClientStates []*IdentifiedClientState `protobuf:"bytes,1,rep,name=client_states,json=clientStates,proto3" json:"client_states,omitempty"` + ClientStates IdentifiedClientStates `protobuf:"bytes,1,rep,name=client_states,json=clientStates,proto3,castrepeated=IdentifiedClientStates" json:"client_states"` // pagination response Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -233,7 +233,7 @@ func (m *QueryClientStatesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryClientStatesResponse proto.InternalMessageInfo -func (m *QueryClientStatesResponse) GetClientStates() []*IdentifiedClientState { +func (m *QueryClientStatesResponse) GetClientStates() IdentifiedClientStates { if m != nil { return m.ClientStates } @@ -500,6 +500,89 @@ func (m *QueryConsensusStatesResponse) GetPagination() *query.PageResponse { return nil } +// QueryClientParamsRequest is the request type for the Query/ClientParams RPC method. +type QueryClientParamsRequest struct { +} + +func (m *QueryClientParamsRequest) Reset() { *m = QueryClientParamsRequest{} } +func (m *QueryClientParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClientParamsRequest) ProtoMessage() {} +func (*QueryClientParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_dc42cdfd1d52d76e, []int{8} +} +func (m *QueryClientParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryClientParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientParamsRequest.Merge(m, src) +} +func (m *QueryClientParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClientParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientParamsRequest proto.InternalMessageInfo + +// QueryClientParamsResponse is the response type for the Query/ClientParams RPC method. +type QueryClientParamsResponse struct { + // params defines the parameters of the module. + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *QueryClientParamsResponse) Reset() { *m = QueryClientParamsResponse{} } +func (m *QueryClientParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClientParamsResponse) ProtoMessage() {} +func (*QueryClientParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dc42cdfd1d52d76e, []int{9} +} +func (m *QueryClientParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClientParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClientParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryClientParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClientParamsResponse.Merge(m, src) +} +func (m *QueryClientParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClientParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClientParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClientParamsResponse proto.InternalMessageInfo + +func (m *QueryClientParamsResponse) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + func init() { proto.RegisterType((*QueryClientStateRequest)(nil), "ibc.core.client.v1.QueryClientStateRequest") proto.RegisterType((*QueryClientStateResponse)(nil), "ibc.core.client.v1.QueryClientStateResponse") @@ -509,59 +592,66 @@ func init() { proto.RegisterType((*QueryConsensusStateResponse)(nil), "ibc.core.client.v1.QueryConsensusStateResponse") proto.RegisterType((*QueryConsensusStatesRequest)(nil), "ibc.core.client.v1.QueryConsensusStatesRequest") proto.RegisterType((*QueryConsensusStatesResponse)(nil), "ibc.core.client.v1.QueryConsensusStatesResponse") + proto.RegisterType((*QueryClientParamsRequest)(nil), "ibc.core.client.v1.QueryClientParamsRequest") + proto.RegisterType((*QueryClientParamsResponse)(nil), "ibc.core.client.v1.QueryClientParamsResponse") } func init() { proto.RegisterFile("ibc/core/client/v1/query.proto", fileDescriptor_dc42cdfd1d52d76e) } var fileDescriptor_dc42cdfd1d52d76e = []byte{ - // 747 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x4f, 0x13, 0x41, - 0x14, 0xef, 0xf0, 0xc7, 0xc0, 0xb4, 0x80, 0x99, 0x90, 0x58, 0x16, 0x52, 0x6a, 0x89, 0x5a, 0x94, - 0xce, 0xd0, 0x1a, 0xc5, 0x8b, 0x07, 0x21, 0x41, 0xb9, 0x10, 0x59, 0x0f, 0x26, 0x26, 0x86, 0xec, - 0x6e, 0x87, 0xed, 0x44, 0xd8, 0x29, 0x9d, 0x69, 0x23, 0x21, 0x5c, 0xf8, 0x04, 0x26, 0x26, 0x5e, - 0xfd, 0x02, 0x86, 0x93, 0x89, 0xdf, 0xc0, 0x70, 0x24, 0x7a, 0xf1, 0x60, 0x8c, 0x01, 0x3f, 0x88, - 0xe9, 0xcc, 0x2c, 0xdd, 0x85, 0x25, 0xac, 0x46, 0x4f, 0x3b, 0xf3, 0xfe, 0xfe, 0xde, 0xef, 0xbd, - 0x79, 0x59, 0x58, 0x60, 0xae, 0x47, 0x3c, 0xde, 0xa2, 0xc4, 0xdb, 0x64, 0x34, 0x90, 0xa4, 0x53, - 0x25, 0xdb, 0x6d, 0xda, 0xda, 0xc1, 0xcd, 0x16, 0x97, 0x1c, 0x21, 0xe6, 0x7a, 0xb8, 0xab, 0xc7, - 0x5a, 0x8f, 0x3b, 0x55, 0xeb, 0xb6, 0xc7,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, 0xe1, 0xef, 0x25, 0xbc, 0x7a, 0x86, 0xbf, 0x70, 0x54, 0xe7, - 0x92, 0xca, 0x8d, 0x87, 0x79, 0xce, 0x64, 0x23, 0x46, 0xc0, 0x58, 0x9c, 0xde, 0x7f, 0x37, 0xb6, - 0xb5, 0x2f, 0x83, 0x70, 0x50, 0x15, 0x82, 0xde, 0x03, 0x98, 0x8d, 0xbc, 0x13, 0x74, 0x27, 0x09, - 0xe7, 0x05, 0x6b, 0xce, 0x9a, 0x4b, 0x67, 0xac, 0x01, 0x94, 0xee, 0xed, 0x7f, 0xfd, 0xf5, 0xb6, - 0x8f, 0xa0, 0x0a, 0x51, 0x8b, 0x3a, 0xdc, 0xd1, 0x7a, 0x9b, 0xc7, 0x9e, 0x37, 0xd9, 0x3d, 0xed, - 0xe5, 0x1e, 0x7a, 0x07, 0x60, 0x2e, 0xba, 0x14, 0x50, 0xaa, 0xac, 0xe1, 0x60, 0x58, 0x95, 0x94, - 0xd6, 0x06, 0xe4, 0xac, 0x02, 0x39, 0x83, 0xae, 0x5f, 0x0a, 0x12, 0x7d, 0x07, 0x70, 0x34, 0xde, - 0x41, 0x84, 0x2f, 0x4e, 0x96, 0xb4, 0x1f, 0x2c, 0x92, 0xda, 0xde, 0xc0, 0x63, 0x0a, 0x9e, 0x87, - 0x9c, 0x44, 0x78, 0x67, 0x46, 0x2f, 0x4a, 0x23, 0x31, 0xdb, 0x82, 0xec, 0xc6, 0x77, 0xce, 0x1e, - 0xd1, 0xaf, 0xb2, 0x27, 0xd7, 0xf7, 0x3d, 0x74, 0x00, 0xe0, 0xd8, 0x99, 0x39, 0x47, 0x69, 0xf1, - 0x9e, 0xb2, 0x3f, 0x9f, 0xde, 0xc1, 0x54, 0xf8, 0x40, 0x55, 0x58, 0x43, 0xf3, 0x7f, 0x5a, 0xe1, - 0xe2, 0xda, 0xe1, 0x71, 0x01, 0x1c, 0x1d, 0x17, 0xc0, 0xcf, 0xe3, 0x02, 0x78, 0x73, 0x52, 0xc8, - 0x1c, 0x9d, 0x14, 0x32, 0xdf, 0x4e, 0x0a, 0x99, 0x17, 0x0b, 0x3e, 0x93, 0x8d, 0xb6, 0x8b, 0x3d, - 0xbe, 0x45, 0xcc, 0x0f, 0x85, 0xfe, 0x54, 0x44, 0xfd, 0x15, 0x79, 0x4d, 0x4e, 0x7f, 0x1c, 0xe6, - 0x6b, 0x15, 0x93, 0x51, 0xee, 0x34, 0xa9, 0x70, 0xaf, 0xa8, 0x75, 0x77, 0xf7, 0x77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x09, 0x8e, 0x83, 0x3d, 0xbb, 0x08, 0x00, 0x00, + // 823 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x4f, 0xdb, 0x48, + 0x18, 0xce, 0xf0, 0x25, 0x98, 0x04, 0x58, 0x8d, 0xd0, 0x6e, 0x30, 0xc8, 0x44, 0x5e, 0x2d, 0x9b, + 0xdd, 0x85, 0x19, 0x92, 0xdd, 0x2d, 0x52, 0x25, 0x0e, 0x05, 0x89, 0x96, 0x4b, 0x0b, 0xee, 0xa1, + 0x52, 0xa5, 0x0a, 0xd9, 0xce, 0xc4, 0xb1, 0x4a, 0x3c, 0x21, 0xe3, 0x44, 0x45, 0x88, 0x0b, 0x7f, + 0xa0, 0x95, 0x7a, 0xec, 0xb5, 0xa7, 0xaa, 0xea, 0xa5, 0x87, 0xfe, 0x83, 0x8a, 0x23, 0x52, 0x7b, + 0xe8, 0xa9, 0x1f, 0xd0, 0x1f, 0xd1, 0x63, 0xe5, 0x99, 0x31, 0xb1, 0x89, 0x11, 0x16, 0x6a, 0x4f, + 0xb1, 0xdf, 0xaf, 0x79, 0x9e, 0xe7, 0x7d, 0xdf, 0x71, 0xa0, 0xee, 0xd9, 0x0e, 0x71, 0x58, 0x9b, + 0x12, 0x67, 0xc7, 0xa3, 0x7e, 0x40, 0xba, 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x30, 0xfa, 0x02, 0x63, + 0x03, 0xd5, 0x2f, 0xc6, 0x78, 0x6e, 0xec, 0xe3, 0x82, 0x12, 0x75, 0x53, 0x91, 0xfd, 0xe4, 0x7d, + 0x77, 0x40, 0xe4, 0x8d, 0xd0, 0xb3, 0xcb, 0xf7, 0x03, 0xf4, 0x1a, 0xc0, 0xc9, 0x73, 0x3b, 0x86, + 0xb2, 0x82, 0x3e, 0xeb, 0xc3, 0x52, 0xf6, 0x04, 0x45, 0x73, 0x45, 0xd0, 0x5c, 0x46, 0xff, 0x5f, + 0x89, 0x26, 0x7a, 0x7c, 0x36, 0x37, 0x72, 0x03, 0x2e, 0x9d, 0x9b, 0xc4, 0xe2, 0x5d, 0x3a, 0x37, + 0xc9, 0x55, 0x34, 0x0c, 0x01, 0x76, 0x16, 0x69, 0x12, 0x6c, 0x12, 0xa7, 0x5c, 0xbd, 0xd5, 0xad, + 0xa3, 0x13, 0x1d, 0x1c, 0x9f, 0xe8, 0xe0, 0xf3, 0x89, 0x0e, 0x9e, 0x9c, 0xea, 0xb9, 0xe3, 0x53, + 0x3d, 0xf7, 0xe1, 0x54, 0xcf, 0xdd, 0x5f, 0x76, 0xbd, 0xa0, 0xd1, 0xb1, 0xb1, 0xc3, 0x9a, 0x44, + 0xfd, 0x07, 0x93, 0x3f, 0x8b, 0xbc, 0xf6, 0x90, 0x3c, 0xea, 0x09, 0xb0, 0x54, 0x5d, 0x54, 0xb5, + 0x83, 0xbd, 0x16, 0xe5, 0xf6, 0x88, 0xf8, 0x02, 0xfc, 0xfb, 0x3d, 0x00, 0x00, 0xff, 0xff, 0xca, + 0xdc, 0xd5, 0x38, 0xee, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -586,6 +676,8 @@ type QueryClient interface { // ConsensusStates queries all the consensus state associated with a given // client. ConsensusStates(ctx context.Context, in *QueryConsensusStatesRequest, opts ...grpc.CallOption) (*QueryConsensusStatesResponse, error) + // ClientParams queries all parameters of the ibc client. + ClientParams(ctx context.Context, in *QueryClientParamsRequest, opts ...grpc.CallOption) (*QueryClientParamsResponse, error) } type queryClient struct { @@ -632,6 +724,15 @@ func (c *queryClient) ConsensusStates(ctx context.Context, in *QueryConsensusSta return out, nil } +func (c *queryClient) ClientParams(ctx context.Context, in *QueryClientParamsRequest, opts ...grpc.CallOption) (*QueryClientParamsResponse, error) { + out := new(QueryClientParamsResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Query/ClientParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ClientState queries an IBC light client. @@ -644,6 +745,8 @@ type QueryServer interface { // ConsensusStates queries all the consensus state associated with a given // client. ConsensusStates(context.Context, *QueryConsensusStatesRequest) (*QueryConsensusStatesResponse, error) + // ClientParams queries all parameters of the ibc client. + ClientParams(context.Context, *QueryClientParamsRequest) (*QueryClientParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -662,6 +765,9 @@ func (*UnimplementedQueryServer) ConsensusState(ctx context.Context, req *QueryC func (*UnimplementedQueryServer) ConsensusStates(ctx context.Context, req *QueryConsensusStatesRequest) (*QueryConsensusStatesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ConsensusStates not implemented") } +func (*UnimplementedQueryServer) ClientParams(ctx context.Context, req *QueryClientParamsRequest) (*QueryClientParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClientParams not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -739,6 +845,24 @@ func _Query_ConsensusStates_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_ClientParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClientParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ClientParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Query/ClientParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ClientParams(ctx, req.(*QueryClientParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.core.client.v1.Query", HandlerType: (*QueryServer)(nil), @@ -759,6 +883,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ConsensusStates", Handler: _Query_ConsensusStates_Handler, }, + { + MethodName: "ClientParams", + Handler: _Query_ClientParams_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/core/client/v1/query.proto", @@ -1123,6 +1251,64 @@ func (m *QueryConsensusStatesResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *QueryClientParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryClientParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryClientParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryClientParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClientParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1275,6 +1461,28 @@ func (m *QueryConsensusStatesResponse) Size() (n int) { return n } +func (m *QueryClientParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryClientParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1669,7 +1877,7 @@ func (m *QueryClientStatesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ClientStates = append(m.ClientStates, &IdentifiedClientState{}) + m.ClientStates = append(m.ClientStates, IdentifiedClientState{}) if err := m.ClientStates[len(m.ClientStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2277,6 +2485,148 @@ func (m *QueryConsensusStatesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryClientParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryClientParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryClientParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryClientParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClientParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/core/02-client/types/query.pb.gw.go b/x/ibc/core/02-client/types/query.pb.gw.go index 935c305d64..77b3df69a8 100644 --- a/x/ibc/core/02-client/types/query.pb.gw.go +++ b/x/ibc/core/02-client/types/query.pb.gw.go @@ -309,6 +309,24 @@ func local_request_Query_ConsensusStates_0(ctx context.Context, marshaler runtim } +func request_Query_ClientParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClientParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.ClientParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ClientParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClientParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.ClientParams(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -395,6 +413,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ClientParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ClientParams_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ClientParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -516,17 +554,39 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ClientParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ClientParams_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ClientParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_Query_ClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ibc", "client", "v1beta1", "client_states", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1beta1", "client_states", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ClientStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "client", "v1beta1", "client_states"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ClientStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "client", "v1beta1", "client_states"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "client", "v1beta1", "consensus_states", "client_id", "version", "version_number", "height", "version_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"ibc", "core", "client", "v1beta1", "consensus_states", "client_id", "version", "version_number", "height", "version_height"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ConsensusStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ibc", "client", "v1beta1", "consensus_states", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConsensusStates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "client", "v1beta1", "consensus_states", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_ClientParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "client", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -537,4 +597,6 @@ var ( forward_Query_ConsensusState_0 = runtime.ForwardResponseMessage forward_Query_ConsensusStates_0 = runtime.ForwardResponseMessage + + forward_Query_ClientParams_0 = runtime.ForwardResponseMessage ) diff --git a/x/ibc/core/02-client/types/tx.pb.go b/x/ibc/core/02-client/types/tx.pb.go new file mode 100644 index 0000000000..4b637e5ba6 --- /dev/null +++ b/x/ibc/core/02-client/types/tx.pb.go @@ -0,0 +1,2128 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/core/client/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgCreateClient defines a message to create an IBC client +type MsgCreateClient struct { + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // light client state + ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` + // consensus state associated with the client that corresponds to a given + // height. + ConsensusState *types.Any `protobuf:"bytes,3,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty" yaml:"consensus_state"` + // signer address + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgCreateClient) Reset() { *m = MsgCreateClient{} } +func (m *MsgCreateClient) String() string { return proto.CompactTextString(m) } +func (*MsgCreateClient) ProtoMessage() {} +func (*MsgCreateClient) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{0} +} +func (m *MsgCreateClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateClient.Merge(m, src) +} +func (m *MsgCreateClient) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateClient proto.InternalMessageInfo + +// MsgCreateClientResponse defines the Msg/CreateClient response type. +type MsgCreateClientResponse struct { +} + +func (m *MsgCreateClientResponse) Reset() { *m = MsgCreateClientResponse{} } +func (m *MsgCreateClientResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateClientResponse) ProtoMessage() {} +func (*MsgCreateClientResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{1} +} +func (m *MsgCreateClientResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateClientResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateClientResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateClientResponse.Merge(m, src) +} +func (m *MsgCreateClientResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateClientResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateClientResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateClientResponse proto.InternalMessageInfo + +// MsgUpdateClient defines an sdk.Msg to update a IBC client state using +// the given header. +type MsgUpdateClient struct { + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // header to update the light client + Header *types.Any `protobuf:"bytes,2,opt,name=header,proto3" json:"header,omitempty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgUpdateClient) Reset() { *m = MsgUpdateClient{} } +func (m *MsgUpdateClient) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateClient) ProtoMessage() {} +func (*MsgUpdateClient) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{2} +} +func (m *MsgUpdateClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateClient.Merge(m, src) +} +func (m *MsgUpdateClient) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateClient proto.InternalMessageInfo + +// MsgUpdateClientResponse defines the Msg/UpdateClient response type. +type MsgUpdateClientResponse struct { +} + +func (m *MsgUpdateClientResponse) Reset() { *m = MsgUpdateClientResponse{} } +func (m *MsgUpdateClientResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateClientResponse) ProtoMessage() {} +func (*MsgUpdateClientResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{3} +} +func (m *MsgUpdateClientResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateClientResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateClientResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateClientResponse.Merge(m, src) +} +func (m *MsgUpdateClientResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateClientResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateClientResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateClientResponse proto.InternalMessageInfo + +// MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client state +type MsgUpgradeClient struct { + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // upgraded client state + ClientState *types.Any `protobuf:"bytes,2,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty" yaml:"client_state"` + // height at which old chain halts and upgrades (i.e last block executed) + UpgradeHeight *Height `protobuf:"bytes,3,opt,name=upgrade_height,json=upgradeHeight,proto3" json:"upgrade_height,omitempty" yaml:"upgrade_height"` + // proof that old chain committed to new client + ProofUpgrade []byte `protobuf:"bytes,4,opt,name=proof_upgrade,json=proofUpgrade,proto3" json:"proof_upgrade,omitempty" yaml:"proof_upgrade"` + // signer address + Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgUpgradeClient) Reset() { *m = MsgUpgradeClient{} } +func (m *MsgUpgradeClient) String() string { return proto.CompactTextString(m) } +func (*MsgUpgradeClient) ProtoMessage() {} +func (*MsgUpgradeClient) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{4} +} +func (m *MsgUpgradeClient) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpgradeClient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpgradeClient.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpgradeClient) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpgradeClient.Merge(m, src) +} +func (m *MsgUpgradeClient) XXX_Size() int { + return m.Size() +} +func (m *MsgUpgradeClient) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpgradeClient.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpgradeClient proto.InternalMessageInfo + +func (m *MsgUpgradeClient) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *MsgUpgradeClient) GetClientState() *types.Any { + if m != nil { + return m.ClientState + } + return nil +} + +func (m *MsgUpgradeClient) GetUpgradeHeight() *Height { + if m != nil { + return m.UpgradeHeight + } + return nil +} + +func (m *MsgUpgradeClient) GetProofUpgrade() []byte { + if m != nil { + return m.ProofUpgrade + } + return nil +} + +func (m *MsgUpgradeClient) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. +type MsgUpgradeClientResponse struct { +} + +func (m *MsgUpgradeClientResponse) Reset() { *m = MsgUpgradeClientResponse{} } +func (m *MsgUpgradeClientResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpgradeClientResponse) ProtoMessage() {} +func (*MsgUpgradeClientResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{5} +} +func (m *MsgUpgradeClientResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpgradeClientResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpgradeClientResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpgradeClientResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpgradeClientResponse.Merge(m, src) +} +func (m *MsgUpgradeClientResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpgradeClientResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpgradeClientResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpgradeClientResponse proto.InternalMessageInfo + +// MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for +// light client misbehaviour. +type MsgSubmitMisbehaviour struct { + // client unique identifier + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` + // misbehaviour used for freezing the light client + Misbehaviour *types.Any `protobuf:"bytes,2,opt,name=misbehaviour,proto3" json:"misbehaviour,omitempty"` + // signer address + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgSubmitMisbehaviour) Reset() { *m = MsgSubmitMisbehaviour{} } +func (m *MsgSubmitMisbehaviour) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitMisbehaviour) ProtoMessage() {} +func (*MsgSubmitMisbehaviour) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{6} +} +func (m *MsgSubmitMisbehaviour) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitMisbehaviour) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitMisbehaviour.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSubmitMisbehaviour) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitMisbehaviour.Merge(m, src) +} +func (m *MsgSubmitMisbehaviour) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitMisbehaviour) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitMisbehaviour.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitMisbehaviour proto.InternalMessageInfo + +// MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response type. +type MsgSubmitMisbehaviourResponse struct { +} + +func (m *MsgSubmitMisbehaviourResponse) Reset() { *m = MsgSubmitMisbehaviourResponse{} } +func (m *MsgSubmitMisbehaviourResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitMisbehaviourResponse) ProtoMessage() {} +func (*MsgSubmitMisbehaviourResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_cb5dc4651eb49a04, []int{7} +} +func (m *MsgSubmitMisbehaviourResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitMisbehaviourResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitMisbehaviourResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSubmitMisbehaviourResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitMisbehaviourResponse.Merge(m, src) +} +func (m *MsgSubmitMisbehaviourResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitMisbehaviourResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitMisbehaviourResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitMisbehaviourResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateClient)(nil), "ibc.core.client.v1.MsgCreateClient") + proto.RegisterType((*MsgCreateClientResponse)(nil), "ibc.core.client.v1.MsgCreateClientResponse") + proto.RegisterType((*MsgUpdateClient)(nil), "ibc.core.client.v1.MsgUpdateClient") + proto.RegisterType((*MsgUpdateClientResponse)(nil), "ibc.core.client.v1.MsgUpdateClientResponse") + proto.RegisterType((*MsgUpgradeClient)(nil), "ibc.core.client.v1.MsgUpgradeClient") + proto.RegisterType((*MsgUpgradeClientResponse)(nil), "ibc.core.client.v1.MsgUpgradeClientResponse") + proto.RegisterType((*MsgSubmitMisbehaviour)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviour") + proto.RegisterType((*MsgSubmitMisbehaviourResponse)(nil), "ibc.core.client.v1.MsgSubmitMisbehaviourResponse") +} + +func init() { proto.RegisterFile("ibc/core/client/v1/tx.proto", fileDescriptor_cb5dc4651eb49a04) } + +var fileDescriptor_cb5dc4651eb49a04 = []byte{ + // 608 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0x8f, 0x1b, 0x88, 0xda, 0x6b, 0xd2, 0x56, 0x26, 0x6d, 0x13, 0x23, 0xec, 0xca, 0x30, 0x14, + 0xd1, 0xda, 0x24, 0x0c, 0xa0, 0x4a, 0x0c, 0xa4, 0x0b, 0x0c, 0x91, 0xc0, 0x15, 0x03, 0x08, 0x29, + 0xf8, 0xcf, 0xf5, 0x62, 0x91, 0xf8, 0x22, 0xdf, 0x39, 0x6a, 0xbe, 0x01, 0x23, 0x12, 0x7c, 0x80, + 0x8a, 0x81, 0xcf, 0xc2, 0xc0, 0xd0, 0x91, 0x29, 0x42, 0xc9, 0xc2, 0x9c, 0x4f, 0x80, 0x7c, 0x77, + 0xb1, 0xec, 0x34, 0x89, 0x22, 0x58, 0x98, 0xe2, 0x77, 0xef, 0xf7, 0x7e, 0xef, 0xe7, 0xdf, 0x7b, + 0x17, 0x83, 0xdb, 0xbe, 0xe3, 0x9a, 0x2e, 0x0e, 0xa1, 0xe9, 0x76, 0x7c, 0x18, 0x50, 0xb3, 0x5f, + 0x33, 0xe9, 0x85, 0xd1, 0x0b, 0x31, 0xc5, 0xb2, 0xec, 0x3b, 0xae, 0x11, 0x27, 0x0d, 0x9e, 0x34, + 0xfa, 0x35, 0xa5, 0x8c, 0x30, 0xc2, 0x2c, 0x6d, 0xc6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 0x97, 0xff, 0xde, 0xc2, 0xea, 0x14, 0x4a, 0x39, + 0x5a, 0x05, 0x95, 0x34, 0x09, 0x81, 0x3c, 0x67, 0xec, 0xf7, 0x17, 0x70, 0x5c, 0x87, 0x2a, 0xb5, + 0x95, 0xa1, 0xd3, 0x9e, 0x8d, 0x57, 0xdf, 0x47, 0xaa, 0x74, 0x35, 0x52, 0xa5, 0x5f, 0x23, 0x55, + 0xfa, 0x34, 0x56, 0x73, 0x57, 0x63, 0x35, 0xf7, 0x73, 0xac, 0xe6, 0xde, 0x3e, 0x46, 0x3e, 0x6d, + 0x47, 0x8e, 0xe1, 0xe2, 0xae, 0xe9, 0x62, 0xd2, 0xc5, 0x44, 0xfc, 0x1c, 0x13, 0xef, 0x83, 0x79, + 0x61, 0x26, 0x9f, 0x85, 0x87, 0xf5, 0x63, 0xf1, 0x65, 0xa0, 0x83, 0x1e, 0x24, 0x4e, 0x81, 0xad, + 0xd5, 0xa3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x03, 0x55, 0x1e, 0x9b, 0x06, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // CreateClient defines a rpc handler method for MsgCreateClient. + CreateClient(ctx context.Context, in *MsgCreateClient, opts ...grpc.CallOption) (*MsgCreateClientResponse, error) + // UpdateClient defines a rpc handler method for MsgUpdateClient. + UpdateClient(ctx context.Context, in *MsgUpdateClient, opts ...grpc.CallOption) (*MsgUpdateClientResponse, error) + // UpgradeClient defines a rpc handler method for MsgUpgradeClient. + UpgradeClient(ctx context.Context, in *MsgUpgradeClient, opts ...grpc.CallOption) (*MsgUpgradeClientResponse, error) + // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. + SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateClient(ctx context.Context, in *MsgCreateClient, opts ...grpc.CallOption) (*MsgCreateClientResponse, error) { + out := new(MsgCreateClientResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/CreateClient", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateClient(ctx context.Context, in *MsgUpdateClient, opts ...grpc.CallOption) (*MsgUpdateClientResponse, error) { + out := new(MsgUpdateClientResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/UpdateClient", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpgradeClient(ctx context.Context, in *MsgUpgradeClient, opts ...grpc.CallOption) (*MsgUpgradeClientResponse, error) { + out := new(MsgUpgradeClientResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/UpgradeClient", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SubmitMisbehaviour(ctx context.Context, in *MsgSubmitMisbehaviour, opts ...grpc.CallOption) (*MsgSubmitMisbehaviourResponse, error) { + out := new(MsgSubmitMisbehaviourResponse) + err := c.cc.Invoke(ctx, "/ibc.core.client.v1.Msg/SubmitMisbehaviour", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateClient defines a rpc handler method for MsgCreateClient. + CreateClient(context.Context, *MsgCreateClient) (*MsgCreateClientResponse, error) + // UpdateClient defines a rpc handler method for MsgUpdateClient. + UpdateClient(context.Context, *MsgUpdateClient) (*MsgUpdateClientResponse, error) + // UpgradeClient defines a rpc handler method for MsgUpgradeClient. + UpgradeClient(context.Context, *MsgUpgradeClient) (*MsgUpgradeClientResponse, error) + // SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. + SubmitMisbehaviour(context.Context, *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateClient(ctx context.Context, req *MsgCreateClient) (*MsgCreateClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateClient not implemented") +} +func (*UnimplementedMsgServer) UpdateClient(ctx context.Context, req *MsgUpdateClient) (*MsgUpdateClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateClient not implemented") +} +func (*UnimplementedMsgServer) UpgradeClient(ctx context.Context, req *MsgUpgradeClient) (*MsgUpgradeClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpgradeClient not implemented") +} +func (*UnimplementedMsgServer) SubmitMisbehaviour(ctx context.Context, req *MsgSubmitMisbehaviour) (*MsgSubmitMisbehaviourResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitMisbehaviour not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateClient) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateClient(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/CreateClient", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateClient(ctx, req.(*MsgCreateClient)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateClient) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateClient(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/UpdateClient", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateClient(ctx, req.(*MsgUpdateClient)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpgradeClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpgradeClient) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpgradeClient(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/UpgradeClient", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpgradeClient(ctx, req.(*MsgUpgradeClient)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SubmitMisbehaviour_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitMisbehaviour) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitMisbehaviour(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.client.v1.Msg/SubmitMisbehaviour", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitMisbehaviour(ctx, req.(*MsgSubmitMisbehaviour)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.core.client.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateClient", + Handler: _Msg_CreateClient_Handler, + }, + { + MethodName: "UpdateClient", + Handler: _Msg_UpdateClient_Handler, + }, + { + MethodName: "UpgradeClient", + Handler: _Msg_UpgradeClient_Handler, + }, + { + MethodName: "SubmitMisbehaviour", + Handler: _Msg_SubmitMisbehaviour_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/core/client/v1/tx.proto", +} + +func (m *MsgCreateClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreateClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if m.ConsensusState != nil { + { + size, err := m.ConsensusState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ClientState != nil { + { + size, err := m.ClientState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateClientResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreateClientResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if m.Header != nil { + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateClientResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateClientResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpgradeClient) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpgradeClient) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpgradeClient) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x2a + } + if len(m.ProofUpgrade) > 0 { + i -= len(m.ProofUpgrade) + copy(dAtA[i:], m.ProofUpgrade) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUpgrade))) + i-- + dAtA[i] = 0x22 + } + if m.UpgradeHeight != nil { + { + size, err := m.UpgradeHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ClientState != nil { + { + size, err := m.ClientState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpgradeClientResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpgradeClientResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpgradeClientResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSubmitMisbehaviour) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSubmitMisbehaviour) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitMisbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a + } + if m.Misbehaviour != nil { + { + size, err := m.Misbehaviour.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitMisbehaviourResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSubmitMisbehaviourResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitMisbehaviourResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ClientState != nil { + l = m.ClientState.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.ConsensusState != nil { + l = m.ConsensusState.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateClientResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateClientResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpgradeClient) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ClientState != nil { + l = m.ClientState.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.UpgradeHeight != nil { + l = m.UpgradeHeight.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ProofUpgrade) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpgradeClientResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitMisbehaviour) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Misbehaviour != nil { + l = m.Misbehaviour.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitMisbehaviourResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ClientState == nil { + m.ClientState = &types.Any{} + } + if err := m.ClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ConsensusState == nil { + m.ConsensusState = &types.Any{} + } + if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateClientResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &types.Any{} + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateClientResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpgradeClient) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpgradeClient: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpgradeClient: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ClientState == nil { + m.ClientState = &types.Any{} + } + if err := m.ClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpgradeHeight", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UpgradeHeight == nil { + m.UpgradeHeight = &Height{} + } + if err := m.UpgradeHeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofUpgrade", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofUpgrade = append(m.ProofUpgrade[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUpgrade == nil { + m.ProofUpgrade = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpgradeClientResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpgradeClientResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpgradeClientResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSubmitMisbehaviour) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSubmitMisbehaviour: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitMisbehaviour: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Misbehaviour", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Misbehaviour == nil { + m.Misbehaviour = &types.Any{} + } + if err := m.Misbehaviour.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSubmitMisbehaviourResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSubmitMisbehaviourResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitMisbehaviourResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc/core/03-connection/client/utils/utils.go b/x/ibc/core/03-connection/client/utils/utils.go index 955ecfe6ba..44283aef82 100644 --- a/x/ibc/core/03-connection/client/utils/utils.go +++ b/x/ibc/core/03-connection/client/utils/utils.go @@ -38,7 +38,7 @@ func QueryConnection( } func queryConnectionABCI(clientCtx client.Context, connectionID string) (*types.QueryConnectionResponse, error) { - key := host.KeyConnection(connectionID) + key := host.ConnectionKey(connectionID) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { @@ -79,7 +79,7 @@ func QueryClientConnections( } func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*types.QueryClientConnectionsResponse, error) { - key := host.KeyClientConnections(clientID) + key := host.ClientConnectionsKey(clientID) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { diff --git a/x/ibc/core/03-connection/keeper/grpc_query.go b/x/ibc/core/03-connection/keeper/grpc_query.go index 1c644e3da7..5b34d1e4ef 100644 --- a/x/ibc/core/03-connection/keeper/grpc_query.go +++ b/x/ibc/core/03-connection/keeper/grpc_query.go @@ -51,7 +51,7 @@ func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsReques ctx := sdk.UnwrapSDKContext(c) connections := []*types.IdentifiedConnection{} - store := prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyConnectionPrefix) + store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyConnectionPrefix)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { var result types.ConnectionEnd diff --git a/x/ibc/core/03-connection/keeper/grpc_query_test.go b/x/ibc/core/03-connection/keeper/grpc_query_test.go index 5a8122e279..7e27b5af10 100644 --- a/x/ibc/core/03-connection/keeper/grpc_query_test.go +++ b/x/ibc/core/03-connection/keeper/grpc_query_test.go @@ -47,7 +47,7 @@ func (suite *KeeperTestSuite) TestQueryConnection() { { "success", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA := suite.chainA.GetFirstTestConnection(clientA, clientB) connB := suite.chainB.GetFirstTestConnection(clientB, clientA) @@ -111,11 +111,11 @@ func (suite *KeeperTestSuite) TestQueryConnections() { { "success", func() { - clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) connA1, connB1, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) - clientA1, clientB1, connA2, connB2 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA1, clientB1, connA2, connB2 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) counterparty1 := types.NewCounterparty(clientB, connB0.ID, suite.chainB.GetPrefix()) counterparty2 := types.NewCounterparty(clientB, connB1.ID, suite.chainB.GetPrefix()) @@ -197,7 +197,7 @@ func (suite *KeeperTestSuite) TestQueryClientConnections() { { "success", func() { - clientA, clientB, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) connA1, _ := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB) expPaths = []string{connA0.ID, connA1.ID} suite.chainA.App.IBCKeeper.ConnectionKeeper.SetClientConnectionPaths(suite.chainA.GetContext(), clientA, expPaths) @@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionClientState() { { "success", func() { - clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) expClientState := suite.chainA.GetClientState(clientA) expIdentifiedClientState = clienttypes.NewIdentifiedClientState(clientA, expClientState) @@ -371,7 +371,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionConsensusState() { { "success", func() { - clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) expConsensusState, _ = suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight()) diff --git a/x/ibc/core/03-connection/keeper/handshake_test.go b/x/ibc/core/03-connection/keeper/handshake_test.go index b677b23520..2ece130ebb 100644 --- a/x/ibc/core/03-connection/keeper/handshake_test.go +++ b/x/ibc/core/03-connection/keeper/handshake_test.go @@ -8,7 +8,6 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" - ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) // TestConnOpenInit - chainA initializes (INIT state) a connection with @@ -27,26 +26,26 @@ func (suite *KeeperTestSuite) TestConnOpenInit() { expPass bool }{ {"success", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) }, true}, {"success with empty counterparty identifier", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) emptyConnBID = true }, true}, {"success with non empty version", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) version = types.ExportedVersionsToProto(types.GetCompatibleVersions())[0] }, true}, {"connection already exists", func() { - clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) }, false}, {"invalid version", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) version = &types.Version{} }, false}, {"couldn't add connection to client", func() { // swap client identifiers to result in client that does not exist - clientB, clientA = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientB, clientA = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) }, false}, } @@ -94,7 +93,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { expPass bool }{ {"success", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -102,7 +101,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { counterpartyClient = suite.chainA.GetClientState(clientA) }, true}, {"success with empty counterpartyChosenConnectionID", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -114,17 +113,17 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connection) - err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) }, true}, {"counterpartyChosenConnectionID does not match desiredConnectionID", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -136,17 +135,17 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connection) - err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) }, false}, {"invalid counterparty client", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -161,7 +160,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, tmClient) }, false}, {"consensus height >= latest height", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -171,7 +170,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { consensusHeight = clienttypes.GetSelfHeight(suite.chainB.GetContext()) }, false}, {"self consensus state not found", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -181,7 +180,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { consensusHeight = clienttypes.NewHeight(0, 1) }, false}, {"counterparty versions is empty", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -191,7 +190,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { versions = nil }, false}, {"counterparty versions don't have a match", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -202,14 +201,14 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { versions = []exported.Version{version} }, false}, {"connection state verification failed", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // chainA connection not created // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) }, false}, {"client state verification failed", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -222,7 +221,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { tmClient.LatestHeight = tmClient.LatestHeight.Increment() }, false}, {"consensus state verification failed", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) @@ -241,7 +240,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { suite.Require().NoError(err) }, false}, {"invalid previous connection is in TRYOPEN", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // open init chainA connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) @@ -251,14 +250,14 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA) suite.Require().NoError(err) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) // retrieve client state of chainA to pass as counterpartyClient counterpartyClient = suite.chainA.GetClientState(clientA) }, false}, {"invalid previous connection has invalid versions", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // open init chainA connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) @@ -273,11 +272,11 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { suite.Require().True(found) connection.State = types.INIT - connection.Versions = []*types.Version{&types.Version{}} + connection.Versions = []*types.Version{{}} suite.chainB.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainB.GetContext(), connB.ID, connection) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) // retrieve client state of chainA to pass as counterpartyClient @@ -306,18 +305,18 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { counterpartyChosenConnectionID = connection.Counterparty.ConnectionId } - connectionKey := host.KeyConnection(connA.ID) + connectionKey := host.ConnectionKey(connA.ID) proofInit, proofHeight := suite.chainA.QueryProof(connectionKey) if consensusHeight.IsZero() { // retrieve consensus state height to provide proof for consensusHeight = counterpartyClient.GetLatestHeight() } - consensusKey := host.FullKeyClientPath(clientA, host.KeyConsensusState(consensusHeight)) + consensusKey := host.FullConsensusStateKey(clientA, consensusHeight) proofConsensus, _ := suite.chainA.QueryProof(consensusKey) // retrieve proof of counterparty clientstate on chainA - clientKey := host.FullKeyClientPath(clientA, host.KeyClientState()) + clientKey := host.FullClientStateKey(clientA) proofClient, _ := suite.chainA.QueryProof(clientKey) err := suite.chainB.App.IBCKeeper.ConnectionKeeper.ConnOpenTry( @@ -353,7 +352,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { expPass bool }{ {"success", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -364,7 +363,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { counterpartyClient = suite.chainB.GetClientState(clientB) }, true}, {"success with empty stored counterparty connection ID", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -381,10 +380,10 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connection) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) - err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) // retrieve client state of chainB to pass as counterpartyClient @@ -392,7 +391,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { }, true}, {"success from tryopen", func() { // chainA is in TRYOPEN, chainB is in TRYOPEN - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA) suite.Require().NoError(err) @@ -404,16 +403,16 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { connection.State = types.TRYOPEN suite.chainB.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainB.GetContext(), connB.ID, connection) // update clientB so state change is committed - suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) // retrieve client state of chainB to pass as counterpartyClient counterpartyClient = suite.chainB.GetClientState(clientB) }, true}, {"success from tryopen with empty stored connection id", func() { // chainA is in TRYOPEN, chainB is in TRYOPEN - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA) suite.Require().NoError(err) @@ -435,15 +434,15 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connection) // update clientB so state change is committed - suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) // retrieve client state of chainB to pass as counterpartyClient counterpartyClient = suite.chainB.GetClientState(clientB) }, true}, {"invalid counterparty client", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -461,7 +460,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.Require().NoError(err) }, false}, {"consensus height >= latest height", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -475,13 +474,13 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { }, false}, {"connection not found", func() { // connections are never created - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // retrieve client state of chainB to pass as counterpartyClient counterpartyClient = suite.chainB.GetClientState(clientB) }, false}, {"invalid counterparty connection ID", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -499,15 +498,15 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connection) - err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) }, false}, {"connection state is not INIT", func() { // connection state is already OPEN on chainA - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -522,7 +521,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { }, false}, {"connection is in INIT but the proposed version is invalid", func() { // chainA is in INIT, chainB is in TRYOPEN - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -536,7 +535,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { }, false}, {"connection is in TRYOPEN but the set version in the connection is invalid", func() { // chainA is in TRYOPEN, chainB is in TRYOPEN - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA) suite.Require().NoError(err) @@ -549,8 +548,8 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.chainB.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainB.GetContext(), connB.ID, connection) // update clientB so state change is committed - suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) // retrieve client state of chainB to pass as counterpartyClient counterpartyClient = suite.chainB.GetClientState(clientB) @@ -558,7 +557,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { version = types.NewVersion("2.0", nil) }, false}, {"incompatible IBC versions", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -572,7 +571,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { version = types.NewVersion("2.0", nil) }, false}, {"empty version", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -585,7 +584,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { version = &types.Version{} }, false}, {"feature set verification failed - unsupported feature", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -598,7 +597,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { version = types.NewVersion(types.DefaultIBCVersionIdentifier, []string{"ORDER_ORDERED", "ORDER_UNORDERED", "ORDER_DAG"}) }, false}, {"self consensus state not found", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -612,7 +611,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { }, false}, {"connection state verification failed", func() { // chainB connection is not in INIT - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, _, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -620,7 +619,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { counterpartyClient = suite.chainB.GetClientState(clientB) }, false}, {"client state verification failed", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -636,7 +635,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { suite.Require().NoError(err) }, false}, {"consensus state verification failed", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -661,10 +660,10 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { for _, tc := range testCases { tc := tc suite.Run(tc.msg, func() { - suite.SetupTest() // reset + suite.SetupTest() // reset version = types.ExportedVersionsToProto(types.GetCompatibleVersions())[0] // must be explicitly changed in malleate - consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate - counterpartyConnectionID = "" // must be explicitly changed in malleate + consensusHeight = clienttypes.ZeroHeight() // must be explicitly changed in malleate + counterpartyConnectionID = "" // must be explicitly changed in malleate tc.malleate() @@ -675,7 +674,7 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { counterpartyConnectionID = connB.ID } - connectionKey := host.KeyConnection(connB.ID) + connectionKey := host.ConnectionKey(connB.ID) proofTry, proofHeight := suite.chainB.QueryProof(connectionKey) if consensusHeight.IsZero() { @@ -683,11 +682,11 @@ func (suite *KeeperTestSuite) TestConnOpenAck() { clientState := suite.chainB.GetClientState(clientB) consensusHeight = clientState.GetLatestHeight() } - consensusKey := host.FullKeyClientPath(clientB, host.KeyConsensusState(consensusHeight)) + consensusKey := host.FullConsensusStateKey(clientB, consensusHeight) proofConsensus, _ := suite.chainB.QueryProof(consensusKey) // retrieve proof of counterparty clientstate on chainA - clientKey := host.FullKeyClientPath(clientB, host.KeyClientState()) + clientKey := host.FullClientStateKey(clientB) proofClient, _ := suite.chainB.QueryProof(clientKey) err := suite.chainA.App.IBCKeeper.ConnectionKeeper.ConnOpenAck( @@ -717,7 +716,7 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() { expPass bool }{ {"success", func() { - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -729,15 +728,15 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() { }, true}, {"connection not found", func() { // connections are never created - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) }, false}, {"chain B's connection state is not TRYOPEN", func() { // connections are OPEN - clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, _, _ = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) }, false}, {"connection state verification failed", func() { // chainA is in INIT - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -757,7 +756,7 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() { connA := suite.chainA.GetFirstTestConnection(clientA, clientB) connB := suite.chainB.GetFirstTestConnection(clientB, clientA) - connectionKey := host.KeyConnection(connA.ID) + connectionKey := host.ConnectionKey(connA.ID) proofAck, proofHeight := suite.chainA.QueryProof(connectionKey) err := suite.chainB.App.IBCKeeper.ConnectionKeeper.ConnOpenConfirm( @@ -772,60 +771,3 @@ func (suite *KeeperTestSuite) TestConnOpenConfirm() { }) } } - -// Ensure consensus params are correctly validated by executing messages. Consensus params are -// set in context by baseapp so test should deliver messages and not call the functions directly. -// Only invalid cases are tested since successful instances are by default tested by the testing -// package. -func (suite *KeeperTestSuite) TestConsensusParamsValidation() { - // invalid client state in ConnOpenTry - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) - connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) - suite.Require().NoError(err) - - // set incorrect consensus params on counterparty client on chainA - clientState := suite.chainA.GetClientState(clientA) - tmClient, ok := clientState.(*ibctmtypes.ClientState) - suite.Require().True(ok) - tmClient.ConsensusParams.Evidence.MaxAgeDuration++ - - suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, tmClient) - - // should fail on validate self client - ibctesting.ExpSimPassSend = false - ibctesting.ExpPassSend = false - err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA) - suite.Require().Error(err) - - // reset values - ibctesting.ExpSimPassSend = true - ibctesting.ExpPassSend = true - - suite.SetupTest() // reset - - // invalid client state in ConnOpenAck - clientA, clientB = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) - connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) - suite.Require().NoError(err) - - err = suite.coordinator.ConnOpenTry(suite.chainB, suite.chainA, connB, connA) - suite.Require().NoError(err) - - // set incorrect consensus params on counterparty client on chainB - clientState = suite.chainB.GetClientState(clientB) - tmClient, ok = clientState.(*ibctmtypes.ClientState) - suite.Require().True(ok) - tmClient.ConsensusParams.Evidence.MaxAgeDuration++ - - suite.chainB.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainB.GetContext(), clientB, tmClient) - - // should fail on validate self client - ibctesting.ExpSimPassSend = false - ibctesting.ExpPassSend = false - err = suite.coordinator.ConnOpenAck(suite.chainA, suite.chainB, connA, connB) - suite.Require().Error(err) - - // reset values - ibctesting.ExpSimPassSend = true - ibctesting.ExpPassSend = true -} diff --git a/x/ibc/core/03-connection/keeper/keeper.go b/x/ibc/core/03-connection/keeper/keeper.go index c838b4fa6f..dda5295877 100644 --- a/x/ibc/core/03-connection/keeper/keeper.go +++ b/x/ibc/core/03-connection/keeper/keeper.go @@ -48,7 +48,7 @@ func (k Keeper) GetCommitmentPrefix() exported.Prefix { // GetConnection returns a connection with a particular identifier func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.ConnectionEnd, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyConnection(connectionID)) + bz := store.Get(host.ConnectionKey(connectionID)) if bz == nil { return types.ConnectionEnd{}, false } @@ -63,7 +63,7 @@ func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (types.Conne func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection types.ConnectionEnd) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshalBinaryBare(&connection) - store.Set(host.KeyConnection(connectionID), bz) + store.Set(host.ConnectionKey(connectionID), bz) } // GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the @@ -87,7 +87,7 @@ func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.Connectio // particular client func (k Keeper) GetClientConnectionPaths(ctx sdk.Context, clientID string) ([]string, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyClientConnections(clientID)) + bz := store.Get(host.ClientConnectionsKey(clientID)) if bz == nil { return nil, false } @@ -102,7 +102,7 @@ func (k Keeper) SetClientConnectionPaths(ctx sdk.Context, clientID string, paths store := ctx.KVStore(k.storeKey) clientPaths := types.ClientPaths{Paths: paths} bz := k.cdc.MustMarshalBinaryBare(&clientPaths) - store.Set(host.KeyClientConnections(clientID), bz) + store.Set(host.ClientConnectionsKey(clientID), bz) } // GetAllClientConnectionPaths returns all stored clients connection id paths. It @@ -129,7 +129,7 @@ func (k Keeper) GetAllClientConnectionPaths(ctx sdk.Context) []types.ConnectionP // iterator will close and stop. func (k Keeper) IterateConnections(ctx sdk.Context, cb func(types.IdentifiedConnection) bool) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, host.KeyConnectionPrefix) + iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyConnectionPrefix)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { diff --git a/x/ibc/core/03-connection/keeper/keeper_test.go b/x/ibc/core/03-connection/keeper/keeper_test.go index 3ae867a5a0..cf8f447179 100644 --- a/x/ibc/core/03-connection/keeper/keeper_test.go +++ b/x/ibc/core/03-connection/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -31,7 +32,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestSetAndGetConnection() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) connA := suite.chainA.GetFirstTestConnection(clientA, clientB) _, existed := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetConnection(suite.chainA.GetContext(), connA.ID) suite.Require().False(existed) @@ -42,7 +43,7 @@ func (suite *KeeperTestSuite) TestSetAndGetConnection() { } func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) _, existed := suite.chainA.App.IBCKeeper.ConnectionKeeper.GetClientConnectionPaths(suite.chainA.GetContext(), clientA) suite.False(existed) @@ -55,7 +56,7 @@ func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() { // create 2 connections: A0 - B0, A1 - B1 func (suite KeeperTestSuite) TestGetAllConnections() { - clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, connA0, connB0 := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) connA1, connB1 := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB) counterpartyB0 := types.NewCounterparty(clientB, connB0.ID, suite.chainB.GetPrefix()) // connection B0 @@ -77,8 +78,8 @@ func (suite KeeperTestSuite) TestGetAllConnections() { // the test creates 2 clients clientA0 and clientA1. clientA0 has a single // connection and clientA1 has 2 connections. func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() { - clientA0, _, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) - clientA1, clientB1, connA1, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA0, _, connA0, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) + clientA1, clientB1, connA1, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) connA2, _ := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA1, clientB1) expPaths := []types.ConnectionPaths{ @@ -102,7 +103,7 @@ func (suite *KeeperTestSuite) TestGetTimestampAtHeight() { expPass bool }{ {"verification success", func() { - _, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) connection = suite.chainA.GetConnection(connA) }, true}, {"consensus state not found", func() { diff --git a/x/ibc/core/03-connection/keeper/verify_test.go b/x/ibc/core/03-connection/keeper/verify_test.go index 7f9705a80b..ace373e12a 100644 --- a/x/ibc/core/03-connection/keeper/verify_test.go +++ b/x/ibc/core/03-connection/keeper/verify_test.go @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestVerifyClientState() { suite.Run(tc.msg, func() { suite.SetupTest() // reset - _, clientB, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, clientB, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) counterpartyClient, clientProof := suite.chainB.QueryClientStateProof(clientB) proofHeight := clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()-1)) @@ -83,20 +83,20 @@ func (suite *KeeperTestSuite) TestVerifyClientConsensusState() { expPass bool }{ {"verification success", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) }, true}, {"client state not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) changeClientID = true }, false}, {"consensus state not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) heightDiff = 5 }, false}, {"verification failed", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) clientB := connB.ClientID clientState := suite.chainB.GetClientState(clientB) @@ -170,7 +170,7 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { suite.Run(tc.msg, func() { suite.SetupTest() // reset - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) connection := suite.chainA.GetConnection(connA) if tc.changeClientID { @@ -178,7 +178,7 @@ func (suite *KeeperTestSuite) TestVerifyConnectionState() { } expectedConnection := suite.chainB.GetConnection(connB) - connectionKey := host.KeyConnection(connB.ID) + connectionKey := host.ConnectionKey(connB.ID) proof, proofHeight := suite.chainB.QueryProof(connectionKey) if tc.changeConnectionState { @@ -227,7 +227,7 @@ func (suite *KeeperTestSuite) TestVerifyChannelState() { connection.ClientId = ibctesting.InvalidID } - channelKey := host.KeyChannel(channelB.PortID, channelB.ID) + channelKey := host.ChannelKey(channelB.PortID, channelB.ID) proof, proofHeight := suite.chainB.QueryProof(channelKey) channel := suite.chainB.GetChannel(channelB) @@ -282,7 +282,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() { err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.Require().NoError(err) - commitmentKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + commitmentKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainA.QueryProof(commitmentKey) if tc.changePacketCommitmentState { @@ -340,7 +340,7 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() { err = suite.coordinator.RecvPacket(suite.chainA, suite.chainB, clientA, packet) suite.Require().NoError(err) - packetAckKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetAckKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetAckKey) ack := ibcmock.MockAcknowledgement @@ -402,10 +402,10 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() { } else { // need to update height to prove absence suite.coordinator.CommitBlock(suite.chainA, suite.chainB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) } - packetReceiptKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetReceiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetReceiptKey) err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyPacketReceiptAbsence( @@ -459,7 +459,7 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() { err = suite.coordinator.RecvPacket(suite.chainA, suite.chainB, clientA, packet) suite.Require().NoError(err) - nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + nextSeqRecvKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) proof, proofHeight := suite.chainB.QueryProof(nextSeqRecvKey) err = suite.chainA.App.IBCKeeper.ConnectionKeeper.VerifyNextSequenceRecv( diff --git a/x/ibc/core/03-connection/simulation/decoder.go b/x/ibc/core/03-connection/simulation/decoder.go index 4b2d3bdf88..ef988a103f 100644 --- a/x/ibc/core/03-connection/simulation/decoder.go +++ b/x/ibc/core/03-connection/simulation/decoder.go @@ -14,13 +14,13 @@ import ( // Value to the corresponding connection type. func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB kv.Pair) (string, bool) { switch { - case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyConnectionPrefix): + case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, []byte(host.KeyConnectionPrefix)): var clientConnectionsA, clientConnectionsB types.ClientPaths cdc.MustUnmarshalBinaryBare(kvA.Value, &clientConnectionsA) cdc.MustUnmarshalBinaryBare(kvB.Value, &clientConnectionsB) return fmt.Sprintf("ClientPaths A: %v\nClientPaths B: %v", clientConnectionsA, clientConnectionsB), true - case bytes.HasPrefix(kvA.Key, host.KeyConnectionPrefix): + case bytes.HasPrefix(kvA.Key, []byte(host.KeyConnectionPrefix)): var connectionA, connectionB types.ConnectionEnd cdc.MustUnmarshalBinaryBare(kvA.Value, &connectionA) cdc.MustUnmarshalBinaryBare(kvB.Value, &connectionB) diff --git a/x/ibc/core/03-connection/simulation/decoder_test.go b/x/ibc/core/03-connection/simulation/decoder_test.go index 7e36b05a70..673bf64006 100644 --- a/x/ibc/core/03-connection/simulation/decoder_test.go +++ b/x/ibc/core/03-connection/simulation/decoder_test.go @@ -31,11 +31,11 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ { - Key: host.KeyClientConnections(connection.ClientId), + Key: host.ClientConnectionsKey(connection.ClientId), Value: cdc.MustMarshalBinaryBare(&paths), }, { - Key: host.KeyConnection(connectionID), + Key: host.ConnectionKey(connectionID), Value: cdc.MustMarshalBinaryBare(&connection), }, { diff --git a/x/ibc/core/03-connection/types/connection_test.go b/x/ibc/core/03-connection/types/connection_test.go index c735841b0e..ff2aa08d4a 100644 --- a/x/ibc/core/03-connection/types/connection_test.go +++ b/x/ibc/core/03-connection/types/connection_test.go @@ -43,7 +43,7 @@ func TestConnectionValidateBasic(t *testing.T) { }, { "invalid version", - types.ConnectionEnd{clientID, []*types.Version{&types.Version{}}, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, + types.ConnectionEnd{clientID, []*types.Version{{}}, types.INIT, types.Counterparty{clientID2, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))}}, false, }, { diff --git a/x/ibc/core/03-connection/types/msgs_test.go b/x/ibc/core/03-connection/types/msgs_test.go index cfb8ce7351..675de99347 100644 --- a/x/ibc/core/03-connection/types/msgs_test.go +++ b/x/ibc/core/03-connection/types/msgs_test.go @@ -62,9 +62,10 @@ func (suite *MsgTestSuite) SetupTest() { Prove: true, }) - merkleProof := commitmenttypes.MerkleProof{Proof: res.ProofOps} + merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) + suite.Require().NoError(err) proof, err := app.AppCodec().MarshalBinaryBare(&merkleProof) - suite.NoError(err) + suite.Require().NoError(err) suite.proof = proof @@ -111,7 +112,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") clientState := ibctmtypes.NewClientState( - chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, + chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) // Pack consensus state into any to test unpacking error @@ -123,7 +124,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { // invalidClientState fails validateBasic invalidClient := ibctmtypes.NewClientState( - chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, + chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) provedID := "" @@ -149,7 +150,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { {"invalid consensusHeight", types.NewMsgConnectionOpenTry("ibcconntest", provedID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clienttypes.ZeroHeight(), signer), false}, {"empty singer", types.NewMsgConnectionOpenTry("ibcconntest", provedID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, nil), false}, {"success", types.NewMsgConnectionOpenTry("ibcconntest", provedID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{ibctesting.ConnectionVersion}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), true}, - {"invalid version", types.NewMsgConnectionOpenTry("ibcconntest", provedID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{&types.Version{}}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, + {"invalid version", types.NewMsgConnectionOpenTry("ibcconntest", provedID, "clienttotesta", "connectiontotest", "clienttotest", clientState, prefix, []*types.Version{{}}, suite.proof, suite.proof, suite.proof, clientHeight, clientHeight, signer), false}, } for _, tc := range testCases { @@ -165,7 +166,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenTry() { func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { signer, _ := sdk.AccAddressFromBech32("cosmos1ckgw5d7jfj7wwxjzs9fdrdev9vc8dzcw3n2lht") clientState := ibctmtypes.NewClientState( - chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, + chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) // Pack consensus state into any to test unpacking error @@ -176,7 +177,7 @@ func (suite *MsgTestSuite) TestNewMsgConnectionOpenAck() { // invalidClientState fails validateBasic invalidClient := ibctmtypes.NewClientState( - chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, + chainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false, ) connectionID := "ibcconntest" diff --git a/x/ibc/core/03-connection/types/query.pb.go b/x/ibc/core/03-connection/types/query.pb.go index 3007ac05bc..5c3a2bcb26 100644 --- a/x/ibc/core/03-connection/types/query.pb.go +++ b/x/ibc/core/03-connection/types/query.pb.go @@ -635,63 +635,63 @@ func init() { } var fileDescriptor_cd8d529f8c7cd06b = []byte{ - // 891 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x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0x1f, 0x00, 0x73, 0xfd, 0x67, 0x48, 0x85, 0x0e, 0x60, 0x26, 0x22, 0xea, 0xe7, 0xc0, - 0xec, 0xd8, 0x42, 0x66, 0xe5, 0x83, 0x41, 0x12, 0xed, 0x57, 0xa8, 0x17, 0xb8, 0xc7, 0x2e, 0xad, - 0x28, 0x62, 0xab, 0x1b, 0xa0, 0xcf, 0x62, 0xa0, 0xd3, 0x1c, 0xf4, 0xfc, 0xbd, 0xa0, 0x05, 0x18, - 0x15, 0x35, 0xda, 0x80, 0x4f, 0x1f, 0xa8, 0xab, 0xcc, 0xd7, 0xb7, 0xe1, 0x5b, 0x82, 0x2e, 0x4f, - 0x4b, 0x10, 0xf6, 0x0d, 0x38, 0x21, 0xb6, 0x88, 0x46, 0xea, 0x99, 0x08, 0xec, 0x57, 0xf4, 0x5f, - 0x00, 0xcc, 0x0f, 0x2a, 0x97, 0x9a, 0x2d, 0xc2, 0x57, 0x95, 0xb1, 0xac, 0x9b, 0x41, 0x55, 0x08, - 0x37, 0x61, 0xbc, 0x12, 0xc5, 0x0f, 0xc3, 0xf0, 0x63, 0x4e, 0x8e, 0x05, 0xdf, 0xbe, 0xd5, 0x55, - 0x81, 0xf8, 0x8b, 0xc0, 0x0c, 0x7a, 0x73, 0x80, 0x4a, 0x89, 0x37, 0xa8, 0x9c, 0xfb, 0xf7, 0x6a, - 0x26, 0xdb, 0x36, 0x6b, 0x27, 0x9b, 0x7a, 0x6c, 0x59, 0xbf, 0x75, 0xb7, 0xba, 0x00, 0xea, 0x77, - 0x1d, 0x22, 0x05, 0x31, 0xe1, 0xb4, 0x7b, 0x33, 0x19, 0x47, 0x52, 0x5b, 0x3f, 0x4c, 0x91, 0x63, - 0xbb, 0x98, 0x44, 0x4d, 0x19, 0x26, 0x65, 0xcf, 0x97, 0x6e, 0x52, 0xf8, 0x31, 0x85, 0xfc, 0x0d, - 0xc0, 0x77, 0x6e, 0x93, 0x0c, 0x69, 0x79, 0x7e, 0xd3, 0xff, 0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 0xdd, 0x9b, 0xc2, 0x0e, 0xba, 0x04, 0xf0, 0x65, 0xa2, 0x25, 0xa1, 0x0f, 0x87, 0x54, 0xaf, - 0xdf, 0x2b, 0xb5, 0xcd, 0x51, 0x4a, 0x25, 0xa1, 0x3d, 0x4e, 0xa8, 0x8c, 0x3e, 0x1e, 0x61, 0x64, - 0x88, 0x6a, 0x98, 0xe8, 0xa7, 0x34, 0xcc, 0x0d, 0xba, 0xd2, 0x68, 0x7b, 0x58, 0x88, 0x49, 0xfe, - 0xa5, 0x95, 0x46, 0xac, 0x96, 0x1c, 0xbf, 0xe5, 0x1c, 0x5b, 0x28, 0x18, 0x89, 0x63, 0xdc, 0x81, - 0x88, 0x34, 0x33, 0x72, 0x16, 0xb7, 0xc4, 0x0e, 0x11, 0x96, 0x11, 0xc5, 0xc5, 0x7b, 0xa7, 0xfc, - 0xe5, 0x79, 0x37, 0x0f, 0x2e, 0xba, 0x79, 0xf0, 0x57, 0x37, 0x0f, 0x7e, 0xb8, 0xce, 0xa7, 0x2e, - 0xae, 0xf3, 0xa9, 0xcb, 0xeb, 0x7c, 0xea, 0xab, 0x2d, 0xc7, 0x0d, 0xaa, 0x4d, 0x0b, 0xdb, 0xac, - 0x46, 0xe4, 0x3f, 0x5f, 0xf1, 0xb3, 0xe4, 0x57, 0xbe, 0x26, 0xdf, 0x90, 0x9b, 0x3f, 0xb0, 0xcb, - 0xab, 0x4b, 0x0a, 0xea, 0xa0, 0x5d, 0xa7, 0xbe, 0xf5, 0x94, 0x7b, 0xdf, 0xea, 0x7f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x3b, 0x66, 0x6e, 0x99, 0x86, 0x0b, 0x00, 0x00, + // 887 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x4f, 0x33, 0x45, + 0x18, 0xee, 0x14, 0xbe, 0x2f, 0x1f, 0x53, 0x40, 0x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0x6d, + 0x6b, 0x94, 0x52, 0xc9, 0xea, 0x73, 0xce, 0xea, 0x00, 0xed, 0x8f, 0x3a, 0x41, 0x44, 0x35, 0x51, + 0xf4, 0x53, 0x1a, 0xe6, 0xfa, 0x5d, 0x73, 0xb4, 0x33, 0x2c, 0xce, 0x24, 0x4f, 0xd3, 0x4a, 0x23, + 0x56, 0x4b, 0xa2, 0xdf, 0x01, 0xce, 0xf4, 0x02, 0xb5, 0x46, 0x67, 0x1a, 0xf7, 0x26, 0x22, 0x6d, + 0x8e, 0x5c, 0xc4, 0xcd, 0xb2, 0x4d, 0x84, 0x99, 0x44, 0x71, 0xf1, 0xde, 0xde, 0xfd, 0xea, 0xaa, + 0x93, 0x07, 0xd7, 0x9d, 0x3c, 0xf8, 0xbb, 0x93, 0x07, 0x3f, 0xdc, 0xe6, 0x53, 0xd7, 0xb7, 0xf9, + 0xd4, 0x9f, 0xb7, 0xf9, 0xd4, 0xd7, 0xdb, 0x8e, 0x1b, 0x54, 0x1a, 0x16, 0xb6, 0x59, 0x95, 0xc8, + 0xff, 0xc4, 0xe2, 0x67, 0xd5, 0x2f, 0x7f, 0x43, 0xbe, 0x8d, 0x20, 0xaf, 0x6d, 0xac, 0x2a, 0xa8, + 0x83, 0x56, 0x8d, 0xfa, 0xd6, 0x73, 0xee, 0x8a, 0x1b, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x91, + 0x3b, 0x2c, 0x79, 0xa0, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ibc/core/03-connection/types/query.pb.gw.go b/x/ibc/core/03-connection/types/query.pb.gw.go index 57b8ab4921..1d7151ad5b 100644 --- a/x/ibc/core/03-connection/types/query.pb.gw.go +++ b/x/ibc/core/03-connection/types/query.pb.gw.go @@ -578,15 +578,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Connection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ibc", "connection", "v1beta1", "connections", "connection_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Connection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "connection", "v1beta1", "connections", "connection_id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Connections_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "connection", "v1beta1", "connections"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Connections_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "connection", "v1beta1", "connections"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ClientConnections_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ibc", "connection", "v1beta1", "client_connections", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ClientConnections_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"ibc", "core", "connection", "v1beta1", "client_connections", "client_id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ConnectionClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"ibc", "connection", "v1beta1", "connections", "connection_id", "client_state"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConnectionClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "connection", "v1beta1", "connections", "connection_id", "client_state"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ConnectionConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"ibc", "connection", "v1beta1", "connections", "connection_id", "consensus_state", "version", "version_number", "height", "version_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConnectionConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "core", "connection", "v1beta1", "connections", "connection_id", "consensus_state", "version", "version_number", "height", "version_height"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/x/ibc/core/04-channel/client/utils/utils.go b/x/ibc/core/04-channel/client/utils/utils.go index a5cae383bd..f28ffcf805 100644 --- a/x/ibc/core/04-channel/client/utils/utils.go +++ b/x/ibc/core/04-channel/client/utils/utils.go @@ -35,7 +35,7 @@ func QueryChannel( } func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*types.QueryChannelResponse, error) { - key := host.KeyChannel(portID, channelID) + key := host.ChannelKey(portID, channelID) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { @@ -176,7 +176,7 @@ func QueryNextSequenceReceive( } func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID string) (*types.QueryNextSequenceReceiveResponse, error) { - key := host.KeyNextSequenceRecv(portID, channelID) + key := host.NextSequenceRecvKey(portID, channelID) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { @@ -217,7 +217,7 @@ func QueryPacketCommitment( func queryPacketCommitmentABCI( clientCtx client.Context, portID, channelID string, sequence uint64, ) (*types.QueryPacketCommitmentResponse, error) { - key := host.KeyPacketCommitment(portID, channelID, sequence) + key := host.PacketCommitmentKey(portID, channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { @@ -256,7 +256,7 @@ func QueryPacketReceipt( func queryPacketReceiptABCI( clientCtx client.Context, portID, channelID string, sequence uint64, ) (*types.QueryPacketReceiptResponse, error) { - key := host.KeyPacketReceipt(portID, channelID, sequence) + key := host.PacketReceiptKey(portID, channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { @@ -285,7 +285,7 @@ func QueryPacketAcknowledgement(clientCtx client.Context, portID, channelID stri } func queryPacketAcknowledgementABCI(clientCtx client.Context, portID, channelID string, sequence uint64) (*types.QueryPacketAcknowledgementResponse, error) { - key := host.KeyPacketAcknowledgement(portID, channelID, sequence) + key := host.PacketAcknowledgementKey(portID, channelID, sequence) value, proofBz, proofHeight, err := ibcclient.QueryTendermintProof(clientCtx, key) if err != nil { diff --git a/x/ibc/core/04-channel/keeper/grpc_query.go b/x/ibc/core/04-channel/keeper/grpc_query.go index 5e279ee435..355f192d75 100644 --- a/x/ibc/core/04-channel/keeper/grpc_query.go +++ b/x/ibc/core/04-channel/keeper/grpc_query.go @@ -52,7 +52,7 @@ func (q Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*t ctx := sdk.UnwrapSDKContext(c) channels := []*types.IdentifiedChannel{} - store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix)) + store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelEndPrefix)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { var result types.Channel @@ -95,7 +95,7 @@ func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnection ctx := sdk.UnwrapSDKContext(c) channels := []*types.IdentifiedChannel{} - store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix)) + store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelEndPrefix)) pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { var result types.Channel diff --git a/x/ibc/core/04-channel/keeper/grpc_query_test.go b/x/ibc/core/04-channel/keeper/grpc_query_test.go index 031b89cc10..9e96d2b2fa 100644 --- a/x/ibc/core/04-channel/keeper/grpc_query_test.go +++ b/x/ibc/core/04-channel/keeper/grpc_query_test.go @@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) TestQueryChannel() { { "success", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // init channel channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -377,7 +377,7 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { { "success", func() { - clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // init channel channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -505,7 +505,7 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { { "success", func() { - clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // init channel channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) diff --git a/x/ibc/core/04-channel/keeper/handshake_test.go b/x/ibc/core/04-channel/keeper/handshake_test.go index fe5dc3593a..857bba57d4 100644 --- a/x/ibc/core/04-channel/keeper/handshake_test.go +++ b/x/ibc/core/04-channel/keeper/handshake_test.go @@ -32,7 +32,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { testCases := []testCase{ {"success", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) features = []string{"ORDER_ORDERED", "ORDER_UNORDERED"} suite.chainA.CreatePortCapability(connA.NextTestChannel(ibctesting.MockPort).PortID) portCap = suite.chainA.GetPortCapability(connA.NextTestChannel(ibctesting.MockPort).PortID) @@ -46,12 +46,12 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { suite.Require().NotNil(connB) }, false}, {"capability is incorrect", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) features = []string{"ORDER_ORDERED", "ORDER_UNORDERED"} portCap = capabilitytypes.NewCapability(3) }, false}, {"connection version not negotiated", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // modify connA versions conn := suite.chainA.GetConnection(connA) @@ -68,7 +68,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { portCap = suite.chainA.GetPortCapability(connA.NextTestChannel(ibctesting.MockPort).PortID) }, false}, {"connection does not support ORDERED channels", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // modify connA versions to only support UNORDERED channels conn := suite.chainA.GetConnection(connA) @@ -145,21 +145,21 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { testCases := []testCase{ {"success", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.chainB.CreatePortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) }, true}, {"success with crossing hello", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) suite.coordinator.ChanOpenInitOnBothChains(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) }, true}, {"success with empty counterparty chosen channel id", func() { var clientA, clientB string - clientA, clientB, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -168,17 +168,17 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { channel.Counterparty.ChannelId = "" suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel) - err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) - err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, ibctesting.Tendermint) + err = suite.coordinator.UpdateClient(suite.chainB, suite.chainA, clientB, exported.Tendermint) suite.Require().NoError(err) suite.chainB.CreatePortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) }, true}, {"previous channel with invalid state", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // make previous channel have wrong ordering suite.coordinator.ChanOpenInit(suite.chainB, suite.chainA, connB, connA, ibctesting.MockPort, ibctesting.MockPort, types.UNORDERED) @@ -193,7 +193,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { portCap = suite.chainB.GetPortCapability(connB.FirstOrNextTestChannel(ibctesting.MockPort).PortID) }, false}, {"connection is not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // pass capability check suite.chainB.CreatePortCapability(connB.FirstOrNextTestChannel(ibctesting.MockPort).PortID) portCap = suite.chainB.GetPortCapability(connB.FirstOrNextTestChannel(ibctesting.MockPort).PortID) @@ -203,7 +203,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { suite.Require().NoError(err) }, false}, {"consensus state not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.chainB.CreatePortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) @@ -212,7 +212,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { heightDiff = 3 // consensus state doesn't exist at this height }, false}, {"counterparty chosen channel id does not match desired channel id", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -226,17 +226,17 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { }, false}, {"channel verification failed", func() { // not creating a channel on chainA will result in an invalid proof of existence - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) }, false}, {"port capability not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) portCap = capabilitytypes.NewCapability(3) }, false}, {"connection version not negotiated", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) // modify connB versions @@ -253,7 +253,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { portCap = suite.chainB.GetPortCapability(connB.NextTestChannel(ibctesting.MockPort).PortID) }, false}, {"connection does not support ORDERED channels", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) // modify connA versions to only support UNORDERED channels @@ -289,7 +289,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { counterpartyChosenChannelID = channel.Counterparty.ChannelId } - channelKey := host.KeyChannel(counterparty.PortId, counterparty.ChannelId) + channelKey := host.ChannelKey(counterparty.PortId, counterparty.ChannelId) proof, proofHeight := suite.chainA.QueryProof(channelKey) cap, err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanOpenTry( @@ -329,7 +329,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { testCases := []testCase{ {"success", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -339,7 +339,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, true}, {"success with empty stored counterparty channel ID", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -365,7 +365,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"connection not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -380,7 +380,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel) }, false}, {"connection is not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) var err error connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) @@ -394,7 +394,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"consensus state not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -406,7 +406,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { heightDiff = 3 // consensus state doesn't exist at this height }, false}, {"invalid counterparty channel identifier", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -419,7 +419,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { }, false}, {"channel verification failed", func() { // chainB is INIT, chainA in TRYOPEN - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelB, channelA, err := suite.coordinator.ChanOpenInit(suite.chainB, suite.chainA, connB, connA, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -429,7 +429,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"channel capability not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -455,7 +455,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { counterpartyChannelID = channelB.ID } - channelKey := host.KeyChannel(channelB.PortID, channelB.ID) + channelKey := host.ChannelKey(channelB.PortID, channelB.ID) proof, proofHeight := suite.chainB.QueryProof(channelKey) err := suite.chainA.App.IBCKeeper.ChannelKeeper.ChanOpenAck( @@ -484,7 +484,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { ) testCases := []testCase{ {"success", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -504,7 +504,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, false}, {"connection not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -522,7 +522,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { suite.chainB.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainB.GetContext(), channelB.PortID, channelB.ID, channel) }, false}, {"connection is not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) var err error connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA) @@ -532,7 +532,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, false}, {"consensus state not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -548,7 +548,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { }, false}, {"channel verification failed", func() { // chainA is INIT, chainB in TRYOPEN - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -558,7 +558,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, false}, {"channel capability not found", func() { - _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB = suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA, channelB, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, ibctesting.MockPort, ibctesting.MockPort, types.ORDERED) suite.Require().NoError(err) @@ -583,7 +583,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { channelA := connA.FirstOrNextTestChannel(ibctesting.MockPort) channelB := connB.FirstOrNextTestChannel(ibctesting.MockPort) - channelKey := host.KeyChannel(channelA.PortID, channelA.ID) + channelKey := host.ChannelKey(channelA.PortID, channelA.ID) proof, proofHeight := suite.chainA.QueryProof(channelKey) err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanOpenConfirm( @@ -645,7 +645,7 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel) }, false}, {"connection is not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) var err error connA, connB, err = suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) @@ -734,7 +734,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { suite.chainB.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainB.GetContext(), channelB.PortID, channelB.ID, channel) }, false}, {"connection is not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) var err error connB, connA, err = suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA) @@ -784,7 +784,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { channelA = connA.FirstOrNextTestChannel(ibctesting.MockPort) channelB = connB.FirstOrNextTestChannel(ibctesting.MockPort) - channelKey := host.KeyChannel(channelA.PortID, channelA.ID) + channelKey := host.ChannelKey(channelA.PortID, channelA.ID) proof, proofHeight := suite.chainA.QueryProof(channelKey) err := suite.chainB.App.IBCKeeper.ChannelKeeper.ChanCloseConfirm( diff --git a/x/ibc/core/04-channel/keeper/keeper.go b/x/ibc/core/04-channel/keeper/keeper.go index b3f23ca7fb..99aee2c6da 100644 --- a/x/ibc/core/04-channel/keeper/keeper.go +++ b/x/ibc/core/04-channel/keeper/keeper.go @@ -58,7 +58,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // GetChannel returns a channel with a particular identifier binded to a specific port func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Channel, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyChannel(portID, channelID)) + bz := store.Get(host.ChannelKey(portID, channelID)) if bz == nil { return types.Channel{}, false } @@ -72,13 +72,13 @@ func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (types.Cha func (k Keeper) SetChannel(ctx sdk.Context, portID, channelID string, channel types.Channel) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshalBinaryBare(&channel) - store.Set(host.KeyChannel(portID, channelID), bz) + store.Set(host.ChannelKey(portID, channelID), bz) } // GetNextSequenceSend gets a channel's next send sequence from the store func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyNextSequenceSend(portID, channelID)) + bz := store.Get(host.NextSequenceSendKey(portID, channelID)) if bz == nil { return 0, false } @@ -90,13 +90,13 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) ( func (k Keeper) SetNextSequenceSend(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) - store.Set(host.KeyNextSequenceSend(portID, channelID), bz) + store.Set(host.NextSequenceSendKey(portID, channelID), bz) } // GetNextSequenceRecv gets a channel's next receive sequence from the store func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyNextSequenceRecv(portID, channelID)) + bz := store.Get(host.NextSequenceRecvKey(portID, channelID)) if bz == nil { return 0, false } @@ -108,13 +108,13 @@ func (k Keeper) GetNextSequenceRecv(ctx sdk.Context, portID, channelID string) ( func (k Keeper) SetNextSequenceRecv(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) - store.Set(host.KeyNextSequenceRecv(portID, channelID), bz) + store.Set(host.NextSequenceRecvKey(portID, channelID), bz) } // GetNextSequenceAck gets a channel's next ack sequence from the store func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (uint64, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyNextSequenceAck(portID, channelID)) + bz := store.Get(host.NextSequenceAckKey(portID, channelID)) if bz == nil { return 0, false } @@ -126,13 +126,13 @@ func (k Keeper) GetNextSequenceAck(ctx sdk.Context, portID, channelID string) (u func (k Keeper) SetNextSequenceAck(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(sequence) - store.Set(host.KeyNextSequenceAck(portID, channelID), bz) + store.Set(host.NextSequenceAckKey(portID, channelID), bz) } // GetPacketReceipt gets a packet receipt from the store func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) (string, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyPacketReceipt(portID, channelID, sequence)) + bz := store.Get(host.PacketReceiptKey(portID, channelID, sequence)) if bz == nil { return "", false } @@ -143,43 +143,43 @@ func (k Keeper) GetPacketReceipt(ctx sdk.Context, portID, channelID string, sequ // SetPacketReceipt sets an empty packet receipt to the store func (k Keeper) SetPacketReceipt(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) - store.Set(host.KeyPacketReceipt(portID, channelID, sequence), []byte("")) + store.Set(host.PacketReceiptKey(portID, channelID, sequence), []byte("")) } // GetPacketCommitment gets the packet commitment hash from the store func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) []byte { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyPacketCommitment(portID, channelID, sequence)) + bz := store.Get(host.PacketCommitmentKey(portID, channelID, sequence)) return bz } // HasPacketCommitment returns true if the packet commitment exists func (k Keeper) HasPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) bool { store := ctx.KVStore(k.storeKey) - return store.Has(host.KeyPacketCommitment(portID, channelID, sequence)) + return store.Has(host.PacketCommitmentKey(portID, channelID, sequence)) } // SetPacketCommitment sets the packet commitment hash to the store func (k Keeper) SetPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64, commitmentHash []byte) { store := ctx.KVStore(k.storeKey) - store.Set(host.KeyPacketCommitment(portID, channelID, sequence), commitmentHash) + store.Set(host.PacketCommitmentKey(portID, channelID, sequence), commitmentHash) } func (k Keeper) deletePacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) { store := ctx.KVStore(k.storeKey) - store.Delete(host.KeyPacketCommitment(portID, channelID, sequence)) + store.Delete(host.PacketCommitmentKey(portID, channelID, sequence)) } // SetPacketAcknowledgement sets the packet ack hash to the store func (k Keeper) SetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64, ackHash []byte) { store := ctx.KVStore(k.storeKey) - store.Set(host.KeyPacketAcknowledgement(portID, channelID, sequence), ackHash) + store.Set(host.PacketAcknowledgementKey(portID, channelID, sequence), ackHash) } // GetPacketAcknowledgement gets the packet ack hash from the store func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) ([]byte, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(host.KeyPacketAcknowledgement(portID, channelID, sequence)) + bz := store.Get(host.PacketAcknowledgementKey(portID, channelID, sequence)) if bz == nil { return nil, false } @@ -189,7 +189,7 @@ func (k Keeper) GetPacketAcknowledgement(ctx sdk.Context, portID, channelID stri // HasPacketAcknowledgement check if the packet ack hash is already on the store func (k Keeper) HasPacketAcknowledgement(ctx sdk.Context, portID, channelID string, sequence uint64) bool { store := ctx.KVStore(k.storeKey) - return store.Has(host.KeyPacketAcknowledgement(portID, channelID, sequence)) + return store.Has(host.PacketAcknowledgementKey(portID, channelID, sequence)) } // IteratePacketSequence provides an iterator over all send, receive or ack sequences. @@ -330,7 +330,7 @@ func (k Keeper) GetAllPacketAcks(ctx sdk.Context) (acks []types.PacketState) { // and stop. func (k Keeper) IterateChannels(ctx sdk.Context, cb func(types.IdentifiedChannel) bool) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyChannelPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(host.KeyChannelEndPrefix)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { diff --git a/x/ibc/core/04-channel/keeper/keeper_test.go b/x/ibc/core/04-channel/keeper/keeper_test.go index 9fcc9e20da..d1ea3de5da 100644 --- a/x/ibc/core/04-channel/keeper/keeper_test.go +++ b/x/ibc/core/04-channel/keeper/keeper_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -30,13 +31,16 @@ func (suite *KeeperTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) + suite.coordinator.CommitNBlocks(suite.chainA, 2) + suite.coordinator.CommitNBlocks(suite.chainB, 2) } // TestSetChannel create clients and connections on both chains. It tests for the non-existence // and existence of a channel in INIT on chainA. func (suite *KeeperTestSuite) TestSetChannel() { // create client and connections on both chains - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) // check for channel to be created on chainB channelA := connA.NextTestChannel(ibctesting.MockPort) diff --git a/x/ibc/core/04-channel/keeper/packet_test.go b/x/ibc/core/04-channel/keeper/packet_test.go index 3d942ce12e..f04b6ac100 100644 --- a/x/ibc/core/04-channel/keeper/packet_test.go +++ b/x/ibc/core/04-channel/keeper/packet_test.go @@ -130,7 +130,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"next sequence send not found", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA := connA.NextTestChannel(ibctesting.TransferPort) channelB := connB.NextTestChannel(ibctesting.TransferPort) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) @@ -276,7 +276,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, false}, {"connection not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // connection on chainB is in INIT connB, connA, err := suite.coordinator.ConnOpenInit(suite.chainB, suite.chainA, clientB, clientA) suite.Require().NoError(err) @@ -304,7 +304,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { channelCap = suite.chainB.GetChannelCapability(channelB.PortID, channelB.ID) }, false}, {"next receive sequence is not found", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA := connA.NextTestChannel(ibctesting.TransferPort) channelB := connB.NextTestChannel(ibctesting.TransferPort) @@ -345,7 +345,7 @@ func (suite *KeeperTestSuite) TestRecvPacket() { tc.malleate() // get proof of packet commitment from chainA - packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainA.QueryProof(packetKey) err := suite.chainB.App.IBCKeeper.ChannelKeeper.RecvPacket(suite.chainB.GetContext(), channelCap, packet, proof, proofHeight) @@ -548,7 +548,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"connection not OPEN", func() { - clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, clientB := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) // connection on chainA is in INIT connA, connB, err := suite.coordinator.ConnOpenInit(suite.chainA, suite.chainB, clientA, clientB) suite.Require().NoError(err) @@ -581,7 +581,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"next ack sequence not found", func() { - _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, ibctesting.Tendermint) + _, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, exported.Tendermint) channelA := connA.NextTestChannel(ibctesting.TransferPort) channelB := connB.NextTestChannel(ibctesting.TransferPort) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) @@ -622,7 +622,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { suite.SetupTest() // reset tc.malleate() - packetKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetKey) err := suite.chainA.App.IBCKeeper.ChannelKeeper.AcknowledgePacket(suite.chainA.GetContext(), channelCap, packet, ack, proof, proofHeight) diff --git a/x/ibc/core/04-channel/keeper/timeout_test.go b/x/ibc/core/04-channel/keeper/timeout_test.go index 774f9eacf1..640452e881 100644 --- a/x/ibc/core/04-channel/keeper/timeout_test.go +++ b/x/ibc/core/04-channel/keeper/timeout_test.go @@ -29,7 +29,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, true}, {"success: UNORDERED", func() { ordered = false @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, true}, {"channel not found", func() { // use wrong channel naming @@ -77,7 +77,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, false}, {"packet already received ", func() { ordered = true @@ -86,12 +86,12 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, false}, {"packet hasn't been sent", func() { clientA, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, false}, {"next seq receive verification failed", func() { // set ordered to false resulting in wrong proof provided @@ -100,7 +100,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.ORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, false}, {"packet ack verification failed", func() { // set ordered to true resulting in wrong proof provided @@ -109,7 +109,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED) packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) }, false}, } @@ -125,8 +125,8 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { nextSeqRecv = 1 // must be explicitly changed tc.malleate() - orderedPacketKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) - unorderedPacketKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + orderedPacketKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) + unorderedPacketKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) if ordered { proof, proofHeight = suite.chainB.QueryProof(orderedPacketKey) @@ -213,7 +213,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, true}, @@ -224,7 +224,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, true}, @@ -273,7 +273,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, @@ -291,7 +291,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"packet ack verification failed", func() { @@ -301,7 +301,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), disabledTimeoutTimestamp) suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID) }, false}, {"channel capability not found", func() { @@ -311,7 +311,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB) suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, channelB) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) chanCap = capabilitytypes.NewCapability(100) }, false}, @@ -326,9 +326,9 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { nextSeqRecv = 1 // must be explicitly changed tc.malleate() - channelKey := host.KeyChannel(packet.GetDestPort(), packet.GetDestChannel()) - unorderedPacketKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - orderedPacketKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + channelKey := host.ChannelKey(packet.GetDestPort(), packet.GetDestChannel()) + unorderedPacketKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + orderedPacketKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) proofClosed, proofHeight := suite.chainB.QueryProof(channelKey) diff --git a/x/ibc/core/04-channel/simulation/decoder.go b/x/ibc/core/04-channel/simulation/decoder.go index 006bc08e93..809976cc0e 100644 --- a/x/ibc/core/04-channel/simulation/decoder.go +++ b/x/ibc/core/04-channel/simulation/decoder.go @@ -15,7 +15,7 @@ import ( // Value to the corresponding channel type. func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB kv.Pair) (string, bool) { switch { - case bytes.HasPrefix(kvA.Key, []byte(host.KeyChannelPrefix)): + case bytes.HasPrefix(kvA.Key, []byte(host.KeyChannelEndPrefix)): var channelA, channelB types.Channel cdc.MustUnmarshalBinaryBare(kvA.Value, &channelA) cdc.MustUnmarshalBinaryBare(kvB.Value, &channelB) diff --git a/x/ibc/core/04-channel/simulation/decoder_test.go b/x/ibc/core/04-channel/simulation/decoder_test.go index 2d61a8f9a4..5f2ba2f5ec 100644 --- a/x/ibc/core/04-channel/simulation/decoder_test.go +++ b/x/ibc/core/04-channel/simulation/decoder_test.go @@ -31,27 +31,27 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ { - Key: host.KeyChannel(portID, channelID), + Key: host.ChannelKey(portID, channelID), Value: cdc.MustMarshalBinaryBare(&channel), }, { - Key: host.KeyNextSequenceSend(portID, channelID), + Key: host.NextSequenceSendKey(portID, channelID), Value: sdk.Uint64ToBigEndian(1), }, { - Key: host.KeyNextSequenceRecv(portID, channelID), + Key: host.NextSequenceRecvKey(portID, channelID), Value: sdk.Uint64ToBigEndian(1), }, { - Key: host.KeyNextSequenceAck(portID, channelID), + Key: host.NextSequenceAckKey(portID, channelID), Value: sdk.Uint64ToBigEndian(1), }, { - Key: host.KeyPacketCommitment(portID, channelID, 1), + Key: host.PacketCommitmentKey(portID, channelID, 1), Value: bz, }, { - Key: host.KeyPacketAcknowledgement(portID, channelID, 1), + Key: host.PacketAcknowledgementKey(portID, channelID, 1), Value: bz, }, { diff --git a/x/ibc/core/04-channel/types/msgs.go b/x/ibc/core/04-channel/types/msgs.go index 96a4283d8f..772a1204ef 100644 --- a/x/ibc/core/04-channel/types/msgs.go +++ b/x/ibc/core/04-channel/types/msgs.go @@ -405,14 +405,14 @@ var _ sdk.Msg = &MsgRecvPacket{} // NewMsgRecvPacket constructs new MsgRecvPacket // nolint:interfacer func NewMsgRecvPacket( - packet Packet, proof []byte, proofHeight clienttypes.Height, + packet Packet, proofCommitment []byte, proofHeight clienttypes.Height, signer sdk.AccAddress, ) *MsgRecvPacket { return &MsgRecvPacket{ - Packet: packet, - Proof: proof, - ProofHeight: proofHeight, - Signer: signer.String(), + Packet: packet, + ProofCommitment: proofCommitment, + ProofHeight: proofHeight, + Signer: signer.String(), } } @@ -423,7 +423,7 @@ func (msg MsgRecvPacket) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgRecvPacket) ValidateBasic() error { - if len(msg.Proof) == 0 { + if len(msg.ProofCommitment) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if msg.ProofHeight.IsZero() { @@ -468,13 +468,13 @@ var _ sdk.Msg = &MsgTimeout{} // NewMsgTimeout constructs new MsgTimeout // nolint:interfacer func NewMsgTimeout( - packet Packet, nextSequenceRecv uint64, proof []byte, + packet Packet, nextSequenceRecv uint64, proofUnreceived []byte, proofHeight clienttypes.Height, signer sdk.AccAddress, ) *MsgTimeout { return &MsgTimeout{ Packet: packet, NextSequenceRecv: nextSequenceRecv, - Proof: proof, + ProofUnreceived: proofUnreceived, ProofHeight: proofHeight, Signer: signer.String(), } @@ -487,12 +487,15 @@ func (msg MsgTimeout) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgTimeout) ValidateBasic() error { - if len(msg.Proof) == 0 { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") + if len(msg.ProofUnreceived) == 0 { + return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty unreceived proof") } if msg.ProofHeight.IsZero() { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be non-zero") } + if msg.NextSequenceRecv == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidSequence, "next sequence receive cannot be 0") + } _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) @@ -524,13 +527,13 @@ func (msg MsgTimeout) Type() string { // nolint:interfacer func NewMsgTimeoutOnClose( packet Packet, nextSequenceRecv uint64, - proof, proofClose []byte, + proofUnreceived, proofClose []byte, proofHeight clienttypes.Height, signer sdk.AccAddress, ) *MsgTimeoutOnClose { return &MsgTimeoutOnClose{ Packet: packet, NextSequenceRecv: nextSequenceRecv, - Proof: proof, + ProofUnreceived: proofUnreceived, ProofClose: proofClose, ProofHeight: proofHeight, Signer: signer.String(), @@ -544,7 +547,10 @@ func (msg MsgTimeoutOnClose) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgTimeoutOnClose) ValidateBasic() error { - if len(msg.Proof) == 0 { + if msg.NextSequenceRecv == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidSequence, "next sequence receive cannot be 0") + } + if len(msg.ProofUnreceived) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if len(msg.ProofClose) == 0 { @@ -585,11 +591,15 @@ var _ sdk.Msg = &MsgAcknowledgement{} // NewMsgAcknowledgement constructs a new MsgAcknowledgement // nolint:interfacer func NewMsgAcknowledgement( - packet Packet, ack []byte, proof []byte, proofHeight clienttypes.Height, signer sdk.AccAddress) *MsgAcknowledgement { + packet Packet, + ack, proofAcked []byte, + proofHeight clienttypes.Height, + signer sdk.AccAddress, +) *MsgAcknowledgement { return &MsgAcknowledgement{ Packet: packet, Acknowledgement: ack, - Proof: proof, + ProofAcked: proofAcked, ProofHeight: proofHeight, Signer: signer.String(), } @@ -602,12 +612,15 @@ func (msg MsgAcknowledgement) Route() string { // ValidateBasic implements sdk.Msg func (msg MsgAcknowledgement) ValidateBasic() error { - if len(msg.Proof) == 0 { + if len(msg.ProofAcked) == 0 { return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof") } if msg.ProofHeight.IsZero() { return sdkerrors.Wrap(sdkerrors.ErrInvalidHeight, "proof height must be non-zero") } + if len(msg.Acknowledgement) == 0 { + return sdkerrors.Wrap(ErrInvalidAcknowledgement, "ack bytes cannot be empty") + } _, err := sdk.AccAddressFromBech32(msg.Signer) if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err) diff --git a/x/ibc/core/04-channel/types/msgs_test.go b/x/ibc/core/04-channel/types/msgs_test.go index 9cf466840c..3a666b31be 100644 --- a/x/ibc/core/04-channel/types/msgs_test.go +++ b/x/ibc/core/04-channel/types/msgs_test.go @@ -93,9 +93,10 @@ func (suite *TypesTestSuite) SetupTest() { Prove: true, }) - merkleProof := commitmenttypes.MerkleProof{Proof: res.ProofOps} + merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) + suite.Require().NoError(err) proof, err := app.AppCodec().MarshalBinaryBare(&merkleProof) - suite.NoError(err) + suite.Require().NoError(err) suite.proof = proof } @@ -332,7 +333,7 @@ func (suite *TypesTestSuite) TestMsgRecvPacketValidateBasic() { msg *types.MsgRecvPacket expPass bool }{ - {"", types.NewMsgRecvPacket(packet, suite.proof, height, addr), true}, + {"success", types.NewMsgRecvPacket(packet, suite.proof, height, addr), true}, {"proof height is zero", types.NewMsgRecvPacket(packet, suite.proof, clienttypes.ZeroHeight(), addr), false}, {"proof contain empty proof", types.NewMsgRecvPacket(packet, emptyProof, height, addr), false}, {"missing signer address", types.NewMsgRecvPacket(packet, suite.proof, height, emptyAddr), false}, @@ -368,8 +369,9 @@ func (suite *TypesTestSuite) TestMsgTimeoutValidateBasic() { msg *types.MsgTimeout expPass bool }{ - {"", types.NewMsgTimeout(packet, 1, suite.proof, height, addr), true}, + {"success", types.NewMsgTimeout(packet, 1, suite.proof, height, addr), true}, {"proof height must be > 0", types.NewMsgTimeout(packet, 1, suite.proof, clienttypes.ZeroHeight(), addr), false}, + {"seq 0", types.NewMsgTimeout(packet, 0, suite.proof, height, addr), false}, {"missing signer address", types.NewMsgTimeout(packet, 1, suite.proof, height, emptyAddr), false}, {"cannot submit an empty proof", types.NewMsgTimeout(packet, 1, emptyProof, height, addr), false}, {"invalid packet", types.NewMsgTimeout(invalidPacket, 1, suite.proof, height, addr), false}, @@ -397,6 +399,7 @@ func (suite *TypesTestSuite) TestMsgTimeoutOnCloseValidateBasic() { expPass bool }{ {"success", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, height, addr), true}, + {"seq 0", types.NewMsgTimeoutOnClose(packet, 0, suite.proof, suite.proof, height, addr), false}, {"empty proof", types.NewMsgTimeoutOnClose(packet, 1, emptyProof, suite.proof, height, addr), false}, {"empty proof close", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, emptyProof, height, addr), false}, {"proof height is zero", types.NewMsgTimeoutOnClose(packet, 1, suite.proof, suite.proof, clienttypes.ZeroHeight(), addr), false}, @@ -425,8 +428,9 @@ func (suite *TypesTestSuite) TestMsgAcknowledgementValidateBasic() { msg *types.MsgAcknowledgement expPass bool }{ - {"", types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, height, addr), true}, + {"success", types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, height, addr), true}, {"proof height must be > 0", types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, clienttypes.ZeroHeight(), addr), false}, + {"empty ack", types.NewMsgAcknowledgement(packet, nil, suite.proof, height, addr), false}, {"missing signer address", types.NewMsgAcknowledgement(packet, packet.GetData(), suite.proof, height, emptyAddr), false}, {"cannot submit an empty proof", types.NewMsgAcknowledgement(packet, packet.GetData(), emptyProof, height, addr), false}, {"invalid packet", types.NewMsgAcknowledgement(invalidPacket, packet.GetData(), suite.proof, height, addr), false}, diff --git a/x/ibc/core/04-channel/types/query.pb.go b/x/ibc/core/04-channel/types/query.pb.go index d66ace7113..7015a2acf9 100644 --- a/x/ibc/core/04-channel/types/query.pb.go +++ b/x/ibc/core/04-channel/types/query.pb.go @@ -1699,100 +1699,100 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/query.proto", fileDescriptor_1034a1e9abc4cca1) } var fileDescriptor_1034a1e9abc4cca1 = []byte{ - // 1488 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xcf, 0x6f, 0x13, 0xc7, - 0x17, 0xcf, 0x38, 0x01, 0x92, 0xc7, 0xef, 0x49, 0x02, 0x61, 0x09, 0x4e, 0xf0, 0x57, 0x7c, 0x1b, - 0x90, 0xd8, 0x21, 0x81, 0xd2, 0xa8, 0x6a, 0x91, 0x48, 0xa4, 0x42, 0xaa, 0xf2, 0x6b, 0x29, 0x2a, - 0x20, 0xb5, 0xee, 0x7a, 0x3d, 0x38, 0xab, 0x24, 0xbb, 0xc6, 0xbb, 0x36, 0x41, 0xa9, 0xab, 0xaa, - 0x95, 0x80, 0x53, 0x55, 0x89, 0x43, 0xa5, 0x5e, 0x2a, 0x55, 0xbd, 0x70, 0xec, 0x5f, 0xd0, 0x2b, - 0xb7, 0x22, 0xd1, 0x43, 0x25, 0x24, 0x5a, 0x91, 0x4a, 0xf4, 0xda, 0x4b, 0xcf, 0xd5, 0xce, 0xbc, - 0x5d, 0xef, 0xda, 0xbb, 0x9b, 0x38, 0x8e, 0xa5, 0xa8, 0xa7, 0x78, 0x67, 0xe7, 0xbd, 0xf9, 0x7c, - 0x3e, 0x6f, 0xde, 0xf3, 0x7b, 0x0e, 0x8c, 0x99, 0x05, 0x83, 0x19, 0x76, 0x85, 0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xf4, 0x62, 0x07, 0x12, 0x44, 0xfa, 0xf0, - 0x19, 0xed, 0xe9, 0xab, 0x2c, 0x79, 0xf6, 0x2a, 0x4b, 0xfe, 0x78, 0x95, 0x25, 0xdf, 0xac, 0x66, - 0x7b, 0x9e, 0xad, 0x66, 0x7b, 0x7e, 0x5b, 0xcd, 0xf6, 0xdc, 0x9e, 0x2e, 0x99, 0xee, 0x7c, 0xb5, - 0xa0, 0x1a, 0xf6, 0x12, 0xc3, 0x7f, 0xe8, 0xc9, 0x3f, 0x27, 0x9d, 0xe2, 0x02, 0x5b, 0x66, 0xc1, - 0x3f, 0xee, 0x4e, 0x9d, 0x39, 0xe9, 0x23, 0x71, 0xef, 0x97, 0xb9, 0x53, 0xd8, 0x2e, 0x7e, 0x7f, - 0x3d, 0xfd, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x22, 0x97, 0x6e, 0x5f, 0x1c, 0x00, 0x00, + // 1487 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x59, 0xdf, 0x6b, 0x14, 0xd7, + 0x17, 0xcf, 0xdd, 0x44, 0x4d, 0x8e, 0xbf, 0x6f, 0x12, 0x8d, 0x63, 0x5c, 0xe3, 0x7e, 0xbf, 0x6d, + 0xa3, 0xe0, 0x5c, 0x13, 0xad, 0x15, 0x8a, 0x2d, 0x31, 0x50, 0x1b, 0x50, 0x6b, 0x47, 0x6d, 0x55, + 0x5a, 0x97, 0xd9, 0xd9, 0xeb, 0x66, 0x48, 0x32, 0xb3, 0xee, 0xcc, 0xc6, 0x84, 0xb0, 0xd0, 0x56, + 0x90, 0x52, 0x2a, 0x14, 0xa4, 0x14, 0xfa, 0xd2, 0x97, 0x42, 0xf1, 0xb1, 0xff, 0x43, 0x1f, 0x7c, + 0xe8, 0x83, 0xd0, 0x16, 0x2c, 0x05, 0x2b, 0x5a, 0xa8, 0x0f, 0x7d, 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, 0x4f, 0x09, 0xe4, 0x25, 0x41, 0xdb, 0xb2, 0xb8, 0xe1, + 0x45, 0x6b, 0xd6, 0x32, 0x0f, 0x60, 0x04, 0x2f, 0xf1, 0x28, 0x45, 0x56, 0x9a, 0xb4, 0xce, 0x3d, + 0xb7, 0xd6, 0xcf, 0x08, 0xec, 0x4f, 0x85, 0xf2, 0xdf, 0x52, 0xfd, 0xb2, 0x2f, 0xba, 0xc4, 0x34, + 0x2d, 0xac, 0x2f, 0xb8, 0xba, 0xcb, 0x3b, 0x2d, 0xde, 0xdf, 0x03, 0x11, 0x13, 0x42, 0xa3, 0x88, + 0x3a, 0xec, 0x36, 0x03, 0x7d, 0x8a, 0x12, 0x6a, 0xd1, 0xf1, 0x4c, 0xb0, 0x52, 0x0e, 0x26, 0x11, + 0x89, 0x48, 0x1a, 0x89, 0x39, 0x6c, 0x26, 0x2d, 0x77, 0xb3, 0xe4, 0xef, 0x11, 0x38, 0x10, 0x63, + 0xe8, 0x71, 0xb2, 0x9c, 0xba, 0xb3, 0x1e, 0xfa, 0xd1, 0x97, 0x60, 0xdb, 0x22, 0xaf, 0x39, 0xa6, + 0x6d, 0x15, 0xad, 0xfa, 0x42, 0x89, 0xd7, 0x04, 0xc8, 0x3e, 0x6d, 0x2b, 0xae, 0x9e, 0x13, 0x8b, + 0x51, 0x33, 0xe4, 0xd2, 0x17, 0x33, 0x43, 0xac, 0xbf, 0x11, 0x28, 0x64, 0x61, 0xc5, 0x84, 0x9c, + 0x84, 0xed, 0x86, 0xff, 0x26, 0x96, 0x88, 0x21, 0x55, 0x7e, 0x17, 0xa8, 0xfe, 0x77, 0x81, 0x3a, + 0x65, 0x2d, 0x6b, 0xdb, 0x8c, 0x58, 0x18, 0xba, 0x17, 0x06, 0x30, 0x89, 0x01, 0xa3, 0x7e, 0xb9, + 0x30, 0x53, 0x0e, 0x33, 0xd1, 0x9b, 0x95, 0x89, 0xbe, 0xe7, 0xc9, 0x44, 0x0d, 0x46, 0x05, 0xb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1, 0xcb, 0x5d, 0xd4, 0x20, 0x36, 0x01, 0xc4, 0xc8, + 0x7b, 0x25, 0x40, 0x7f, 0x25, 0x30, 0x98, 0x70, 0x43, 0xa6, 0x19, 0x77, 0x86, 0xf4, 0xcb, 0xba, + 0xf2, 0x6a, 0x9b, 0x5e, 0x28, 0xc4, 0x25, 0xa1, 0xc3, 0x3b, 0xf4, 0x6c, 0xa7, 0x3a, 0xc4, 0x2e, + 0xf3, 0xa7, 0xb4, 0xfb, 0x4f, 0xf2, 0xe4, 0xc1, 0x93, 0x3c, 0x79, 0xfc, 0x24, 0x4f, 0xbe, 0x78, + 0x9a, 0xef, 0x79, 0xf0, 0x34, 0xdf, 0xf3, 0xf0, 0x69, 0xbe, 0xe7, 0xea, 0x89, 0x8a, 0xe9, 0xce, + 0xd6, 0x4b, 0xaa, 0x61, 0x2f, 0x30, 0xfc, 0xaf, 0xa0, 0xfc, 0x73, 0xd8, 0x29, 0xcf, 0xb1, 0xa5, + 0x10, 0xc6, 0x91, 0x63, 0x87, 0x7d, 0x24, 0xee, 0x72, 0x95, 0x3b, 0xa5, 0x8d, 0xe2, 0x47, 0xdc, + 0xa3, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x48, 0x61, 0x15, 0x26, 0xa4, 0x1c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ibc/core/04-channel/types/query.pb.gw.go b/x/ibc/core/04-channel/types/query.pb.gw.go index a2ae71d96b..270aa3db9f 100644 --- a/x/ibc/core/04-channel/types/query.pb.gw.go +++ b/x/ibc/core/04-channel/types/query.pb.gw.go @@ -1736,31 +1736,31 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Channel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Channels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ibc", "channel", "v1beta1", "channels"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Channels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "core", "channel", "v1beta1", "channels"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ConnectionChannels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"ibc", "channel", "v1beta1", "connections", "connection", "channels"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ConnectionChannels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6}, []string{"ibc", "core", "channel", "v1beta1", "connections", "connection", "channels"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ChannelClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "client_state"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ChannelClientState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "client_state"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_ChannelConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 2, 8, 1, 0, 4, 1, 5, 9, 2, 10, 1, 0, 4, 1, 5, 11}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "consensus_state", "version", "version_number", "height", "version_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ChannelConsensusState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "consensus_state", "version", "version_number", "height", "version_height"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PacketCommitment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PacketCommitments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PacketReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_receipts", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PacketAcknowledgement_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acks", "sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_PacketAcknowledgements_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_acknowledgements"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_commitment_sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_UnreceivedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9, 2, 10}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_commitment_sequences", "unreceived_packets"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_UnreceivedAcks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8, 1, 0, 4, 1, 5, 9, 2, 10}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "packet_commitments", "packet_ack_sequences", "unreceived_acks"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_NextSequenceReceive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7}, []string{"ibc", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "next_sequence"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_NextSequenceReceive_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 2, 8}, []string{"ibc", "core", "channel", "v1beta1", "channels", "channel_id", "ports", "port_id", "next_sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/x/ibc/core/04-channel/types/tx.pb.go b/x/ibc/core/04-channel/types/tx.pb.go index 2ad25780da..608f573a77 100644 --- a/x/ibc/core/04-channel/types/tx.pb.go +++ b/x/ibc/core/04-channel/types/tx.pb.go @@ -513,10 +513,10 @@ var xxx_messageInfo_MsgChannelCloseConfirmResponse proto.InternalMessageInfo // MsgRecvPacket receives incoming IBC packet type MsgRecvPacket struct { - Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` - ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height" yaml:"proof_height"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` + ProofCommitment []byte `protobuf:"bytes,2,opt,name=proof_commitment,json=proofCommitment,proto3" json:"proof_commitment,omitempty" yaml:"proof_commitment"` + ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height" yaml:"proof_height"` + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgRecvPacket) Reset() { *m = MsgRecvPacket{} } @@ -592,7 +592,7 @@ var xxx_messageInfo_MsgRecvPacketResponse proto.InternalMessageInfo // MsgTimeout receives timed-out packet type MsgTimeout struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty" yaml:"proof_unreceived"` ProofHeight types.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height" yaml:"proof_height"` NextSequenceRecv uint64 `protobuf:"varint,4,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty" yaml:"next_sequence_recv"` Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` @@ -671,7 +671,7 @@ var xxx_messageInfo_MsgTimeoutResponse proto.InternalMessageInfo // MsgTimeoutOnClose timed-out packet upon counterparty channel closure. type MsgTimeoutOnClose struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` - Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` + ProofUnreceived []byte `protobuf:"bytes,2,opt,name=proof_unreceived,json=proofUnreceived,proto3" json:"proof_unreceived,omitempty" yaml:"proof_unreceived"` ProofClose []byte `protobuf:"bytes,3,opt,name=proof_close,json=proofClose,proto3" json:"proof_close,omitempty" yaml:"proof_close"` ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height" yaml:"proof_height"` NextSequenceRecv uint64 `protobuf:"varint,5,opt,name=next_sequence_recv,json=nextSequenceRecv,proto3" json:"next_sequence_recv,omitempty" yaml:"next_sequence_recv"` @@ -752,7 +752,7 @@ var xxx_messageInfo_MsgTimeoutOnCloseResponse proto.InternalMessageInfo type MsgAcknowledgement struct { Packet Packet `protobuf:"bytes,1,opt,name=packet,proto3" json:"packet"` Acknowledgement []byte `protobuf:"bytes,2,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"` - Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + ProofAcked []byte `protobuf:"bytes,3,opt,name=proof_acked,json=proofAcked,proto3" json:"proof_acked,omitempty" yaml:"proof_acked"` ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height" yaml:"proof_height"` Signer string `protobuf:"bytes,5,opt,name=signer,proto3" json:"signer,omitempty"` } @@ -853,77 +853,80 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/tx.proto", fileDescriptor_bc4637e0ac3fc7b7) } var fileDescriptor_bc4637e0ac3fc7b7 = []byte{ - // 1110 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4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d3, 0x86, - 0x17, 0x79, 0xbd, 0x12, 0x00, 0x00, + // 1158 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0xd6, 0x9f, 0x65, 0x7b, 0xec, 0xc6, 0x0e, 0xfd, 0xa7, 0x50, 0xb6, 0xe8, 0x12, 0x68, 0xe2, + 0xa6, 0x88, 0x14, 0x3b, 0x01, 0xda, 0x06, 0xbd, 0x58, 0x02, 0x8a, 0x1a, 0x81, 0x91, 0x82, 0x71, + 0x7b, 0x30, 0x0a, 0x08, 0xf2, 0x6a, 0x43, 0x11, 0xb2, 0x76, 0x55, 0x92, 0x56, 0xac, 0x37, 0xe8, + 0x31, 0xe7, 0x9e, 0x72, 0xef, 0x21, 0x7d, 0x87, 0x5e, 0x72, 0xcc, 0x2d, 0x45, 0x0f, 0x44, 0x61, + 0x5f, 0x7a, 0xe6, 0x13, 0x14, 0x5c, 0x2e, 0x7f, 0x44, 0x91, 0x31, 0x5d, 0x57, 0x6a, 0x4f, 0x22, + 0x67, 0xbe, 0x9d, 0x9d, 0xfd, 0xe6, 0xdb, 0xd9, 0xa5, 0x60, 0x53, 0x3b, 0x41, 0x35, 0x44, 0x75, + 0x5c, 0x43, 0x9d, 0x16, 0x21, 0xf8, 0xb4, 0x36, 0xd8, 0xad, 0x99, 0xe7, 0xd5, 0xbe, 0x4e, 0x4d, + 0x2a, 0xac, 0x68, 0x27, 0xa8, 0xea, 0x78, 0xab, 0xdc, 0x5b, 0x1d, 0xec, 0x8a, 0xab, 0x2a, 0x55, + 0x29, 0xf3, 0xd7, 0x9c, 0x27, 0x17, 0x2a, 0x4a, 0x41, 0xa0, 0x53, 0x0d, 0x13, 0xd3, 0x89, 0xe3, + 0x3e, 0x71, 0xc0, 0xc7, 0x71, 0x33, 0x79, 0x61, 0x19, 0x44, 0x7e, 0x9f, 0x05, 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0x57, 0x9c, 0x7d, 0xe7, 0xe5, 0x3f, 0xee, 0xd6, 0xee, 0x27, 0x56, 0x84, + 0x31, 0x8f, 0xd0, 0xbd, 0x37, 0x73, 0x90, 0x3f, 0x34, 0x54, 0xa1, 0x0b, 0x4b, 0xd1, 0xcf, 0xcb, + 0x7b, 0xb1, 0x24, 0x8e, 0x7f, 0xae, 0x89, 0xb5, 0x94, 0x40, 0x6f, 0x52, 0xa1, 0x03, 0xb7, 0x22, + 0xdf, 0x74, 0x77, 0x53, 0x84, 0x38, 0xd2, 0x87, 0x62, 0x35, 0x1d, 0x2e, 0x61, 0x26, 0xe7, 0x26, + 0x95, 0x66, 0xa6, 0x7d, 0xd4, 0x4d, 0x35, 0x53, 0xe8, 0x46, 0x29, 0x98, 0x20, 0xc4, 0xdc, 0x26, + 0xef, 0xa7, 0x88, 0xc2, 0xb1, 0xe2, 0x5e, 0x7a, 0xac, 0x3f, 0x2b, 0x81, 0xe5, 0xb1, 0x4b, 0xd7, + 0xce, 0x15, 0x71, 0x7c, 0xa4, 0xf8, 0x30, 0x2d, 0xd2, 0x9f, 0xef, 0x25, 0xac, 0xc4, 0x5e, 0x94, + 0xd2, 0x04, 0xf2, 0xd6, 0xf9, 0xe8, 0x1a, 0x60, 0x7f, 0xe2, 0x1f, 0x00, 0x42, 0xb7, 0x09, 0x39, + 0x29, 0x44, 0x80, 0x11, 0xef, 0x5f, 0x8d, 0xf1, 0xa3, 0x3f, 0x87, 0x59, 0xef, 0xfc, 0x95, 0x92, + 0x86, 0x71, 0x80, 0x78, 0xef, 0x0a, 0x40, 0x58, 0x7b, 0x91, 0x13, 0xe6, 0xee, 0x15, 0x43, 0x39, + 0x2e, 0x59, 0x7b, 0xf1, 0x5d, 0xd1, 0xd9, 0xbc, 0xd1, 0x8e, 0x98, 0x98, 0x65, 0x04, 0x98, 0xbc, + 0x79, 0x13, 0x3a, 0x46, 0x5d, 0x79, 0x7b, 0x51, 0xc9, 0xbe, 0xbb, 0xa8, 0x64, 0xff, 0xbc, 0xa8, + 0x64, 0x5f, 0x5d, 0x56, 0x32, 0xef, 0x2e, 0x2b, 0x99, 0xdf, 0x2f, 0x2b, 0x99, 0xe3, 0x2f, 0x54, + 0xcd, 0xec, 0x9c, 0x9d, 0x54, 0x11, 0xed, 0xd5, 0x10, 0x35, 0x7a, 0xd4, 0xe0, 0x3f, 0x0f, 0x8c, + 0x76, 0xb7, 0x76, 0x5e, 0xf3, 0xff, 0xe8, 0x7a, 0xf8, 0xf8, 0x81, 0xf7, 0x5f, 0x97, 0x39, 0xec, + 0x63, 0xe3, 0xa4, 0xc8, 0xfe, 0xe7, 0x7a, 0xf4, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x07, + 0x48, 0xeb, 0x76, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1905,10 +1908,10 @@ func (m *MsgRecvPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + if len(m.ProofCommitment) > 0 { + i -= len(m.ProofCommitment) + copy(dAtA[i:], m.ProofCommitment) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofCommitment))) i-- dAtA[i] = 0x12 } @@ -1990,10 +1993,10 @@ func (m *MsgTimeout) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) i-- dAtA[i] = 0x12 } @@ -2082,10 +2085,10 @@ func (m *MsgTimeoutOnClose) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + if len(m.ProofUnreceived) > 0 { + i -= len(m.ProofUnreceived) + copy(dAtA[i:], m.ProofUnreceived) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofUnreceived))) i-- dAtA[i] = 0x12 } @@ -2162,10 +2165,10 @@ func (m *MsgAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x22 - if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + if len(m.ProofAcked) > 0 { + i -= len(m.ProofAcked) + copy(dAtA[i:], m.ProofAcked) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProofAcked))) i-- dAtA[i] = 0x1a } @@ -2455,7 +2458,7 @@ func (m *MsgRecvPacket) Size() (n int) { _ = l l = m.Packet.Size() n += 1 + l + sovTx(uint64(l)) - l = len(m.Proof) + l = len(m.ProofCommitment) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2485,7 +2488,7 @@ func (m *MsgTimeout) Size() (n int) { _ = l l = m.Packet.Size() n += 1 + l + sovTx(uint64(l)) - l = len(m.Proof) + l = len(m.ProofUnreceived) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2518,7 +2521,7 @@ func (m *MsgTimeoutOnClose) Size() (n int) { _ = l l = m.Packet.Size() n += 1 + l + sovTx(uint64(l)) - l = len(m.Proof) + l = len(m.ProofUnreceived) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2559,7 +2562,7 @@ func (m *MsgAcknowledgement) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Proof) + l = len(m.ProofAcked) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -4325,7 +4328,7 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofCommitment", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -4352,9 +4355,9 @@ func (m *MsgRecvPacket) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} + m.ProofCommitment = append(m.ProofCommitment[:0], dAtA[iNdEx:postIndex]...) + if m.ProofCommitment == nil { + m.ProofCommitment = []byte{} } iNdEx = postIndex case 3: @@ -4563,7 +4566,7 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -4590,9 +4593,9 @@ func (m *MsgTimeout) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} + m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUnreceived == nil { + m.ProofUnreceived = []byte{} } iNdEx = postIndex case 3: @@ -4820,7 +4823,7 @@ func (m *MsgTimeoutOnClose) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofUnreceived", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -4847,9 +4850,9 @@ func (m *MsgTimeoutOnClose) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} + m.ProofUnreceived = append(m.ProofUnreceived[:0], dAtA[iNdEx:postIndex]...) + if m.ProofUnreceived == nil { + m.ProofUnreceived = []byte{} } iNdEx = postIndex case 3: @@ -5145,7 +5148,7 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProofAcked", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -5172,9 +5175,9 @@ func (m *MsgAcknowledgement) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) - if m.Proof == nil { - m.Proof = []byte{} + m.ProofAcked = append(m.ProofAcked[:0], dAtA[iNdEx:postIndex]...) + if m.ProofAcked == nil { + m.ProofAcked = []byte{} } iNdEx = postIndex case 4: diff --git a/x/ibc/core/23-commitment/types/commitment.pb.go b/x/ibc/core/23-commitment/types/commitment.pb.go index ac72127113..9634e25735 100644 --- a/x/ibc/core/23-commitment/types/commitment.pb.go +++ b/x/ibc/core/23-commitment/types/commitment.pb.go @@ -5,9 +5,9 @@ package types import ( fmt "fmt" + _go "github.com/confio/ics23/go" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - crypto "github.com/tendermint/tendermint/proto/tendermint/crypto" io "io" math "math" math_bits "math/bits" @@ -24,34 +24,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// KeyEncoding defines the encoding format of a key's bytes. -type KeyEncoding int32 - -const ( - // URL encoding - URL KeyEncoding = 0 - // Hex encoding - HEX KeyEncoding = 1 -) - -var KeyEncoding_name = map[int32]string{ - 0: "KEY_ENCODING_URL_UNSPECIFIED", - 1: "KEY_ENCODING_HEX", -} - -var KeyEncoding_value = map[string]int32{ - "KEY_ENCODING_URL_UNSPECIFIED": 0, - "KEY_ENCODING_HEX": 1, -} - -func (x KeyEncoding) String() string { - return proto.EnumName(KeyEncoding_name, int32(x)) -} - -func (KeyEncoding) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_7921d88972a41469, []int{0} -} - // MerkleRoot defines a merkle root hash. // In the Cosmos SDK, the AppHash of a block header becomes the root. type MerkleRoot struct { @@ -140,8 +112,9 @@ func (m *MerklePrefix) GetKeyPrefix() []byte { // MerklePath is the path used to verify commitment proofs, which can be an // arbitrary structured object (defined by a commitment type). +// MerklePath is represented from root-to-leaf type MerklePath struct { - KeyPath KeyPath `protobuf:"bytes,1,opt,name=key_path,json=keyPath,proto3" json:"key_path" yaml:"key_path"` + KeyPath []string `protobuf:"bytes,1,rep,name=key_path,json=keyPath,proto3" json:"key_path,omitempty" yaml:"key_path"` } func (m *MerklePath) Reset() { *m = MerklePath{} } @@ -176,19 +149,20 @@ func (m *MerklePath) XXX_DiscardUnknown() { var xxx_messageInfo_MerklePath proto.InternalMessageInfo -func (m *MerklePath) GetKeyPath() KeyPath { +func (m *MerklePath) GetKeyPath() []string { if m != nil { return m.KeyPath } - return KeyPath{} + return nil } -// MerkleProof is a wrapper type that contains a merkle proof. +// MerkleProof is a wrapper type over a chain of CommitmentProofs. // It demonstrates membership or non-membership for an element or set of // elements, verifiable in conjunction with a known commitment root. Proofs // should be succinct. +// MerkleProofs are ordered from leaf-to-root type MerkleProof struct { - Proof *crypto.ProofOps `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` + Proofs []*_go.CommitmentProof `protobuf:"bytes,1,rep,name=proofs,proto3" json:"proofs,omitempty"` } func (m *MerkleProof) Reset() { *m = MerkleProof{} } @@ -224,97 +198,18 @@ func (m *MerkleProof) XXX_DiscardUnknown() { var xxx_messageInfo_MerkleProof proto.InternalMessageInfo -func (m *MerkleProof) GetProof() *crypto.ProofOps { +func (m *MerkleProof) GetProofs() []*_go.CommitmentProof { if m != nil { - return m.Proof + return m.Proofs } return nil } -// KeyPath defines a slice of keys -type KeyPath struct { - Keys []*Key `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` -} - -func (m *KeyPath) Reset() { *m = KeyPath{} } -func (*KeyPath) ProtoMessage() {} -func (*KeyPath) Descriptor() ([]byte, []int) { - return fileDescriptor_7921d88972a41469, []int{4} -} -func (m *KeyPath) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *KeyPath) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_KeyPath.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *KeyPath) XXX_Merge(src proto.Message) { - xxx_messageInfo_KeyPath.Merge(m, src) -} -func (m *KeyPath) XXX_Size() int { - return m.Size() -} -func (m *KeyPath) XXX_DiscardUnknown() { - xxx_messageInfo_KeyPath.DiscardUnknown(m) -} - -var xxx_messageInfo_KeyPath proto.InternalMessageInfo - -// Key defines a proof Key -type Key struct { - Name []byte `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Enc KeyEncoding `protobuf:"varint,2,opt,name=enc,proto3,enum=ibc.core.commitment.v1.KeyEncoding" json:"enc,omitempty"` -} - -func (m *Key) Reset() { *m = Key{} } -func (m *Key) String() string { return proto.CompactTextString(m) } -func (*Key) ProtoMessage() {} -func (*Key) Descriptor() ([]byte, []int) { - return fileDescriptor_7921d88972a41469, []int{5} -} -func (m *Key) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Key) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Key.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Key) XXX_Merge(src proto.Message) { - xxx_messageInfo_Key.Merge(m, src) -} -func (m *Key) XXX_Size() int { - return m.Size() -} -func (m *Key) XXX_DiscardUnknown() { - xxx_messageInfo_Key.DiscardUnknown(m) -} - -var xxx_messageInfo_Key proto.InternalMessageInfo - func init() { - proto.RegisterEnum("ibc.core.commitment.v1.KeyEncoding", KeyEncoding_name, KeyEncoding_value) proto.RegisterType((*MerkleRoot)(nil), "ibc.core.commitment.v1.MerkleRoot") proto.RegisterType((*MerklePrefix)(nil), "ibc.core.commitment.v1.MerklePrefix") proto.RegisterType((*MerklePath)(nil), "ibc.core.commitment.v1.MerklePath") proto.RegisterType((*MerkleProof)(nil), "ibc.core.commitment.v1.MerkleProof") - proto.RegisterType((*KeyPath)(nil), "ibc.core.commitment.v1.KeyPath") - proto.RegisterType((*Key)(nil), "ibc.core.commitment.v1.Key") } func init() { @@ -322,39 +217,28 @@ func init() { } var fileDescriptor_7921d88972a41469 = []byte{ - // 499 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x13, 0x5a, 0xe8, 0x70, 0x27, 0x28, 0x16, 0x7f, 0xaa, 0xc2, 0x92, 0x2a, 0x48, 0x30, - 0x90, 0x16, 0xab, 0x1d, 0x5c, 0xca, 0x05, 0x75, 0x0d, 0xac, 0xea, 0xe8, 0x2a, 0x4f, 0x45, 0x03, - 0x09, 0x55, 0x69, 0xea, 0x26, 0x51, 0x96, 0x38, 0x4a, 0xcc, 0xb4, 0x7c, 0x83, 0x89, 0x13, 0x47, - 0x2e, 0x48, 0x48, 0x7c, 0x99, 0x1d, 0x77, 0xe4, 0x54, 0xa1, 0xf6, 0x1b, 0xec, 0x13, 0x20, 0xdb, - 0x2d, 0x0b, 0x12, 0x70, 0xca, 0x6b, 0xbd, 0xbf, 0x37, 0xcf, 0xe3, 0xc7, 0x2f, 0x78, 0xec, 0x8f, - 0x1d, 0xe4, 0xd0, 0x84, 0x20, 0x87, 0x86, 0xa1, 0xcf, 0x42, 0x12, 0x31, 0x74, 0xdc, 0xc8, 0x9d, - 0xcc, 0x38, 0xa1, 0x8c, 0xc2, 0xbb, 0xfe, 0xd8, 0x31, 0x39, 0x68, 0xe6, 0x5a, 0xc7, 0x8d, 0xda, - 0x6d, 0x97, 0xba, 0x54, 0x20, 0x88, 0x57, 0x92, 0xae, 0x6d, 0x30, 0x12, 0x4d, 0x48, 0x12, 0xfa, - 0x11, 0x43, 0x4e, 0x92, 0xc5, 0x8c, 0xa2, 0x38, 0xa1, 0x74, 0x2a, 0xdb, 0xc6, 0x23, 0x00, 0xde, - 0x90, 0x24, 0x38, 0x22, 0x98, 0x52, 0x06, 0x21, 0x28, 0x7a, 0x76, 0xea, 0x55, 0xd5, 0xba, 0xba, - 0xb9, 0x8e, 0x45, 0xdd, 0x2a, 0x9e, 0x7e, 0xd3, 0x15, 0xa3, 0x03, 0xd6, 0x25, 0x37, 0x48, 0xc8, - 0xd4, 0x3f, 0x81, 0xcf, 0x00, 0x08, 0x48, 0x36, 0x8a, 0xc5, 0x49, 0xf2, 0xed, 0x3b, 0x17, 0x33, - 0xfd, 0x56, 0x66, 0x87, 0x47, 0x2d, 0xe3, 0xb2, 0x67, 0xe0, 0xeb, 0x01, 0xc9, 0xe4, 0x94, 0xe1, - 0xae, 0xd4, 0x06, 0x36, 0xf3, 0xe0, 0x01, 0x58, 0x13, 0x9c, 0xcd, 0xa4, 0x62, 0xb9, 0xa9, 0x9b, - 0x7f, 0xbf, 0x9b, 0xd9, 0x23, 0x19, 0x1f, 0x69, 0xdf, 0x3b, 0x9b, 0xe9, 0xca, 0xc5, 0x4c, 0xbf, - 0x99, 0x93, 0xb1, 0x99, 0x67, 0xe0, 0x52, 0x20, 0x89, 0x56, 0xf1, 0x0b, 0xb7, 0xfb, 0x12, 0x94, - 0x57, 0x76, 0x29, 0x9d, 0xc2, 0x06, 0xb8, 0x2a, 0x2e, 0xbd, 0x94, 0xb9, 0x6f, 0x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0x02, 0x74, 0x82, 0x7e, 0x2f, 0x71, 0x73, 0x7b, 0x2b, 0xb7, 0xc7, 0x2c, 0x8b, 0x49, 0x3a, - 0xbe, 0x26, 0x76, 0x6e, 0xfb, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x78, 0x4b, 0x97, 0xeb, - 0x02, 0x00, 0x00, + // 334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xcf, 0x4e, 0xfa, 0x40, + 0x10, 0xc7, 0xdb, 0xfc, 0x08, 0x3f, 0x59, 0x48, 0x8c, 0x45, 0x89, 0xe1, 0x50, 0x4c, 0x0f, 0xca, + 0x85, 0xdd, 0x00, 0x9e, 0x30, 0x5e, 0xaa, 0x57, 0x13, 0xd2, 0xc4, 0x8b, 0x17, 0xd3, 0xae, 0x5b, + 0xba, 0x29, 0x65, 0x9a, 0xee, 0x4a, 0xe8, 0x1b, 0x78, 0xf4, 0xe8, 0xd1, 0xc7, 0xf1, 0xc8, 0xd1, + 0x13, 0x31, 0xf0, 0x06, 0x3c, 0x81, 0xe9, 0x2e, 0x60, 0x4f, 0x3b, 0xb3, 0xf3, 0x99, 0x7f, 0xdf, + 0x41, 0x57, 0x3c, 0xa0, 0x84, 0x42, 0xc6, 0x08, 0x85, 0x24, 0xe1, 0x32, 0x61, 0x33, 0x49, 0xe6, + 0xfd, 0x92, 0x87, 0xd3, 0x0c, 0x24, 0x58, 0x2d, 0x1e, 0x50, 0x5c, 0x80, 0xb8, 0x14, 0x9a, 0xf7, + 0xdb, 0xa7, 0x13, 0x98, 0x80, 0x42, 0x48, 0x61, 0x69, 0xba, 0xdd, 0xa4, 0x30, 0x0b, 0x39, 0x90, + 0x34, 0x03, 0x08, 0x85, 0xfe, 0x74, 0x2e, 0x11, 0x7a, 0x60, 0x59, 0x3c, 0x65, 0x1e, 0x80, 0xb4, + 0x2c, 0x54, 0x89,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xd0, 0xbc, 0x01, 0x00, 0x00, } func (m *MerkleRoot) Marshal() (dAtA []byte, err error) { @@ -437,16 +321,15 @@ func (m *MerklePath) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.KeyPath.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.KeyPath) > 0 { + for iNdEx := len(m.KeyPath) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.KeyPath[iNdEx]) + copy(dAtA[i:], m.KeyPath[iNdEx]) + i = encodeVarintCommitment(dAtA, i, uint64(len(m.KeyPath[iNdEx]))) + i-- + dAtA[i] = 0xa } - i -= size - i = encodeVarintCommitment(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -470,45 +353,10 @@ func (m *MerkleProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Proof != nil { - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCommitment(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *KeyPath) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *KeyPath) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *KeyPath) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Keys) > 0 { - for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Proofs) > 0 { + for iNdEx := len(m.Proofs) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Keys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Proofs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -522,41 +370,6 @@ func (m *KeyPath) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Key) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Key) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Key) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Enc != 0 { - i = encodeVarintCommitment(dAtA, i, uint64(m.Enc)) - i-- - dAtA[i] = 0x10 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintCommitment(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintCommitment(dAtA []byte, offset int, v uint64) int { offset -= sovCommitment(v) base := offset @@ -600,8 +413,12 @@ func (m *MerklePath) Size() (n int) { } var l int _ = l - l = m.KeyPath.Size() - n += 1 + l + sovCommitment(uint64(l)) + if len(m.KeyPath) > 0 { + for _, s := range m.KeyPath { + l = len(s) + n += 1 + l + sovCommitment(uint64(l)) + } + } return n } @@ -611,21 +428,8 @@ func (m *MerkleProof) Size() (n int) { } var l int _ = l - if m.Proof != nil { - l = m.Proof.Size() - n += 1 + l + sovCommitment(uint64(l)) - } - return n -} - -func (m *KeyPath) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Keys) > 0 { - for _, e := range m.Keys { + if len(m.Proofs) > 0 { + for _, e := range m.Proofs { l = e.Size() n += 1 + l + sovCommitment(uint64(l)) } @@ -633,22 +437,6 @@ func (m *KeyPath) Size() (n int) { return n } -func (m *Key) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovCommitment(uint64(l)) - } - if m.Enc != 0 { - n += 1 + sovCommitment(uint64(m.Enc)) - } - return n -} - func sovCommitment(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -862,7 +650,7 @@ func (m *MerklePath) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field KeyPath", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCommitment @@ -872,24 +660,23 @@ func (m *MerklePath) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthCommitment } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthCommitment } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.KeyPath.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.KeyPath = append(m.KeyPath, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -946,7 +733,7 @@ func (m *MerkleProof) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Proofs", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -973,10 +760,8 @@ func (m *MerkleProof) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Proof == nil { - m.Proof = &crypto.ProofOps{} - } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Proofs = append(m.Proofs, &_go.CommitmentProof{}) + if err := m.Proofs[len(m.Proofs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1004,199 +789,6 @@ func (m *MerkleProof) Unmarshal(dAtA []byte) error { } return nil } -func (m *KeyPath) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitment - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: KeyPath: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: KeyPath: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitment - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCommitment - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCommitment - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Keys = append(m.Keys, &Key{}) - if err := m.Keys[len(m.Keys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommitment(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthCommitment - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthCommitment - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Key) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitment - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Key: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Key: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitment - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCommitment - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthCommitment - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = append(m.Name[:0], dAtA[iNdEx:postIndex]...) - if m.Name == nil { - m.Name = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enc", wireType) - } - m.Enc = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommitment - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Enc |= KeyEncoding(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipCommitment(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthCommitment - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthCommitment - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipCommitment(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ibc/core/23-commitment/types/key_path.go b/x/ibc/core/23-commitment/types/key_path.go deleted file mode 100644 index 589406b901..0000000000 --- a/x/ibc/core/23-commitment/types/key_path.go +++ /dev/null @@ -1,40 +0,0 @@ -package types - -import ( - fmt "fmt" - "net/url" -) - -// AppendKey appends a new key to a KeyPath -func (pth KeyPath) AppendKey(key []byte, enc KeyEncoding) KeyPath { - pth.Keys = append(pth.Keys, &Key{Name: key, Enc: enc}) - return pth -} - -// String implements the fmt.Stringer interface -func (pth *KeyPath) String() string { - res := "" - for _, key := range pth.Keys { - switch key.Enc { - case URL: - res += "/" + url.PathEscape(string(key.Name)) - case HEX: - res += "/x:" + fmt.Sprintf("%X", key.Name) - default: - panic("unexpected key encoding type") - } - } - return res -} - -// GetKey returns the bytes representation of key at given index -// Passing in a positive index return the key at index in forward order -// from the highest key to the lowest key -// Passing in a negative index will return the key at index in reverse order -// from the lowest key to the highest key. This is the order for proof verification, -// since we prove lowest key first before moving to key of higher subtrees -func (pth *KeyPath) GetKey(i int) []byte { - total := len(pth.Keys) - index := (total + i) % total - return pth.Keys[index].Name -} diff --git a/x/ibc/core/23-commitment/types/merkle.go b/x/ibc/core/23-commitment/types/merkle.go index 87a830e294..fe7d5c302b 100644 --- a/x/ibc/core/23-commitment/types/merkle.go +++ b/x/ibc/core/23-commitment/types/merkle.go @@ -2,6 +2,7 @@ package types import ( "bytes" + "fmt" "net/url" ics23 "github.com/confio/ics23/go" @@ -9,7 +10,6 @@ import ( tmcrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ) @@ -68,51 +68,62 @@ func (mp MerklePrefix) Empty() bool { var _ exported.Path = (*MerklePath)(nil) // NewMerklePath creates a new MerklePath instance -func NewMerklePath(keyPathStr []string) MerklePath { - merkleKeyPath := KeyPath{} - for _, keyStr := range keyPathStr { - merkleKeyPath = merkleKeyPath.AppendKey([]byte(keyStr), URL) - } - +// The keys must be passed in from root-to-leaf order +func NewMerklePath(keyPath ...string) MerklePath { return MerklePath{ - KeyPath: merkleKeyPath, + KeyPath: keyPath, } } // String implements fmt.Stringer. +// This represents the path in the same way the tendermint KeyPath will +// represent a key path. The backslashes partition the key path into +// the respective stores they belong to. func (mp MerklePath) String() string { - return mp.KeyPath.String() + pathStr := "" + for _, k := range mp.KeyPath { + pathStr += "/" + url.PathEscape(k) + } + return pathStr } // Pretty returns the unescaped path of the URL string. +// This function will unescape any backslash within a particular store key. +// This makes the keypath more human-readable while removing information +// about the exact partitions in the key path. func (mp MerklePath) Pretty() string { - path, err := url.PathUnescape(mp.KeyPath.String()) + path, err := url.PathUnescape(mp.String()) if err != nil { panic(err) } return path } -// Empty returns true if the path is empty -func (mp MerklePath) Empty() bool { - return len(mp.KeyPath.Keys) == 0 +// GetKey will return a byte representation of the key +// after URL escaping the key element +func (mp MerklePath) GetKey(i uint64) ([]byte, error) { + if i >= uint64(len(mp.KeyPath)) { + return nil, fmt.Errorf("index out of range. %d (index) >= %d (len)", i, len(mp.KeyPath)) + } + key, err := url.PathUnescape(mp.KeyPath[i]) + if err != nil { + return nil, err + } + return []byte(key), nil } -// ApplyPrefix constructs a new commitment path from the arguments. It interprets -// the path argument in the context of the prefix argument. -// -// CONTRACT: provided path string MUST be a well formated path. See ICS24 for -// reference. -func ApplyPrefix(prefix exported.Prefix, path string) (MerklePath, error) { - err := host.PathValidator(path) - if err != nil { - return MerklePath{}, err - } +// Empty returns true if the path is empty +func (mp MerklePath) Empty() bool { + return len(mp.KeyPath) == 0 +} +// ApplyPrefix constructs a new commitment path from the arguments. It prepends the prefix key +// with the given path. +func ApplyPrefix(prefix exported.Prefix, path MerklePath) (MerklePath, error) { if prefix == nil || prefix.Empty() { return MerklePath{}, sdkerrors.Wrap(ErrInvalidPrefix, "prefix can't be empty") } - return NewMerklePath([]string{string(prefix.Bytes()), path}), nil + return NewMerklePath(append([]string{string(prefix.Bytes())}, path.KeyPath...)...), nil } var _ exported.Proof = (*MerkleProof)(nil) @@ -128,22 +139,17 @@ func (proof MerkleProof) VerifyMembership(specs []*ics23.ProofSpec, root exporte if !ok { return sdkerrors.Wrapf(ErrInvalidProof, "path %v is not of type MerklePath", path) } - if len(mpath.KeyPath.Keys) != len(specs) { + if len(mpath.KeyPath) != len(specs) { return sdkerrors.Wrapf(ErrInvalidProof, "path length %d not same as proof %d", - len(mpath.KeyPath.Keys), len(specs)) + len(mpath.KeyPath), len(specs)) } if len(value) == 0 { return sdkerrors.Wrap(ErrInvalidProof, "empty value in membership proof") } - // Convert Proof to []CommitmentProof - proofs, err := convertProofs(proof) - if err != nil { - return err - } - - // Since every proof in chain is a membership proof we can chain from index 0 - if err := verifyChainedMembershipProof(root.GetHash(), specs, proofs, mpath.KeyPath, value, 0); err != nil { + // Since every proof in chain is a membership proof we can use verifyChainedMembershipProof from index 0 + // to validate entire proof + if err := verifyChainedMembershipProof(root.GetHash(), specs, proof.Proofs, mpath, value, 0); err != nil { return err } return nil @@ -162,31 +168,37 @@ func (proof MerkleProof) VerifyNonMembership(specs []*ics23.ProofSpec, root expo if !ok { return sdkerrors.Wrapf(ErrInvalidProof, "path %v is not of type MerkleProof", path) } - if len(mpath.KeyPath.Keys) != len(specs) { + if len(mpath.KeyPath) != len(specs) { return sdkerrors.Wrapf(ErrInvalidProof, "path length %d not same as proof %d", - len(mpath.KeyPath.Keys), len(specs)) + len(mpath.KeyPath), len(specs)) } - // Convert Proof to []CommitmentProof - proofs, err := convertProofs(proof) - if err != nil { - return err - } + switch proof.Proofs[0].Proof.(type) { + case *ics23.CommitmentProof_Nonexist: + // VerifyNonMembership will verify the absence of key in lowest subtree, and then chain inclusion proofs + // of all subroots up to final root + subroot, err := proof.Proofs[0].Calculate() + if err != nil { + return sdkerrors.Wrapf(ErrInvalidProof, "could not calculate root for proof index 0, merkle tree is likely empty. %v", err) + } + key, err := mpath.GetKey(uint64(len(mpath.KeyPath) - 1)) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidProof, "could not retrieve key bytes for key: %s", mpath.KeyPath[len(mpath.KeyPath)-1]) + } + if ok := ics23.VerifyNonMembership(specs[0], subroot, proof.Proofs[0], key); !ok { + return sdkerrors.Wrapf(ErrInvalidProof, "could not verify absence of key %s. Please ensure that the path is correct.", string(key)) + } - // VerifyNonMembership will verify the absence of key in lowest subtree, and then chain inclusion proofs - // of all subroots up to final root - subroot, err := proofs[0].Calculate() - if err != nil { - sdkerrors.Wrapf(ErrInvalidProof, "could not calculate root for proof index 0. %v", err) - } - key := mpath.KeyPath.GetKey(-1) - if ok := ics23.VerifyNonMembership(specs[0], subroot, proofs[0], key); !ok { - return sdkerrors.Wrapf(ErrInvalidProof, "could not verify absence of key %s", string(key)) - } - - // Verify chained membership proof starting from index 1 with value = subroot - if err := verifyChainedMembershipProof(root.GetHash(), specs, proofs, mpath.KeyPath, subroot, 1); err != nil { - return err + // Verify chained membership proof starting from index 1 with value = subroot + if err := verifyChainedMembershipProof(root.GetHash(), specs, proof.Proofs, mpath, subroot, 1); err != nil { + return err + } + case *ics23.CommitmentProof_Exist: + return sdkerrors.Wrapf(ErrInvalidProof, + "got ExistenceProof in VerifyNonMembership. If this is unexpected, please ensure that proof was queried with the correct key.") + default: + return sdkerrors.Wrapf(ErrInvalidProof, + "expected proof type: %T, got: %T", &ics23.CommitmentProof_Exist{}, proof.Proofs[0].Proof) } return nil } @@ -208,7 +220,7 @@ func (proof MerkleProof) BatchVerifyNonMembership(specs []*ics23.ProofSpec, root // The proofs and specs are passed in from lowest subtree to the highest subtree, but the keys are passed in from highest subtree to lowest. // The index specifies what index to start chaining the membership proofs, this is useful since the lowest proof may not be a membership proof, thus we // will want to start the membership proof chaining from index 1 with value being the lowest subroot -func verifyChainedMembershipProof(root []byte, specs []*ics23.ProofSpec, proofs []*ics23.CommitmentProof, keys KeyPath, value []byte, index int) error { +func verifyChainedMembershipProof(root []byte, specs []*ics23.ProofSpec, proofs []*ics23.CommitmentProof, keys MerklePath, value []byte, index int) error { var ( subroot []byte err error @@ -218,42 +230,45 @@ func verifyChainedMembershipProof(root []byte, specs []*ics23.ProofSpec, proofs // In this case, there may be no intermediate proofs to verify and we just check that lowest proof root equals final root subroot = value for i := index; i < len(proofs); i++ { - subroot, err = proofs[i].Calculate() - if err != nil { - return sdkerrors.Wrapf(ErrInvalidProof, "could not calculate proof root at index %d. %v", i, err) + switch proofs[i].Proof.(type) { + case *ics23.CommitmentProof_Exist: + subroot, err = proofs[i].Calculate() + if err != nil { + return sdkerrors.Wrapf(ErrInvalidProof, "could not calculate proof root at index %d, merkle tree may be empty. %v", i, err) + } + // Since keys are passed in from highest to lowest, we must grab their indices in reverse order + // from the proofs and specs which are lowest to highest + key, err := keys.GetKey(uint64(len(keys.KeyPath) - 1 - i)) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidProof, "could not retrieve key bytes for key %s: %v", keys.KeyPath[len(keys.KeyPath)-1-i], err) + } + + // verify membership of the proof at this index with appropriate key and value + if ok := ics23.VerifyMembership(specs[i], subroot, proofs[i], key, value); !ok { + return sdkerrors.Wrapf(ErrInvalidProof, + "chained membership proof failed to verify membership of value: %X in subroot %X at index %d. Please ensure the path and value are both correct.", + value, subroot, i) + } + // Set value to subroot so that we verify next proof in chain commits to this subroot + value = subroot + case *ics23.CommitmentProof_Nonexist: + return sdkerrors.Wrapf(ErrInvalidProof, + "chained membership proof contains nonexistence proof at index %d. If this is unexpected, please ensure that proof was queried from the height that contained the value in store and was queried with the correct key.", + i) + default: + return sdkerrors.Wrapf(ErrInvalidProof, + "expected proof type: %T, got: %T", &ics23.CommitmentProof_Exist{}, proofs[i].Proof) } - // Since keys are passed in from highest to lowest, we must grab their indices in reverse order - // from the proofs and specs which are lowest to highest - key := keys.GetKey(-1 * (i + 1)) - if ok := ics23.VerifyMembership(specs[i], subroot, proofs[i], key, value); !ok { - return sdkerrors.Wrapf(ErrInvalidProof, "chained membership proof failed to verify membership of value: %X in subroot %X at index %d for proof %v", - value, subroot, i, proofs[i]) - } - // Set value to subroot so that we verify next proof in chain commits to this subroot - value = subroot } // Check that chained proof root equals passed-in root if !bytes.Equal(root, subroot) { - return sdkerrors.Wrapf(ErrInvalidProof, "proof did not commit to expected root: %X, got: %X", root, subroot) + return sdkerrors.Wrapf(ErrInvalidProof, + "proof did not commit to expected root: %X, got: %X. Please ensure proof was submitted with correct proofHeight and to the correct chain.", + root, subroot) } return nil } -// convertProofs converts a MerkleProof into []*ics23.CommitmentProof -func convertProofs(mproof MerkleProof) ([]*ics23.CommitmentProof, error) { - // Unmarshal all proof ops to CommitmentProof - proofs := make([]*ics23.CommitmentProof, len(mproof.Proof.Ops)) - for i, op := range mproof.Proof.Ops { - var p ics23.CommitmentProof - err := p.Unmarshal(op.Data) - if err != nil { - return nil, sdkerrors.Wrapf(ErrInvalidMerkleProof, "could not unmarshal proof op into CommitmentProof at index: %d", i) - } - proofs[i] = &p - } - return proofs, nil -} - // Empty returns true if the root is empty func (proof MerkleProof) Empty() bool { return proto.Equal(&proof, nil) || proto.Equal(&proof, &MerkleProof{}) || proto.Equal(&proof, &tmcrypto.ProofOps{}) @@ -277,10 +292,10 @@ func (proof MerkleProof) validateVerificationArgs(specs []*ics23.ProofSpec, root return sdkerrors.Wrap(ErrInvalidMerkleProof, "root cannot be empty") } - if len(specs) != len(proof.Proof.Ops) { + if len(specs) != len(proof.Proofs) { return sdkerrors.Wrapf(ErrInvalidMerkleProof, "length of specs: %d not equal to length of proof: %d", - len(specs), len(proof.Proof.Ops)) + len(specs), len(proof.Proofs)) } for i, spec := range specs { diff --git a/x/ibc/core/23-commitment/types/merkle_test.go b/x/ibc/core/23-commitment/types/merkle_test.go index 4da9099e85..3c53847fad 100644 --- a/x/ibc/core/23-commitment/types/merkle_test.go +++ b/x/ibc/core/23-commitment/types/merkle_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - tmcrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" - tmmerkle "github.com/tendermint/tendermint/proto/tendermint/crypto" "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" ) @@ -23,9 +21,9 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { }) require.NotNil(suite.T(), res.ProofOps) - proof := types.MerkleProof{ - Proof: res.ProofOps, - } + proof, err := types.ConvertProofs(res.ProofOps) + require.NoError(suite.T(), err) + suite.Require().NoError(proof.ValidateBasic()) suite.Require().Error(types.MerkleProof{}.ValidateBasic()) @@ -49,9 +47,7 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { {"nil root", []byte(nil), []string{suite.storeKey.Name(), "MYKEY"}, []byte("MYVALUE"), func() {}, false}, // invalid proof with nil root {"proof is wrong length", cid.Hash, []string{suite.storeKey.Name(), "MYKEY"}, []byte("MYVALUE"), func() { proof = types.MerkleProof{ - Proof: &tmmerkle.ProofOps{ - Ops: res.ProofOps.Ops[1:], - }, + Proofs: proof.Proofs[1:], } }, false}, // invalid proof with wrong length @@ -63,7 +59,7 @@ func (suite *MerkleTestSuite) TestVerifyMembership() { tc.malleate() root := types.NewMerkleRoot(tc.root) - path := types.NewMerklePath(tc.pathArr) + path := types.NewMerklePath(tc.pathArr...) err := proof.VerifyMembership(types.GetSDKSpecs(), &root, path, tc.value) @@ -91,9 +87,9 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { }) require.NotNil(suite.T(), res.ProofOps) - proof := types.MerkleProof{ - Proof: res.ProofOps, - } + proof, err := types.ConvertProofs(res.ProofOps) + require.NoError(suite.T(), err) + suite.Require().NoError(proof.ValidateBasic()) cases := []struct { @@ -114,9 +110,7 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { {"nil root", []byte(nil), []string{suite.storeKey.Name(), "MYABSENTKEY"}, func() {}, false}, // invalid proof with nil root {"proof is wrong length", cid.Hash, []string{suite.storeKey.Name(), "MYKEY"}, func() { proof = types.MerkleProof{ - Proof: &tmcrypto.ProofOps{ - Ops: res.ProofOps.Ops[1:], - }, + Proofs: proof.Proofs[1:], } }, false}, // invalid proof with wrong length @@ -129,7 +123,7 @@ func (suite *MerkleTestSuite) TestVerifyNonMembership() { tc.malleate() root := types.NewMerkleRoot(tc.root) - path := types.NewMerklePath(tc.pathArr) + path := types.NewMerklePath(tc.pathArr...) err := proof.VerifyNonMembership(types.GetSDKSpecs(), &root, path) @@ -149,16 +143,30 @@ func TestApplyPrefix(t *testing.T) { prefix := types.NewMerklePrefix([]byte("storePrefixKey")) pathStr := "pathone/pathtwo/paththree/key" + path := types.MerklePath{ + KeyPath: []string{pathStr}, + } - prefixedPath, err := types.ApplyPrefix(prefix, pathStr) - require.Nil(t, err, "valid prefix returns error") + prefixedPath, err := types.ApplyPrefix(prefix, path) + require.NoError(t, err, "valid prefix returns error") require.Equal(t, "/storePrefixKey/"+pathStr, prefixedPath.Pretty(), "Prefixed path incorrect") - require.Equal(t, "/storePrefixKey/pathone%2Fpathtwo%2Fpaththree%2Fkey", prefixedPath.String(), "Prefixed scaped path incorrect") - - // invalid prefix contains non-alphanumeric character - invalidPathStr := "invalid-path/doesitfail?/hopefully" - invalidPath, err := types.ApplyPrefix(prefix, invalidPathStr) - require.NotNil(t, err, "invalid prefix does not returns error") - require.Equal(t, types.MerklePath{}, invalidPath, "invalid prefix returns valid Path on ApplyPrefix") + require.Equal(t, "/storePrefixKey/pathone%2Fpathtwo%2Fpaththree%2Fkey", prefixedPath.String(), "Prefixed escaped path incorrect") +} + +func TestString(t *testing.T) { + path := types.NewMerklePath("rootKey", "storeKey", "path/to/leaf") + + require.Equal(t, "/rootKey/storeKey/path%2Fto%2Fleaf", path.String(), "path String returns unxpected value") + require.Equal(t, "/rootKey/storeKey/path/to/leaf", path.Pretty(), "path's pretty string representation is incorrect") + + onePath := types.NewMerklePath("path/to/leaf") + + require.Equal(t, "/path%2Fto%2Fleaf", onePath.String(), "one element path does not have correct string representation") + require.Equal(t, "/path/to/leaf", onePath.Pretty(), "one element path has incorrect pretty string representation") + + zeroPath := types.NewMerklePath() + + require.Equal(t, "", zeroPath.String(), "zero element path does not have correct string representation") + require.Equal(t, "", zeroPath.Pretty(), "zero element path does not have correct pretty string representation") } diff --git a/x/ibc/core/23-commitment/types/utils.go b/x/ibc/core/23-commitment/types/utils.go new file mode 100644 index 0000000000..7d2937f0fb --- /dev/null +++ b/x/ibc/core/23-commitment/types/utils.go @@ -0,0 +1,27 @@ +package types + +import ( + ics23 "github.com/confio/ics23/go" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + crypto "github.com/tendermint/tendermint/proto/tendermint/crypto" +) + +// ConvertProofs converts crypto.ProofOps into MerkleProof +func ConvertProofs(tmProof *crypto.ProofOps) (MerkleProof, error) { + if tmProof == nil { + return MerkleProof{}, sdkerrors.Wrapf(ErrInvalidMerkleProof, "tendermint proof is nil") + } + // Unmarshal all proof ops to CommitmentProof + proofs := make([]*ics23.CommitmentProof, len(tmProof.Ops)) + for i, op := range tmProof.Ops { + var p ics23.CommitmentProof + err := p.Unmarshal(op.Data) + if err != nil || p.Proof == nil { + return MerkleProof{}, sdkerrors.Wrapf(ErrInvalidMerkleProof, "could not unmarshal proof op into CommitmentProof at index %d: %v", i, err) + } + proofs[i] = &p + } + return MerkleProof{ + Proofs: proofs, + }, nil +} diff --git a/x/ibc/core/23-commitment/types/utils_test.go b/x/ibc/core/23-commitment/types/utils_test.go new file mode 100644 index 0000000000..a4c08d13fa --- /dev/null +++ b/x/ibc/core/23-commitment/types/utils_test.go @@ -0,0 +1,97 @@ +package types_test + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + crypto "github.com/tendermint/tendermint/proto/tendermint/crypto" +) + +func (suite *MerkleTestSuite) TestConvertProofs() { + suite.iavlStore.Set([]byte("MYKEY"), []byte("MYVALUE")) + cid := suite.store.Commit() + + root := types.NewMerkleRoot(cid.Hash) + existsPath := types.NewMerklePath(suite.storeKey.Name(), "MYKEY") + nonexistPath := types.NewMerklePath(suite.storeKey.Name(), "NOTMYKEY") + value := []byte("MYVALUE") + + var proofOps *crypto.ProofOps + testcases := []struct { + name string + malleate func() + keyExists bool + expPass bool + }{ + { + "success for ExistenceProof", + func() { + res := suite.store.Query(abci.RequestQuery{ + Path: fmt.Sprintf("/%s/key", suite.storeKey.Name()), // required path to get key/value+proof + Data: []byte("MYKEY"), + Prove: true, + }) + require.NotNil(suite.T(), res.ProofOps) + + proofOps = res.ProofOps + }, + true, true, + }, + { + "success for NonexistenceProof", + func() { + res := suite.store.Query(abci.RequestQuery{ + Path: fmt.Sprintf("/%s/key", suite.storeKey.Name()), // required path to get key/value+proof + Data: []byte("NOTMYKEY"), + Prove: true, + }) + require.NotNil(suite.T(), res.ProofOps) + + proofOps = res.ProofOps + }, + false, true, + }, + { + "nil proofOps", + func() { + proofOps = nil + }, + true, false, + }, + { + "proof op data is nil", + func() { + res := suite.store.Query(abci.RequestQuery{ + Path: fmt.Sprintf("/%s/key", suite.storeKey.Name()), // required path to get key/value+proof + Data: []byte("MYKEY"), + Prove: true, + }) + require.NotNil(suite.T(), res.ProofOps) + + proofOps = res.ProofOps + proofOps.Ops[0].Data = nil + }, + true, false, + }, + } + + for _, tc := range testcases { + tc.malleate() + + proof, err := types.ConvertProofs(proofOps) + if tc.expPass { + suite.Require().NoError(err, "ConvertProofs unexpectedly returned error for case: %s", tc.name) + if tc.keyExists { + err := proof.VerifyMembership(types.GetSDKSpecs(), &root, existsPath, value) + suite.Require().NoError(err, "converted proof failed to verify membership for case: %s", tc.name) + } else { + err := proof.VerifyNonMembership(types.GetSDKSpecs(), &root, nonexistPath) + suite.Require().NoError(err, "converted proof failed to verify membership for case: %s", tc.name) + } + } else { + suite.Require().Error(err, "ConvertProofs passed on invalid case for case: %s", tc.name) + } + } +} diff --git a/x/ibc/core/24-host/errors.go b/x/ibc/core/24-host/errors.go index 3ec901625d..fe8129bde8 100644 --- a/x/ibc/core/24-host/errors.go +++ b/x/ibc/core/24-host/errors.go @@ -9,8 +9,7 @@ const SubModuleName = "host" // IBC client sentinel errors var ( - ErrInvalidID = sdkerrors.Register(SubModuleName, 2, "invalid identifier") - ErrInvalidPath = sdkerrors.Register(SubModuleName, 3, "invalid path") - ErrInvalidPacket = sdkerrors.Register(SubModuleName, 4, "invalid packet") - ErrInvalidVersion = sdkerrors.Register(SubModuleName, 5, "invalid version") + ErrInvalidID = sdkerrors.Register(SubModuleName, 2, "invalid identifier") + ErrInvalidPath = sdkerrors.Register(SubModuleName, 3, "invalid path") + ErrInvalidPacket = sdkerrors.Register(SubModuleName, 4, "invalid packet") ) diff --git a/x/ibc/core/24-host/keys.go b/x/ibc/core/24-host/keys.go index 3a51a13db1..51d2939577 100644 --- a/x/ibc/core/24-host/keys.go +++ b/x/ibc/core/24-host/keys.go @@ -22,14 +22,18 @@ const ( // KVStore key prefixes for IBC var ( - KeyClientStorePrefix = []byte("clients") - KeyConsensusStatesPrefix = []byte("consensusStates") - KeyConnectionPrefix = []byte("connections") + KeyClientStorePrefix = []byte("clients") ) // KVStore key prefixes for IBC const ( - KeyChannelPrefix = "channelEnds" + KeyClientState = "clientState" + KeyConsensusStatePrefix = "consensusStates" + KeyConnectionPrefix = "connections" + KeyChannelEndPrefix = "channelEnds" + KeyChannelPrefix = "channels" + KeyPortPrefix = "ports" + KeySequencePrefix = "sequences" KeyChannelCapabilityPrefix = "capabilities" KeyNextSeqSendPrefix = "nextSequenceSend" KeyNextSeqRecvPrefix = "nextSequenceRecv" @@ -42,38 +46,57 @@ const ( // FullClientPath returns the full path of a specific client path in the format: // "clients/{clientID}/{path}" as a string. func FullClientPath(clientID string, path string) string { - return string(FullKeyClientPath(clientID, []byte(path))) + return fmt.Sprintf("%s/%s/%s", KeyClientStorePrefix, clientID, path) } -// FullKeyClientPath returns the full path of specific client path in the format: +// FullClientKey returns the full path of specific client path in the format: // "clients/{clientID}/{path}" as a byte array. -func FullKeyClientPath(clientID string, path []byte) []byte { - return append(KeyClientStorePrefix, append([]byte("/"+clientID+"/"), path...)...) +func FullClientKey(clientID string, path []byte) []byte { + return []byte(FullClientPath(clientID, string(path))) } // ICS02 // The following paths are the keys to the store as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#path-space -// ClientStatePath takes an Identifier and returns a Path under which to store a +// FullClientStatePath takes a client identifier and returns a Path under which to store a // particular client state -func ClientStatePath() string { - return "clientState" +func FullClientStatePath(clientID string) string { + return FullClientPath(clientID, KeyClientState) } -// ConsensusStatePath takes an Identifier and returns a Path under which to +// FullClientStateKey takes a client identifier and returns a Key under which to store a +// particular client state. +func FullClientStateKey(clientID string) []byte { + return FullClientKey(clientID, []byte(KeyClientState)) +} + +// ClientStateKey returns a store key under which a particular client state is stored +// in a client prefixed store +func ClientStateKey() []byte { + return []byte(KeyClientState) +} + +// FullConsensusStatePath takes a client identifier and returns a Path under which to // store the consensus state of a client. +func FullConsensusStatePath(clientID string, height exported.Height) string { + return FullClientPath(clientID, fmt.Sprintf("%s/%s", KeyConsensusStatePrefix, height)) +} + +// FullConsensusStateKey returns the store key for the consensus state of a particular +// client. +func FullConsensusStateKey(clientID string, height exported.Height) []byte { + return []byte(FullConsensusStatePath(clientID, height)) +} + +// ConsensusStatePath returns the suffix store key for the consensus state at a +// particular height stored in a client prefixed store. func ConsensusStatePath(height exported.Height) string { - return fmt.Sprintf("%s/%s", KeyConsensusStatesPrefix, height) + return fmt.Sprintf("%s/%s", KeyConsensusStatePrefix, height) } -// KeyClientState returns the store key for a particular client state -func KeyClientState() []byte { - return []byte(ClientStatePath()) -} - -// KeyConsensusState returns the store key for the consensus state of a particular -// client -func KeyConsensusState(height exported.Height) []byte { +// ConsensusStateKey returns the store key for a the consensus state of a particular +// client stored in a client prefixed store. +func ConsensusStateKey(height exported.Height) []byte { return []byte(ConsensusStatePath(height)) } @@ -82,7 +105,12 @@ func KeyConsensusState(height exported.Height) []byte { // ClientConnectionsPath defines a reverse mapping from clients to a set of connections func ClientConnectionsPath(clientID string) string { - return fmt.Sprintf("%s/%s/connections", KeyClientStorePrefix, clientID) + return FullClientPath(clientID, KeyConnectionPrefix) +} + +// ClientConnectionsKey returns the store key for the connections of a given client +func ClientConnectionsKey(clientID string) []byte { + return []byte(ClientConnectionsPath(clientID)) } // ConnectionPath defines the path under which connection paths are stored @@ -90,13 +118,8 @@ func ConnectionPath(connectionID string) string { return fmt.Sprintf("%s/%s", KeyConnectionPrefix, connectionID) } -// KeyClientConnections returns the store key for the connections of a given client -func KeyClientConnections(clientID string) []byte { - return []byte(ClientConnectionsPath(clientID)) -} - -// KeyConnection returns the store key for a particular connection -func KeyConnection(connectionID string) []byte { +// ConnectionKey returns the store key for a particular connection +func ConnectionKey(connectionID string) []byte { return []byte(ConnectionPath(connectionID)) } @@ -105,98 +128,102 @@ func KeyConnection(connectionID string) []byte { // ChannelPath defines the path under which channels are stored func ChannelPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyChannelPrefix) + channelPath(portID, channelID) + return fmt.Sprintf("%s/%s", KeyChannelEndPrefix, channelPath(portID, channelID)) +} + +// ChannelKey returns the store key for a particular channel +func ChannelKey(portID, channelID string) []byte { + return []byte(ChannelPath(portID, channelID)) } // ChannelCapabilityPath defines the path under which capability keys associated // with a channel are stored func ChannelCapabilityPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyChannelCapabilityPrefix) + channelPath(portID, channelID) + "/key" + return fmt.Sprintf("%s/%s", KeyChannelCapabilityPrefix, channelPath(portID, channelID)) } // NextSequenceSendPath defines the next send sequence counter store path func NextSequenceSendPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyNextSeqSendPrefix) + channelPath(portID, channelID) + return fmt.Sprintf("%s/%s", KeyNextSeqSendPrefix, channelPath(portID, channelID)) } -// NextSequenceRecvPath defines the next receive sequence counter store path +// NextSequenceSendKey returns the store key for the send sequence of a particular +// channel binded to a specific port. +func NextSequenceSendKey(portID, channelID string) []byte { + return []byte(NextSequenceSendPath(portID, channelID)) +} + +// NextSequenceRecvPath defines the next receive sequence counter store path. func NextSequenceRecvPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyNextSeqRecvPrefix) + channelPath(portID, channelID) + return fmt.Sprintf("%s/%s", KeyNextSeqRecvPrefix, channelPath(portID, channelID)) +} + +// NextSequenceRecvKey returns the store key for the receive sequence of a particular +// channel binded to a specific port +func NextSequenceRecvKey(portID, channelID string) []byte { + return []byte(NextSequenceRecvPath(portID, channelID)) } // NextSequenceAckPath defines the next acknowledgement sequence counter store path func NextSequenceAckPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyNextSeqAckPrefix) + channelPath(portID, channelID) + return fmt.Sprintf("%s/%s", KeyNextSeqAckPrefix, channelPath(portID, channelID)) +} + +// NextSequenceAckKey returns the store key for the acknowledgement sequence of +// a particular channel binded to a specific port. +func NextSequenceAckKey(portID, channelID string) []byte { + return []byte(NextSequenceAckPath(portID, channelID)) } // PacketCommitmentPath defines the commitments to packet data fields store path func PacketCommitmentPath(portID, channelID string, sequence uint64) string { - return fmt.Sprintf("%s/", KeyPacketCommitmentPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/packets/%d", sequence) + return fmt.Sprintf("%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), sequencePath(sequence)) +} + +// PacketCommitmentKey returns the store key of under which a packet commitment +// is stored +func PacketCommitmentKey(portID, channelID string, sequence uint64) []byte { + return []byte(PacketCommitmentPath(portID, channelID, sequence)) } // PacketCommitmentPrefixPath defines the prefix for commitments to packet data fields store path. func PacketCommitmentPrefixPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyPacketCommitmentPrefix) + channelPath(portID, channelID) + return fmt.Sprintf("%s/%s/%s", KeyPacketCommitmentPrefix, channelPath(portID, channelID), KeySequencePrefix) } // PacketAcknowledgementPath defines the packet acknowledgement store path func PacketAcknowledgementPath(portID, channelID string, sequence uint64) string { - return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/acknowledgements/%d", sequence) + return fmt.Sprintf("%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), sequencePath(sequence)) +} + +// PacketAcknowledgementKey returns the store key of under which a packet +// acknowledgement is stored +func PacketAcknowledgementKey(portID, channelID string, sequence uint64) []byte { + return []byte(PacketAcknowledgementPath(portID, channelID, sequence)) } // PacketAcknowledgementPrefixPath defines the prefix for commitments to packet data fields store path. func PacketAcknowledgementPrefixPath(portID, channelID string) string { - return fmt.Sprintf("%s/", KeyPacketAckPrefix) + channelPath(portID, channelID) + return fmt.Sprintf("%s/%s/%s", KeyPacketAckPrefix, channelPath(portID, channelID), KeySequencePrefix) } // PacketReceiptPath defines the packet receipt store path func PacketReceiptPath(portID, channelID string, sequence uint64) string { - return fmt.Sprintf("%s/", KeyPacketReceiptPrefix) + channelPath(portID, channelID) + fmt.Sprintf("/receipts/%d", sequence) + return fmt.Sprintf("%s/%s/%s", KeyPacketReceiptPrefix, channelPath(portID, channelID), sequencePath(sequence)) } -// KeyChannel returns the store key for a particular channel -func KeyChannel(portID, channelID string) []byte { - return []byte(ChannelPath(portID, channelID)) -} - -// KeyNextSequenceSend returns the store key for the send sequence of a particular -// channel binded to a specific port -func KeyNextSequenceSend(portID, channelID string) []byte { - return []byte(NextSequenceSendPath(portID, channelID)) -} - -// KeyNextSequenceRecv returns the store key for the receive sequence of a particular -// channel binded to a specific port -func KeyNextSequenceRecv(portID, channelID string) []byte { - return []byte(NextSequenceRecvPath(portID, channelID)) -} - -// KeyNextSequenceAck returns the store key for the acknowledgement sequence of -// a particular channel binded to a specific port. -func KeyNextSequenceAck(portID, channelID string) []byte { - return []byte(NextSequenceAckPath(portID, channelID)) -} - -// KeyPacketCommitment returns the store key of under which a packet commitment -// is stored -func KeyPacketCommitment(portID, channelID string, sequence uint64) []byte { - return []byte(PacketCommitmentPath(portID, channelID, sequence)) -} - -// KeyPacketAcknowledgement returns the store key of under which a packet -// acknowledgement is stored -func KeyPacketAcknowledgement(portID, channelID string, sequence uint64) []byte { - return []byte(PacketAcknowledgementPath(portID, channelID, sequence)) -} - -// KeyPacketReceipt returns the store key of under which a packet +// PacketReceiptKey returns the store key of under which a packet // receipt is stored -func KeyPacketReceipt(portID, channelID string, sequence uint64) []byte { +func PacketReceiptKey(portID, channelID string, sequence uint64) []byte { return []byte(PacketReceiptPath(portID, channelID, sequence)) } func channelPath(portID, channelID string) string { - return fmt.Sprintf("ports/%s/channels/%s", portID, channelID) + return fmt.Sprintf("%s/%s/%s/%s", KeyPortPrefix, portID, KeyChannelPrefix, channelID) +} + +func sequencePath(sequence uint64) string { + return fmt.Sprintf("%s/%d", KeySequencePrefix, sequence) } // ICS05 @@ -204,5 +231,5 @@ func channelPath(portID, channelID string) string { // PortPath defines the path under which ports paths are stored on the capability module func PortPath(portID string) string { - return fmt.Sprintf("ports/%s", portID) + return fmt.Sprintf("%s/%s", KeyPortPrefix, portID) } diff --git a/x/ibc/core/24-host/parse.go b/x/ibc/core/24-host/parse.go index 7200c4ff00..7e6301a391 100644 --- a/x/ibc/core/24-host/parse.go +++ b/x/ibc/core/24-host/parse.go @@ -25,7 +25,7 @@ func ParseChannelPath(path string) (string, string, error) { return "", "", sdkerrors.Wrapf(ErrInvalidPath, "cannot parse channel path %s", path) } - if split[1] != "ports" || split[3] != "channels" { + if split[1] != KeyPortPrefix || split[3] != KeyChannelPrefix { return "", "", sdkerrors.Wrapf(ErrInvalidPath, "cannot parse channel path %s", path) } diff --git a/x/ibc/core/24-host/validate.go b/x/ibc/core/24-host/validate.go index 6d512fbe0c..bbfafbee75 100644 --- a/x/ibc/core/24-host/validate.go +++ b/x/ibc/core/24-host/validate.go @@ -56,36 +56,37 @@ func defaultIdentifierValidator(id string, min, max int) error { //nolint:unpara } // ClientIdentifierValidator is the default validator function for Client identifiers. -// A valid Identifier must be between 9-64 characters and only contain lowercase -// alphabetic characters. +// A valid Identifier must be between 9-64 characters and only contain alphanumeric and some allowed +// special characters (see IsValidID). func ClientIdentifierValidator(id string) error { return defaultIdentifierValidator(id, 9, DefaultMaxCharacterLength) } // ConnectionIdentifierValidator is the default validator function for Connection identifiers. -// A valid Identifier must be between 10-64 characters and only contain lowercase -// alphabetic characters. +// A valid Identifier must be between 10-64 characters and only contain alphanumeric and some allowed +// special characters (see IsValidID). func ConnectionIdentifierValidator(id string) error { return defaultIdentifierValidator(id, 10, DefaultMaxCharacterLength) } // ChannelIdentifierValidator is the default validator function for Channel identifiers. -// A valid Identifier must be between 10-64 characters and only contain lowercase -// alphabetic characters. +// A valid Identifier must be between 10-64 characters and only contain alphanumeric and some allowed +// special characters (see IsValidID). func ChannelIdentifierValidator(id string) error { return defaultIdentifierValidator(id, 10, DefaultMaxCharacterLength) } // PortIdentifierValidator is the default validator function for Port identifiers. -// A valid Identifier must be between 2-64 characters and only contain lowercase -// alphabetic characters. +// A valid Identifier must be between 2-64 characters and only contain alphanumeric and some allowed +// special characters (see IsValidID). func PortIdentifierValidator(id string) error { return defaultIdentifierValidator(id, 2, DefaultMaxCharacterLength) } // NewPathValidator takes in a Identifier Validator function and returns -// a Path Validator function which requires path only has valid identifiers -// alphanumeric character strings, and "/" separators +// a Path Validator function which requires path to consist of `/`-separated valid identifiers, +// where a valid identifier is between 1-64 characters, contains only alphanumeric and some allowed +// special characters (see IsValidID), and satisfies the custom `idValidator` function. func NewPathValidator(idValidator ValidateFn) ValidateFn { return func(path string) error { pathArr := strings.Split(path, "/") @@ -112,25 +113,13 @@ func NewPathValidator(idValidator ValidateFn) ValidateFn { } } -// PathValidator takes in path string and validates with default identifier rules. -// This is optimized by simply checking that all path elements are alphanumeric. +// PathValidator takes in path string and validates with default identifier rules: +// path consists of `/`-separated valid identifiers, +// each identifier is between 1-64 characters and contains only alphanumeric and some allowed +// special characters (see IsValidID). func PathValidator(path string) error { - pathArr := strings.Split(path, "/") - if len(pathArr) > 0 && pathArr[0] == path { - return sdkerrors.Wrapf(ErrInvalidPath, "path %s doesn't contain any separator '/'", path) - } - - for _, p := range pathArr { - // a path beginning or ending in a separator returns empty string elements. - if p == "" { - return sdkerrors.Wrapf(ErrInvalidPath, "path %s cannot begin or end with '/'", path) - } - - // Each path element must be a valid identifier or constant number - if err := defaultIdentifierValidator(p, 1, DefaultMaxCharacterLength); err != nil { - return sdkerrors.Wrapf(err, "path %s contains an invalid identifier: '%s'", path, p) - } - } - - return nil + f := NewPathValidator(func(path string) error { + return nil + }) + return f(path) } diff --git a/x/ibc/core/client/query.go b/x/ibc/core/client/query.go index 273e25583c..dad0c28998 100644 --- a/x/ibc/core/client/query.go +++ b/x/ibc/core/client/query.go @@ -50,8 +50,9 @@ func QueryTendermintProof(clientCtx client.Context, key []byte) ([]byte, []byte, return nil, nil, clienttypes.Height{}, err } - merkleProof := commitmenttypes.MerkleProof{ - Proof: res.ProofOps, + merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) + if err != nil { + return nil, nil, clienttypes.Height{}, err } cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry) diff --git a/x/ibc/core/exported/client.go b/x/ibc/core/exported/client.go index e5b38a0598..10d437cbce 100644 --- a/x/ibc/core/exported/client.go +++ b/x/ibc/core/exported/client.go @@ -12,9 +12,15 @@ const ( // TypeClientMisbehaviour is the shared evidence misbehaviour type TypeClientMisbehaviour string = "client_misbehaviour" + // Solomachine is used to indicate that the light client is a solo machine. + Solomachine string = "06-solomachine" + + // Tendermint is used to indicate that the client uses the Tendermint Consensus Algorithm. + Tendermint string = "07-tendermint" + // Localhost is the client type for a localhost client. It is also used as the clientID // for the localhost client. - Localhost string = "localhost" + Localhost string = "09-localhost" ) // ClientState defines the required common functions for light clients. @@ -33,14 +39,14 @@ type ClientState interface { CheckProposedHeaderAndUpdateState(sdk.Context, codec.BinaryMarshaler, sdk.KVStore, Header) (ClientState, ConsensusState, error) // Upgrade functions - VerifyUpgrade( + VerifyUpgradeAndUpdateState( ctx sdk.Context, cdc codec.BinaryMarshaler, store sdk.KVStore, newClient ClientState, upgradeHeight Height, proofUpgrade []byte, - ) error + ) (ClientState, ConsensusState, error) // Utility function that zeroes out any client customizable fields in client state // Ledger enforced fields are maintained while all custom fields are zero values // Used to verify upgrades @@ -148,7 +154,6 @@ type ConsensusState interface { type Misbehaviour interface { ClientType() string GetClientID() string - String() string ValidateBasic() error // Height at which the infraction occurred diff --git a/x/ibc/core/genesis_test.go b/x/ibc/core/genesis_test.go index d4cf1ec3aa..a14669faaa 100644 --- a/x/ibc/core/genesis_test.go +++ b/x/ibc/core/genesis_test.go @@ -77,7 +77,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { ClientGenesis: clienttypes.NewGenesisState( []clienttypes.IdentifiedClientState{ clienttypes.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), clienttypes.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight), @@ -96,6 +96,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() { }, ), }, + clienttypes.NewParams(exported.Tendermint, exported.Localhost), true, ), ConnectionGenesis: connectiontypes.NewGenesisState( @@ -143,13 +144,14 @@ func (suite *IBCTestSuite) TestValidateGenesis() { ClientGenesis: clienttypes.NewGenesisState( []clienttypes.IdentifiedClientState{ clienttypes.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), clienttypes.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("(chaindID)", clienttypes.ZeroHeight()), ), }, nil, + clienttypes.NewParams(exported.Tendermint), false, ), ConnectionGenesis: connectiontypes.DefaultGenesisState(), @@ -214,7 +216,7 @@ func (suite *IBCTestSuite) TestInitGenesis() { ClientGenesis: clienttypes.NewGenesisState( []clienttypes.IdentifiedClientState{ clienttypes.NewIdentifiedClientState( - clientID, ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), + clientID, ibctmtypes.NewClientState(suite.chainA.ChainID, ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false), ), clienttypes.NewIdentifiedClientState( exported.Localhost, localhosttypes.NewClientState("chaindID", clientHeight), @@ -233,6 +235,7 @@ func (suite *IBCTestSuite) TestInitGenesis() { }, ), }, + clienttypes.NewParams(exported.Tendermint, exported.Localhost), true, ), ConnectionGenesis: connectiontypes.NewGenesisState( @@ -295,8 +298,8 @@ func (suite *IBCTestSuite) TestExportGenesis() { // creates clients suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) // create extra clients - suite.coordinator.CreateClient(suite.chainA, suite.chainB, ibctesting.Tendermint) - suite.coordinator.CreateClient(suite.chainA, suite.chainB, ibctesting.Tendermint) + suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint) + suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint) }, }, } diff --git a/x/ibc/core/keeper/grpc_query.go b/x/ibc/core/keeper/grpc_query.go index e7dbe26109..f406d2e86f 100644 --- a/x/ibc/core/keeper/grpc_query.go +++ b/x/ibc/core/keeper/grpc_query.go @@ -28,6 +28,11 @@ func (q Keeper) ConsensusStates(c context.Context, req *clienttypes.QueryConsens return q.ClientKeeper.ConsensusStates(c, req) } +// ClientParams implements the IBC QueryServer interface +func (q Keeper) ClientParams(c context.Context, req *clienttypes.QueryClientParamsRequest) (*clienttypes.QueryClientParamsResponse, error) { + return q.ClientKeeper.ClientParams(c, req) +} + // Connection implements the IBC QueryServer interface func (q Keeper) Connection(c context.Context, req *connectiontypes.QueryConnectionRequest) (*connectiontypes.QueryConnectionResponse, error) { return q.ConnectionKeeper.Connection(c, req) diff --git a/x/ibc/core/keeper/keeper.go b/x/ibc/core/keeper/keeper.go index e9b7a0f1e5..5f9abc382e 100644 --- a/x/ibc/core/keeper/keeper.go +++ b/x/ibc/core/keeper/keeper.go @@ -11,6 +11,7 @@ import ( portkeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/keeper" porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ types.QueryServer = (*Keeper)(nil) @@ -31,9 +32,10 @@ type Keeper struct { // NewKeeper creates a new ibc Keeper func NewKeeper( - cdc codec.BinaryMarshaler, key sdk.StoreKey, stakingKeeper clienttypes.StakingKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, + cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace, + stakingKeeper clienttypes.StakingKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, ) *Keeper { - clientKeeper := clientkeeper.NewKeeper(cdc, key, stakingKeeper) + clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper) connectionKeeper := connectionkeeper.NewKeeper(cdc, key, clientKeeper) portKeeper := portkeeper.NewKeeper(scopedKeeper) channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper) diff --git a/x/ibc/core/keeper/msg_server.go b/x/ibc/core/keeper/msg_server.go index 01d3dae311..c7579fdbba 100644 --- a/x/ibc/core/keeper/msg_server.go +++ b/x/ibc/core/keeper/msg_server.go @@ -431,7 +431,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke } // Perform TAO verification - if err := k.ChannelKeeper.RecvPacket(ctx, cap, msg.Packet, msg.Proof, msg.ProofHeight); err != nil { + if err := k.ChannelKeeper.RecvPacket(ctx, cap, msg.Packet, msg.ProofCommitment, msg.ProofHeight); err != nil { return nil, sdkerrors.Wrap(err, "receive packet verification failed") } @@ -482,7 +482,7 @@ func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*c } // Perform TAO verification - if err := k.ChannelKeeper.TimeoutPacket(ctx, msg.Packet, msg.Proof, msg.ProofHeight, msg.NextSequenceRecv); err != nil { + if err := k.ChannelKeeper.TimeoutPacket(ctx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv); err != nil { return nil, sdkerrors.Wrap(err, "timeout packet verification failed") } @@ -531,7 +531,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo } // Perform TAO verification - if err := k.ChannelKeeper.TimeoutOnClose(ctx, cap, msg.Packet, msg.Proof, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv); err != nil { + if err := k.ChannelKeeper.TimeoutOnClose(ctx, cap, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv); err != nil { return nil, sdkerrors.Wrap(err, "timeout on close packet verification failed") } @@ -582,7 +582,7 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn } // Perform TAO verification - if err := k.ChannelKeeper.AcknowledgePacket(ctx, cap, msg.Packet, msg.Acknowledgement, msg.Proof, msg.ProofHeight); err != nil { + if err := k.ChannelKeeper.AcknowledgePacket(ctx, cap, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight); err != nil { return nil, sdkerrors.Wrap(err, "acknowledge packet verification failed") } diff --git a/x/ibc/core/keeper/msg_server_test.go b/x/ibc/core/keeper/msg_server_test.go index 0bed10ae7a..69a80fcb72 100644 --- a/x/ibc/core/keeper/msg_server_test.go +++ b/x/ibc/core/keeper/msg_server_test.go @@ -41,6 +41,9 @@ func (suite *KeeperTestSuite) SetupTest() { suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) + suite.coordinator.CommitNBlocks(suite.chainA, 2) + suite.coordinator.CommitNBlocks(suite.chainB, 2) } func TestIBCTestSuite(t *testing.T) { @@ -139,7 +142,7 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { tc.malleate() // get proof of packet commitment from chainA - packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := suite.chainA.QueryProof(packetKey) msg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, suite.chainB.SenderAccount.GetAddress()) @@ -278,7 +281,7 @@ func (suite *KeeperTestSuite) TestHandleAcknowledgePacket() { tc.malleate() - packetKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := suite.chainB.QueryProof(packetKey) msg := channeltypes.NewMsgAcknowledgement(packet, ibcmock.MockAcknowledgement, proof, proofHeight, suite.chainA.SenderAccount.GetAddress()) @@ -328,9 +331,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, true}, {"success: UNORDERED", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) @@ -341,9 +344,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) - packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, true}, {"success: UNORDERED timeout out of order packet", func() { // setup uses an UNORDERED channel @@ -359,8 +362,8 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) } - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, true}, {"success: ORDERED timeout out of order packet", func() { clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.ORDERED) @@ -375,20 +378,20 @@ func (suite *KeeperTestSuite) TestHandleTimeoutPacket() { suite.Require().NoError(err) } - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, true}, {"channel does not exist", func() { // any non-nil value of packet is valid suite.Require().NotNil(packet) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, false}, {"UNORDERED: packet not sent", func() { _, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) packet = channeltypes.NewPacket(ibctesting.MockCommitment, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) - packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) }, false}, } @@ -455,9 +458,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) @@ -476,9 +479,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) - packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) @@ -502,8 +505,8 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) } - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) + packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) @@ -526,8 +529,8 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) } - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) // close counterparty channel suite.coordinator.SetChannelClosed(suite.chainB, suite.chainA, counterpartyChannel) @@ -536,12 +539,12 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { // any non-nil value of packet is valid suite.Require().NotNil(packet) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, false}, {"UNORDERED: packet not sent", func() { clientA, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, channeltypes.UNORDERED) packet = channeltypes.NewPacket(ibctesting.MockCommitment, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, 0) - packetKey = host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey = host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) counterpartyChannel = ibctesting.TestChannel{ PortID: channelB.PortID, ID: channelB.ID, @@ -565,9 +568,9 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { suite.Require().NoError(err) // need to update chainA client to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) - packetKey = host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) }, false}, } @@ -581,7 +584,7 @@ func (suite *KeeperTestSuite) TestHandleTimeoutOnClosePacket() { proof, proofHeight := suite.chainB.QueryProof(packetKey) - channelKey := host.KeyChannel(counterpartyChannel.PortID, counterpartyChannel.ID) + channelKey := host.ChannelKey(counterpartyChannel.PortID, counterpartyChannel.ID) proofClosed, _ := suite.chainB.QueryProof(channelKey) msg := channeltypes.NewMsgTimeoutOnClose(packet, 1, proof, proofClosed, proofHeight, suite.chainA.SenderAccount.GetAddress()) @@ -625,7 +628,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { name: "successful upgrade", setup: func() { - upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -636,7 +639,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -675,7 +678,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { name: "VerifyUpgrade fails", setup: func() { - upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) + upgradedClient = ibctmtypes.NewClientState("newChainId", ibctmtypes.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod+ibctesting.TrustingPeriod, ibctesting.MaxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -686,7 +689,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) msg, err = clienttypes.NewMsgUpgradeClient(clientA, upgradedClient, upgradeHeight, nil, suite.chainA.SenderAccount.GetAddress()) @@ -698,7 +701,7 @@ func (suite *KeeperTestSuite) TestUpgradeClient() { for _, tc := range cases { tc := tc - clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) tc.setup() diff --git a/x/ibc/core/simulation/decoder_test.go b/x/ibc/core/simulation/decoder_test.go index d14a9f28cc..0951572743 100644 --- a/x/ibc/core/simulation/decoder_test.go +++ b/x/ibc/core/simulation/decoder_test.go @@ -40,15 +40,15 @@ func TestDecodeStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ { - Key: host.FullKeyClientPath(clientID, host.KeyClientState()), + Key: host.FullClientStateKey(clientID), Value: app.IBCKeeper.ClientKeeper.MustMarshalClientState(clientState), }, { - Key: host.KeyConnection(connectionID), + Key: host.ConnectionKey(connectionID), Value: app.IBCKeeper.Codec().MustMarshalBinaryBare(&connection), }, { - Key: host.KeyChannel(portID, channelID), + Key: host.ChannelKey(portID, channelID), Value: app.IBCKeeper.Codec().MustMarshalBinaryBare(&channel), }, { diff --git a/x/ibc/core/spec/02_state.md b/x/ibc/core/spec/02_state.md index 5df09a097b..54eb41bc4b 100644 --- a/x/ibc/core/spec/02_state.md +++ b/x/ibc/core/spec/02_state.md @@ -16,10 +16,10 @@ The client type is not stored since it can be obtained through the client state. | "0/" | "connections/{identifier}" | ConnectionEnd | | "0/" | "ports/{identifier}" | CapabilityKey | | "0/" | "channelEnds/ports/{identifier}/channels/{identifier}" | ChannelEnd | -| "0/" | "capabilities/ports/{identifier}/channels/{identifier}/key" | CapabilityKey | -| "0/" | "seqSends/ports/{identifier}/channels/{identifier}/nextSequenceSend" | uint64 | -| "0/" | "seqRecvs/ports/{identifier}/channels/{identifier}/nextSequenceRecv" | uint64 | -| "0/" | "seqAcks/ports/{identifier}/channels/{identifier}/nextSequenceAck" | uint64 | -| "0/" | "commitments/ports/{identifier}/channels/{identifier}/packets/{sequence}" | bytes | -| "0/" | "receipts/ports/{identifier}/channels/{identifier}/receipts/{sequence}" | bytes | -| "0/" | "acks/ports/{identifier}/channels/{identifier}/acknowledgements/{sequence}" | bytes | +| "0/" | "capabilities/ports/{identifier}/channels/{identifier}" | CapabilityKey | +| "0/" | "nextSequenceSend/ports/{identifier}/channels/{identifier}" | uint64 | +| "0/" | "nextSequenceRecv/ports/{identifier}/channels/{identifier}" | uint64 | +| "0/" | "nextSequenceAck/ports/{identifier}/channels/{identifier}" | uint64 | +| "0/" | "commitments/ports/{identifier}/channels/{identifier}/sequences/{sequence}" | bytes | +| "0/" | "receipts/ports/{identifier}/channels/{identifier}/sequences/{sequence}" | bytes | +| "0/" | "acks/ports/{identifier}/channels/{identifier}/sequences/{sequence}" | bytes | diff --git a/x/ibc/core/spec/07_params.md b/x/ibc/core/spec/07_params.md new file mode 100644 index 0000000000..67e79ef81d --- /dev/null +++ b/x/ibc/core/spec/07_params.md @@ -0,0 +1,21 @@ + + +# Parameters + +## Clients + +The ibc clients contain the following parameters: + +| Key | Type | Default Value | +|------------------|------|---------------| +| `AllowedClients` | []string | `"06-solomachine","07-tendermint"` | + +### AllowedClients + +The allowed clients parameter defines an allowlist of client types supported by the chain. A client +that is not registered on this list will fail upon creation or on genesis validation. Note that, +since the client type is an arbitrary string, chains they must not register two light clients which +return the same value for the `ClientType()` function, otherwise the allowlist check can be +bypassed. diff --git a/x/ibc/core/spec/README.md b/x/ibc/core/spec/README.md index 432aca93e1..f6de9749b5 100644 --- a/x/ibc/core/spec/README.md +++ b/x/ibc/core/spec/README.md @@ -1,11 +1,11 @@ -# `ibc` +# `ibc core` ## Abstract @@ -23,89 +23,4 @@ For the general specification please refer to the [Interchain Standards](https:/ 4. **[Messages](04_messages.md)** 5. **[Callbacks](05_callbacks.md)** 6. **[Events](06_events.md)** - -## Implementation Details - -As stated above, the IBC implementation on the Cosmos SDK introduces some changes -to the general specification, in order to avoid code duplication and to take -advantage of the SDK architectural components such as the transaction routing -through `Handlers`. - -### Interchain Standards reference - -The following list is a mapping from each Interchain Standard to their implementation -in the SDK's `x/ibc` module: - -* [ICS 002 - Client Semantics](https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics): Implemented in [`x/ibc/core/02-client`](https://github.com/cosmos/tree/master/ibc/core/02-client) -* [ICS 003 - Connection Semantics](https://github.com/cosmos/ics/blob/master/spec/ics-003-connection-semantics): Implemented in [`x/ibc/core/03-connection`](https://github.com/cosmos/tree/master/ibc/core/03-connection) -* [ICS 004 - Channel and Packet Semantics](https://github.com/cosmos/ics/blob/master/spec/ics-004-channel-and-packet-semantics): Implemented in [`x/ibc/core/04-channel`](https://github.com/cosmos/tree/master/ibc/core/04-channel) -* [ICS 005 - Port Allocation](https://github.com/cosmos/ics/blob/master/spec/ics-005-port-allocation): Implemented in [`x/ibc/core/05-port`](https://github.com/cosmos/tree/master/ibc/core/05-port) -* [ICS 006 - Solo Machine Client](https://github.com/cosmos/ics/blob/master/spec/ics-006-solo-machine-client): Implemented in [`x/ibc/light-clients/06-solomachine`](https://github.com/cosmos/tree/master/ibc/solomachine) -* [ICS 007 - Tendermint Client](https://github.com/cosmos/ics/blob/master/spec/ics-007-tendermint-client): Implemented in [`x/ibc/light-clients/07-tendermint`](https://github.com/cosmos/tree/master/ibc/light-clients/07-tendermint) -* [ICS 009 - Loopback Client](https://github.com/cosmos/ics/blob/master/spec/ics-009-loopback-client): Implemented in [`x/ibc/light-clients/09-localhost`](https://github.com/cosmos/tree/master/ibc/light-clients/09-localhost) -* [ICS 018- Relayer Algorithms](https://github.com/cosmos/ics/tree/master/spec/ics-018-relayer-algorithms): Implemented in it's own [relayer repository](https://github.com/cosmos/relayer) -* [ICS 020 - Fungible Token Transfer](https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer): Implemented in [`x/ibc/applications/transfer`](https://github.com/cosmos/tree/master/ibc/applications/transfer) -* [ICS 023 - Vector Commitments](https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments): Implemented in [`x/ibc/core/23-commitment`](https://github.com/cosmos/tree/master/ibc/core/23-commitment) -* [ICS 024 - Host Requirements](https://github.com/cosmos/ics/tree/master/spec/ics-024-host-requirements): Implemented in [`x/ibc/core/24-host`](https://github.com/cosmos/tree/master/ibc/core/24-host) -* [ICS 025 - Handler Interface](https://github.com/cosmos/ics/tree/master/spec/ics-025-handler-interface): Handler interfaces are implemented at the top level in `x/ibc/handler.go`, -which call each ICS submodule's handlers (i.e `x/ibc/{XX-ICS}/handler.go`). -* [ICS 026 - Routing Module](https://github.com/cosmos/ics/blob/master/spec/ics-026-routing-module): Replaced by [ADR 15 - IBC Packet Receiver](../../../docs/architecture/adr-015-ibc-packet-receiver.md). - -### Architecture Decision Records (ADR) - -The following ADR provide the design and architecture decision of IBC-related components. - -* [ADR 001 - Coin Source Tracing](../../../docs/architecture/adr-001-coin-source-tracing.md): standard to hash the ICS20's fungible token -denomination trace path in order to support special characters and limit the maximum denomination length. -* [ADR 17 - Historical Header Module](../../../docs/architecture/adr-017-historical-header-module.md): Introduces the ability to introspect past -consensus states in order to verify their membership in the counterparty clients. -* [ADR 19 - Protobuf State Encoding](../../../docs/architecture/adr-019-protobuf-state-encoding.md): Migration from Amino to Protobuf for state encoding. -* [ADR 020 - Protocol Buffer Transaction Encoding](./../../docs/architecture/adr-020-protobuf-transaction-encoding.md): Client side migration to Protobuf. -* [ADR 021 - Protocol Buffer Query Encoding](../../../docs/architecture/adr-020-protobuf-query-encoding.md): Queries migration to Protobuf. -* [ADR 026 - IBC Client Recovery Mechanisms](../../../docs/architecture/adr-026-ibc-client-recovery-mechanisms.md): Allows IBC Clients to be recovered after freezing or expiry. - -### SDK Modules - -* [`x/capability`](https://github.com/cosmos/tree/master/x/capability): The capability module provides object-capability keys support through scoped keepers in order to authenticate usage of ports or channels. Check [ADR 3 - Dynamic Capability Store](../../../docs/architecture/adr-003-dynamic-capability-store.md) for more details. -* [`x/evidence`](https://github.com/cosmos/tree/master/x/evidence): The evidence module provides the interfaces and client logic to handle light client misbehaviour. Check [ADR 09 - Evidence Module](../../../docs/architecture/adr-009-evidence-module.md) for more details. - -## IBC module architecture - -> **NOTE for auditors**: If you're not familiar with the overall module structure from -the SDK modules, please check this [document](../../../docs/building-modules/structure.md) as -prerequisite reading. - -For ease of auditing, every Interchain Standard has been developed in its own -package. The development team separated the IBC TAO (Transport, Authentication, Ordering) ICS specifications from the IBC application level -specification. The following tree describes the architecture of the directories that -the `ibc` (TAO) and `ibc-transfer` ([ICS20](https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer)) modules: - -```shell -x/ibc -├── applications/ -│ └──ibc-transfer/ -├── 02-client/ -├── 02-client/ -├── 03-connection/ -├── 04-channel/ -├── 05-port/ -├── light-clients/ -│   ├── 06-solomachine/ -│   ├── 07-tendermint/ -│   └── 09-localhost/ -├── 23-commitment/ -├── 24-host/ -├── client -│   ├── cli -│   │   └── cli.go -│   └── rest -│  └── rest.go -├── keeper -│  ├── keeper.go -│   └── querier.go -├── types -│ ├── errors.go -│ └── keys.go -├── handler.go -└── module.go -``` +7. **[Params](07_params.md)** diff --git a/x/ibc/light-clients/06-solomachine/spec/01_concepts.md b/x/ibc/light-clients/06-solomachine/spec/01_concepts.md index 1723c8740e..fd8a4f71b2 100644 --- a/x/ibc/light-clients/06-solomachine/spec/01_concepts.md +++ b/x/ibc/light-clients/06-solomachine/spec/01_concepts.md @@ -154,6 +154,9 @@ If the misbehaviour is successfully processed: - the client is frozen by setting the frozen sequence to the misbehaviour sequence +NOTE: Misbehaviour processing is data processing order dependent. A misbehaving solo machine +could update to a new public key to prevent being frozen before misbehaviour is submitted. + ## Upgrades Upgrades to solo machine light clients are not supported since an entirely different type of diff --git a/x/ibc/light-clients/06-solomachine/types/client_state.go b/x/ibc/light-clients/06-solomachine/types/client_state.go index f23b6824bf..4a6fb86962 100644 --- a/x/ibc/light-clients/06-solomachine/types/client_state.go +++ b/x/ibc/light-clients/06-solomachine/types/client_state.go @@ -4,6 +4,7 @@ import ( ics23 "github.com/confio/ics23/go" "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -15,9 +16,6 @@ import ( var _ exported.ClientState = (*ClientState)(nil) -// SoloMachine is used to indicate that the light client is a solo machine. -const SoloMachine string = "Solo Machine" - // NewClientState creates a new ClientState instance. func NewClientState(latestSequence uint64, consensusState *ConsensusState, allowUpdateAfterProposal bool) *ClientState { return &ClientState{ @@ -30,7 +28,7 @@ func NewClientState(latestSequence uint64, consensusState *ConsensusState, allow // ClientType is Solo Machine. func (cs ClientState) ClientType() string { - return SoloMachine + return exported.Solomachine } // GetLatestHeight returns the latest sequence number. @@ -76,12 +74,12 @@ func (cs ClientState) ZeroCustomFields() exported.ClientState { ) } -// VerifyUpgrade returns an error since solomachine client does not support upgrades -func (cs ClientState) VerifyUpgrade( +// VerifyUpgradeAndUpdateState returns an error since solomachine client does not support upgrades +func (cs ClientState) VerifyUpgradeAndUpdateState( _ sdk.Context, _ codec.BinaryMarshaler, _ sdk.KVStore, _ exported.ClientState, _ exported.Height, _ []byte, -) error { - return sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade solomachine client") +) (exported.ClientState, exported.ConsensusState, error) { + return nil, nil, sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade solomachine client") } // VerifyClientState verifies a proof of the client state of the running chain @@ -95,12 +93,12 @@ func (cs ClientState) VerifyClientState( proof []byte, clientState exported.ClientState, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath() + clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier)) path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath) if err != nil { return err @@ -111,7 +109,7 @@ func (cs ClientState) VerifyClientState( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -133,12 +131,12 @@ func (cs ClientState) VerifyClientConsensusState( proof []byte, consensusState exported.ConsensusState, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight) + clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullConsensusStatePath(counterpartyClientIdentifier, consensusHeight)) path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath) if err != nil { return err @@ -149,7 +147,7 @@ func (cs ClientState) VerifyClientConsensusState( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -170,12 +168,13 @@ func (cs ClientState) VerifyConnectionState( connectionID string, connectionEnd exported.ConnectionI, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.ConnectionPath(connectionID)) + connectionPath := commitmenttypes.NewMerklePath(host.ConnectionPath(connectionID)) + path, err := commitmenttypes.ApplyPrefix(prefix, connectionPath) if err != nil { return err } @@ -185,7 +184,7 @@ func (cs ClientState) VerifyConnectionState( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -207,12 +206,13 @@ func (cs ClientState) VerifyChannelState( channelID string, channel exported.ChannelI, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.ChannelPath(portID, channelID)) + channelPath := commitmenttypes.NewMerklePath(host.ChannelPath(portID, channelID)) + path, err := commitmenttypes.ApplyPrefix(prefix, channelPath) if err != nil { return err } @@ -222,7 +222,7 @@ func (cs ClientState) VerifyChannelState( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -245,12 +245,13 @@ func (cs ClientState) VerifyPacketCommitment( packetSequence uint64, commitmentBytes []byte, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketCommitmentPath(portID, channelID, packetSequence)) + commitmentPath := commitmenttypes.NewMerklePath(host.PacketCommitmentPath(portID, channelID, packetSequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, commitmentPath) if err != nil { return err } @@ -260,7 +261,7 @@ func (cs ClientState) VerifyPacketCommitment( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -283,12 +284,13 @@ func (cs ClientState) VerifyPacketAcknowledgement( packetSequence uint64, acknowledgement []byte, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, packetSequence)) + ackPath := commitmenttypes.NewMerklePath(host.PacketAcknowledgementPath(portID, channelID, packetSequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, ackPath) if err != nil { return err } @@ -298,7 +300,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -321,12 +323,13 @@ func (cs ClientState) VerifyPacketReceiptAbsence( channelID string, packetSequence uint64, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketReceiptPath(portID, channelID, packetSequence)) + receiptPath := commitmenttypes.NewMerklePath(host.PacketReceiptPath(portID, channelID, packetSequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, receiptPath) if err != nil { return err } @@ -336,7 +339,7 @@ func (cs ClientState) VerifyPacketReceiptAbsence( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -358,12 +361,13 @@ func (cs ClientState) VerifyNextSequenceRecv( channelID string, nextSequenceRecv uint64, ) error { - sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) + publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof) if err != nil { return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.NextSequenceRecvPath(portID, channelID)) + nextSequenceRecvPath := commitmenttypes.NewMerklePath(host.NextSequenceRecvPath(portID, channelID)) + path, err := commitmenttypes.ApplyPrefix(prefix, nextSequenceRecvPath) if err != nil { return err } @@ -373,7 +377,7 @@ func (cs ClientState) VerifyNextSequenceRecv( return err } - if err := VerifySignature(cs.ConsensusState.GetPubKey(), signBz, sigData); err != nil { + if err := VerifySignature(publicKey, signBz, sigData); err != nil { return err } @@ -384,75 +388,80 @@ func (cs ClientState) VerifyNextSequenceRecv( } // produceVerificationArgs perfoms the basic checks on the arguments that are -// shared between the verification functions and returns the unmarshalled -// proof representing the signature and timestamp along with the solo-machine sequence -// encoded in the proofHeight. +// shared between the verification functions and returns the public key of the +// consensus state, the unmarshalled proof representing the signature and timestamp +// along with the solo-machine sequence encoded in the proofHeight. func produceVerificationArgs( cdc codec.BinaryMarshaler, cs ClientState, height exported.Height, prefix exported.Prefix, proof []byte, -) (signing.SignatureData, uint64, uint64, error) { +) (cryptotypes.PubKey, signing.SignatureData, uint64, uint64, error) { if version := height.GetVersionNumber(); version != 0 { - return nil, 0, 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version must be 0 for solomachine, got version-number: %d", version) + return nil, nil, 0, 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version must be 0 for solomachine, got version-number: %d", version) } // sequence is encoded in the version height of height struct sequence := height.GetVersionHeight() if cs.IsFrozen() { - return nil, 0, 0, clienttypes.ErrClientFrozen + return nil, nil, 0, 0, clienttypes.ErrClientFrozen } if prefix == nil { - return nil, 0, 0, sdkerrors.Wrap(commitmenttypes.ErrInvalidPrefix, "prefix cannot be empty") + return nil, nil, 0, 0, sdkerrors.Wrap(commitmenttypes.ErrInvalidPrefix, "prefix cannot be empty") } _, ok := prefix.(commitmenttypes.MerklePrefix) if !ok { - return nil, 0, 0, sdkerrors.Wrapf(commitmenttypes.ErrInvalidPrefix, "invalid prefix type %T, expected MerklePrefix", prefix) + return nil, nil, 0, 0, sdkerrors.Wrapf(commitmenttypes.ErrInvalidPrefix, "invalid prefix type %T, expected MerklePrefix", prefix) } if proof == nil { - return nil, 0, 0, sdkerrors.Wrap(ErrInvalidProof, "proof cannot be empty") + return nil, nil, 0, 0, sdkerrors.Wrap(ErrInvalidProof, "proof cannot be empty") } timestampedSigData := &TimestampedSignatureData{} if err := cdc.UnmarshalBinaryBare(proof, timestampedSigData); err != nil { - return nil, 0, 0, sdkerrors.Wrapf(err, "failed to unmarshal proof into type %T", timestampedSigData) + return nil, nil, 0, 0, sdkerrors.Wrapf(err, "failed to unmarshal proof into type %T", timestampedSigData) } timestamp := timestampedSigData.Timestamp if len(timestampedSigData.SignatureData) == 0 { - return nil, 0, 0, sdkerrors.Wrap(ErrInvalidProof, "signature data cannot be empty") + return nil, nil, 0, 0, sdkerrors.Wrap(ErrInvalidProof, "signature data cannot be empty") } sigData, err := UnmarshalSignatureData(cdc, timestampedSigData.SignatureData) if err != nil { - return nil, 0, 0, err + return nil, nil, 0, 0, err } if cs.ConsensusState == nil { - return nil, 0, 0, sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty") + return nil, nil, 0, 0, sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state cannot be empty") } latestSequence := cs.GetLatestHeight().GetVersionHeight() if latestSequence != sequence { - return nil, 0, 0, sdkerrors.Wrapf( + return nil, nil, 0, 0, sdkerrors.Wrapf( sdkerrors.ErrInvalidHeight, "client state sequence != proof sequence (%d != %d)", latestSequence, sequence, ) } if cs.ConsensusState.GetTimestamp() > timestamp { - return nil, 0, 0, sdkerrors.Wrapf(ErrInvalidProof, "the consensus state timestamp is greater than the signature timestamp (%d >= %d)", cs.ConsensusState.GetTimestamp(), timestamp) + return nil, nil, 0, 0, sdkerrors.Wrapf(ErrInvalidProof, "the consensus state timestamp is greater than the signature timestamp (%d >= %d)", cs.ConsensusState.GetTimestamp(), timestamp) } - return sigData, timestamp, sequence, nil + publicKey, err := cs.ConsensusState.GetPubKey() + if err != nil { + return nil, nil, 0, 0, err + } + + return publicKey, sigData, timestamp, sequence, nil } // sets the client state to the store func setClientState(store sdk.KVStore, cdc codec.BinaryMarshaler, clientState exported.ClientState) { bz := clienttypes.MustMarshalClientState(cdc, clientState) - store.Set(host.KeyClientState(), bz) + store.Set([]byte(host.KeyClientState), bz) } diff --git a/x/ibc/light-clients/06-solomachine/types/client_state_test.go b/x/ibc/light-clients/06-solomachine/types/client_state_test.go index f2daca5ae3..597adff345 100644 --- a/x/ibc/light-clients/06-solomachine/types/client_state_test.go +++ b/x/ibc/light-clients/06-solomachine/types/client_state_test.go @@ -82,7 +82,7 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() { func (suite *SoloMachineTestSuite) TestVerifyClientState() { // create client for tendermint so we can use client state for verification - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) path := suite.solomachine.GetClientStatePath(counterpartyClientIdentifier) @@ -208,7 +208,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { // create client for tendermint so we can use consensus state for verification - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA) consensusState, found := suite.chainA.GetConsensusState(clientA, clientState.GetLatestHeight()) suite.Require().True(found) diff --git a/x/ibc/light-clients/06-solomachine/types/consensus_state.go b/x/ibc/light-clients/06-solomachine/types/consensus_state.go index f912aa3501..1cc95caf08 100644 --- a/x/ibc/light-clients/06-solomachine/types/consensus_state.go +++ b/x/ibc/light-clients/06-solomachine/types/consensus_state.go @@ -3,8 +3,7 @@ package types import ( "strings" - tmcrypto "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" @@ -14,7 +13,7 @@ var _ exported.ConsensusState = ConsensusState{} // ClientType returns Solo Machine type. func (ConsensusState) ClientType() string { - return SoloMachine + return exported.Solomachine } // GetTimestamp returns zero. @@ -27,14 +26,20 @@ func (cs ConsensusState) GetRoot() exported.Root { return nil } -// GetPubKey unmarshals the public key into a tmcrypto.PubKey type. -func (cs ConsensusState) GetPubKey() tmcrypto.PubKey { - publicKey, ok := cs.PublicKey.GetCachedValue().(tmcrypto.PubKey) - if !ok { - panic("ConsensusState PublicKey is not crypto.PubKey") +// GetPubKey unmarshals the public key into a cryptotypes.PubKey type. +// An error is returned if the public key is nil or the cached value +// is not a PubKey. +func (cs ConsensusState) GetPubKey() (cryptotypes.PubKey, error) { + if cs.PublicKey == nil { + return nil, sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state PublicKey cannot be nil") } - return publicKey + publicKey, ok := cs.PublicKey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return nil, sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "consensus state PublicKey is not cryptotypes.PubKey") + } + + return publicKey, nil } // ValidateBasic defines basic validation for the solo machine consensus state. @@ -45,7 +50,9 @@ func (cs ConsensusState) ValidateBasic() error { if cs.Diversifier != "" && strings.TrimSpace(cs.Diversifier) == "" { return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "diversifier cannot contain only spaces") } - if cs.PublicKey == nil || cs.GetPubKey() == nil || len(cs.GetPubKey().Bytes()) == 0 { + + publicKey, err := cs.GetPubKey() + if err != nil || publicKey == nil || len(publicKey.Bytes()) == 0 { return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "public key cannot be empty") } diff --git a/x/ibc/light-clients/06-solomachine/types/consensus_state_test.go b/x/ibc/light-clients/06-solomachine/types/consensus_state_test.go index 820e812462..e0c22f9595 100644 --- a/x/ibc/light-clients/06-solomachine/types/consensus_state_test.go +++ b/x/ibc/light-clients/06-solomachine/types/consensus_state_test.go @@ -1,6 +1,7 @@ package types_test import ( + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -8,7 +9,7 @@ import ( func (suite *SoloMachineTestSuite) TestConsensusState() { consensusState := suite.solomachine.ConsensusState() - suite.Require().Equal(types.SoloMachine, consensusState.ClientType()) + suite.Require().Equal(exported.Solomachine, consensusState.ClientType()) suite.Require().Equal(suite.solomachine.Time, consensusState.GetTimestamp()) suite.Require().Nil(consensusState.GetRoot()) } diff --git a/x/ibc/light-clients/06-solomachine/types/header.go b/x/ibc/light-clients/06-solomachine/types/header.go index a4f757a373..dc43cee4f7 100644 --- a/x/ibc/light-clients/06-solomachine/types/header.go +++ b/x/ibc/light-clients/06-solomachine/types/header.go @@ -3,8 +3,7 @@ package types import ( "strings" - tmcrypto "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" @@ -14,7 +13,7 @@ var _ exported.Header = Header{} // ClientType defines that the Header is a Solo Machine. func (Header) ClientType() string { - return SoloMachine + return exported.Solomachine } // GetHeight returns the current sequence number as the height. @@ -24,14 +23,20 @@ func (h Header) GetHeight() exported.Height { return clienttypes.NewHeight(0, h.Sequence) } -// GetPubKey unmarshals the new public key into a tmcrypto.PubKey type. -func (h Header) GetPubKey() tmcrypto.PubKey { - publicKey, ok := h.NewPublicKey.GetCachedValue().(tmcrypto.PubKey) - if !ok { - panic("Header NewPublicKey is not crypto.PubKey") +// GetPubKey unmarshals the new public key into a cryptotypes.PubKey type. +// An error is returned if the new public key is nil or the cached value +// is not a PubKey. +func (h Header) GetPubKey() (cryptotypes.PubKey, error) { + if h.NewPublicKey == nil { + return nil, sdkerrors.Wrap(ErrInvalidHeader, "header NewPublicKey cannot be nil") } - return publicKey + publicKey, ok := h.NewPublicKey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return nil, sdkerrors.Wrap(ErrInvalidHeader, "header NewPublicKey is not cryptotypes.PubKey") + } + + return publicKey, nil } // ValidateBasic ensures that the sequence, signature and public key have all @@ -53,7 +58,8 @@ func (h Header) ValidateBasic() error { return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "signature cannot be empty") } - if h.NewPublicKey == nil || h.GetPubKey() == nil || len(h.GetPubKey().Bytes()) == 0 { + newPublicKey, err := h.GetPubKey() + if err != nil || newPublicKey == nil || len(newPublicKey.Bytes()) == 0 { return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "new public key cannot be empty") } diff --git a/x/ibc/light-clients/06-solomachine/types/header_test.go b/x/ibc/light-clients/06-solomachine/types/header_test.go index e456f9e966..a5ca45e8aa 100644 --- a/x/ibc/light-clients/06-solomachine/types/header_test.go +++ b/x/ibc/light-clients/06-solomachine/types/header_test.go @@ -1,6 +1,7 @@ package types_test import ( + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -78,7 +79,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, } - suite.Require().Equal(types.SoloMachine, header.ClientType()) + suite.Require().Equal(exported.Solomachine, header.ClientType()) for _, tc := range cases { tc := tc diff --git a/x/ibc/light-clients/06-solomachine/types/misbehaviour.go b/x/ibc/light-clients/06-solomachine/types/misbehaviour.go index 1f97f323ce..8a59eb2d9a 100644 --- a/x/ibc/light-clients/06-solomachine/types/misbehaviour.go +++ b/x/ibc/light-clients/06-solomachine/types/misbehaviour.go @@ -3,8 +3,6 @@ package types import ( "bytes" - yaml "gopkg.in/yaml.v2" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" @@ -17,7 +15,7 @@ var ( // ClientType is a Solo Machine light client. func (misbehaviour Misbehaviour) ClientType() string { - return SoloMachine + return exported.Solomachine } // GetClientID returns the ID of the client that committed a misbehaviour. @@ -30,12 +28,6 @@ func (misbehaviour Misbehaviour) Type() string { return exported.TypeClientMisbehaviour } -// String implements Evidence interface. -func (misbehaviour Misbehaviour) String() string { - out, _ := yaml.Marshal(misbehaviour) - return string(out) -} - // GetHeight returns the sequence at which misbehaviour occurred. // Return exported.Height to satisfy interface // Version number is always 0 for a solo-machine diff --git a/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle.go b/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle.go index 2fcbe75c7a..83335ec59f 100644 --- a/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle.go +++ b/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle.go @@ -11,6 +11,9 @@ import ( // CheckMisbehaviourAndUpdateState determines whether or not the currently registered // public key signed over two different messages with the same sequence. If this is true // the client state is updated to a frozen status. +// NOTE: Misbehaviour is not tracked for previous public keys, a solo machine may update to +// a new public key before the misbehaviour is processed. Therefore, misbehaviour is data +// order processing dependent. func (cs ClientState) CheckMisbehaviourAndUpdateState( ctx sdk.Context, cdc codec.BinaryMarshaler, @@ -49,14 +52,10 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( // verifySignatureAndData verifies that the currently registered public key has signed // over the provided data and that the data is valid. The data is valid if it can be -// unmarshaled into the specified data type or the timestamp of the signature is less -// than the consensus state timestamp. +// unmarshaled into the specified data type. func verifySignatureAndData(cdc codec.BinaryMarshaler, clientState ClientState, misbehaviour *Misbehaviour, sigAndData *SignatureAndData) error { - // timestamp less than consensus state would always fail and not succeed in fooling the - // light client - if sigAndData.Timestamp < clientState.ConsensusState.Timestamp { - return sdkerrors.Wrapf(clienttypes.ErrInvalidMisbehaviour, "timestamp is less than consensus state timestamp (%d < %d)", sigAndData.Timestamp, clientState.ConsensusState.Timestamp) - } + + // do not check misbehaviour timestamp since we want to allow processing of past misbehaviour // ensure data can be unmarshaled to the specified data type if _, err := UnmarshalDataByType(cdc, sigAndData.DataType, sigAndData.Data); err != nil { @@ -79,7 +78,12 @@ func verifySignatureAndData(cdc codec.BinaryMarshaler, clientState ClientState, return err } - if err := VerifySignature(clientState.ConsensusState.GetPubKey(), data, sigData); err != nil { + publicKey, err := clientState.ConsensusState.GetPubKey() + if err != nil { + return err + } + + if err := VerifySignature(publicKey, data, sigData); err != nil { return err } diff --git a/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle_test.go b/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle_test.go index fd5871adc6..89692c5c4d 100644 --- a/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle_test.go +++ b/x/ibc/light-clients/06-solomachine/types/misbehaviour_handle_test.go @@ -29,6 +29,14 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() { }, true, }, + { + "old misbehaviour is successful (timestamp is less than current consensus state)", + func() { + clientState = solomachine.ClientState() + solomachine.Time = solomachine.Time - 5 + misbehaviour = solomachine.CreateMisbehaviour() + }, true, + }, { "client is frozen", func() { @@ -95,14 +103,6 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() { misbehaviour = m }, false, }, - { - "timestamp is less than consensus state timestamp", - func() { - clientState = solomachine.ClientState() - solomachine.Time = solomachine.Time - 5 - misbehaviour = solomachine.CreateMisbehaviour() - }, false, - }, { "invalid first signature data", func() { @@ -241,6 +241,16 @@ func (suite *SoloMachineTestSuite) TestCheckMisbehaviourAndUpdateState() { }, false, }, + { + "consensus state pubkey is nil", + func() { + cs := solomachine.ClientState() + cs.ConsensusState.PublicKey = nil + clientState = cs + misbehaviour = solomachine.CreateMisbehaviour() + }, + false, + }, } for _, tc := range testCases { diff --git a/x/ibc/light-clients/06-solomachine/types/misbehaviour_test.go b/x/ibc/light-clients/06-solomachine/types/misbehaviour_test.go index 311dc8d8c8..a976186eab 100644 --- a/x/ibc/light-clients/06-solomachine/types/misbehaviour_test.go +++ b/x/ibc/light-clients/06-solomachine/types/misbehaviour_test.go @@ -1,6 +1,7 @@ package types_test import ( + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -8,7 +9,7 @@ import ( func (suite *SoloMachineTestSuite) TestMisbehaviour() { misbehaviour := suite.solomachine.CreateMisbehaviour() - suite.Require().Equal(types.SoloMachine, misbehaviour.ClientType()) + suite.Require().Equal(exported.Solomachine, misbehaviour.ClientType()) suite.Require().Equal(suite.solomachine.ClientID, misbehaviour.GetClientID()) suite.Require().Equal(uint64(0), misbehaviour.GetHeight().GetVersionNumber()) suite.Require().Equal(suite.solomachine.Sequence, misbehaviour.GetHeight().GetVersionHeight()) diff --git a/x/ibc/light-clients/06-solomachine/types/proof.go b/x/ibc/light-clients/06-solomachine/types/proof.go index 7a5204e7f7..6c2e0b8428 100644 --- a/x/ibc/light-clients/06-solomachine/types/proof.go +++ b/x/ibc/light-clients/06-solomachine/types/proof.go @@ -1,9 +1,8 @@ package types import ( - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -16,32 +15,34 @@ import ( // VerifySignature verifies if the the provided public key generated the signature // over the given data. Single and Multi signature public keys are supported. -// The type of the signature data determines how the public key is used to -// verify the signature. An error is returned if signature verification fails -// or an invalid SignatureData type is provided. -func VerifySignature(pubKey crypto.PubKey, signBytes []byte, sigData signing.SignatureData) error { - switch data := sigData.(type) { - case *signing.SingleSignatureData: - if !pubKey.VerifySignature(signBytes, data.Signature) { - return ErrSignatureVerificationFailed - } - - case *signing.MultiSignatureData: - multiPK, ok := pubKey.(multisig.PubKey) +// The signature data type must correspond to the public key type. An error is +// returned if signature verification fails or an invalid SignatureData type is +// provided. +func VerifySignature(pubKey cryptotypes.PubKey, signBytes []byte, sigData signing.SignatureData) error { + switch pubKey := pubKey.(type) { + case multisig.PubKey: + data, ok := sigData.(*signing.MultiSignatureData) if !ok { - return sdkerrors.Wrapf(ErrSignatureVerificationFailed, "invalid pubkey type: expected %T, got %T", (multisig.PubKey)(nil), pubKey) + return sdkerrors.Wrapf(ErrSignatureVerificationFailed, "invalid signature data type, expected %T, got %T", (*signing.MultiSignatureData)(nil), data) } // The function supplied fulfills the VerifyMultisignature interface. No special // adjustments need to be made to the sign bytes based on the sign mode. - if err := multiPK.VerifyMultisignature(func(signing.SignMode) ([]byte, error) { + if err := pubKey.VerifyMultisignature(func(signing.SignMode) ([]byte, error) { return signBytes, nil }, data); err != nil { return err } default: - return sdkerrors.Wrapf(ErrSignatureVerificationFailed, "unsupported signature data type %T", data) + data, ok := sigData.(*signing.SingleSignatureData) + if !ok { + return sdkerrors.Wrapf(ErrSignatureVerificationFailed, "invalid signature data type, expected %T, got %T", (*signing.SingleSignatureData)(nil), data) + } + + if !pubKey.VerifySignature(signBytes, data.Signature) { + return ErrSignatureVerificationFailed + } } return nil diff --git a/x/ibc/light-clients/06-solomachine/types/proof_test.go b/x/ibc/light-clients/06-solomachine/types/proof_test.go index 5ecd9c4c5d..e2ba679a5b 100644 --- a/x/ibc/light-clients/06-solomachine/types/proof_test.go +++ b/x/ibc/light-clients/06-solomachine/types/proof_test.go @@ -1,10 +1,72 @@ package types_test import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types" + solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) +func (suite *SoloMachineTestSuite) TestVerifySignature() { + cdc := suite.chainA.App.AppCodec() + signBytes := []byte("sign bytes") + + singleSignature := suite.solomachine.GenerateSignature(signBytes) + singleSigData, err := solomachinetypes.UnmarshalSignatureData(cdc, singleSignature) + suite.Require().NoError(err) + + multiSignature := suite.solomachineMulti.GenerateSignature(signBytes) + multiSigData, err := solomachinetypes.UnmarshalSignatureData(cdc, multiSignature) + suite.Require().NoError(err) + + testCases := []struct { + name string + publicKey cryptotypes.PubKey + sigData signing.SignatureData + expPass bool + }{ + { + "single signature with regular public key", + suite.solomachine.PublicKey, + singleSigData, + true, + }, + { + "multi signature with multisig public key", + suite.solomachineMulti.PublicKey, + multiSigData, + true, + }, + { + "single signature with multisig public key", + suite.solomachineMulti.PublicKey, + singleSigData, + false, + }, + { + "multi signature with regular public key", + suite.solomachine.PublicKey, + multiSigData, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + err := solomachinetypes.VerifySignature(tc.publicKey, signBytes, tc.sigData) + + if tc.expPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + func (suite *SoloMachineTestSuite) TestClientStateSignBytes() { cdc := suite.chainA.App.AppCodec() diff --git a/x/ibc/light-clients/06-solomachine/types/proposal_handle.go b/x/ibc/light-clients/06-solomachine/types/proposal_handle.go index f715ebb4c5..b55e612b3c 100644 --- a/x/ibc/light-clients/06-solomachine/types/proposal_handle.go +++ b/x/ibc/light-clients/06-solomachine/types/proposal_handle.go @@ -33,7 +33,17 @@ func (cs ClientState) CheckProposedHeaderAndUpdateState( ) } - if reflect.DeepEqual(cs.ConsensusState.GetPubKey(), smHeader.GetPubKey()) { + consensusPublicKey, err := cs.ConsensusState.GetPubKey() + if err != nil { + return nil, nil, sdkerrors.Wrap(err, "failed to get consensus public key") + } + + headerPublicKey, err := smHeader.GetPubKey() + if err != nil { + return nil, nil, sdkerrors.Wrap(err, "failed to get header public key") + } + + if reflect.DeepEqual(consensusPublicKey, headerPublicKey) { return nil, nil, sdkerrors.Wrapf( clienttypes.ErrInvalidHeader, "new public key in header equals current public key", ) diff --git a/x/ibc/light-clients/06-solomachine/types/proposal_handle_test.go b/x/ibc/light-clients/06-solomachine/types/proposal_handle_test.go index c36e252d41..86d5c78dcc 100644 --- a/x/ibc/light-clients/06-solomachine/types/proposal_handle_test.go +++ b/x/ibc/light-clients/06-solomachine/types/proposal_handle_test.go @@ -69,7 +69,14 @@ func (suite *SoloMachineTestSuite) TestCheckProposedHeaderAndUpdateState() { suite.Require().True(ok) suite.Require().Equal(cs.(*types.ClientState).ConsensusState, consState) - suite.Require().Equal(smHeader.GetPubKey(), smConsState.GetPubKey()) + + headerPubKey, err := smHeader.GetPubKey() + suite.Require().NoError(err) + + consStatePubKey, err := smConsState.GetPubKey() + suite.Require().NoError(err) + + suite.Require().Equal(headerPubKey, consStatePubKey) suite.Require().Equal(smHeader.NewDiversifier, smConsState.Diversifier) suite.Require().Equal(smHeader.Timestamp, smConsState.Timestamp) suite.Require().Equal(smHeader.GetHeight().GetVersionHeight(), cs.(*types.ClientState).Sequence) diff --git a/x/ibc/light-clients/06-solomachine/types/solomachine.go b/x/ibc/light-clients/06-solomachine/types/solomachine.go index 06d8fc05f6..d3936ef427 100644 --- a/x/ibc/light-clients/06-solomachine/types/solomachine.go +++ b/x/ibc/light-clients/06-solomachine/types/solomachine.go @@ -1,9 +1,8 @@ package types import ( - "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ) @@ -20,17 +19,17 @@ func (cs ClientState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (cs ConsensusState) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return unpacker.UnpackAny(cs.PublicKey, new(crypto.PubKey)) + return unpacker.UnpackAny(cs.PublicKey, new(cryptotypes.PubKey)) } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (h Header) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return unpacker.UnpackAny(h.NewPublicKey, new(crypto.PubKey)) + return unpacker.UnpackAny(h.NewPublicKey, new(cryptotypes.PubKey)) } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (hd HeaderData) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return unpacker.UnpackAny(hd.NewPubKey, new(crypto.PubKey)) + return unpacker.UnpackAny(hd.NewPubKey, new(cryptotypes.PubKey)) } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method diff --git a/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go b/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go index 833535da16..592d73b22b 100644 --- a/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go +++ b/x/ibc/light-clients/06-solomachine/types/solomachine.pb.go @@ -229,8 +229,9 @@ type Misbehaviour struct { SignatureTwo *SignatureAndData `protobuf:"bytes,4,opt,name=signature_two,json=signatureTwo,proto3" json:"signature_two,omitempty" yaml:"signature_two"` } -func (m *Misbehaviour) Reset() { *m = Misbehaviour{} } -func (*Misbehaviour) ProtoMessage() {} +func (m *Misbehaviour) Reset() { *m = Misbehaviour{} } +func (m *Misbehaviour) String() string { return proto.CompactTextString(m) } +func (*Misbehaviour) ProtoMessage() {} func (*Misbehaviour) Descriptor() ([]byte, []int) { return fileDescriptor_6cc2ee18f7f86d4e, []int{3} } @@ -820,93 +821,92 @@ func init() { } var fileDescriptor_6cc2ee18f7f86d4e = []byte{ - // 1368 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xdf, 0x8f, 0xdb, 0xc4, - 0x13, 0x3f, 0xa7, 0xe9, 0xf5, 0x32, 0xb9, 0xe6, 0xf2, 0x75, 0xd3, 0x36, 0xe7, 0x56, 0x89, 0xbf, - 0x46, 0x94, 0x03, 0xd1, 0x84, 0x2b, 0xa2, 0x42, 0x15, 0x02, 0x1c, 0xc7, 0xd0, 0xb4, 0x77, 0xbe, - 0xe0, 0xf8, 0x80, 0x56, 0x48, 0x96, 0xe3, 0xec, 0x25, 0xd6, 0x25, 0x76, 0x88, 0x9d, 0xa4, 0x41, - 0x42, 0x42, 0x3c, 0x95, 0x88, 0x07, 0x1e, 0x79, 0x89, 0x84, 0x40, 0xfc, 0x2b, 0x08, 0x89, 0x97, - 0xf2, 0xc6, 0x53, 0x40, 0xed, 0x7f, 0x90, 0xbf, 0x00, 0xad, 0x77, 0x13, 0xdb, 0xb9, 0x5e, 0x4e, - 0xfc, 0x7a, 0xca, 0xee, 0xcc, 0x67, 0x3e, 0x33, 0x3b, 0x33, 0x99, 0x5d, 0xc3, 0xae, 0x55, 0x37, - 0x8b, 0x6d, 0xab, 0xd9, 0xf2, 0xcc, 0xb6, 0x85, 0x6c, 0xcf, 0x2d, 0xba, 0x4e, 0xdb, 0xe9, 0x18, - 0x66, 0xcb, 0xb2, 0x51, 0x71, 0xb0, 0x1b, 0xde, 0x16, 0xba, 0x3d, 0xc7, 0x73, 0xd8, 0xbc, 0x55, - 0x37, 0x0b, 0x61, 0x93, 0x42, 0x18, 0x33, 0xd8, 0xe5, 0x5e, 0xc2, 0x9c, 0xa6, 0xd3, 0x43, 0x45, - 0xd3, 0xb1, 0x6d, 0x64, 0x7a, 0x96, 0x63, 0x63, 0xaa, 0x60, 0x47, 0x98, 0xb8, 0xff, 0x07, 0xc0, - 0x96, 0x61, 0xdb, 0xa8, 0xed, 0xa3, 0xc8, 0x92, 0x42, 0x32, 0x4d, 0xa7, 0xe9, 0xf8, 0xcb, 0x22, - 0x5e, 0x51, 0xe9, 0x76, 0xd3, 0x71, 0x9a, 0x6d, 0x54, 0xf4, 0x77, 0xf5, 0xfe, 0x51, 0xd1, 0xb0, - 0x47, 0x44, 0x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3d, 0xcb, 0xad, 0x3d, 0x94, 0x9b, 0x96, - 0xd7, 0xea, 0xd7, 0x0b, 0xa6, 0xd3, 0x29, 0x9a, 0x8e, 0xdb, 0x71, 0x5c, 0xfa, 0x73, 0xd3, 0x6d, - 0x1c, 0x17, 0x1f, 0x15, 0x17, 0x1f, 0x59, 0x37, 0xe7, 0x5f, 0x59, 0xaf, 0xdd, 0xbe, 0x19, 0xfe, - 0xd0, 0xc2, 0xb7, 0x8c, 0x5b, 0x5f, 0xf7, 0xc7, 0xd9, 0xeb, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, - 0x20, 0x84, 0x51, 0xf7, 0x95, 0x0d, 0x00, 0x00, + // 1359 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x5f, 0x8f, 0xdb, 0x44, + 0x10, 0x3f, 0xa7, 0xe9, 0xf5, 0x32, 0xb9, 0xe6, 0x82, 0x9b, 0xb6, 0x39, 0xb7, 0x4a, 0x8c, 0x11, + 0xe5, 0x40, 0x34, 0xe1, 0x8a, 0xa8, 0x50, 0x85, 0x00, 0xc7, 0x31, 0x34, 0xed, 0x9d, 0x2f, 0x38, + 0x3e, 0xa0, 0x15, 0x92, 0xe5, 0x38, 0x7b, 0x89, 0x75, 0x89, 0x1d, 0xe2, 0x4d, 0xd2, 0x20, 0x21, + 0x21, 0x9e, 0x4a, 0xc4, 0x03, 0x5f, 0x20, 0x12, 0x02, 0xf1, 0x55, 0x80, 0xc7, 0xf2, 0xc6, 0x53, + 0x40, 0xed, 0x37, 0xc8, 0x27, 0x40, 0xf6, 0x6e, 0x62, 0x3b, 0xd7, 0xcb, 0x89, 0x7f, 0x4f, 0xd9, + 0x9d, 0xf9, 0xcd, 0x6f, 0x66, 0x67, 0x26, 0xb3, 0x6b, 0xd8, 0xb5, 0xea, 0x66, 0xb1, 0x6d, 0x35, + 0x5b, 0xd8, 0x6c, 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0x4d, 0x17, 0x4b, 0x35, 0x59, 0x91, 0xe4, 0xf4, 0x05, + 0x2e, 0x3b, 0x9e, 0xf0, 0x19, 0xa2, 0xa5, 0x4a, 0xaa, 0x63, 0x6f, 0xc3, 0xf5, 0xc0, 0x5e, 0x91, + 0x3f, 0xd5, 0xf4, 0x9a, 0xfc, 0xd1, 0xa1, 0xa7, 0xf2, 0x68, 0x3e, 0x4e, 0x6f, 0x90, 0xc0, 0x3d, + 0xcd, 0x5c, 0xe1, 0xc9, 0x59, 0x1e, 0xd2, 0x81, 0xdd, 0x5d, 0x59, 0x2c, 0xcb, 0x6a, 0x3a, 0x41, + 0x2a, 0x43, 0x76, 0x5c, 0xfc, 0xf1, 0x8f, 0xb9, 0xb5, 0x92, 0xfe, 0xeb, 0xd3, 0x1c, 0xf3, 0xe4, + 0x69, 0x8e, 0xf9, 0xf3, 0x69, 0x8e, 0xf9, 0xee, 0x59, 0x6e, 0xed, 0xc9, 0xb3, 0xdc, 0xda, 0xef, + 0xcf, 0x72, 0x6b, 0x0f, 0xe5, 0xa6, 0x85, 0x5b, 0xfd, 0x7a, 0xc1, 0x74, 0x3a, 0x45, 0xd3, 0x71, + 0x3b, 0x8e, 0x4b, 0x7f, 0x6e, 0xba, 0x8d, 0xe3, 0xe2, 0xa3, 0xe2, 0xe2, 0x03, 0xeb, 0xe6, 0xfc, + 0x0b, 0xeb, 0x8d, 0xdb, 0x37, 0xc3, 0x1f, 0x59, 0xde, 0x2d, 0xe3, 0xd6, 0xd7, 0xfd, 0x71, 0xf6, + 0xe6, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x80, 0xd3, 0x79, 0xb6, 0x91, 0x0d, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { diff --git a/x/ibc/light-clients/06-solomachine/types/solomachine_test.go b/x/ibc/light-clients/06-solomachine/types/solomachine_test.go index ee236a9e88..b3b647d829 100644 --- a/x/ibc/light-clients/06-solomachine/types/solomachine_test.go +++ b/x/ibc/light-clients/06-solomachine/types/solomachine_test.go @@ -41,7 +41,7 @@ func (suite *SoloMachineTestSuite) SetupTest() { suite.solomachine = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachinesingle", "testing", 1) suite.solomachineMulti = ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachinemulti", "testing", 4) - suite.store = suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), types.SoloMachine) + suite.store = suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), exported.Solomachine) } func TestSoloMachineTestSuite(t *testing.T) { @@ -49,7 +49,7 @@ func TestSoloMachineTestSuite(t *testing.T) { } func (suite *SoloMachineTestSuite) GetSequenceFromStore() uint64 { - bz := suite.store.Get(host.KeyClientState()) + bz := suite.store.Get(host.ClientStateKey()) suite.Require().NotNil(bz) var clientState exported.ClientState diff --git a/x/ibc/light-clients/06-solomachine/types/update.go b/x/ibc/light-clients/06-solomachine/types/update.go index 4deb8833d5..4cf31fd988 100644 --- a/x/ibc/light-clients/06-solomachine/types/update.go +++ b/x/ibc/light-clients/06-solomachine/types/update.go @@ -62,7 +62,12 @@ func checkHeader(cdc codec.BinaryMarshaler, clientState *ClientState, header *He return err } - if err := VerifySignature(clientState.ConsensusState.GetPubKey(), data, sigData); err != nil { + publicKey, err := clientState.ConsensusState.GetPubKey() + if err != nil { + return err + } + + if err := VerifySignature(publicKey, data, sigData); err != nil { return sdkerrors.Wrap(ErrInvalidHeader, err.Error()) } diff --git a/x/ibc/light-clients/06-solomachine/types/update_test.go b/x/ibc/light-clients/06-solomachine/types/update_test.go index a58b00dc48..74a29017b5 100644 --- a/x/ibc/light-clients/06-solomachine/types/update_test.go +++ b/x/ibc/light-clients/06-solomachine/types/update_test.go @@ -143,6 +143,16 @@ func (suite *SoloMachineTestSuite) TestCheckHeaderAndUpdateState() { }, false, }, + { + "consensus state public key is nil", + func() { + cs := solomachine.ClientState() + cs.ConsensusState.PublicKey = nil + clientState = cs + header = solomachine.CreateHeader() + }, + false, + }, } for _, tc := range testCases { diff --git a/x/ibc/light-clients/07-tendermint/client/cli/tx.go b/x/ibc/light-clients/07-tendermint/client/cli/tx.go index 54c0ac01b0..be2b4c4725 100644 --- a/x/ibc/light-clients/07-tendermint/client/cli/tx.go +++ b/x/ibc/light-clients/07-tendermint/client/cli/tx.go @@ -10,7 +10,6 @@ import ( ics23 "github.com/confio/ics23/go" "github.com/pkg/errors" "github.com/spf13/cobra" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/light" "github.com/cosmos/cosmos-sdk/client" @@ -25,7 +24,6 @@ import ( const ( flagTrustLevel = "trust-level" - flagConsensusParams = "consensus-params" flagProofSpecs = "proof-specs" flagUpgradePath = "upgrade-path" flagAllowUpdateAfterExpiry = "allow_update_after_expiry" @@ -40,7 +38,6 @@ func NewCreateClientCmd() *cobra.Command { Short: "create new tendermint client", Long: `Create a new tendermint IBC client. - 'trust-level' flag can be a fraction (eg: '1/3') or 'default' - - 'consensus-params' flag can be a JSON input, a path to a .json file. The params must match the consensus parameters of the chain this light client represents. - 'proof-specs' flag can be JSON input, a path to a .json file or 'default' - 'upgrade-path' flag is a string specifying the upgrade path for this chain where a future upgraded client will be stored. The path represents a keypath for the store with each key separated by a '/'. Any slash within a key must be escaped. e.g. 'upgrade/upgradedClient'`, @@ -71,9 +68,8 @@ func NewCreateClientCmd() *cobra.Command { } var ( - trustLevel types.Fraction - consensusParams *abci.ConsensusParams - specs []*ics23.ProofSpec + trustLevel types.Fraction + specs []*ics23.ProofSpec ) lvl, _ := cmd.Flags().GetString(flagTrustLevel) @@ -102,22 +98,6 @@ func NewCreateClientCmd() *cobra.Command { return err } - cp, _ := cmd.Flags().GetString(flagConsensusParams) - if cp != "" { - if err := legacyAmino.UnmarshalJSON([]byte(cp), &consensusParams); err != nil { - // check for file path if JSON input not provided - contents, err := ioutil.ReadFile(cp) - if err != nil { - return errors.New("neither JSON input nor path to .json file was provided for consensus params flag") - } - // TODO migrate to use JSONMarshaler (implement MarshalJSONArray - // or wrap lists of proto.Message in some other message) - if err := legacyAmino.UnmarshalJSON(contents, &consensusParams); err != nil { - return errors.Wrap(err, "error unmarshalling consensus params file") - } - } - } - spc, _ := cmd.Flags().GetString(flagProofSpecs) if spc == "default" { specs = commitmenttypes.GetSDKSpecs() @@ -150,7 +130,7 @@ func NewCreateClientCmd() *cobra.Command { clientState := types.NewClientState( header.GetHeader().GetChainID(), trustLevel, trustingPeriod, ubdPeriod, maxClockDrift, - height, consensusParams, specs, upgradePath, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, + height, specs, upgradePath, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, ) consensusState := header.ConsensusState() @@ -290,12 +270,12 @@ func parseFraction(fraction string) (types.Fraction, error) { return types.Fraction{}, fmt.Errorf("fraction must have format 'numerator/denominator' got %s", fraction) } - numerator, err := strconv.ParseInt(fr[0], 10, 64) + numerator, err := strconv.ParseUint(fr[0], 10, 64) if err != nil { return types.Fraction{}, fmt.Errorf("invalid trust-level numerator: %w", err) } - denominator, err := strconv.ParseInt(fr[1], 10, 64) + denominator, err := strconv.ParseUint(fr[1], 10, 64) if err != nil { return types.Fraction{}, fmt.Errorf("invalid trust-level denominator: %w", err) } diff --git a/x/ibc/light-clients/07-tendermint/types/client_state.go b/x/ibc/light-clients/07-tendermint/types/client_state.go index cb6e4630fa..8cfc849541 100644 --- a/x/ibc/light-clients/07-tendermint/types/client_state.go +++ b/x/ibc/light-clients/07-tendermint/types/client_state.go @@ -5,10 +5,8 @@ import ( "time" ics23 "github.com/confio/ics23/go" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/light" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -22,14 +20,11 @@ import ( var _ exported.ClientState = (*ClientState)(nil) -// Tendermint is used to indicate that the client uses the Tendermint Consensus Algorithm. -const Tendermint string = "Tendermint" - // NewClientState creates a new ClientState instance func NewClientState( chainID string, trustLevel Fraction, trustingPeriod, ubdPeriod, maxClockDrift time.Duration, - latestHeight clienttypes.Height, consensusParams *abci.ConsensusParams, specs []*ics23.ProofSpec, + latestHeight clienttypes.Height, specs []*ics23.ProofSpec, upgradePath string, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool, ) *ClientState { return &ClientState{ @@ -40,7 +35,6 @@ func NewClientState( MaxClockDrift: maxClockDrift, LatestHeight: latestHeight, FrozenHeight: clienttypes.ZeroHeight(), - ConsensusParams: consensusParams, ProofSpecs: specs, UpgradePath: upgradePath, AllowUpdateAfterExpiry: allowUpdateAfterExpiry, @@ -55,7 +49,7 @@ func (cs ClientState) GetChainID() string { // ClientType is tendermint. func (cs ClientState) ClientType() string { - return Tendermint + return exported.Tendermint } // GetLatestHeight returns latest block height. @@ -108,21 +102,6 @@ func (cs ClientState) Validate() error { ) } - // validate consensus params - if cs.ConsensusParams == nil || cs.ConsensusParams.Evidence == nil || - cs.ConsensusParams.Block == nil || cs.ConsensusParams.Validator == nil { - return sdkerrors.Wrap(ErrInvalidConsensusParams, "consensus params including block, evidence, and validator params cannot be empty") - } - if err := baseapp.ValidateBlockParams(*cs.ConsensusParams.Block); err != nil { - return sdkerrors.Wrap(err, "invalid block params") - } - if err := baseapp.ValidateEvidenceParams(*cs.ConsensusParams.Evidence); err != nil { - return sdkerrors.Wrap(err, "invalid evidence params") - } - if err := baseapp.ValidateValidatorParams(*cs.ConsensusParams.Validator); err != nil { - return sdkerrors.Wrap(err, "invalid validator params") - } - if cs.ProofSpecs == nil { return sdkerrors.Wrap(ErrInvalidProofSpecs, "proof specs cannot be nil for tm client") } @@ -158,7 +137,6 @@ func (cs ClientState) ZeroCustomFields() exported.ClientState { ChainId: cs.ChainId, UnbondingPeriod: cs.UnbondingPeriod, LatestHeight: cs.LatestHeight, - ConsensusParams: cs.ConsensusParams, ProofSpecs: cs.ProofSpecs, UpgradePath: cs.UpgradePath, } @@ -180,7 +158,7 @@ func (cs ClientState) VerifyClientState( return err } - clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath() + clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier)) path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath) if err != nil { return err @@ -220,7 +198,7 @@ func (cs ClientState) VerifyClientConsensusState( return err } - clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight) + clientPrefixedPath := commitmenttypes.NewMerklePath(host.FullConsensusStatePath(counterpartyClientIdentifier, consensusHeight)) path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath) if err != nil { return err @@ -263,7 +241,8 @@ func (cs ClientState) VerifyConnectionState( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.ConnectionPath(connectionID)) + connectionPath := commitmenttypes.NewMerklePath(host.ConnectionPath(connectionID)) + path, err := commitmenttypes.ApplyPrefix(prefix, connectionPath) if err != nil { return err } @@ -302,7 +281,8 @@ func (cs ClientState) VerifyChannelState( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.ChannelPath(portID, channelID)) + channelPath := commitmenttypes.NewMerklePath(host.ChannelPath(portID, channelID)) + path, err := commitmenttypes.ApplyPrefix(prefix, channelPath) if err != nil { return err } @@ -342,13 +322,14 @@ func (cs ClientState) VerifyPacketCommitment( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketCommitmentPath(portID, channelID, sequence)) + commitmentPath := commitmenttypes.NewMerklePath(host.PacketCommitmentPath(portID, channelID, sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, commitmentPath) if err != nil { return err } if err := merkleProof.VerifyMembership(cs.ProofSpecs, consensusState.GetRoot(), path, commitmentBytes); err != nil { - return sdkerrors.Wrap(clienttypes.ErrFailedPacketCommitmentVerification, err.Error()) + return err } return nil @@ -372,7 +353,8 @@ func (cs ClientState) VerifyPacketAcknowledgement( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, sequence)) + ackPath := commitmenttypes.NewMerklePath(host.PacketAcknowledgementPath(portID, channelID, sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, ackPath) if err != nil { return err } @@ -402,7 +384,8 @@ func (cs ClientState) VerifyPacketReceiptAbsence( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketReceiptPath(portID, channelID, sequence)) + receiptPath := commitmenttypes.NewMerklePath(host.PacketReceiptPath(portID, channelID, sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, receiptPath) if err != nil { return err } @@ -431,7 +414,8 @@ func (cs ClientState) VerifyNextSequenceRecv( return err } - path, err := commitmenttypes.ApplyPrefix(prefix, host.NextSequenceRecvPath(portID, channelID)) + nextSequenceRecvPath := commitmenttypes.NewMerklePath(host.NextSequenceRecvPath(portID, channelID)) + path, err := commitmenttypes.ApplyPrefix(prefix, nextSequenceRecvPath) if err != nil { return err } diff --git a/x/ibc/light-clients/07-tendermint/types/client_state_test.go b/x/ibc/light-clients/07-tendermint/types/client_state_test.go index 4f82044664..a160484609 100644 --- a/x/ibc/light-clients/07-tendermint/types/client_state_test.go +++ b/x/ibc/light-clients/07-tendermint/types/client_state_test.go @@ -33,57 +33,57 @@ func (suite *TendermintTestSuite) TestValidate() { }{ { name: "valid client", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: true, }, { name: "valid client with nil upgrade path", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), "", false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), "", false, false), expPass: true, }, { name: "invalid chainID", - clientState: types.NewClientState(" ", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(" ", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid trust level", - clientState: types.NewClientState(chainID, types.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid trusting period", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid unbonding period", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid max clock drift", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, 0, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, 0, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid height", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "trusting period not less than unbonding period", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "proof specs is nil", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, nil, upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, nil, upgradePath, false, false), expPass: false, }, { name: "proof specs contains nil", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, []*ics23.ProofSpec{ics23.TendermintSpec, nil}, upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, []*ics23.ProofSpec{ics23.TendermintSpec, nil}, upgradePath, false, false), expPass: false, }, } @@ -110,7 +110,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { // FIXME: uncomment // { // name: "successful verification", - // clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs()), + // clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs()), // consensusState: types.ConsensusState{ // Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), // }, @@ -119,7 +119,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { // }, { name: "ApplyPrefix failed", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), consensusState: types.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), }, @@ -128,7 +128,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { }, { name: "latest client height < height", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), consensusState: types.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), }, @@ -146,7 +146,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { }, { name: "proof verification failed", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), consensusState: types.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), NextValidatorsHash: suite.valsHash, @@ -230,7 +230,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { prefix = suite.chainB.GetPrefix() // make connection proof - connectionKey := host.KeyConnection(connB.ID) + connectionKey := host.ConnectionKey(connB.ID) proof, proofHeight = suite.chainB.QueryProof(connectionKey) tc.malleate() // make changes as necessary @@ -308,7 +308,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { prefix = suite.chainB.GetPrefix() // make channel proof - channelKey := host.KeyChannel(channelB.PortID, channelB.ID) + channelKey := host.ChannelKey(channelB.PortID, channelB.ID) proof, proofHeight = suite.chainB.QueryProof(channelKey) tc.malleate() // make changes as necessary @@ -389,7 +389,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { prefix = suite.chainB.GetPrefix() // make packet commitment proof - packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight = suite.chainB.QueryProof(packetKey) tc.malleate() // make changes as necessary @@ -477,7 +477,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { prefix = suite.chainB.GetPrefix() // make packet acknowledgement proof - acknowledgementKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + acknowledgementKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight = suite.chainB.QueryProof(acknowledgementKey) tc.malleate() // make changes as necessary @@ -554,7 +554,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketReceiptAbsence() { suite.Require().NoError(err) // need to update chainA's client representing chainB to prove missing ack - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) var ok bool clientStateI := suite.chainA.GetClientState(clientA) @@ -564,7 +564,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketReceiptAbsence() { prefix = suite.chainB.GetPrefix() // make packet receipt absence proof - receiptKey := host.KeyPacketReceipt(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + receiptKey := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight = suite.chainB.QueryProof(receiptKey) tc.malleate() // make changes as necessary @@ -645,7 +645,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { suite.Require().NoError(err) // need to update chainA's client representing chainB - suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) var ok bool clientStateI := suite.chainA.GetClientState(clientA) @@ -655,7 +655,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { prefix = suite.chainB.GetPrefix() // make next seq recv proof - nextSeqRecvKey := host.KeyNextSequenceRecv(packet.GetDestPort(), packet.GetDestChannel()) + nextSeqRecvKey := host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) proof, proofHeight = suite.chainB.QueryProof(nextSeqRecvKey) tc.malleate() // make changes as necessary diff --git a/x/ibc/light-clients/07-tendermint/types/codec.go b/x/ibc/light-clients/07-tendermint/types/codec.go index f0ff8b2f56..5d876c8fe0 100644 --- a/x/ibc/light-clients/07-tendermint/types/codec.go +++ b/x/ibc/light-clients/07-tendermint/types/codec.go @@ -24,8 +24,4 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*exported.Misbehaviour)(nil), &Misbehaviour{}, ) - registry.RegisterImplementations( - (*exported.Header)(nil), - &Header{}, - ) } diff --git a/x/ibc/light-clients/07-tendermint/types/consensus_state.go b/x/ibc/light-clients/07-tendermint/types/consensus_state.go index 0a8981281c..d55bc11305 100644 --- a/x/ibc/light-clients/07-tendermint/types/consensus_state.go +++ b/x/ibc/light-clients/07-tendermint/types/consensus_state.go @@ -26,7 +26,7 @@ func NewConsensusState( // ClientType returns Tendermint func (ConsensusState) ClientType() string { - return Tendermint + return exported.Tendermint } // GetRoot returns the commitment Root for the specific diff --git a/x/ibc/light-clients/07-tendermint/types/consensus_state_test.go b/x/ibc/light-clients/07-tendermint/types/consensus_state_test.go index a3a8b154a6..313815d0c7 100644 --- a/x/ibc/light-clients/07-tendermint/types/consensus_state_test.go +++ b/x/ibc/light-clients/07-tendermint/types/consensus_state_test.go @@ -4,6 +4,7 @@ import ( "time" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" ) @@ -54,13 +55,15 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { for i, tc := range testCases { tc := tc - suite.Require().Equal(tc.consensusState.ClientType(), types.Tendermint) + // check just to increase coverage + suite.Require().Equal(exported.Tendermint, tc.consensusState.ClientType()) suite.Require().Equal(tc.consensusState.GetRoot(), tc.consensusState.Root) + err := tc.consensusState.ValidateBasic() if tc.expectPass { - suite.Require().NoError(tc.consensusState.ValidateBasic(), "valid test case %d failed: %s", i, tc.msg) + suite.Require().NoError(err, "valid test case %d failed: %s", i, tc.msg) } else { - suite.Require().Error(tc.consensusState.ValidateBasic(), "invalid test case %d passed: %s", i, tc.msg) + suite.Require().Error(err, "invalid test case %d passed: %s", i, tc.msg) } } } diff --git a/x/ibc/light-clients/07-tendermint/types/errors.go b/x/ibc/light-clients/07-tendermint/types/errors.go index 6037c4c232..9683dbf3cf 100644 --- a/x/ibc/light-clients/07-tendermint/types/errors.go +++ b/x/ibc/light-clients/07-tendermint/types/errors.go @@ -20,5 +20,4 @@ var ( ErrUnbondingPeriodExpired = sdkerrors.Register(SubModuleName, 9, "time since latest trusted state has passed the unbonding period") ErrInvalidProofSpecs = sdkerrors.Register(SubModuleName, 10, "invalid proof specs") ErrInvalidValidatorSet = sdkerrors.Register(SubModuleName, 11, "invalid validator set") - ErrInvalidConsensusParams = sdkerrors.Register(SubModuleName, 12, "invalid consensus params") ) diff --git a/x/ibc/light-clients/07-tendermint/types/fraction.go b/x/ibc/light-clients/07-tendermint/types/fraction.go index e445f19ba6..a8d8274146 100644 --- a/x/ibc/light-clients/07-tendermint/types/fraction.go +++ b/x/ibc/light-clients/07-tendermint/types/fraction.go @@ -11,15 +11,15 @@ var DefaultTrustLevel = NewFractionFromTm(light.DefaultTrustLevel) // NewFractionFromTm returns a new Fraction instance from a tmmath.Fraction func NewFractionFromTm(f tmmath.Fraction) Fraction { return Fraction{ - Numerator: f.Numerator, - Denominator: f.Denominator, + Numerator: uint64(f.Numerator), + Denominator: uint64(f.Denominator), } } // ToTendermint converts Fraction to tmmath.Fraction func (f Fraction) ToTendermint() tmmath.Fraction { return tmmath.Fraction{ - Numerator: f.Numerator, - Denominator: f.Denominator, + Numerator: int64(f.Numerator), + Denominator: int64(f.Denominator), } } diff --git a/x/ibc/light-clients/07-tendermint/types/header.go b/x/ibc/light-clients/07-tendermint/types/header.go index 86e166caf5..40858c7350 100644 --- a/x/ibc/light-clients/07-tendermint/types/header.go +++ b/x/ibc/light-clients/07-tendermint/types/header.go @@ -25,25 +25,21 @@ func (h Header) ConsensusState() *ConsensusState { // ClientType defines that the Header is a Tendermint consensus algorithm func (h Header) ClientType() string { - return Tendermint + return exported.Tendermint } // GetHeight returns the current height. It returns 0 if the tendermint // header is nil. +// NOTE: the header.Header is checked to be non nil in ValidateBasic. func (h Header) GetHeight() exported.Height { - if h.Header == nil { - return clienttypes.ZeroHeight() - } version := clienttypes.ParseChainID(h.Header.ChainID) return clienttypes.NewHeight(version, uint64(h.Header.Height)) } // GetTime returns the current block timestamp. It returns a zero time if // the tendermint header is nil. +// NOTE: the header.Header is checked to be non nil in ValidateBasic. func (h Header) GetTime() time.Time { - if h.Header == nil { - return time.Time{} - } return h.Header.Time } diff --git a/x/ibc/light-clients/07-tendermint/types/header_test.go b/x/ibc/light-clients/07-tendermint/types/header_test.go index 235e1f7584..2dbba94b97 100644 --- a/x/ibc/light-clients/07-tendermint/types/header_test.go +++ b/x/ibc/light-clients/07-tendermint/types/header_test.go @@ -6,23 +6,18 @@ import ( tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" ) func (suite *TendermintTestSuite) TestGetHeight() { header := suite.chainA.LastHeader suite.Require().NotEqual(uint64(0), header.GetHeight()) - - header.Header = nil - suite.Require().Equal(clienttypes.ZeroHeight(), header.GetHeight()) } func (suite *TendermintTestSuite) TestGetTime() { header := suite.chainA.LastHeader suite.Require().NotEqual(time.Time{}, header.GetTime()) - - header.Header = nil - suite.Require().Equal(time.Time{}, header.GetTime()) } func (suite *TendermintTestSuite) TestHeaderValidateBasic() { @@ -63,7 +58,7 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { }, false}, } - suite.Require().Equal(types.Tendermint, suite.header.ClientType()) + suite.Require().Equal(exported.Tendermint, suite.header.ClientType()) for _, tc := range testCases { tc := tc diff --git a/x/ibc/light-clients/07-tendermint/types/misbehaviour.go b/x/ibc/light-clients/07-tendermint/types/misbehaviour.go index b1277110a2..85fb615e5e 100644 --- a/x/ibc/light-clients/07-tendermint/types/misbehaviour.go +++ b/x/ibc/light-clients/07-tendermint/types/misbehaviour.go @@ -1,11 +1,10 @@ package types import ( + "bytes" "math" "time" - yaml "gopkg.in/yaml.v2" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" @@ -20,19 +19,17 @@ var ( ) // NewMisbehaviour creates a new Misbehaviour instance. -func NewMisbehaviour(clientID, chainID string, header1, header2 *Header) *Misbehaviour { +func NewMisbehaviour(clientID string, header1, header2 *Header) *Misbehaviour { return &Misbehaviour{ ClientId: clientID, - ChainId: chainID, Header1: header1, Header2: header2, } - } // ClientType is Tendermint light client func (misbehaviour Misbehaviour) ClientType() string { - return Tendermint + return exported.Tendermint } // GetClientID returns the ID of the client that committed a misbehaviour. @@ -40,16 +37,6 @@ func (misbehaviour Misbehaviour) GetClientID() string { return misbehaviour.ClientId } -// String implements Misbehaviour interface -func (misbehaviour Misbehaviour) String() string { - // FIXME: implement custom marshaller - bz, err := yaml.Marshal(misbehaviour) - if err != nil { - panic(err) - } - return string(bz) -} - // GetHeight returns the height at which misbehaviour occurred // // NOTE: assumes that misbehaviour headers have the same height @@ -85,6 +72,9 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { if misbehaviour.Header2.TrustedValidators == nil { return sdkerrors.Wrap(ErrInvalidValidatorSet, "trusted validator set in Header2 cannot be empty") } + if misbehaviour.Header1.Header.ChainID != misbehaviour.Header2.Header.ChainID { + return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "headers must have identical chainIDs") + } if err := host.ClientIdentifierValidator(misbehaviour.ClientId); err != nil { return sdkerrors.Wrap(err, "misbehaviour client ID is invalid") @@ -118,13 +108,13 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { } // Ensure that Commit Hashes are different - if blockID1.Equals(*blockID2) { - return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "headers blockIDs are equal") + if bytes.Equal(blockID1.Hash, blockID2.Hash) { + return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "headers block hashes are equal") } - if err := ValidCommit(misbehaviour.ChainId, misbehaviour.Header1.Commit, misbehaviour.Header1.ValidatorSet); err != nil { + if err := ValidCommit(misbehaviour.Header1.Header.ChainID, misbehaviour.Header1.Commit, misbehaviour.Header1.ValidatorSet); err != nil { return err } - if err := ValidCommit(misbehaviour.ChainId, misbehaviour.Header2.Commit, misbehaviour.Header2.ValidatorSet); err != nil { + if err := ValidCommit(misbehaviour.Header2.Header.ChainID, misbehaviour.Header2.Commit, misbehaviour.Header2.ValidatorSet); err != nil { return err } return nil @@ -156,8 +146,8 @@ func ValidCommit(chainID string, commit *tmproto.Commit, valSet *tmproto.Validat blockID, ok := voteSet.TwoThirdsMajority() - // Check that ValidatorSet did indeed commit to blockID in Commit - if !ok || !blockID.Equals(tmCommit.BlockID) { + // Check that ValidatorSet did indeed commit to blockID hash in Commit + if !ok || !bytes.Equal(blockID.Hash, tmCommit.BlockID.Hash) { return sdkerrors.Wrap(clienttypes.ErrInvalidMisbehaviour, "validator set did not commit to header") } diff --git a/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle.go b/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle.go index d37a21402a..b27cc06a45 100644 --- a/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle.go +++ b/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle.go @@ -51,35 +51,6 @@ func (cs ClientState) CheckMisbehaviourAndUpdateState( return nil, sdkerrors.Wrapf(err, "could not get trusted consensus state from clientStore for Header2 at TrustedHeight: %s", tmMisbehaviour.Header2) } - // calculate the age of the misbehaviour - infractionTime := tmMisbehaviour.GetTime() - ageDuration := ctx.BlockTime().Sub(infractionTime) - - var ageBlocks int64 - if tmMisbehaviour.GetHeight().GetVersionNumber() == cs.LatestHeight.VersionNumber { - // if the misbehaviour is in the same version as the client then - // perform expiry check using block height in addition to time - infractionHeight := tmMisbehaviour.GetHeight().GetVersionHeight() - ageBlocks = int64(cs.LatestHeight.VersionHeight - infractionHeight) - } else { - // if the misbehaviour is from a different version, then the version-height - // of misbehaviour has no correlation with the current version-height - // so we disable the block check by setting ageBlocks to 0 and only - // rely on the time expiry check with ageDuration - ageBlocks = 0 - } - - // Reject misbehaviour if the age is too old. Misbehaviour is considered stale - // if the difference in time and number of blocks is greater than the allowed - // parameters defined. - if ageDuration > cs.ConsensusParams.Evidence.MaxAgeDuration || - ageBlocks > cs.ConsensusParams.Evidence.MaxAgeNumBlocks { - return nil, sdkerrors.Wrapf(clienttypes.ErrInvalidMisbehaviour, - "age duration (%s) and age blocks (%d) are greater than max consensus params for duration (%s) and block (%d)", - ageDuration, ageBlocks, cs.ConsensusParams.Evidence.MaxAgeDuration, cs.ConsensusParams.Evidence.MaxAgeNumBlocks, - ) - } - // Check the validity of the two conflicting headers against their respective // trusted consensus states // NOTE: header height and commitment root assertions are checked in @@ -137,7 +108,7 @@ func checkMisbehaviourHeader( chainID, _ = clienttypes.SetVersionNumber(chainID, header.GetHeight().GetVersionNumber()) } - // - ValidatorSet must have 2/3 similarity with trusted FromValidatorSet + // - ValidatorSet must have TrustLevel similarity with trusted FromValidatorSet // - ValidatorSets on both headers are valid given the last trusted ValidatorSet if err := tmTrustedValset.VerifyCommitLightTrusting( chainID, tmCommit, clientState.TrustLevel.ToTendermint(), diff --git a/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle_test.go b/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle_test.go index 2133611860..6d8cd5e32a 100644 --- a/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle_test.go +++ b/x/ibc/light-clients/07-tendermint/types/misbehaviour_handle_test.go @@ -7,8 +7,6 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmtypes "github.com/tendermint/tendermint/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/simapp" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" @@ -22,7 +20,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { altPubKey, err := altPrivVal.GetPubKey() suite.Require().NoError(err) - altVal := tmtypes.NewValidator(altPubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 4) + altVal := tmtypes.NewValidator(altPubKey, 4) // Create bothValSet with both suite validator and altVal bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) @@ -37,7 +35,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { altSigners := []tmtypes.PrivValidator{altPrivVal} - versionHeight := int64(height.VersionHeight) heightMinus1 := clienttypes.NewHeight(height.VersionNumber, height.VersionHeight-1) heightMinus3 := clienttypes.NewHeight(height.VersionNumber, height.VersionHeight-3) @@ -54,7 +51,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }{ { "valid misbehavior misbehaviour", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -62,7 +59,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -70,7 +66,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "valid misbehavior at height greater than last consensusState", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -78,7 +74,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -86,7 +81,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "valid misbehaviour with different trusted heights", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -94,7 +89,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -102,7 +96,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "valid misbehaviour at a previous version", - types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -110,7 +104,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainIDVersion0, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainIDVersion0, int64(height.VersionHeight), heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainIDVersion0, ClientId: chainID, }, suite.now, @@ -118,7 +111,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "valid misbehaviour at a future version", - types.NewClientState(chainIDVersion0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainIDVersion0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -126,7 +119,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainIDVersion0, 3, heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainIDVersion0, 3, heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainIDVersion0, ClientId: chainID, }, suite.now, @@ -134,7 +126,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "valid misbehaviour with trusted heights at a previous version", - types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -142,7 +134,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainIDVersion1, 1, heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainIDVersion1, 1, heightMinus3, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainIDVersion1, ClientId: chainID, }, suite.now, @@ -150,7 +141,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "consensus state's valset hash different from misbehaviour should still pass", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -158,7 +149,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, suite.valSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -166,7 +156,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "invalid misbehavior misbehaviour from different chain", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -174,7 +164,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader("ethermint", int64(height.VersionHeight), height, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader("ethermint", int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: "ethermint", ClientId: chainID, }, suite.now, @@ -182,7 +171,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "invalid misbehavior misbehaviour with trusted height different from trusted consensus state", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -190,7 +179,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -198,7 +186,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "invalid misbehavior misbehaviour with trusted validators different from trusted consensus state", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), suite.valsHash), @@ -206,7 +194,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus3, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -222,7 +209,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -230,7 +216,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "trusted consensus state does not exist", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), nil, // consensus state for trusted height - 1 does not exist in store clienttypes.Height{}, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -238,7 +224,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -246,7 +231,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "invalid tendermint misbehaviour", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -255,41 +240,9 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { suite.now, false, }, - { - "rejected misbehaviour due to expired age duration", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), - types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), - height, - types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), - height, - &types.Misbehaviour{ - Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, bothValSet, bothSigners), - Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, - ClientId: chainID, - }, - suite.now.Add(2 * time.Minute).Add(simapp.DefaultConsensusParams.Evidence.MaxAgeDuration), - false, - }, - { - "rejected misbehaviour due to expired block duration", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(0, uint64(versionHeight+simapp.DefaultConsensusParams.Evidence.MaxAgeNumBlocks+1)), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), - types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), - height, - types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), - height, - &types.Misbehaviour{ - Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, bothValSet, bothSigners), - Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, - ClientId: chainID, - }, - suite.now.Add(time.Hour), - false, - }, { "provided height > header height", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -297,7 +250,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -305,7 +257,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "unbonding period expired", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(time.Time{}, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), heightMinus1, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -313,7 +265,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now.Add(ubdPeriod), @@ -321,7 +272,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "trusted validators is incorrect for given consensus state", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -329,7 +280,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, suite.valSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, suite.valSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -337,7 +287,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "first valset has too much change", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -345,7 +295,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, altValSet, bothValSet, altSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), bothValSet, bothValSet, bothSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -353,7 +302,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "second valset has too much change", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -361,7 +310,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, bothValSet, bothValSet, bothSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), altValSet, bothValSet, altSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, @@ -369,7 +317,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { }, { "both valsets have too much change", - types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), height, types.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), bothValsHash), @@ -377,7 +325,6 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviourAndUpdateState() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now, altValSet, bothValSet, altSigners), Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), height, suite.now.Add(time.Minute), altValSet, bothValSet, altSigners), - ChainId: chainID, ClientId: chainID, }, suite.now, diff --git a/x/ibc/light-clients/07-tendermint/types/misbehaviour_test.go b/x/ibc/light-clients/07-tendermint/types/misbehaviour_test.go index 22bd8674fb..c8e4416612 100644 --- a/x/ibc/light-clients/07-tendermint/types/misbehaviour_test.go +++ b/x/ibc/light-clients/07-tendermint/types/misbehaviour_test.go @@ -7,8 +7,8 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ibctestingmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock" @@ -21,11 +21,10 @@ func (suite *TendermintTestSuite) TestMisbehaviour() { misbehaviour := &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, signers), - ChainId: chainID, ClientId: clientID, } - suite.Require().Equal(types.Tendermint, misbehaviour.ClientType()) + suite.Require().Equal(exported.Tendermint, misbehaviour.ClientType()) suite.Require().Equal(clientID, misbehaviour.GetClientID()) suite.Require().Equal(height, misbehaviour.GetHeight()) } @@ -37,7 +36,7 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { versionHeight := int64(height.VersionHeight) - altVal := tmtypes.NewValidator(altPubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), versionHeight) + altVal := tmtypes.NewValidator(altPubKey, versionHeight) // Create bothValSet with both suite validator and altVal bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) @@ -65,7 +64,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -73,13 +71,13 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { }, { "misbehaviour Header1 is nil", - types.NewMisbehaviour(clientID, chainID, nil, suite.header), + types.NewMisbehaviour(clientID, nil, suite.header), func(m *types.Misbehaviour) error { return nil }, false, }, { "misbehaviour Header2 is nil", - types.NewMisbehaviour(clientID, chainID, suite.header, nil), + types.NewMisbehaviour(clientID, suite.header, nil), func(m *types.Misbehaviour) error { return nil }, false, }, @@ -88,7 +86,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), clienttypes.NewHeight(0, height.VersionHeight-3), suite.now.Add(time.Minute), suite.valSet, bothValSet, signers), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -99,7 +96,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), clienttypes.ZeroHeight(), suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), Header2: suite.header, - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -110,7 +106,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), clienttypes.ZeroHeight(), suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -121,7 +116,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, nil, signers), Header2: suite.header, - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -132,7 +126,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, nil, signers), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -143,40 +136,16 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, signers), - ChainId: chainID, ClientId: "GAIA", }, func(misbehaviour *types.Misbehaviour) error { return nil }, false, }, { - "wrong chainID on header1", + "chainIDs do not match", &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader("ethermint", int64(height.VersionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, signers), - ChainId: "ethermint", - ClientId: clientID, - }, - func(misbehaviour *types.Misbehaviour) error { return nil }, - false, - }, - { - "wrong chainID on header2", - &types.Misbehaviour{ - Header1: suite.header, - Header2: suite.chainA.CreateTMClientHeader("ethermint", int64(height.VersionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, signers), - ChainId: chainID, - ClientId: clientID, - }, - func(misbehaviour *types.Misbehaviour) error { return nil }, - false, - }, - { - "wrong chainID in misbehaviour", - &types.Misbehaviour{ - Header1: suite.header, - Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers), - ChainId: "ethermint", ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -187,7 +156,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, 6, clienttypes.NewHeight(0, 4), suite.now, suite.valSet, suite.valSet, signers), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -198,7 +166,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.header, - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { return nil }, @@ -209,7 +176,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, suite.valSet, bothSigners), Header2: suite.header, - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { @@ -231,7 +197,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, suite.valSet, bothSigners), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { @@ -253,7 +218,6 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { &types.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, bothValSet, suite.valSet, bothSigners), - ChainId: chainID, ClientId: clientID, }, func(misbehaviour *types.Misbehaviour) error { diff --git a/x/ibc/light-clients/07-tendermint/types/proposal_handle_test.go b/x/ibc/light-clients/07-tendermint/types/proposal_handle_test.go index 33c10854e7..062a29a0dc 100644 --- a/x/ibc/light-clients/07-tendermint/types/proposal_handle_test.go +++ b/x/ibc/light-clients/07-tendermint/types/proposal_handle_test.go @@ -2,6 +2,7 @@ package types_test import ( clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" + "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" ) @@ -12,7 +13,7 @@ var ( // sanity checks func (suite *TendermintTestSuite) TestCheckProposedHeaderAndUpdateStateBasic() { - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA).(*types.ClientState) clientStore := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA) @@ -201,7 +202,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeaderAndUpdateState() { suite.SetupTest() // reset // construct client state based on test case parameters - clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState := suite.chainA.GetClientState(clientA).(*types.ClientState) clientState.AllowUpdateAfterExpiry = tc.AllowUpdateAfterExpiry clientState.AllowUpdateAfterMisbehaviour = tc.AllowUpdateAfterMisbehaviour @@ -319,7 +320,7 @@ func (suite *TendermintTestSuite) TestCheckProposedHeader() { suite.Run(tc.name, func() { suite.SetupTest() // reset - clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) clientState = suite.chainA.GetClientState(clientA).(*types.ClientState) clientState.AllowUpdateAfterExpiry = true clientState.AllowUpdateAfterMisbehaviour = false diff --git a/x/ibc/light-clients/07-tendermint/types/store.go b/x/ibc/light-clients/07-tendermint/types/store.go index 096d798333..50f8d2a1db 100644 --- a/x/ibc/light-clients/07-tendermint/types/store.go +++ b/x/ibc/light-clients/07-tendermint/types/store.go @@ -12,7 +12,7 @@ import ( // GetConsensusState retrieves the consensus state from the client prefixed // store. An error is returned if the consensus state does not exist. func GetConsensusState(store sdk.KVStore, cdc codec.BinaryMarshaler, height exported.Height) (*ConsensusState, error) { - bz := store.Get(host.KeyConsensusState(height)) + bz := store.Get(host.ConsensusStateKey(height)) if bz == nil { return nil, sdkerrors.Wrapf( clienttypes.ErrConsensusStateNotFound, diff --git a/x/ibc/light-clients/07-tendermint/types/store_test.go b/x/ibc/light-clients/07-tendermint/types/store_test.go index 91cb973ca0..3bb267b0fc 100644 --- a/x/ibc/light-clients/07-tendermint/types/store_test.go +++ b/x/ibc/light-clients/07-tendermint/types/store_test.go @@ -34,7 +34,7 @@ func (suite *TendermintTestSuite) TestGetConsensusState() { // marshal an empty client state and set as consensus state store := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA) clientStateBz := suite.chainA.App.IBCKeeper.ClientKeeper.MustMarshalClientState(&types.ClientState{}) - store.Set(host.KeyConsensusState(height), clientStateBz) + store.Set(host.ConsensusStateKey(height), clientStateBz) }, false, }, { @@ -42,7 +42,7 @@ func (suite *TendermintTestSuite) TestGetConsensusState() { // marshal and set solomachine consensus state store := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA) consensusStateBz := suite.chainA.App.IBCKeeper.ClientKeeper.MustMarshalConsensusState(&solomachinetypes.ConsensusState{}) - store.Set(host.KeyConsensusState(height), consensusStateBz) + store.Set(host.ConsensusStateKey(height), consensusStateBz) }, false, }, } diff --git a/x/ibc/light-clients/07-tendermint/types/tendermint.pb.go b/x/ibc/light-clients/07-tendermint/types/tendermint.pb.go index f4b26ae3c0..df0967ef02 100644 --- a/x/ibc/light-clients/07-tendermint/types/tendermint.pb.go +++ b/x/ibc/light-clients/07-tendermint/types/tendermint.pb.go @@ -7,15 +7,14 @@ import ( fmt "fmt" _go "github.com/confio/ics23/go" types "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" - types2 "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" + types1 "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/golang/protobuf/ptypes/timestamp" - types1 "github.com/tendermint/tendermint/abci/types" github_com_tendermint_tendermint_libs_bytes "github.com/tendermint/tendermint/libs/bytes" - types3 "github.com/tendermint/tendermint/proto/tendermint/types" + types2 "github.com/tendermint/tendermint/proto/tendermint/types" io "io" math "math" math_bits "math/bits" @@ -50,18 +49,16 @@ type ClientState struct { FrozenHeight types.Height `protobuf:"bytes,6,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height" yaml:"frozen_height"` // Latest height the client was updated to LatestHeight types.Height `protobuf:"bytes,7,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height" yaml:"latest_height"` - // Consensus params of the chain - ConsensusParams *types1.ConsensusParams `protobuf:"bytes,8,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params,omitempty" yaml:"consensus_params"` // Proof specifications used in verifying counterparty state - ProofSpecs []*_go.ProofSpec `protobuf:"bytes,9,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"` + ProofSpecs []*_go.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"` // Path at which next upgraded client will be committed - UpgradePath string `protobuf:"bytes,10,opt,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty" yaml:"upgrade_path"` + UpgradePath string `protobuf:"bytes,9,opt,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty" yaml:"upgrade_path"` // This flag, when set to true, will allow governance to recover a client // which has expired - AllowUpdateAfterExpiry bool `protobuf:"varint,11,opt,name=allow_update_after_expiry,json=allowUpdateAfterExpiry,proto3" json:"allow_update_after_expiry,omitempty" yaml:"allow_update_after_expiry"` + AllowUpdateAfterExpiry bool `protobuf:"varint,10,opt,name=allow_update_after_expiry,json=allowUpdateAfterExpiry,proto3" json:"allow_update_after_expiry,omitempty" yaml:"allow_update_after_expiry"` // This flag, when set to true, will allow governance to unfreeze a client // whose chain has experienced a misbehaviour event - AllowUpdateAfterMisbehaviour bool `protobuf:"varint,12,opt,name=allow_update_after_misbehaviour,json=allowUpdateAfterMisbehaviour,proto3" json:"allow_update_after_misbehaviour,omitempty" yaml:"allow_update_after_misbehaviour"` + AllowUpdateAfterMisbehaviour bool `protobuf:"varint,11,opt,name=allow_update_after_misbehaviour,json=allowUpdateAfterMisbehaviour,proto3" json:"allow_update_after_misbehaviour,omitempty" yaml:"allow_update_after_misbehaviour"` } func (m *ClientState) Reset() { *m = ClientState{} } @@ -103,7 +100,7 @@ type ConsensusState struct { // was stored. Timestamp time.Time `protobuf:"bytes,1,opt,name=timestamp,proto3,stdtime" json:"timestamp"` // commitment root (i.e app hash) - Root types2.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` + Root types1.MerkleRoot `protobuf:"bytes,2,opt,name=root,proto3" json:"root"` NextValidatorsHash github_com_tendermint_tendermint_libs_bytes.HexBytes `protobuf:"bytes,3,opt,name=next_validators_hash,json=nextValidatorsHash,proto3,casttype=github.com/tendermint/tendermint/libs/bytes.HexBytes" json:"next_validators_hash,omitempty" yaml:"next_validators_hash"` } @@ -144,13 +141,13 @@ var xxx_messageInfo_ConsensusState proto.InternalMessageInfo // that implements Misbehaviour interface expected by ICS-02 type Misbehaviour struct { ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"` - ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty" yaml:"chain_id"` - Header1 *Header `protobuf:"bytes,3,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` - Header2 *Header `protobuf:"bytes,4,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty" yaml:"header_2"` + Header1 *Header `protobuf:"bytes,2,opt,name=header_1,json=header1,proto3" json:"header_1,omitempty" yaml:"header_1"` + Header2 *Header `protobuf:"bytes,3,opt,name=header_2,json=header2,proto3" json:"header_2,omitempty" yaml:"header_2"` } -func (m *Misbehaviour) Reset() { *m = Misbehaviour{} } -func (*Misbehaviour) ProtoMessage() {} +func (m *Misbehaviour) Reset() { *m = Misbehaviour{} } +func (m *Misbehaviour) String() string { return proto.CompactTextString(m) } +func (*Misbehaviour) ProtoMessage() {} func (*Misbehaviour) Descriptor() ([]byte, []int) { return fileDescriptor_c6d6cf2b288949be, []int{2} } @@ -194,10 +191,10 @@ var xxx_messageInfo_Misbehaviour proto.InternalMessageInfo // hash to TrustedConsensusState.NextValidatorsHash since that is the last // trusted validator set at the TrustedHeight. type Header struct { - *types3.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header,omitempty" yaml:"signed_header"` - ValidatorSet *types3.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty" yaml:"validator_set"` + *types2.SignedHeader `protobuf:"bytes,1,opt,name=signed_header,json=signedHeader,proto3,embedded=signed_header" json:"signed_header,omitempty" yaml:"signed_header"` + ValidatorSet *types2.ValidatorSet `protobuf:"bytes,2,opt,name=validator_set,json=validatorSet,proto3" json:"validator_set,omitempty" yaml:"validator_set"` TrustedHeight types.Height `protobuf:"bytes,3,opt,name=trusted_height,json=trustedHeight,proto3" json:"trusted_height" yaml:"trusted_height"` - TrustedValidators *types3.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty" yaml:"trusted_validators"` + TrustedValidators *types2.ValidatorSet `protobuf:"bytes,4,opt,name=trusted_validators,json=trustedValidators,proto3" json:"trusted_validators,omitempty" yaml:"trusted_validators"` } func (m *Header) Reset() { *m = Header{} } @@ -233,7 +230,7 @@ func (m *Header) XXX_DiscardUnknown() { var xxx_messageInfo_Header proto.InternalMessageInfo -func (m *Header) GetValidatorSet() *types3.ValidatorSet { +func (m *Header) GetValidatorSet() *types2.ValidatorSet { if m != nil { return m.ValidatorSet } @@ -247,17 +244,17 @@ func (m *Header) GetTrustedHeight() types.Height { return types.Height{} } -func (m *Header) GetTrustedValidators() *types3.ValidatorSet { +func (m *Header) GetTrustedValidators() *types2.ValidatorSet { if m != nil { return m.TrustedValidators } return nil } -// Fraction defines the protobuf message type for tmmath.Fraction +// Fraction defines the protobuf message type for tmmath.Fraction that only supports positive values. type Fraction struct { - Numerator int64 `protobuf:"varint,1,opt,name=numerator,proto3" json:"numerator,omitempty"` - Denominator int64 `protobuf:"varint,2,opt,name=denominator,proto3" json:"denominator,omitempty"` + Numerator uint64 `protobuf:"varint,1,opt,name=numerator,proto3" json:"numerator,omitempty"` + Denominator uint64 `protobuf:"varint,2,opt,name=denominator,proto3" json:"denominator,omitempty"` } func (m *Fraction) Reset() { *m = Fraction{} } @@ -293,14 +290,14 @@ func (m *Fraction) XXX_DiscardUnknown() { var xxx_messageInfo_Fraction proto.InternalMessageInfo -func (m *Fraction) GetNumerator() int64 { +func (m *Fraction) GetNumerator() uint64 { if m != nil { return m.Numerator } return 0 } -func (m *Fraction) GetDenominator() int64 { +func (m *Fraction) GetDenominator() uint64 { if m != nil { return m.Denominator } @@ -320,79 +317,75 @@ func init() { } var fileDescriptor_c6d6cf2b288949be = []byte{ - // 1142 bytes of a gzipped FileDescriptorProto + // 1079 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0xe3, 0xc4, - 0x17, 0x6f, 0xda, 0x7e, 0xb7, 0xe9, 0x24, 0xdd, 0xf6, 0xeb, 0x2d, 0xbb, 0x69, 0xb7, 0x1b, 0x47, - 0x06, 0x2d, 0x15, 0xd2, 0xda, 0x24, 0x8b, 0x84, 0x54, 0x71, 0xc1, 0x5b, 0x50, 0x8b, 0x58, 0xa9, - 0x72, 0xf9, 0x21, 0x21, 0x81, 0x99, 0xd8, 0x93, 0x78, 0x54, 0xdb, 0x63, 0x3c, 0x93, 0x90, 0xf2, - 0x17, 0xc0, 0x6d, 0x8f, 0x2b, 0x4e, 0x1c, 0xf8, 0x47, 0xb8, 0xed, 0xb1, 0xe2, 0xc4, 0xc9, 0xa0, - 0xf6, 0x3f, 0xc8, 0x91, 0x13, 0x9a, 0x1f, 0x8e, 0x27, 0xd9, 0x2e, 0xd5, 0x72, 0x49, 0xe6, 0xbd, - 0xf7, 0x79, 0xef, 0xa3, 0x79, 0xf3, 0xe6, 0x33, 0x06, 0x0e, 0xee, 0x07, 0x4e, 0x8c, 0x87, 0x11, - 0x0b, 0x62, 0x8c, 0x52, 0x46, 0x1d, 0x86, 0xd2, 0x10, 0xe5, 0x09, 0x4e, 0x99, 0x33, 0xee, 0x6a, - 0x96, 0x9d, 0xe5, 0x84, 0x11, 0xa3, 0x8d, 0xfb, 0x81, 0xad, 0x27, 0xd8, 0x1a, 0x64, 0xdc, 0xdd, - 0xed, 0x68, 0xf9, 0xec, 0x3c, 0x43, 0xd4, 0x19, 0xc3, 0x18, 0x87, 0x90, 0x91, 0x5c, 0x56, 0xd8, - 0xdd, 0x7b, 0x09, 0x21, 0x7e, 0x55, 0xf4, 0xbe, 0x16, 0x85, 0xfd, 0x00, 0xcf, 0x05, 0xef, 0x04, - 0x24, 0x1d, 0x60, 0xe2, 0x64, 0x39, 0x21, 0x83, 0xd2, 0xd9, 0x1e, 0x12, 0x32, 0x8c, 0x91, 0x23, - 0xac, 0xfe, 0x68, 0xe0, 0x84, 0xa3, 0x1c, 0x32, 0x4c, 0x52, 0x15, 0x37, 0x17, 0xe3, 0x0c, 0x27, - 0x88, 0x32, 0x98, 0x64, 0x25, 0x80, 0xf7, 0x20, 0x20, 0x39, 0x72, 0xe4, 0x96, 0xf8, 0xbe, 0xe5, - 0x4a, 0x01, 0xde, 0xae, 0x00, 0x24, 0x49, 0x30, 0x4b, 0x4a, 0xd0, 0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0xa6, 0x3d, 0x2e, 0x65, 0xbe, 0xe5, 0xad, 0x29, 0x87, + 0x1a, 0x63, 0x11, 0x30, 0x0a, 0x44, 0xd5, 0xac, 0xea, 0x61, 0xb9, 0x6b, 0x17, 0x8f, 0x66, 0xb9, + 0xb9, 0x7d, 0x53, 0xa5, 0xe2, 0xb0, 0xbc, 0xff, 0x2b, 0x67, 0xd5, 0xb6, 0xd6, 0xc7, 0xa0, 0x5e, + 0x3c, 0xb0, 0xc6, 0x2e, 0x58, 0x4d, 0xc6, 0x31, 0xca, 0x78, 0x44, 0x9c, 0xcc, 0xb2, 0x57, 0x39, + 0x8c, 0x0e, 0x68, 0x84, 0x28, 0x21, 0x31, 0x4e, 0x44, 0x7c, 0x51, 0xc4, 0x75, 0x97, 0xfb, 0xf5, + 0xf3, 0xab, 0x76, 0xed, 0xf2, 0xaa, 0x5d, 0xfb, 0xf3, 0xaa, 0x5d, 0x7b, 0x76, 0xdd, 0x5e, 0xb8, + 0xbc, 0x6e, 0x2f, 0xfc, 0x7e, 0xdd, 0x5e, 0xf8, 0xf2, 0x48, 0xbb, 0x62, 0x01, 0xa1, 0x31, 0xa1, + 0xea, 0xdf, 0x3e, 0x0d, 0xcf, 0x9d, 0x69, 0xf5, 0x29, 0xb6, 0x5f, 0x7c, 0x8b, 0xbd, 0xf3, 0xde, + 0xfe, 0xfc, 0xc7, 0x52, 0xff, 0x9e, 0x98, 0x28, 0x4f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x4c, + 0xb7, 0x2c, 0x8e, 0xba, 0x09, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { @@ -423,7 +416,7 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x60 + dAtA[i] = 0x58 } if m.AllowUpdateAfterExpiry { i-- @@ -433,14 +426,14 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x58 + dAtA[i] = 0x50 } if len(m.UpgradePath) > 0 { i -= len(m.UpgradePath) copy(dAtA[i:], m.UpgradePath) i = encodeVarintTendermint(dAtA, i, uint64(len(m.UpgradePath))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x4a } if len(m.ProofSpecs) > 0 { for iNdEx := len(m.ProofSpecs) - 1; iNdEx >= 0; iNdEx-- { @@ -453,21 +446,9 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTendermint(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x42 } } - if m.ConsensusParams != nil { - { - size, err := m.ConsensusParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTendermint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } { size, err := m.LatestHeight.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -488,29 +469,29 @@ func (m *ClientState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x32 - n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) + n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxClockDrift, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxClockDrift):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintTendermint(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x2a + n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) if err4 != nil { return 0, err4 } i -= n4 i = encodeVarintTendermint(dAtA, i, uint64(n4)) i-- - dAtA[i] = 0x2a - n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) + dAtA[i] = 0x22 + n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) if err5 != nil { return 0, err5 } i -= n5 i = encodeVarintTendermint(dAtA, i, uint64(n5)) i-- - dAtA[i] = 0x22 - n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.TrustingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.TrustingPeriod):]) - if err6 != nil { - return 0, err6 - } - i -= n6 - i = encodeVarintTendermint(dAtA, i, uint64(n6)) - i-- dAtA[i] = 0x1a { size, err := m.TrustLevel.MarshalToSizedBuffer(dAtA[:i]) @@ -569,12 +550,12 @@ func (m *ConsensusState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err9 != nil { - return 0, err9 + n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) + if err8 != nil { + return 0, err8 } - i -= n9 - i = encodeVarintTendermint(dAtA, i, uint64(n9)) + i -= n8 + i = encodeVarintTendermint(dAtA, i, uint64(n8)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -610,7 +591,7 @@ func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTendermint(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if m.Header1 != nil { { @@ -622,13 +603,6 @@ func (m *Misbehaviour) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTendermint(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintTendermint(dAtA, i, uint64(len(m.ChainId))) - i-- dAtA[i] = 0x12 } if len(m.ClientId) > 0 { @@ -776,10 +750,6 @@ func (m *ClientState) Size() (n int) { n += 1 + l + sovTendermint(uint64(l)) l = m.LatestHeight.Size() n += 1 + l + sovTendermint(uint64(l)) - if m.ConsensusParams != nil { - l = m.ConsensusParams.Size() - n += 1 + l + sovTendermint(uint64(l)) - } if len(m.ProofSpecs) > 0 { for _, e := range m.ProofSpecs { l = e.Size() @@ -826,10 +796,6 @@ func (m *Misbehaviour) Size() (n int) { if l > 0 { n += 1 + l + sovTendermint(uint64(l)) } - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovTendermint(uint64(l)) - } if m.Header1 != nil { l = m.Header1.Size() n += 1 + l + sovTendermint(uint64(l)) @@ -1145,42 +1111,6 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsensusParams", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTendermint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTendermint - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTendermint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ConsensusParams == nil { - m.ConsensusParams = &types1.ConsensusParams{} - } - if err := m.ConsensusParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ProofSpecs", wireType) } @@ -1214,7 +1144,7 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UpgradePath", wireType) } @@ -1246,7 +1176,7 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } m.UpgradePath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 11: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AllowUpdateAfterExpiry", wireType) } @@ -1266,7 +1196,7 @@ func (m *ClientState) Unmarshal(dAtA []byte) error { } } m.AllowUpdateAfterExpiry = bool(v != 0) - case 12: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AllowUpdateAfterMisbehaviour", wireType) } @@ -1525,38 +1455,6 @@ func (m *Misbehaviour) Unmarshal(dAtA []byte) error { m.ClientId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTendermint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTendermint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTendermint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Header1", wireType) } @@ -1592,7 +1490,7 @@ func (m *Misbehaviour) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Header2", wireType) } @@ -1711,7 +1609,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.SignedHeader == nil { - m.SignedHeader = &types3.SignedHeader{} + m.SignedHeader = &types2.SignedHeader{} } if err := m.SignedHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1747,7 +1645,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.ValidatorSet == nil { - m.ValidatorSet = &types3.ValidatorSet{} + m.ValidatorSet = &types2.ValidatorSet{} } if err := m.ValidatorSet.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1816,7 +1714,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.TrustedValidators == nil { - m.TrustedValidators = &types3.ValidatorSet{} + m.TrustedValidators = &types2.ValidatorSet{} } if err := m.TrustedValidators.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1889,7 +1787,7 @@ func (m *Fraction) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Numerator |= int64(b&0x7F) << shift + m.Numerator |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1908,7 +1806,7 @@ func (m *Fraction) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Denominator |= int64(b&0x7F) << shift + m.Denominator |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/ibc/light-clients/07-tendermint/types/tendermint_test.go b/x/ibc/light-clients/07-tendermint/types/tendermint_test.go index b175bfd5a5..c30a784a5c 100644 --- a/x/ibc/light-clients/07-tendermint/types/tendermint_test.go +++ b/x/ibc/light-clients/07-tendermint/types/tendermint_test.go @@ -11,7 +11,6 @@ import ( tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" @@ -61,6 +60,9 @@ func (suite *TendermintTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + // commit some blocks so that QueryProof returns valid proof (cannot return valid query if height <= 1) + suite.coordinator.CommitNBlocks(suite.chainA, 2) + suite.coordinator.CommitNBlocks(suite.chainB, 2) // TODO: deprecate usage in favor of testing package checkTx := false @@ -82,7 +84,7 @@ func (suite *TendermintTestSuite) SetupTest() { heightMinus1 := clienttypes.NewHeight(0, height.VersionHeight-1) - val := tmtypes.NewValidator(pubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 10) + val := tmtypes.NewValidator(pubKey, 10) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) suite.valsHash = suite.valSet.Hash() suite.header = suite.chainA.CreateTMClientHeader(chainID, int64(height.VersionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) diff --git a/x/ibc/light-clients/07-tendermint/types/update_test.go b/x/ibc/light-clients/07-tendermint/types/update_test.go index 2d075ad0a5..b75d71b827 100644 --- a/x/ibc/light-clients/07-tendermint/types/update_test.go +++ b/x/ibc/light-clients/07-tendermint/types/update_test.go @@ -5,7 +5,6 @@ import ( tmtypes "github.com/tendermint/tendermint/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types" commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" types "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" @@ -35,7 +34,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { heightMinus3 := clienttypes.NewHeight(height.VersionNumber, height.VersionHeight-3) heightPlus5 := clienttypes.NewHeight(height.VersionNumber, height.VersionHeight+5) - altVal := tmtypes.NewValidator(altPubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), versionHeight) + altVal := tmtypes.NewValidator(altPubKey, versionHeight) // Create bothValSet with both suite validator and altVal. Would be valid update bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) @@ -58,7 +57,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "successful update with next height and same validator set", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.headerTime, suite.valSet, suite.valSet, signers) currentTime = suite.now @@ -68,7 +67,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "successful update with future height and different validator set", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus5.VersionHeight), height, suite.headerTime, bothValSet, suite.valSet, bothSigners) currentTime = suite.now @@ -78,7 +77,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "successful update with next height and different validator set", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), bothValSet.Hash()) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.headerTime, bothValSet, bothValSet, bothSigners) currentTime = suite.now @@ -88,7 +87,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "successful update for a previous height", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) consStateHeight = heightMinus3 newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightMinus1.VersionHeight), heightMinus3, suite.headerTime, bothValSet, suite.valSet, bothSigners) @@ -99,7 +98,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "successful update for a previous version", setup: func() { - clientState = types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainIDVersion0, int64(height.VersionHeight), heightMinus3, suite.headerTime, bothValSet, suite.valSet, bothSigners) currentTime = suite.now @@ -109,7 +108,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update with incorrect header chain-id", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader("ethermint", int64(heightPlus1.VersionHeight), height, suite.headerTime, suite.valSet, suite.valSet, signers) currentTime = suite.now @@ -119,7 +118,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update to a future version", setup: func() { - clientState = types.NewClientState(chainIDVersion0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainIDVersion0, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainIDVersion1, 1, height, suite.headerTime, suite.valSet, suite.valSet, signers) currentTime = suite.now @@ -129,7 +128,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update: header height version and trusted height version mismatch", setup: func() { - clientState = types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainIDVersion1, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainIDVersion1, 3, height, suite.headerTime, suite.valSet, suite.valSet, signers) currentTime = suite.now @@ -139,7 +138,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update with next height: update header mismatches nextValSetHash", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.headerTime, bothValSet, suite.valSet, bothSigners) currentTime = suite.now @@ -149,7 +148,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update with next height: update header mismatches different nextValSetHash", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), bothValSet.Hash()) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.headerTime, suite.valSet, bothValSet, signers) currentTime = suite.now @@ -159,7 +158,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update with future height: too much change in validator set", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus5.VersionHeight), height, suite.headerTime, altValSet, suite.valSet, altSigners) currentTime = suite.now @@ -169,7 +168,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful updates, passed in incorrect trusted validators for given consensus state", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus5.VersionHeight), height, suite.headerTime, bothValSet, bothValSet, bothSigners) currentTime = suite.now @@ -179,7 +178,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update: trusting period has passed since last client timestamp", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.headerTime, suite.valSet, suite.valSet, signers) // make current time pass trusting period from last timestamp on clientstate @@ -190,7 +189,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update: header timestamp is past current timestamp", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.now.Add(time.Minute), suite.valSet, suite.valSet, signers) currentTime = suite.now @@ -200,7 +199,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "unsuccessful update: header timestamp is not past last client timestamp", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.clientTime, suite.valSet, suite.valSet, signers) currentTime = suite.now @@ -210,7 +209,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "header basic validation failed", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightPlus1.VersionHeight), height, suite.headerTime, suite.valSet, suite.valSet, signers) // cause new header to fail validatebasic by changing commit height to mismatch header height @@ -222,7 +221,7 @@ func (suite *TendermintTestSuite) TestCheckHeaderAndUpdateState() { { name: "header height < consensus height", setup: func() { - clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(height.VersionNumber, heightPlus5.VersionHeight), ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + clientState = types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(height.VersionNumber, heightPlus5.VersionHeight), commitmenttypes.GetSDKSpecs(), upgradePath, false, false) consensusState = types.NewConsensusState(suite.clientTime, commitmenttypes.NewMerkleRoot(suite.header.Header.GetAppHash()), suite.valsHash) // Make new header at height less than latest client state newHeader = suite.chainA.CreateTMClientHeader(chainID, int64(heightMinus1.VersionHeight), height, suite.headerTime, suite.valSet, suite.valSet, signers) diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade.go b/x/ibc/light-clients/07-tendermint/types/upgrade.go index 3c096f94a8..dcd3cd1a5f 100644 --- a/x/ibc/light-clients/07-tendermint/types/upgrade.go +++ b/x/ibc/light-clients/07-tendermint/types/upgrade.go @@ -3,7 +3,6 @@ package types import ( "fmt" "net/url" - "reflect" "strings" "github.com/cosmos/cosmos-sdk/codec" @@ -14,51 +13,54 @@ import ( "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" ) -// VerifyUpgrade checks if the upgraded client has been committed by the current client +// VerifyUpgradeAndUpdateState checks if the upgraded client has been committed by the current client // It will zero out all client-specific fields (e.g. TrustingPeriod and verify all data // in client state that must be the same across all valid Tendermint clients for the new chain. // VerifyUpgrade will return an error if: // - the upgradedClient is not a Tendermint ClientState +// - the lastest height of the client state does not have the same version number or has a greater +// height than the committed client. // - the height of upgraded client is not greater than that of current client -// - the latest height of the new client does not match the height in committed client +// - the latest height of the new client does not match or is greater than the height in committed client // - any Tendermint chain specified parameter in upgraded client such as ChainID, UnbondingPeriod, // and ProofSpecs do not match parameters set by committed client -func (cs ClientState) VerifyUpgrade( +func (cs ClientState) VerifyUpgradeAndUpdateState( ctx sdk.Context, cdc codec.BinaryMarshaler, clientStore sdk.KVStore, upgradedClient exported.ClientState, upgradeHeight exported.Height, proofUpgrade []byte, -) error { +) (exported.ClientState, exported.ConsensusState, error) { if cs.UpgradePath == "" { - return sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade client, no upgrade path set") + return nil, nil, sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade client, no upgrade path set") } upgradePath, err := constructUpgradeMerklePath(cs.UpgradePath, upgradeHeight) if err != nil { - return sdkerrors.Wrapf(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade client, unescaping key with URL format failed: %v", err) + return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade client, unescaping key with URL format failed: %v", err) } // UpgradeHeight must be in same version as client state height if cs.GetLatestHeight().GetVersionNumber() != upgradeHeight.GetVersionNumber() { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version at which upgrade occurs must be same as current client version. expected version %d, got %d", + return nil, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version at which upgrade occurs must be same as current client version. expected version %d, got %d", cs.GetLatestHeight().GetVersionNumber(), upgradeHeight.GetVersionNumber()) } - tmClient, ok := upgradedClient.(*ClientState) - if !ok { - return sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "upgraded client must be Tendermint client. expected: %T got: %T", - &ClientState{}, upgradedClient) + // UpgradeHeight must be greater than or equal to current client state height + if cs.GetLatestHeight().GetVersionHeight() > upgradeHeight.GetVersionHeight() { + return nil, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "version height at which upgrade occurs must be greater than or equal to current client height (%d > %d)", + cs.GetLatestHeight().GetVersionHeight(), upgradeHeight.GetVersionHeight(), + ) } if !upgradedClient.GetLatestHeight().GT(cs.GetLatestHeight()) { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "upgraded client height %s must be greater than current client height %s", + return nil, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "upgraded client height %s must be greater than current client height %s", upgradedClient.GetLatestHeight(), cs.GetLatestHeight()) } if len(proofUpgrade) == 0 { - return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "proof of upgrade is empty") + return nil, nil, sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "proof of upgrade is empty") } var merkleProof commitmenttypes.MerkleProof if err := cdc.UnmarshalBinaryBare(proofUpgrade, &merkleProof); err != nil { - return sdkerrors.Wrapf(commitmenttypes.ErrInvalidProof, "could not unmarshal merkle proof: %v", err) + return nil, nil, sdkerrors.Wrapf(commitmenttypes.ErrInvalidProof, "could not unmarshal merkle proof: %v", err) } // counterparty chain must commit the upgraded client with all client-customizable fields zeroed out @@ -66,7 +68,7 @@ func (cs ClientState) VerifyUpgrade( committedClient := upgradedClient.ZeroCustomFields() bz, err := codec.MarshalAny(cdc, committedClient) if err != nil { - return sdkerrors.Wrapf(clienttypes.ErrInvalidClient, "could not marshal client state: %v", err) + return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClient, "could not marshal client state: %v", err) } // Must prove against latest consensus state to ensure we are verifying against latest upgrade plan @@ -74,34 +76,38 @@ func (cs ClientState) VerifyUpgrade( // at this consensus state consState, err := GetConsensusState(clientStore, cdc, upgradeHeight) if err != nil { - return sdkerrors.Wrap(err, "could not retrieve consensus state for upgradeHeight") + return nil, nil, sdkerrors.Wrap(err, "could not retrieve consensus state for upgradeHeight") } if cs.IsExpired(consState.Timestamp, ctx.BlockTime()) { - return sdkerrors.Wrap(clienttypes.ErrInvalidClient, "cannot upgrade an expired client") + return nil, nil, sdkerrors.Wrap(clienttypes.ErrInvalidClient, "cannot upgrade an expired client") } tmCommittedClient, ok := committedClient.(*ClientState) if !ok { - return sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "upgraded client must be Tendermint client. expected: %T got: %T", + return nil, nil, sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "upgraded client must be Tendermint client. expected: %T got: %T", &ClientState{}, upgradedClient) } - // Relayer must keep all client-chosen parameters the same as the previous client. - // Compare relayer-provided client state against expected client state. + // Relayer chosen client parameters are ignored. // All chain-chosen parameters come from committed client, all client-chosen parameters - // come from current client - expectedClient := NewClientState( + // come from current client. + updatedClientState := NewClientState( tmCommittedClient.ChainId, cs.TrustLevel, cs.TrustingPeriod, tmCommittedClient.UnbondingPeriod, - cs.MaxClockDrift, tmCommittedClient.LatestHeight, tmCommittedClient.ConsensusParams, tmCommittedClient.ProofSpecs, tmCommittedClient.UpgradePath, + cs.MaxClockDrift, tmCommittedClient.LatestHeight, tmCommittedClient.ProofSpecs, tmCommittedClient.UpgradePath, cs.AllowUpdateAfterExpiry, cs.AllowUpdateAfterMisbehaviour, ) - if !reflect.DeepEqual(expectedClient, tmClient) { - return sdkerrors.Wrapf(clienttypes.ErrInvalidClient, "upgraded client does not maintain previous chosen parameters. expected: %v got: %v", - expectedClient, tmClient) + + if err := updatedClientState.Validate(); err != nil { + return nil, nil, sdkerrors.Wrap(err, "updated client state failed basic validation") } - return merkleProof.VerifyMembership(cs.ProofSpecs, consState.GetRoot(), upgradePath, bz) + if err := merkleProof.VerifyMembership(cs.ProofSpecs, consState.GetRoot(), upgradePath, bz); err != nil { + return nil, nil, err + } + + // TODO: Return valid consensus state https://github.com/cosmos/cosmos-sdk/issues/7708 + return updatedClientState, &ConsensusState{}, nil } // construct MerklePath from upgradePath @@ -117,5 +123,5 @@ func constructUpgradeMerklePath(upgradePath string, upgradeHeight exported.Heigh // append upgradeHeight to last key in merkle path // this will create the IAVL key that is used to store client in upgrade store upgradeKeys[len(upgradeKeys)-1] = fmt.Sprintf("%s/%d", lastKey, upgradeHeight.GetVersionHeight()) - return commitmenttypes.NewMerklePath(upgradeKeys), nil + return commitmenttypes.NewMerklePath(upgradeKeys...), nil } diff --git a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go index f5debb01a6..6bffb19408 100644 --- a/x/ibc/light-clients/07-tendermint/types/upgrade_test.go +++ b/x/ibc/light-clients/07-tendermint/types/upgrade_test.go @@ -5,7 +5,6 @@ import ( commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/23-commitment/types" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" - ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -26,7 +25,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "successful upgrade", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -37,7 +36,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -51,7 +50,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "successful upgrade with different client chosen parameters set in upgraded client", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -60,10 +59,10 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) // change upgradedClient client-specified parameters - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -71,7 +70,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // Previous client-chosen parameters must be the same as upgraded client chosen parameters tmClient, _ := cs.(*types.ClientState) - oldClient := types.NewClientState(tmClient.ChainId, types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, tmClient.LatestHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) + oldClient := types.NewClientState(tmClient.ChainId, types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, tmClient.LatestHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, oldClient) proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight()) @@ -82,7 +81,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: upgrade height version does not match current client version", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(10, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -93,7 +92,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -103,11 +102,37 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { }, expPass: false, }, + { + name: "unsuccessful upgrade: upgrade height version height is less than the current client version height", + setup: func() { + + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + + // upgrade Height is at next block + upgradeHeight = clienttypes.NewHeight(10, uint64(suite.chainB.GetContext().BlockHeight()-1)) + + // zero custom fields and store in upgrade store + suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) + + // commit upgrade store changes and update clients + + suite.coordinator.CommitBlock(suite.chainB) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) + suite.Require().NoError(err) + + cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) + suite.Require().True(found) + + proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight()) + }, + expPass: false, + }, + { name: "unsuccessful upgrade: chain-specified parameters do not match committed client", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -116,10 +141,10 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) // change upgradedClient client-specified parameters - upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, true) + upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, true) suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -133,15 +158,15 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: client-specified parameters do not match previous client", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // zero custom fields and store in upgrade store suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) // change upgradedClient client-specified parameters - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, upgradeHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, upgradeHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -154,7 +179,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { { name: "unsuccessful upgrade: proof is empty", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) proofUpgrade = []byte{} }, expPass: false, @@ -162,7 +187,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { { name: "unsuccessful upgrade: proof unmarshal failed", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) proofUpgrade = []byte("proof") }, expPass: false, @@ -171,7 +196,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: proof verification failed", setup: func() { // create but do not store upgraded client - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -187,7 +212,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: upgrade path is empty", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -198,7 +223,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -217,7 +242,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: upgrade path is malformed and cannot be correctly unescaped", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -228,7 +253,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -247,7 +272,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: upgraded height is not greater than current height", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, height, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) @@ -258,7 +283,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -272,7 +297,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: consensus state for upgrade height cannot be found", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // upgrade Height is at next block upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+100)) @@ -283,7 +308,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) @@ -297,14 +322,14 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: client is expired", setup: func() { - upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, ibctesting.DefaultConsensusParams, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, upgradeHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) // zero custom fields and store in upgrade store suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) // commit upgrade store changes and update clients suite.coordinator.CommitBlock(suite.chainB) - err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, ibctesting.Tendermint) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) suite.Require().NoError(err) // expire chainB's client @@ -317,6 +342,31 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { }, expPass: false, }, + { + name: "unsuccessful upgrade: updated unbonding period is equal to trusting period", + setup: func() { + + upgradedClient = types.NewClientState("newChainId", types.DefaultTrustLevel, trustingPeriod, trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + + // upgrade Height is at next block + upgradeHeight = clienttypes.NewHeight(0, uint64(suite.chainB.GetContext().BlockHeight()+1)) + + // zero custom fields and store in upgrade store + suite.chainB.App.UpgradeKeeper.SetUpgradedClient(suite.chainB.GetContext(), int64(upgradeHeight.GetVersionHeight()), upgradedClient) + + // commit upgrade store changes and update clients + + suite.coordinator.CommitBlock(suite.chainB) + err := suite.coordinator.UpdateClient(suite.chainA, suite.chainB, clientA, exported.Tendermint) + suite.Require().NoError(err) + + cs, found := suite.chainA.App.IBCKeeper.ClientKeeper.GetClientState(suite.chainA.GetContext(), clientA) + suite.Require().True(found) + + proofUpgrade, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedClientKey(int64(upgradeHeight.GetVersionHeight())), cs.GetLatestHeight().GetVersionHeight()) + }, + expPass: false, + }, } for _, tc := range testCases { @@ -325,14 +375,14 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { // reset suite suite.SetupTest() - clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint) + clientA, _ = suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) tc.setup() cs := suite.chainA.GetClientState(clientA) clientStore := suite.chainA.App.IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), clientA) - err := cs.VerifyUpgrade( + clientState, consensusState, err := cs.VerifyUpgradeAndUpdateState( suite.chainA.GetContext(), suite.cdc, clientStore, @@ -343,8 +393,14 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { if tc.expPass { suite.Require().NoError(err, "verify upgrade failed on valid case: %s", tc.name) + suite.Require().NotNil(clientState, "verify upgrade failed on valid case: %s", tc.name) + suite.Require().NotNil(consensusState, "verify upgrade failed on valid case: %s", tc.name) } else { suite.Require().Error(err, "verify upgrade passed on invalid case: %s", tc.name) + suite.Require().Nil(clientState, "verify upgrade passed on invalid case: %s", tc.name) + + suite.Require().Nil(consensusState, "verify upgrade passed on invalid case: %s", tc.name) + } } } diff --git a/x/ibc/light-clients/09-localhost/types/client_state.go b/x/ibc/light-clients/09-localhost/types/client_state.go index fa4223fc9a..32b799fccd 100644 --- a/x/ibc/light-clients/09-localhost/types/client_state.go +++ b/x/ibc/light-clients/09-localhost/types/client_state.go @@ -102,12 +102,12 @@ func (cs ClientState) CheckProposedHeaderAndUpdateState( return nil, nil, sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "cannot update localhost client with a proposal") } -// VerifyUpgrade returns an error since localhost cannot be upgraded -func (cs ClientState) VerifyUpgrade( +// VerifyUpgradeAndUpdateState returns an error since localhost cannot be upgraded +func (cs ClientState) VerifyUpgradeAndUpdateState( _ sdk.Context, _ codec.BinaryMarshaler, _ sdk.KVStore, _ exported.ClientState, _ exported.Height, _ []byte, -) error { - return sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade localhost client") +) (exported.ClientState, exported.ConsensusState, error) { + return nil, nil, sdkerrors.Wrap(clienttypes.ErrInvalidUpgradeClient, "cannot upgrade localhost client") } // VerifyClientState verifies that the localhost client state is stored locally @@ -115,8 +115,8 @@ func (cs ClientState) VerifyClientState( store sdk.KVStore, cdc codec.BinaryMarshaler, _ exported.Height, _ exported.Prefix, _ string, _ []byte, clientState exported.ClientState, ) error { - path := host.KeyClientState() - bz := store.Get(path) + path := host.KeyClientState + bz := store.Get([]byte(path)) if bz == nil { return sdkerrors.Wrapf(clienttypes.ErrFailedClientStateVerification, "not found for path: %s", path) @@ -154,7 +154,7 @@ func (cs ClientState) VerifyConnectionState( connectionID string, connectionEnd exported.ConnectionI, ) error { - path := host.KeyConnection(connectionID) + path := host.ConnectionKey(connectionID) bz := store.Get(path) if bz == nil { return sdkerrors.Wrapf(clienttypes.ErrFailedConnectionStateVerification, "not found for path %s", path) @@ -188,7 +188,7 @@ func (cs ClientState) VerifyChannelState( channelID string, channel exported.ChannelI, ) error { - path := host.KeyChannel(portID, channelID) + path := host.ChannelKey(portID, channelID) bz := store.Get(path) if bz == nil { return sdkerrors.Wrapf(clienttypes.ErrFailedChannelStateVerification, "not found for path %s", path) @@ -223,7 +223,7 @@ func (cs ClientState) VerifyPacketCommitment( sequence uint64, commitmentBytes []byte, ) error { - path := host.KeyPacketCommitment(portID, channelID, sequence) + path := host.PacketCommitmentKey(portID, channelID, sequence) data := store.Get(path) if len(data) == 0 { @@ -253,7 +253,7 @@ func (cs ClientState) VerifyPacketAcknowledgement( sequence uint64, acknowledgement []byte, ) error { - path := host.KeyPacketAcknowledgement(portID, channelID, sequence) + path := host.PacketAcknowledgementKey(portID, channelID, sequence) data := store.Get(path) if len(data) == 0 { @@ -283,7 +283,7 @@ func (cs ClientState) VerifyPacketReceiptAbsence( channelID string, sequence uint64, ) error { - path := host.KeyPacketReceipt(portID, channelID, sequence) + path := host.PacketReceiptKey(portID, channelID, sequence) data := store.Get(path) if data != nil { @@ -305,7 +305,7 @@ func (cs ClientState) VerifyNextSequenceRecv( channelID string, nextSequenceRecv uint64, ) error { - path := host.KeyNextSequenceRecv(portID, channelID) + path := host.NextSequenceRecvKey(portID, channelID) data := store.Get(path) if len(data) == 0 { diff --git a/x/ibc/light-clients/09-localhost/types/client_state_test.go b/x/ibc/light-clients/09-localhost/types/client_state_test.go index f56cec5d7a..a4443867d7 100644 --- a/x/ibc/light-clients/09-localhost/types/client_state_test.go +++ b/x/ibc/light-clients/09-localhost/types/client_state_test.go @@ -66,7 +66,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientState() { clientState: clientState, malleate: func() { bz := clienttypes.MustMarshalClientState(suite.cdc, clientState) - suite.store.Set(host.KeyClientState(), bz) + suite.store.Set(host.ClientStateKey(), bz) }, counterparty: clientState, expPass: true, @@ -76,7 +76,7 @@ func (suite *LocalhostTestSuite) TestVerifyClientState() { clientState: clientState, malleate: func() { bz := clienttypes.MustMarshalClientState(suite.cdc, clientState) - suite.store.Set(host.KeyClientState(), bz) + suite.store.Set(host.ClientStateKey(), bz) }, counterparty: invalidClient, expPass: false, @@ -161,7 +161,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { malleate: func() { bz, err := suite.cdc.MarshalBinaryBare(&conn1) suite.Require().NoError(err) - suite.store.Set(host.KeyConnection(testConnectionID), bz) + suite.store.Set(host.ConnectionKey(testConnectionID), bz) }, connection: conn1, expPass: true, @@ -177,7 +177,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { name: "proof verification failed: unmarshal error", clientState: types.NewClientState("chainID", clientHeight), malleate: func() { - suite.store.Set(host.KeyConnection(testConnectionID), []byte("connection")) + suite.store.Set(host.ConnectionKey(testConnectionID), []byte("connection")) }, connection: conn1, expPass: false, @@ -188,7 +188,7 @@ func (suite *LocalhostTestSuite) TestVerifyConnectionState() { malleate: func() { bz, err := suite.cdc.MarshalBinaryBare(&conn2) suite.Require().NoError(err) - suite.store.Set(host.KeyConnection(testConnectionID), bz) + suite.store.Set(host.ConnectionKey(testConnectionID), bz) }, connection: conn1, expPass: false, @@ -233,7 +233,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { malleate: func() { bz, err := suite.cdc.MarshalBinaryBare(&ch1) suite.Require().NoError(err) - suite.store.Set(host.KeyChannel(testPortID, testChannelID), bz) + suite.store.Set(host.ChannelKey(testPortID, testChannelID), bz) }, channel: ch1, expPass: true, @@ -249,7 +249,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { name: "proof verification failed: unmarshal failed", clientState: types.NewClientState("chainID", clientHeight), malleate: func() { - suite.store.Set(host.KeyChannel(testPortID, testChannelID), []byte("channel")) + suite.store.Set(host.ChannelKey(testPortID, testChannelID), []byte("channel")) }, channel: ch1, @@ -261,7 +261,7 @@ func (suite *LocalhostTestSuite) TestVerifyChannelState() { malleate: func() { bz, err := suite.cdc.MarshalBinaryBare(&ch2) suite.Require().NoError(err) - suite.store.Set(host.KeyChannel(testPortID, testChannelID), bz) + suite.store.Set(host.ChannelKey(testPortID, testChannelID), bz) }, channel: ch1, @@ -302,7 +302,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set( - host.KeyPacketCommitment(testPortID, testChannelID, testSequence), []byte("commitment"), + host.PacketCommitmentKey(testPortID, testChannelID, testSequence), []byte("commitment"), ) }, commitment: []byte("commitment"), @@ -313,7 +313,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketCommitment() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set( - host.KeyPacketCommitment(testPortID, testChannelID, testSequence), []byte("different"), + host.PacketCommitmentKey(testPortID, testChannelID, testSequence), []byte("different"), ) }, commitment: []byte("commitment"), @@ -361,7 +361,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set( - host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("acknowledgement"), + host.PacketAcknowledgementKey(testPortID, testChannelID, testSequence), []byte("acknowledgement"), ) }, ack: []byte("acknowledgement"), @@ -372,7 +372,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketAcknowledgement() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set( - host.KeyPacketAcknowledgement(testPortID, testChannelID, testSequence), []byte("different"), + host.PacketAcknowledgementKey(testPortID, testChannelID, testSequence), []byte("different"), ) }, ack: []byte("acknowledgement"), @@ -416,7 +416,7 @@ func (suite *LocalhostTestSuite) TestVerifyPacketReceiptAbsence() { suite.Require().NoError(err, "receipt absence failed") - suite.store.Set(host.KeyPacketReceipt(testPortID, testChannelID, testSequence), []byte("receipt")) + suite.store.Set(host.PacketReceiptKey(testPortID, testChannelID, testSequence), []byte("receipt")) err = clientState.VerifyPacketReceiptAbsence( suite.store, suite.cdc, clientHeight, nil, nil, testPortID, testChannelID, testSequence, @@ -439,7 +439,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set( - host.KeyNextSequenceRecv(testPortID, testChannelID), + host.NextSequenceRecvKey(testPortID, testChannelID), sdk.Uint64ToBigEndian(nextSeqRecv), ) }, @@ -451,7 +451,7 @@ func (suite *LocalhostTestSuite) TestVerifyNextSeqRecv() { clientState: types.NewClientState("chainID", clientHeight), malleate: func() { suite.store.Set( - host.KeyNextSequenceRecv(testPortID, testChannelID), + host.NextSequenceRecvKey(testPortID, testChannelID), sdk.Uint64ToBigEndian(3), ) }, diff --git a/x/ibc/spec/README.md b/x/ibc/spec/README.md new file mode 100644 index 0000000000..a699c10abd --- /dev/null +++ b/x/ibc/spec/README.md @@ -0,0 +1,114 @@ + + +# `ibc` + +## Abstract + +This specification defines the implementation of the IBC protocol on the Cosmos SDK, the +changes made to the specification and where to find each specific ICS spec within +the module. + +For the general specification please refer to the [Interchain Standards](https://github.com/cosmos/ics). + +## Contents + +1. **Applications** + + 1.1. [Transfer](./../applications/transfer/spec/README.md) +2. **[Core](./../core/spec/README.md)** +3. **Light Clients** + + 3.1 [Solo Machine Client](./../light-clients/06-solomachine/spec/README.md) + + 3.2 [Tendermint Client](./../light-clients/07-tendermint/spec/README.md) + + 3.3 [Localhost Client](./../light-clients/09-localhost/spec/README.md) + +## Implementation Details + +As stated above, the IBC implementation on the Cosmos SDK introduces some changes +to the general specification, in order to avoid code duplication and to take +advantage of the SDK architectural components such as the transaction routing +through `Handlers`. + +### Interchain Standards reference + +The following list is a mapping from each Interchain Standard to their implementation +in the SDK's `x/ibc` module: + +* [ICS 002 - Client Semantics](https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics): Implemented in [`x/ibc/core/02-client`](https://github.com/cosmos/tree/master/ibc/core/02-client) +* [ICS 003 - Connection Semantics](https://github.com/cosmos/ics/blob/master/spec/ics-003-connection-semantics): Implemented in [`x/ibc/core/03-connection`](https://github.com/cosmos/tree/master/ibc/core/03-connection) +* [ICS 004 - Channel and Packet Semantics](https://github.com/cosmos/ics/blob/master/spec/ics-004-channel-and-packet-semantics): Implemented in [`x/ibc/core/04-channel`](https://github.com/cosmos/tree/master/ibc/core/04-channel) +* [ICS 005 - Port Allocation](https://github.com/cosmos/ics/blob/master/spec/ics-005-port-allocation): Implemented in [`x/ibc/core/05-port`](https://github.com/cosmos/tree/master/ibc/core/05-port) +* [ICS 006 - Solo Machine Client](https://github.com/cosmos/ics/blob/master/spec/ics-006-solo-machine-client): Implemented in [`x/ibc/light-clients/06-solomachine`](https://github.com/cosmos/tree/master/ibc/solomachine) +* [ICS 007 - Tendermint Client](https://github.com/cosmos/ics/blob/master/spec/ics-007-tendermint-client): Implemented in [`x/ibc/light-clients/07-tendermint`](https://github.com/cosmos/tree/master/ibc/light-clients/07-tendermint) +* [ICS 009 - Loopback Client](https://github.com/cosmos/ics/blob/master/spec/ics-009-loopback-client): Implemented in [`x/ibc/light-clients/09-localhost`](https://github.com/cosmos/tree/master/ibc/light-clients/09-localhost) +* [ICS 018- Relayer Algorithms](https://github.com/cosmos/ics/tree/master/spec/ics-018-relayer-algorithms): Implemented in it's own [relayer repository](https://github.com/cosmos/relayer) +* [ICS 020 - Fungible Token Transfer](https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer): Implemented in [`x/ibc/applications/transfer`](https://github.com/cosmos/tree/master/ibc/applications/transfer) +* [ICS 023 - Vector Commitments](https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments): Implemented in [`x/ibc/core/23-commitment`](https://github.com/cosmos/tree/master/ibc/core/23-commitment) +* [ICS 024 - Host Requirements](https://github.com/cosmos/ics/tree/master/spec/ics-024-host-requirements): Implemented in [`x/ibc/core/24-host`](https://github.com/cosmos/tree/master/ibc/core/24-host) +* [ICS 025 - Handler Interface](https://github.com/cosmos/ics/tree/master/spec/ics-025-handler-interface): `Handler` interfaces are implemented at the top level in `x/ibc/handler.go`, +which call each ICS submodule's handlers (i.e `x/ibc/*/{XX-ICS}/handler.go`). +* [ICS 026 - Routing Module](https://github.com/cosmos/ics/blob/master/spec/ics-026-routing-module): Replaced by [ADR 15 - IBC Packet Receiver](../../../docs/architecture/adr-015-ibc-packet-receiver.md). + +### Architecture Decision Records (ADR) + +The following ADR provide the design and architecture decision of IBC-related components. + +* [ADR 001 - Coin Source Tracing](../../../docs/architecture/adr-001-coin-source-tracing.md): standard to hash the ICS20's fungible token +denomination trace path in order to support special characters and limit the maximum denomination length. +* [ADR 17 - Historical Header Module](../../../docs/architecture/adr-017-historical-header-module.md): Introduces the ability to introspect past +consensus states in order to verify their membership in the counterparty clients. +* [ADR 19 - Protobuf State Encoding](../../../docs/architecture/adr-019-protobuf-state-encoding.md): Migration from Amino to Protobuf for state encoding. +* [ADR 020 - Protocol Buffer Transaction Encoding](./../../docs/architecture/adr-020-protobuf-transaction-encoding.md): Client side migration to Protobuf. +* [ADR 021 - Protocol Buffer Query Encoding](../../../docs/architecture/adr-020-protobuf-query-encoding.md): Queries migration to Protobuf. +* [ADR 026 - IBC Client Recovery Mechanisms](../../../docs/architecture/adr-026-ibc-client-recovery-mechanisms.md): Allows IBC Clients to be recovered after freezing or expiry. + +### SDK Modules + +* [`x/capability`](https://github.com/cosmos/tree/master/x/capability): The capability module provides object-capability keys support through scoped keepers in order to authenticate usage of ports or channels. Check [ADR 3 - Dynamic Capability Store](../../../docs/architecture/adr-003-dynamic-capability-store.md) for more details. + +## IBC module architecture + +> **NOTE for auditors**: If you're not familiar with the overall module structure from +the SDK modules, please check this [document](../../../docs/building-modules/structure.md) as +prerequisite reading. + +For ease of auditing, every Interchain Standard has been developed in its own +package. The development team separated the IBC TAO (Transport, Authentication, Ordering) ICS specifications from the IBC application level +specification. The following tree describes the architecture of the directories that +the `ibc` (TAO) and `ibc-transfer` ([ICS20](https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer)) modules: + +```shell +x/ibc +├── applications/ +│ └──transfer/ +├── core/ +│   ├── 02-client/ +│   ├── 03-connection/ +│   ├── 04-channel/ +│   ├── 05-port/ +│   ├── 23-commitment/ +│   ├── 24-host/ +│  ├── client +│  │   └── cli +│ │       └── cli.go +│  ├── keeper +│  │ ├── keeper.go +│   │ └── querier.go +│ ├── types +│ │ ├── errors.go +│ │ └── keys.go +│ ├── handler.go +│ └── module.go +├── light-clients/ +│   ├── 06-solomachine/ +│   ├── 07-tendermint/ +│   └── 09-localhost/ +└── testing/ +``` diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 2c0554c6aa..2d3172b938 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmprotoversion "github.com/tendermint/tendermint/proto/tendermint/version" @@ -34,17 +33,13 @@ import ( host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host" "github.com/cosmos/cosmos-sdk/x/ibc/core/exported" "github.com/cosmos/cosmos-sdk/x/ibc/core/types" - solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/06-solomachine/types" ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types" "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock" + "github.com/cosmos/cosmos-sdk/x/staking/teststaking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) const ( - // client types - Tendermint = ibctmtypes.Tendermint - SoloMachine = solomachinetypes.SoloMachine - // Default params constants used to create a TM client TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2 UnbondingPeriod time.Duration = time.Hour * 24 * 7 * 3 @@ -65,8 +60,6 @@ const ( ) var ( - DefaultConsensusParams = simapp.DefaultConsensusParams - DefaultOpenInitVersion *connectiontypes.Version // Default params variables used to create a TM client @@ -80,14 +73,6 @@ var ( MockAcknowledgement = mock.MockAcknowledgement MockCommitment = mock.MockCommitment - - // Conditionals for expected output of executing messages. - // Change values to false to test messages expected to fail. - // Reset to true otherwise successful messages will error. - // Use in rare cases, will be deprecated in favor of better - // dev ux. - ExpSimPassSend = true - ExpPassSend = true ) // TestChain is a testing struct that wraps a simapp with the last TM Header, the current ABCI @@ -109,7 +94,7 @@ type TestChain struct { Vals *tmtypes.ValidatorSet Signers []tmtypes.PrivValidator - senderPrivKey crypto.PrivKey + senderPrivKey cryptotypes.PrivKey SenderAccount authtypes.AccountI // IBC specific helpers @@ -132,7 +117,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain { require.NoError(t, err) // create validator set with single validator - validator := tmtypes.NewValidator(pubKey.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 1) + validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) signers := []tmtypes.PrivValidator{privVal} @@ -183,8 +168,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain { // GetContext returns the current context for the application. func (chain *TestChain) GetContext() sdk.Context { - ctx := chain.App.BaseApp.NewContext(false, chain.CurrentHeader) - return ctx.WithConsensusParams(DefaultConsensusParams) + return chain.App.BaseApp.NewContext(false, chain.CurrentHeader) } // QueryProof performs an abci query with the given key and returns the proto encoded merkle proof @@ -197,9 +181,8 @@ func (chain *TestChain) QueryProof(key []byte) ([]byte, clienttypes.Height) { Prove: true, }) - merkleProof := commitmenttypes.MerkleProof{ - Proof: res.ProofOps, - } + merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) + require.NoError(chain.t, err) proof, err := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) require.NoError(chain.t, err) @@ -222,9 +205,8 @@ func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, cl Prove: true, }) - merkleProof := commitmenttypes.MerkleProof{ - Proof: res.ProofOps, - } + merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) + require.NoError(chain.t, err) proof, err := chain.App.AppCodec().MarshalBinaryBare(&merkleProof) require.NoError(chain.t, err) @@ -244,7 +226,7 @@ func (chain *TestChain) QueryClientStateProof(clientID string) (exported.ClientS clientState, found := chain.App.IBCKeeper.ClientKeeper.GetClientState(chain.GetContext(), clientID) require.True(chain.t, found) - clientKey := host.FullKeyClientPath(clientID, host.KeyClientState()) + clientKey := host.FullClientStateKey(clientID) proofClient, _ := chain.QueryProof(clientKey) return clientState, proofClient @@ -256,7 +238,7 @@ func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clien clientState := chain.GetClientState(clientID) consensusHeight := clientState.GetLatestHeight().(clienttypes.Height) - consensusKey := host.FullKeyClientPath(clientID, host.KeyConsensusState(consensusHeight)) + consensusKey := host.FullConsensusStateKey(clientID, consensusHeight) proofConsensus, _ := chain.QueryProof(consensusKey) return proofConsensus, consensusHeight @@ -306,7 +288,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { chain.ChainID, []uint64{chain.SenderAccount.GetAccountNumber()}, []uint64{chain.SenderAccount.GetSequence()}, - ExpSimPassSend, ExpPassSend, chain.senderPrivKey, + true, true, chain.senderPrivKey, ) if err != nil { return nil, err @@ -346,7 +328,7 @@ func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bo valSet := stakingtypes.Validators(histInfo.Valset) - tmValidators, err := valSet.ToTmValidators() + tmValidators, err := teststaking.ToTmValidators(valSet) if err != nil { panic(err) } @@ -434,15 +416,14 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client ) switch clientType { - case Tendermint: + case exported.Tendermint: height := counterparty.LastHeader.GetHeight().(clienttypes.Height) clientState = ibctmtypes.NewClientState( counterparty.ChainID, DefaultTrustLevel, TrustingPeriod, UnbondingPeriod, MaxClockDrift, - height, counterparty.App.GetConsensusParams(counterparty.GetContext()), commitmenttypes.GetSDKSpecs(), - UpgradePath, false, false, + height, commitmenttypes.GetSDKSpecs(), UpgradePath, false, false, ) consensusState = counterparty.LastHeader.ConsensusState() - case SoloMachine: + case exported.Solomachine: solo := NewSolomachine(chain.t, chain.Codec, clientID, "", 1) clientState = solo.ClientState() consensusState = solo.ConsensusState() @@ -461,7 +442,7 @@ func (chain *TestChain) ConstructMsgCreateClient(counterparty *TestChain, client // client will be created on the (target) chain. func (chain *TestChain) CreateTMClient(counterparty *TestChain, clientID string) error { // construct MsgCreateClient using counterparty - msg := chain.ConstructMsgCreateClient(counterparty, clientID, Tendermint) + msg := chain.ConstructMsgCreateClient(counterparty, clientID, exported.Tendermint) return chain.sendMsgs(msg) } @@ -647,7 +628,7 @@ func (chain *TestChain) ConnectionOpenTry( ) error { counterpartyClient, proofClient := counterparty.QueryClientStateProof(counterpartyConnection.ClientID) - connectionKey := host.KeyConnection(counterpartyConnection.ID) + connectionKey := host.ConnectionKey(counterpartyConnection.ID) proofInit, proofHeight := counterparty.QueryProof(connectionKey) proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID) @@ -670,7 +651,7 @@ func (chain *TestChain) ConnectionOpenAck( ) error { counterpartyClient, proofClient := counterparty.QueryClientStateProof(counterpartyConnection.ClientID) - connectionKey := host.KeyConnection(counterpartyConnection.ID) + connectionKey := host.ConnectionKey(counterpartyConnection.ID) proofTry, proofHeight := counterparty.QueryProof(connectionKey) proofConsensus, consensusHeight := counterparty.QueryConsensusStateProof(counterpartyConnection.ClientID) @@ -690,7 +671,7 @@ func (chain *TestChain) ConnectionOpenConfirm( counterparty *TestChain, connection, counterpartyConnection *TestConnection, ) error { - connectionKey := host.KeyConnection(counterpartyConnection.ID) + connectionKey := host.ConnectionKey(counterpartyConnection.ID) proof, height := counterparty.QueryProof(connectionKey) msg := connectiontypes.NewMsgConnectionOpenConfirm( @@ -790,7 +771,7 @@ func (chain *TestChain) ChanOpenTry( order channeltypes.Order, connectionID string, ) error { - proof, height := counterparty.QueryProof(host.KeyChannel(counterpartyCh.PortID, counterpartyCh.ID)) + proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID)) msg := channeltypes.NewMsgChannelOpenTry( ch.PortID, ch.ID, ch.ID, // testing doesn't use flexible selection @@ -808,7 +789,7 @@ func (chain *TestChain) ChanOpenAck( counterparty *TestChain, ch, counterpartyCh TestChannel, ) error { - proof, height := counterparty.QueryProof(host.KeyChannel(counterpartyCh.PortID, counterpartyCh.ID)) + proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID)) msg := channeltypes.NewMsgChannelOpenAck( ch.PortID, ch.ID, @@ -824,7 +805,7 @@ func (chain *TestChain) ChanOpenConfirm( counterparty *TestChain, ch, counterpartyCh TestChannel, ) error { - proof, height := counterparty.QueryProof(host.KeyChannel(counterpartyCh.PortID, counterpartyCh.ID)) + proof, height := counterparty.QueryProof(host.ChannelKey(counterpartyCh.PortID, counterpartyCh.ID)) msg := channeltypes.NewMsgChannelOpenConfirm( ch.PortID, ch.ID, diff --git a/x/ibc/testing/chain_test.go b/x/ibc/testing/chain_test.go index 243eb06447..bf5af6de63 100644 --- a/x/ibc/testing/chain_test.go +++ b/x/ibc/testing/chain_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" tmtypes "github.com/tendermint/tendermint/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing" "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock" ) @@ -20,8 +19,8 @@ func TestCreateSortedSignerArray(t *testing.T) { pubKey2, err := privVal2.GetPubKey() require.NoError(t, err) - validator1 := tmtypes.NewValidator(pubKey1.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 1) - validator2 := tmtypes.NewValidator(pubKey2.(cryptotypes.IntoTmPubKey).AsTmPubKey(), 2) + validator1 := tmtypes.NewValidator(pubKey1, 1) + validator2 := tmtypes.NewValidator(pubKey2, 2) expected := []tmtypes.PrivValidator{privVal2, privVal1} diff --git a/x/ibc/testing/coordinator.go b/x/ibc/testing/coordinator.go index 7ead436abe..b1c6e99d3f 100644 --- a/x/ibc/testing/coordinator.go +++ b/x/ibc/testing/coordinator.go @@ -49,7 +49,7 @@ func NewCoordinator(t *testing.T, n int) *Coordinator { func (coord *Coordinator) Setup( chainA, chainB *TestChain, order channeltypes.Order, ) (string, string, *TestConnection, *TestConnection, TestChannel, TestChannel) { - clientA, clientB, connA, connB := coord.SetupClientConnections(chainA, chainB, Tendermint) + clientA, clientB, connA, connB := coord.SetupClientConnections(chainA, chainB, exported.Tendermint) // channels can also be referenced through the returned connections channelA, channelB := coord.CreateMockChannels(chainA, chainB, connA, connB, order) @@ -98,7 +98,7 @@ func (coord *Coordinator) CreateClient( clientID = source.NewClientID(counterparty.ChainID) switch clientType { - case Tendermint: + case exported.Tendermint: err = source.CreateTMClient(counterparty, clientID) default: @@ -123,7 +123,7 @@ func (coord *Coordinator) UpdateClient( coord.CommitBlock(source, counterparty) switch clientType { - case Tendermint: + case exported.Tendermint: err = source.UpdateTMClient(counterparty, clientID) default: @@ -226,7 +226,7 @@ func (coord *Coordinator) SendPacket( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - counterpartyClientID, Tendermint, + counterpartyClientID, exported.Tendermint, ) } @@ -238,7 +238,7 @@ func (coord *Coordinator) RecvPacket( packet channeltypes.Packet, ) error { // get proof of packet commitment on source - packetKey := host.KeyPacketCommitment(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) + packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) proof, proofHeight := source.QueryProof(packetKey) recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, counterparty.SenderAccount.GetAddress()) @@ -262,7 +262,7 @@ func (coord *Coordinator) WriteAcknowledgement( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - counterpartyClientID, Tendermint, + counterpartyClientID, exported.Tendermint, ) } @@ -277,7 +277,7 @@ func (coord *Coordinator) AcknowledgePacket( packet channeltypes.Packet, ack []byte, ) error { // get proof of acknowledgement on counterparty - packetKey := host.KeyPacketAcknowledgement(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) + packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) proof, proofHeight := counterparty.QueryProof(packetKey) ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, source.SenderAccount.GetAddress()) @@ -327,7 +327,7 @@ func (coord *Coordinator) SendMsgs(source, counterparty *TestChain, counterparty // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - counterpartyClientID, Tendermint, + counterpartyClientID, exported.Tendermint, ) } @@ -386,7 +386,7 @@ func (coord *Coordinator) ConnOpenInit( // update source client on counterparty connection if err := coord.UpdateClient( counterparty, source, - counterpartyClientID, Tendermint, + counterpartyClientID, exported.Tendermint, ); err != nil { return sourceConnection, counterpartyConnection, err } @@ -409,7 +409,7 @@ func (coord *Coordinator) ConnOpenTry( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - counterpartyConnection.ClientID, Tendermint, + counterpartyConnection.ClientID, exported.Tendermint, ) } @@ -428,7 +428,7 @@ func (coord *Coordinator) ConnOpenAck( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - counterpartyConnection.ClientID, Tendermint, + counterpartyConnection.ClientID, exported.Tendermint, ) } @@ -446,7 +446,7 @@ func (coord *Coordinator) ConnOpenConfirm( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - counterpartyConnection.ClientID, Tendermint, + counterpartyConnection.ClientID, exported.Tendermint, ) } @@ -478,7 +478,7 @@ func (coord *Coordinator) ChanOpenInit( // update source client on counterparty connection if err := coord.UpdateClient( counterparty, source, - counterpartyConnection.ClientID, Tendermint, + counterpartyConnection.ClientID, exported.Tendermint, ); err != nil { return sourceChannel, counterpartyChannel, err } @@ -518,7 +518,7 @@ func (coord *Coordinator) ChanOpenInitOnBothChains( // update counterparty client on source connection if err := coord.UpdateClient( source, counterparty, - connection.ClientID, Tendermint, + connection.ClientID, exported.Tendermint, ); err != nil { return sourceChannel, counterpartyChannel, err } @@ -526,7 +526,7 @@ func (coord *Coordinator) ChanOpenInitOnBothChains( // update source client on counterparty connection if err := coord.UpdateClient( counterparty, source, - counterpartyConnection.ClientID, Tendermint, + counterpartyConnection.ClientID, exported.Tendermint, ); err != nil { return sourceChannel, counterpartyChannel, err } @@ -552,7 +552,7 @@ func (coord *Coordinator) ChanOpenTry( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - connection.CounterpartyClientID, Tendermint, + connection.CounterpartyClientID, exported.Tendermint, ) } @@ -571,7 +571,7 @@ func (coord *Coordinator) ChanOpenAck( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - sourceChannel.CounterpartyClientID, Tendermint, + sourceChannel.CounterpartyClientID, exported.Tendermint, ) } @@ -590,7 +590,7 @@ func (coord *Coordinator) ChanOpenConfirm( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - sourceChannel.CounterpartyClientID, Tendermint, + sourceChannel.CounterpartyClientID, exported.Tendermint, ) } @@ -611,7 +611,7 @@ func (coord *Coordinator) ChanCloseInit( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - channel.CounterpartyClientID, Tendermint, + channel.CounterpartyClientID, exported.Tendermint, ) } @@ -630,6 +630,6 @@ func (coord *Coordinator) SetChannelClosed( // update source client on counterparty connection return coord.UpdateClient( counterparty, source, - testChannel.CounterpartyClientID, Tendermint, + testChannel.CounterpartyClientID, exported.Tendermint, ) } diff --git a/x/ibc/testing/mock/privval.go b/x/ibc/testing/mock/privval.go index ec40a8aad6..fe46659b3d 100644 --- a/x/ibc/testing/mock/privval.go +++ b/x/ibc/testing/mock/privval.go @@ -5,7 +5,9 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) var _ tmtypes.PrivValidator = PV{} @@ -13,7 +15,7 @@ var _ tmtypes.PrivValidator = PV{} // MockPV implements PrivValidator without any safety or persistence. // Only use it for testing. type PV struct { - PrivKey crypto.PrivKey + PrivKey cryptotypes.PrivKey } func NewPV() PV { @@ -22,7 +24,7 @@ func NewPV() PV { // GetPubKey implements PrivValidator interface func (pv PV) GetPubKey() (crypto.PubKey, error) { - return pv.PrivKey.PubKey(), nil + return cryptocodec.ToTmPubKeyInterface(pv.PrivKey.PubKey()) } // SignVote implements PrivValidator interface diff --git a/x/ibc/testing/solomachine.go b/x/ibc/testing/solomachine.go index 21b02516e9..03fe887b85 100644 --- a/x/ibc/testing/solomachine.go +++ b/x/ibc/testing/solomachine.go @@ -4,11 +4,11 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/codec" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -28,9 +28,9 @@ type Solomachine struct { cdc codec.BinaryMarshaler ClientID string - PrivateKeys []crypto.PrivKey // keys used for signing - PublicKeys []crypto.PubKey // keys used for generating solo machine pub key - PublicKey crypto.PubKey // key used for verification + PrivateKeys []cryptotypes.PrivKey // keys used for signing + PublicKeys []cryptotypes.PubKey // keys used for generating solo machine pub key + PublicKey cryptotypes.PubKey // key used for verification Sequence uint64 Time uint64 Diversifier string @@ -63,17 +63,17 @@ func NewSolomachine(t *testing.T, cdc codec.BinaryMarshaler, clientID, diversifi // The key type can be swapped for any key type supported by the PublicKey // interface, if needed. The same is true for the amino based Multisignature // public key. -func GenerateKeys(t *testing.T, n uint64) ([]crypto.PrivKey, []crypto.PubKey, crypto.PubKey) { +func GenerateKeys(t *testing.T, n uint64) ([]cryptotypes.PrivKey, []cryptotypes.PubKey, cryptotypes.PubKey) { require.NotEqual(t, uint64(0), n, "generation of zero keys is not allowed") - privKeys := make([]crypto.PrivKey, n) - pubKeys := make([]crypto.PubKey, n) + privKeys := make([]cryptotypes.PrivKey, n) + pubKeys := make([]cryptotypes.PubKey, n) for i := uint64(0); i < n; i++ { privKeys[i] = secp256k1.GenPrivKey() pubKeys[i] = privKeys[i].PubKey() } - var pk crypto.PubKey + var pk cryptotypes.PubKey if len(privKeys) > 1 { // generate multi sig pk pk = kmultisig.NewLegacyAminoPubKey(int(n), pubKeys) @@ -251,8 +251,7 @@ func (solo *Solomachine) GenerateSignature(signBytes []byte) []byte { // GetClientStatePath returns the commitment path for the client state. func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string) commitmenttypes.MerklePath { - clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ClientStatePath() - path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath) + path, err := commitmenttypes.ApplyPrefix(prefix, commitmenttypes.NewMerklePath(host.FullClientStatePath(counterpartyClientIdentifier))) require.NoError(solo.t, err) return path @@ -260,8 +259,7 @@ func (solo *Solomachine) GetClientStatePath(counterpartyClientIdentifier string) // GetConsensusStatePath returns the commitment path for the consensus state. func (solo *Solomachine) GetConsensusStatePath(counterpartyClientIdentifier string, consensusHeight exported.Height) commitmenttypes.MerklePath { - clientPrefixedPath := "clients/" + counterpartyClientIdentifier + "/" + host.ConsensusStatePath(consensusHeight) - path, err := commitmenttypes.ApplyPrefix(prefix, clientPrefixedPath) + path, err := commitmenttypes.ApplyPrefix(prefix, commitmenttypes.NewMerklePath(host.FullConsensusStatePath(counterpartyClientIdentifier, consensusHeight))) require.NoError(solo.t, err) return path @@ -269,7 +267,8 @@ func (solo *Solomachine) GetConsensusStatePath(counterpartyClientIdentifier stri // GetConnectionStatePath returns the commitment path for the connection state. func (solo *Solomachine) GetConnectionStatePath(connID string) commitmenttypes.MerklePath { - path, err := commitmenttypes.ApplyPrefix(prefix, host.ConnectionPath(connID)) + connectionPath := commitmenttypes.NewMerklePath(host.ConnectionPath(connID)) + path, err := commitmenttypes.ApplyPrefix(prefix, connectionPath) require.NoError(solo.t, err) return path @@ -277,7 +276,8 @@ func (solo *Solomachine) GetConnectionStatePath(connID string) commitmenttypes.M // GetChannelStatePath returns the commitment path for that channel state. func (solo *Solomachine) GetChannelStatePath(portID, channelID string) commitmenttypes.MerklePath { - path, err := commitmenttypes.ApplyPrefix(prefix, host.ChannelPath(portID, channelID)) + channelPath := commitmenttypes.NewMerklePath(host.ChannelPath(portID, channelID)) + path, err := commitmenttypes.ApplyPrefix(prefix, channelPath) require.NoError(solo.t, err) return path @@ -285,7 +285,8 @@ func (solo *Solomachine) GetChannelStatePath(portID, channelID string) commitmen // GetPacketCommitmentPath returns the commitment path for a packet commitment. func (solo *Solomachine) GetPacketCommitmentPath(portID, channelID string) commitmenttypes.MerklePath { - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketCommitmentPath(portID, channelID, solo.Sequence)) + commitmentPath := commitmenttypes.NewMerklePath(host.PacketCommitmentPath(portID, channelID, solo.Sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, commitmentPath) require.NoError(solo.t, err) return path @@ -293,7 +294,8 @@ func (solo *Solomachine) GetPacketCommitmentPath(portID, channelID string) commi // GetPacketAcknowledgementPath returns the commitment path for a packet acknowledgement. func (solo *Solomachine) GetPacketAcknowledgementPath(portID, channelID string) commitmenttypes.MerklePath { - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketAcknowledgementPath(portID, channelID, solo.Sequence)) + ackPath := commitmenttypes.NewMerklePath(host.PacketAcknowledgementPath(portID, channelID, solo.Sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, ackPath) require.NoError(solo.t, err) return path @@ -302,7 +304,8 @@ func (solo *Solomachine) GetPacketAcknowledgementPath(portID, channelID string) // GetPacketReceiptPath returns the commitment path for a packet receipt // and an absent receipts. func (solo *Solomachine) GetPacketReceiptPath(portID, channelID string) commitmenttypes.MerklePath { - path, err := commitmenttypes.ApplyPrefix(prefix, host.PacketReceiptPath(portID, channelID, solo.Sequence)) + receiptPath := commitmenttypes.NewMerklePath(host.PacketReceiptPath(portID, channelID, solo.Sequence)) + path, err := commitmenttypes.ApplyPrefix(prefix, receiptPath) require.NoError(solo.t, err) return path @@ -310,7 +313,8 @@ func (solo *Solomachine) GetPacketReceiptPath(portID, channelID string) commitme // GetNextSequenceRecvPath returns the commitment path for the next sequence recv counter. func (solo *Solomachine) GetNextSequenceRecvPath(portID, channelID string) commitmenttypes.MerklePath { - path, err := commitmenttypes.ApplyPrefix(prefix, host.NextSequenceRecvPath(portID, channelID)) + nextSequenceRecvPath := commitmenttypes.NewMerklePath(host.NextSequenceRecvPath(portID, channelID)) + path, err := commitmenttypes.ApplyPrefix(prefix, nextSequenceRecvPath) require.NoError(solo.t, err) return path diff --git a/x/slashing/genesis.go b/x/slashing/genesis.go index ae8f315553..2c8b667576 100644 --- a/x/slashing/genesis.go +++ b/x/slashing/genesis.go @@ -12,7 +12,7 @@ import ( func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, stakingKeeper types.StakingKeeper, data *types.GenesisState) { stakingKeeper.IterateValidators(ctx, func(index int64, validator stakingtypes.ValidatorI) bool { - consPk, err := validator.TmConsPubKey() + consPk, err := validator.ConsPubKey() if err != nil { panic(err) } diff --git a/x/slashing/keeper/hooks.go b/x/slashing/keeper/hooks.go index daf2e051e1..d596014258 100644 --- a/x/slashing/keeper/hooks.go +++ b/x/slashing/keeper/hooks.go @@ -28,11 +28,12 @@ func (k Keeper) AfterValidatorBonded(ctx sdk.Context, address sdk.ConsAddress, _ // AfterValidatorCreated adds the address-pubkey relation when a validator is created. func (k Keeper) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) error { validator := k.sk.Validator(ctx, valAddr) - consPk, err := validator.TmConsPubKey() + consPk, err := validator.ConsPubKey() if err != nil { return err } k.AddPubkey(ctx, consPk) + return nil } diff --git a/x/slashing/keeper/infractions.go b/x/slashing/keeper/infractions.go index a8e349b75b..168b97b235 100644 --- a/x/slashing/keeper/infractions.go +++ b/x/slashing/keeper/infractions.go @@ -3,14 +3,13 @@ package keeper import ( "fmt" - "github.com/tendermint/tendermint/crypto" - + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/slashing/types" ) // HandleValidatorSignature handles a validator signature, must be called once per validator per block. -func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr crypto.Address, power int64, signed bool) { +func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Address, power int64, signed bool) { logger := k.Logger(ctx) height := ctx.BlockHeight() diff --git a/x/slashing/keeper/keeper.go b/x/slashing/keeper/keeper.go index ee46915b74..999e82404b 100644 --- a/x/slashing/keeper/keeper.go +++ b/x/slashing/keeper/keeper.go @@ -5,10 +5,10 @@ import ( gogotypes "github.com/gogo/protobuf/types" - "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/slashing/types" ) @@ -42,7 +42,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // AddPubkey sets a address-pubkey relation -func (k Keeper) AddPubkey(ctx sdk.Context, pubkey crypto.PubKey) { +func (k Keeper) AddPubkey(ctx sdk.Context, pubkey cryptotypes.PubKey) { addr := pubkey.Address() pkStr, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pubkey) @@ -54,7 +54,7 @@ func (k Keeper) AddPubkey(ctx sdk.Context, pubkey crypto.PubKey) { } // GetPubkey returns the pubkey from the adddress-pubkey relation -func (k Keeper) GetPubkey(ctx sdk.Context, address crypto.Address) (crypto.PubKey, error) { +func (k Keeper) GetPubkey(ctx sdk.Context, address cryptotypes.Address) (cryptotypes.PubKey, error) { store := ctx.KVStore(k.storeKey) var pubkey gogotypes.StringValue @@ -99,14 +99,14 @@ func (k Keeper) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) { k.sk.Jail(ctx, consAddr) } -func (k Keeper) setAddrPubkeyRelation(ctx sdk.Context, addr crypto.Address, pubkey string) { +func (k Keeper) setAddrPubkeyRelation(ctx sdk.Context, addr cryptotypes.Address, pubkey string) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshalBinaryBare(&gogotypes.StringValue{Value: pubkey}) store.Set(types.AddrPubkeyRelationKey(addr), bz) } -func (k Keeper) deleteAddrPubkeyRelation(ctx sdk.Context, addr crypto.Address) { +func (k Keeper) deleteAddrPubkeyRelation(ctx sdk.Context, addr cryptotypes.Address) { store := ctx.KVStore(k.storeKey) store.Delete(types.AddrPubkeyRelationKey(addr)) } diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index d637007277..20acc9e91a 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -65,11 +65,10 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnjail, "validator is not jailed"), nil, nil } - cons, err := validator.TmConsPubKey() + consAddr, err := validator.GetConsAddr() if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnjail, "unable to get validator consensus key"), nil, err } - consAddr := sdk.ConsAddress(cons.Address()) info, found := k.GetValidatorSigningInfo(ctx, consAddr) if !found { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnjail, "unable to find validator signing info"), nil, nil // skip diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index ab486c5a98..e83e50f275 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -7,11 +7,11 @@ import ( "github.com/spf13/cobra" flag "github.com/spf13/pflag" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -416,7 +416,7 @@ type TxCreateValidatorConfig struct { Identity string } -func PrepareConfigForTxCreateValidator(flagSet *flag.FlagSet, moniker, nodeID, chainID string, valPubKey crypto.PubKey) (TxCreateValidatorConfig, error) { +func PrepareConfigForTxCreateValidator(flagSet *flag.FlagSet, moniker, nodeID, chainID string, valPubKey cryptotypes.PubKey) (TxCreateValidatorConfig, error) { c := TxCreateValidatorConfig{} ip, err := flagSet.GetString(FlagIP) diff --git a/x/staking/genesis.go b/x/staking/genesis.go index 1b646f2364..02f6bc3174 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -5,9 +5,9 @@ import ( "log" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" tmtypes "github.com/tendermint/tendermint/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -198,14 +198,18 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { // WriteValidators returns a slice of bonded genesis validators. func WriteValidators(ctx sdk.Context, keeper keeper.Keeper) (vals []tmtypes.GenesisValidator, err error) { keeper.IterateLastValidators(ctx, func(_ int64, validator types.ValidatorI) (stop bool) { - var consPk crypto.PubKey - consPk, err = validator.TmConsPubKey() + pk, err := validator.ConsPubKey() if err != nil { return true } + tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) + if err != nil { + return true + } + vals = append(vals, tmtypes.GenesisValidator{ - Address: sdk.ConsAddress(consPk.Address()).Bytes(), - PubKey: consPk, + Address: sdk.ConsAddress(tmPk.Address()).Bytes(), + PubKey: tmPk, Power: validator.GetConsensusPower(), Name: validator.GetMoniker(), }) @@ -231,7 +235,7 @@ func validateGenesisStateValidators(validators []types.Validator) error { for i := 0; i < len(validators); i++ { val := validators[i] - consPk, err := val.TmConsPubKey() + consPk, err := val.ConsPubKey() if err != nil { return err } diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 34a8cd78e7..c3bcc8ea33 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -11,6 +11,8 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" @@ -132,9 +134,11 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) { validator := tstaking.CheckValidator(addr1, types.Bonded, false) assert.Equal(t, addr1.String(), validator.OperatorAddress) - consKey, err := validator.TmConsPubKey() + consKey, err := validator.TmConsPublicKey() require.NoError(t, err) - assert.Equal(t, pk1.(cryptotypes.IntoTmPubKey).AsTmPubKey(), consKey) + tmPk1, err := cryptocodec.ToTmProtoPublicKey(pk1) + require.NoError(t, err) + assert.Equal(t, tmPk1, consKey) assert.Equal(t, valTokens, validator.BondedTokens()) assert.Equal(t, valTokens.ToDec(), validator.DelegatorShares) assert.Equal(t, types.Description{}, validator.Description) @@ -155,9 +159,11 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) { validator = tstaking.CheckValidator(addr2, types.Bonded, false) assert.Equal(t, addr2.String(), validator.OperatorAddress) - consPk, err := validator.TmConsPubKey() + consPk, err := validator.TmConsPublicKey() require.NoError(t, err) - assert.Equal(t, pk2.(cryptotypes.IntoTmPubKey).AsTmPubKey(), consPk) + tmPk2, err := cryptocodec.ToTmProtoPublicKey(pk2) + require.NoError(t, err) + assert.Equal(t, tmPk2, consPk) assert.True(sdk.IntEq(t, valTokens, validator.Tokens)) assert.True(sdk.DecEq(t, valTokens.ToDec(), validator.DelegatorShares)) assert.Equal(t, types.Description{}, validator.Description) @@ -177,6 +183,37 @@ func TestInvalidPubKeyTypeMsgCreateValidator(t *testing.T) { tstaking.CreateValidator(addr, invalidPk, 10, false) } +func TestBothPubKeyTypesMsgCreateValidator(t *testing.T) { + app, ctx, _, valAddrs := bootstrapHandlerGenesisTest(t, 1000, 2, 1000) + ctx = ctx.WithConsensusParams(&abci.ConsensusParams{ + Validator: &tmproto.ValidatorParams{PubKeyTypes: []string{tmtypes.ABCIPubKeyTypeEd25519, tmtypes.ABCIPubKeyTypeSecp256k1}}, + }) + + tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) + + testCases := []struct { + name string + addr sdk.ValAddress + pk cryptotypes.PubKey + }{ + { + "can create a validator with ed25519 pubkey", + valAddrs[0], + ed25519.GenPrivKey().PubKey(), + }, + { + "can create a validator with secp256k1 pubkey", + valAddrs[1], + secp256k1.GenPrivKey().PubKey(), + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(*testing.T) { + tstaking.CreateValidator(tc.addr, tc.pk, 10, true) + }) + } +} + func TestLegacyValidatorDelegations(t *testing.T) { app, ctx, delAddrs, valAddrs := bootstrapHandlerGenesisTest(t, 1000, 2, 100000000) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 472a96c485..3f112a0abb 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -41,7 +41,7 @@ func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateVa pk, ok := msg.Pubkey.GetCachedValue().(cryptotypes.PubKey) if !ok { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting crypto.PubKey, got %T", pk) + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting cryptotypes.PubKey, got %T", pk) } if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pk)); found { diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index c28b6db358..894a600850 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -19,7 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" ) -func newMonikerValidator(t *testing.T, operator sdk.ValAddress, pubKey crypto.PubKey, moniker string) types.Validator { +func newMonikerValidator(t *testing.T, operator sdk.ValAddress, pubKey cryptotypes.PubKey, moniker string) types.Validator { v, err := types.NewValidator(operator, pubKey, types.Description{Moniker: moniker}) require.NoError(t, err) return v diff --git a/x/staking/legacy/v034/types.go b/x/staking/legacy/v034/types.go index 6e93b7986a..9f8622d4be 100644 --- a/x/staking/legacy/v034/types.go +++ b/x/staking/legacy/v034/types.go @@ -5,9 +5,8 @@ package v034 import ( "time" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -76,17 +75,17 @@ type ( } Validator struct { - OperatorAddress sdk.ValAddress `json:"operator_address"` - ConsPubKey crypto.PubKey `json:"consensus_pubkey"` - Jailed bool `json:"jailed"` - Status BondStatus `json:"status"` - Tokens sdk.Int `json:"tokens"` - DelegatorShares sdk.Dec `json:"delegator_shares"` - Description Description `json:"description"` - UnbondingHeight int64 `json:"unbonding_height"` - UnbondingCompletionTime time.Time `json:"unbonding_time"` - Commission Commission `json:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation"` + OperatorAddress sdk.ValAddress `json:"operator_address"` + ConsPubKey cryptotypes.PubKey `json:"consensus_pubkey"` + Jailed bool `json:"jailed"` + Status BondStatus `json:"status"` + Tokens sdk.Int `json:"tokens"` + DelegatorShares sdk.Dec `json:"delegator_shares"` + Description Description `json:"description"` + UnbondingHeight int64 `json:"unbonding_height"` + UnbondingCompletionTime time.Time `json:"unbonding_time"` + Commission Commission `json:"commission"` + MinSelfDelegation sdk.Int `json:"min_self_delegation"` } Validators []Validator @@ -170,6 +169,7 @@ func (v *Validator) UnmarshalJSON(data []byte) error { if err != nil { return err } + *v = Validator{ OperatorAddress: bv.OperatorAddress, ConsPubKey: consPubKey, diff --git a/x/staking/legacy/v036/migrate_test.go b/x/staking/legacy/v036/migrate_test.go new file mode 100644 index 0000000000..7278774bf7 --- /dev/null +++ b/x/staking/legacy/v036/migrate_test.go @@ -0,0 +1,103 @@ +package v036_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v034" + v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v036" + "github.com/stretchr/testify/require" +) + +func TestMigrate(t *testing.T) { + aminoCdc := codec.NewLegacyAmino() + consPubKeyEd := ed25519.GenPrivKeyFromSecret([]byte("val0")).PubKey() + consPubKeySecp := secp256k1.GenPrivKeyFromSecret([]byte("val1")).PubKey() + stakingGenState := v034staking.GenesisState{ + Validators: v034staking.Validators{ + v034staking.Validator{ + ConsPubKey: consPubKeyEd, + Status: v034staking.Unbonded, + }, v034staking.Validator{ + ConsPubKey: consPubKeySecp, + Status: v034staking.Unbonded, + }, + }, + } + + migrated := v036staking.Migrate(stakingGenState) + + json, err := aminoCdc.MarshalJSONIndent(migrated, "", " ") + require.NoError(t, err) + + expectedJSON := `{ + "params": { + "unbonding_time": "0", + "max_validators": 0, + "max_entries": 0, + "bond_denom": "" + }, + "last_total_power": "0", + "last_validator_powers": null, + "validators": [ + { + "operator_address": "", + "consensus_pubkey": "cosmosvalconspub1zcjduepq9ymett3nlv6fytn7lqxzd3q3ckvd79eqlcf3wkhgamcl4rzghesq83ecpx", + "jailed": false, + "status": 0, + "tokens": "0", + "delegator_shares": "0", + "description": { + "moniker": "", + "identity": "", + "website": "", + "details": "" + }, + "unbonding_height": "0", + "unbonding_time": "0001-01-01T00:00:00Z", + "commission": { + "commission_rates": { + "rate": "0", + "max_rate": "0", + "max_change_rate": "0" + }, + "update_time": "0001-01-01T00:00:00Z" + }, + "min_self_delegation": "0" + }, + { + "operator_address": "", + "consensus_pubkey": "cosmosvalconspub1addwnpepqwfxk5k5pugwz3quqyzvzupefm3589tw6x9dkzjdkuzn7hgpz33ag84e406", + "jailed": false, + "status": 0, + "tokens": "0", + "delegator_shares": "0", + "description": { + "moniker": "", + "identity": "", + "website": "", + "details": "" + }, + "unbonding_height": "0", + "unbonding_time": "0001-01-01T00:00:00Z", + "commission": { + "commission_rates": { + "rate": "0", + "max_rate": "0", + "max_change_rate": "0" + }, + "update_time": "0001-01-01T00:00:00Z" + }, + "min_self_delegation": "0" + } + ], + "delegations": null, + "unbonding_delegations": null, + "redelegations": null, + "exported": false +}` + + require.Equal(t, expectedJSON, string(json)) +} diff --git a/x/staking/legacy/v036/types.go b/x/staking/legacy/v036/types.go index 6c110bbe57..b433b00701 100644 --- a/x/staking/legacy/v036/types.go +++ b/x/staking/legacy/v036/types.go @@ -5,9 +5,8 @@ package v036 import ( "time" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v034" ) @@ -30,7 +29,7 @@ type ( Validator struct { OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` - ConsPubKey crypto.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` + ConsPubKey cryptotypes.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` Jailed bool `json:"jailed" yaml:"jailed"` Status v034staking.BondStatus `json:"status" yaml:"status"` Tokens sdk.Int `json:"tokens" yaml:"tokens"` diff --git a/x/staking/legacy/v038/types.go b/x/staking/legacy/v038/types.go index aff9a559d4..58ffa1351b 100644 --- a/x/staking/legacy/v038/types.go +++ b/x/staking/legacy/v038/types.go @@ -5,9 +5,8 @@ package v038 import ( "time" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" v034staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v034" v036staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v036" @@ -28,7 +27,7 @@ type ( Validator struct { OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` - ConsPubKey crypto.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` + ConsPubKey cryptotypes.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` Jailed bool `json:"jailed" yaml:"jailed"` Status v034staking.BondStatus `json:"status" yaml:"status"` Tokens sdk.Int `json:"tokens" yaml:"tokens"` diff --git a/x/staking/teststaking/helper.go b/x/staking/teststaking/helper.go index c0ba45bb1a..e63c816abb 100644 --- a/x/staking/teststaking/helper.go +++ b/x/staking/teststaking/helper.go @@ -5,8 +5,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -32,14 +32,14 @@ func NewHelper(t *testing.T, ctx sdk.Context, k keeper.Keeper) *Helper { } // CreateValidator calls handler to create a new staking validator -func (sh *Helper) CreateValidator(addr sdk.ValAddress, pk crypto.PubKey, stakeAmount int64, ok bool) { +func (sh *Helper) CreateValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount int64, ok bool) { coin := sdk.NewCoin(sh.Denom, sdk.NewInt(stakeAmount)) sh.createValidator(addr, pk, coin, ok) } // CreateValidatorWithValPower calls handler to create a new staking validator with zero // commission -func (sh *Helper) CreateValidatorWithValPower(addr sdk.ValAddress, pk crypto.PubKey, valPower int64, ok bool) sdk.Int { +func (sh *Helper) CreateValidatorWithValPower(addr sdk.ValAddress, pk cryptotypes.PubKey, valPower int64, ok bool) sdk.Int { amount := sdk.TokensFromConsensusPower(valPower) coin := sdk.NewCoin(sh.Denom, amount) sh.createValidator(addr, pk, coin, ok) @@ -47,14 +47,14 @@ func (sh *Helper) CreateValidatorWithValPower(addr sdk.ValAddress, pk crypto.Pub } // CreateValidatorMsg returns a message used to create validator in this service. -func (sh *Helper) CreateValidatorMsg(addr sdk.ValAddress, pk crypto.PubKey, stakeAmount int64) *stakingtypes.MsgCreateValidator { +func (sh *Helper) CreateValidatorMsg(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount int64) *stakingtypes.MsgCreateValidator { coin := sdk.NewCoin(sh.Denom, sdk.NewInt(stakeAmount)) msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, sdk.OneInt()) require.NoError(sh.t, err) return msg } -func (sh *Helper) createValidator(addr sdk.ValAddress, pk crypto.PubKey, coin sdk.Coin, ok bool) { +func (sh *Helper) createValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, coin sdk.Coin, ok bool) { msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, sdk.OneInt()) require.NoError(sh.t, err) sh.Handle(msg, ok) diff --git a/x/staking/teststaking/tm.go b/x/staking/teststaking/tm.go new file mode 100644 index 0000000000..9a9c030d06 --- /dev/null +++ b/x/staking/teststaking/tm.go @@ -0,0 +1,43 @@ +package teststaking + +import ( + tmcrypto "github.com/tendermint/tendermint/crypto" + tmtypes "github.com/tendermint/tendermint/types" + + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// GetTmConsPubKey gets the validator's public key as a tmcrypto.PubKey. +func GetTmConsPubKey(v types.Validator) (tmcrypto.PubKey, error) { + pk, err := v.ConsPubKey() + if err != nil { + return nil, err + } + + return cryptocodec.ToTmPubKeyInterface(pk) +} + +// ToTmValidator casts an SDK validator to a tendermint type Validator. +func ToTmValidator(v types.Validator) (*tmtypes.Validator, error) { + tmPk, err := GetTmConsPubKey(v) + if err != nil { + return nil, err + } + + return tmtypes.NewValidator(tmPk, v.ConsensusPower()), nil +} + +// ToTmValidators casts all validators to the corresponding tendermint type. +func ToTmValidators(v types.Validators) ([]*tmtypes.Validator, error) { + validators := make([]*tmtypes.Validator, len(v)) + var err error + for i, val := range v { + validators[i], err = ToTmValidator(val) + if err != nil { + return nil, err + } + } + + return validators, nil +} diff --git a/x/staking/teststaking/validator.go b/x/staking/teststaking/validator.go index 90dd485999..901395d76e 100644 --- a/x/staking/teststaking/validator.go +++ b/x/staking/teststaking/validator.go @@ -4,14 +4,14 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) // NewValidator is a testing helper method to create validators in tests -func NewValidator(t *testing.T, operator sdk.ValAddress, pubKey crypto.PubKey) types.Validator { +func NewValidator(t *testing.T, operator sdk.ValAddress, pubKey cryptotypes.PubKey) types.Validator { v, err := types.NewValidator(operator, pubKey, types.Description{}) require.NoError(t, err) return v diff --git a/x/staking/types/commission_test.go b/x/staking/types/commission_test.go index ec6186122a..3ca95cf4b4 100644 --- a/x/staking/types/commission_test.go +++ b/x/staking/types/commission_test.go @@ -1,4 +1,4 @@ -package types +package types_test import ( "testing" @@ -7,27 +7,28 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestCommissionValidate(t *testing.T) { testCases := []struct { - input Commission + input types.Commission expectErr bool }{ // invalid commission; max rate < 0% - {NewCommission(sdk.ZeroDec(), sdk.MustNewDecFromStr("-1.00"), sdk.ZeroDec()), true}, + {types.NewCommission(sdk.ZeroDec(), sdk.MustNewDecFromStr("-1.00"), sdk.ZeroDec()), true}, // invalid commission; max rate > 100% - {NewCommission(sdk.ZeroDec(), sdk.MustNewDecFromStr("2.00"), sdk.ZeroDec()), true}, + {types.NewCommission(sdk.ZeroDec(), sdk.MustNewDecFromStr("2.00"), sdk.ZeroDec()), true}, // invalid commission; rate < 0% - {NewCommission(sdk.MustNewDecFromStr("-1.00"), sdk.ZeroDec(), sdk.ZeroDec()), true}, + {types.NewCommission(sdk.MustNewDecFromStr("-1.00"), sdk.ZeroDec(), sdk.ZeroDec()), true}, // invalid commission; rate > max rate - {NewCommission(sdk.MustNewDecFromStr("0.75"), sdk.MustNewDecFromStr("0.50"), sdk.ZeroDec()), true}, + {types.NewCommission(sdk.MustNewDecFromStr("0.75"), sdk.MustNewDecFromStr("0.50"), sdk.ZeroDec()), true}, // invalid commission; max change rate < 0% - {NewCommission(sdk.OneDec(), sdk.OneDec(), sdk.MustNewDecFromStr("-1.00")), true}, + {types.NewCommission(sdk.OneDec(), sdk.OneDec(), sdk.MustNewDecFromStr("-1.00")), true}, // invalid commission; max change rate > max rate - {NewCommission(sdk.OneDec(), sdk.MustNewDecFromStr("0.75"), sdk.MustNewDecFromStr("0.90")), true}, + {types.NewCommission(sdk.OneDec(), sdk.MustNewDecFromStr("0.75"), sdk.MustNewDecFromStr("0.90")), true}, // valid commission - {NewCommission(sdk.MustNewDecFromStr("0.20"), sdk.OneDec(), sdk.MustNewDecFromStr("0.10")), false}, + {types.NewCommission(sdk.MustNewDecFromStr("0.20"), sdk.OneDec(), sdk.MustNewDecFromStr("0.10")), false}, } for i, tc := range testCases { @@ -38,11 +39,11 @@ func TestCommissionValidate(t *testing.T) { func TestCommissionValidateNewRate(t *testing.T) { now := time.Now().UTC() - c1 := NewCommission(sdk.MustNewDecFromStr("0.40"), sdk.MustNewDecFromStr("0.80"), sdk.MustNewDecFromStr("0.10")) + c1 := types.NewCommission(sdk.MustNewDecFromStr("0.40"), sdk.MustNewDecFromStr("0.80"), sdk.MustNewDecFromStr("0.10")) c1.UpdateTime = now testCases := []struct { - input Commission + input types.Commission newRate sdk.Dec blockTime time.Time expectErr bool diff --git a/x/staking/types/data_test.go b/x/staking/types/data_test.go index 5505b9d5ce..3f8b290f94 100644 --- a/x/staking/types/data_test.go +++ b/x/staking/types/data_test.go @@ -1,12 +1,11 @@ -package types +package types_test import ( "fmt" - "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -23,7 +22,7 @@ var ( valAddr3 = sdk.ValAddress(pk3.Address()) emptyAddr sdk.ValAddress - emptyPubkey crypto.PubKey + emptyPubkey cryptotypes.PubKey ) func init() { diff --git a/x/staking/types/delegation_test.go b/x/staking/types/delegation_test.go index 7723570ff0..7ca5e8132e 100644 --- a/x/staking/types/delegation_test.go +++ b/x/staking/types/delegation_test.go @@ -1,4 +1,4 @@ -package types +package types_test import ( "encoding/json" @@ -9,10 +9,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestDelegationEqual(t *testing.T) { - d1 := NewDelegation(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(100)) + d1 := types.NewDelegation(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(100)) d2 := d1 ok := d1.String() == d2.String() @@ -26,12 +27,12 @@ func TestDelegationEqual(t *testing.T) { } func TestDelegationString(t *testing.T) { - d := NewDelegation(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(100)) + d := types.NewDelegation(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(100)) require.NotEmpty(t, d.String()) } func TestUnbondingDelegationEqual(t *testing.T) { - ubd1 := NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, + ubd1 := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, time.Unix(0, 0), sdk.NewInt(0)) ubd2 := ubd1 @@ -46,17 +47,17 @@ func TestUnbondingDelegationEqual(t *testing.T) { } func TestUnbondingDelegationString(t *testing.T) { - ubd := NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, + ubd := types.NewUnbondingDelegation(sdk.AccAddress(valAddr1), valAddr2, 0, time.Unix(0, 0), sdk.NewInt(0)) require.NotEmpty(t, ubd.String()) } func TestRedelegationEqual(t *testing.T) { - r1 := NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, + r1 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, time.Unix(0, 0), sdk.NewInt(0), sdk.NewDec(0)) - r2 := NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, + r2 := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, time.Unix(0, 0), sdk.NewInt(0), sdk.NewDec(0)) @@ -71,7 +72,7 @@ func TestRedelegationEqual(t *testing.T) { } func TestRedelegationString(t *testing.T) { - r := NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, + r := types.NewRedelegation(sdk.AccAddress(valAddr1), valAddr2, valAddr3, 0, time.Unix(0, 0), sdk.NewInt(0), sdk.NewDec(10)) @@ -80,11 +81,11 @@ func TestRedelegationString(t *testing.T) { func TestDelegationResponses(t *testing.T) { cdc := codec.NewLegacyAmino() - dr1 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5), + dr1 := types.NewDelegationResp(sdk.AccAddress(valAddr1), valAddr2, sdk.NewDec(5), sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) - dr2 := NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5), + dr2 := types.NewDelegationResp(sdk.AccAddress(valAddr1), valAddr3, sdk.NewDec(5), sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) - drs := DelegationResponses{dr1, dr2} + drs := types.DelegationResponses{dr1, dr2} bz1, err := json.Marshal(dr1) require.NoError(t, err) @@ -102,20 +103,20 @@ func TestDelegationResponses(t *testing.T) { require.Equal(t, bz1, bz2) - var drs2 DelegationResponses + var drs2 types.DelegationResponses require.NoError(t, cdc.UnmarshalJSON(bz2, &drs2)) require.Equal(t, drs, drs2) } func TestRedelegationResponses(t *testing.T) { cdc := codec.NewLegacyAmino() - entries := []RedelegationEntryResponse{ - NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), - NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), + entries := []types.RedelegationEntryResponse{ + types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), + types.NewRedelegationEntryResponse(0, time.Unix(0, 0), sdk.NewDec(5), sdk.NewInt(5), sdk.NewInt(5)), } - rdr1 := NewRedelegationResponse(sdk.AccAddress(valAddr1), valAddr2, valAddr3, entries) - rdr2 := NewRedelegationResponse(sdk.AccAddress(valAddr2), valAddr1, valAddr3, entries) - rdrs := RedelegationResponses{rdr1, rdr2} + rdr1 := types.NewRedelegationResponse(sdk.AccAddress(valAddr1), valAddr2, valAddr3, entries) + rdr2 := types.NewRedelegationResponse(sdk.AccAddress(valAddr2), valAddr1, valAddr3, entries) + rdrs := types.RedelegationResponses{rdr1, rdr2} bz1, err := json.Marshal(rdr1) require.NoError(t, err) @@ -133,7 +134,7 @@ func TestRedelegationResponses(t *testing.T) { require.Equal(t, bz1, bz2) - var rdrs2 RedelegationResponses + var rdrs2 types.RedelegationResponses require.NoError(t, cdc.UnmarshalJSON(bz2, &rdrs2)) bz3, err := cdc.MarshalJSON(rdrs2) diff --git a/x/staking/types/exported.go b/x/staking/types/exported.go index f8cf8be99e..a02adc34ba 100644 --- a/x/staking/types/exported.go +++ b/x/staking/types/exported.go @@ -1,8 +1,10 @@ package types import ( + tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/tendermint/tendermint/crypto" ) // DelegationI delegation bond for a delegated proof of stake system @@ -21,7 +23,8 @@ type ValidatorI interface { IsUnbonded() bool // check if has status unbonded IsUnbonding() bool // check if has status unbonding GetOperator() sdk.ValAddress // operator address to receive/return validators coins - TmConsPubKey() (crypto.PubKey, error) // validation consensus pubkey + ConsPubKey() (cryptotypes.PubKey, error) // validation consensus pubkey (cryptotypes.PubKey) + TmConsPublicKey() (tmprotocrypto.PublicKey, error) // validation consensus pubkey (Tendermint) GetConsAddr() (sdk.ConsAddress, error) // validation consensus address GetTokens() sdk.Int // validation tokens GetBondedTokens() sdk.Int // validator bonded tokens diff --git a/x/staking/types/historical_info_test.go b/x/staking/types/historical_info_test.go index f7f6f2a869..ca3e48951e 100644 --- a/x/staking/types/historical_info_test.go +++ b/x/staking/types/historical_info_test.go @@ -1,10 +1,11 @@ -package types +package types_test import ( "math/rand" "sort" "testing" + "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -14,8 +15,8 @@ var header = tmproto.Header{ Height: 5, } -func createValidators(t *testing.T) []Validator { - return []Validator{ +func createValidators(t *testing.T) []types.Validator { + return []types.Validator{ newValidator(t, valAddr1, pk1), newValidator(t, valAddr2, pk2), newValidator(t, valAddr3, pk3), @@ -24,48 +25,48 @@ func createValidators(t *testing.T) []Validator { func TestHistoricalInfo(t *testing.T) { validators := createValidators(t) - hi := NewHistoricalInfo(header, validators) - require.True(t, sort.IsSorted(Validators(hi.Valset)), "Validators are not sorted") + hi := types.NewHistoricalInfo(header, validators) + require.True(t, sort.IsSorted(types.Validators(hi.Valset)), "Validators are not sorted") var value []byte require.NotPanics(t, func() { - value = ModuleCdc.MustMarshalBinaryBare(&hi) + value = types.ModuleCdc.MustMarshalBinaryBare(&hi) }) require.NotNil(t, value, "Marshalled HistoricalInfo is nil") - recv, err := UnmarshalHistoricalInfo(ModuleCdc, value) + recv, err := types.UnmarshalHistoricalInfo(types.ModuleCdc, value) require.Nil(t, err, "Unmarshalling HistoricalInfo failed") require.Equal(t, hi.Header, recv.Header) for i := range hi.Valset { require.True(t, hi.Valset[i].Equal(&recv.Valset[i])) } - require.True(t, sort.IsSorted(Validators(hi.Valset)), "Validators are not sorted") + require.True(t, sort.IsSorted(types.Validators(hi.Valset)), "Validators are not sorted") } func TestValidateBasic(t *testing.T) { validators := createValidators(t) - hi := HistoricalInfo{ + hi := types.HistoricalInfo{ Header: header, } - err := ValidateBasic(hi) + err := types.ValidateBasic(hi) require.Error(t, err, "ValidateBasic passed on nil ValSet") // Ensure validators are not sorted - for sort.IsSorted(Validators(validators)) { + for sort.IsSorted(types.Validators(validators)) { rand.Shuffle(len(validators), func(i, j int) { it := validators[i] validators[i] = validators[j] validators[j] = it }) } - hi = HistoricalInfo{ + hi = types.HistoricalInfo{ Header: header, Valset: validators, } - err = ValidateBasic(hi) + err = types.ValidateBasic(hi) require.Error(t, err, "ValidateBasic passed on unsorted ValSet") - hi = NewHistoricalInfo(header, validators) - err = ValidateBasic(hi) + hi = types.NewHistoricalInfo(header, validators) + err = types.ValidateBasic(hi) require.NoError(t, err, "ValidateBasic failed on valid HistoricalInfo") } diff --git a/x/staking/types/keys.go b/x/staking/types/keys.go index 71aa587506..40d62244a0 100644 --- a/x/staking/types/keys.go +++ b/x/staking/types/keys.go @@ -71,17 +71,8 @@ func AddressFromLastValidatorPowerKey(key []byte) []byte { // VALUE: validator operator address ([]byte) func GetValidatorsByPowerIndexKey(validator Validator) []byte { // NOTE the address doesn't need to be stored because counter bytes must always be different - return getValidatorPowerRank(validator) -} + // NOTE the larger values are of higher value -// get the bonded validator index key for an operator address -func GetLastValidatorPowerKey(operator sdk.ValAddress) []byte { - return append(LastValidatorPowerKey, operator...) -} - -// get the power ranking of a validator -// NOTE the larger values are of higher value -func getValidatorPowerRank(validator Validator) []byte { consensusPower := sdk.TokensToConsensusPower(validator.Tokens) consensusPowerBytes := make([]byte, 8) binary.BigEndian.PutUint64(consensusPowerBytes, uint64(consensusPower)) @@ -109,6 +100,11 @@ func getValidatorPowerRank(validator Validator) []byte { return key } +// get the bonded validator index key for an operator address +func GetLastValidatorPowerKey(operator sdk.ValAddress) []byte { + return append(LastValidatorPowerKey, operator...) +} + // parse the validators operator address from power rank key func ParseValidatorPowerRankKey(key []byte) (operAddr []byte) { powerBytesLen := 8 diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 3569b126c1..0f63617f26 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -1,4 +1,4 @@ -package types +package types_test import ( "bytes" @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -33,7 +34,7 @@ func TestGetValidatorPowerRank(t *testing.T) { val4.Tokens = sdk.TokensFromConsensusPower(x.Int64()) tests := []struct { - validator Validator + validator types.Validator wantHex string }{ {val1, "2300000000000000009c288ede7df62742fc3b7d0962045a8cef0f79f6"}, @@ -42,7 +43,7 @@ func TestGetValidatorPowerRank(t *testing.T) { {val4, "2300000100000000009c288ede7df62742fc3b7d0962045a8cef0f79f6"}, } for i, tt := range tests { - got := hex.EncodeToString(getValidatorPowerRank(tt.validator)) + got := hex.EncodeToString(types.GetValidatorsByPowerIndexKey(tt.validator)) require.Equal(t, tt.wantHex, got, "Keys did not match on test case %d", i) } @@ -63,7 +64,7 @@ func TestGetREDByValDstIndexKey(t *testing.T) { "363ab62f0d93849be495e21e3e9013a517038f45bd5ef3b5f25c54946d4a89fc0d09d2f126614540f263d771218209d8bd03c482f69dfba57310f08609"}, } for i, tt := range tests { - got := hex.EncodeToString(GetREDByValDstIndexKey(tt.delAddr, tt.valSrcAddr, tt.valDstAddr)) + got := hex.EncodeToString(types.GetREDByValDstIndexKey(tt.delAddr, tt.valSrcAddr, tt.valDstAddr)) require.Equal(t, tt.wantHex, got, "Keys did not match on test case %d", i) } @@ -84,7 +85,7 @@ func TestGetREDByValSrcIndexKey(t *testing.T) { "3563d771218209d8bd03c482f69dfba57310f086095ef3b5f25c54946d4a89fc0d09d2f126614540f23ab62f0d93849be495e21e3e9013a517038f45bd"}, } for i, tt := range tests { - got := hex.EncodeToString(GetREDByValSrcIndexKey(tt.delAddr, tt.valSrcAddr, tt.valDstAddr)) + got := hex.EncodeToString(types.GetREDByValSrcIndexKey(tt.delAddr, tt.valSrcAddr, tt.valDstAddr)) require.Equal(t, tt.wantHex, got, "Keys did not match on test case %d", i) } @@ -94,8 +95,8 @@ func TestGetValidatorQueueKey(t *testing.T) { ts := time.Now() height := int64(1024) - bz := GetValidatorQueueKey(ts, height) - rTs, rHeight, err := ParseValidatorQueueKey(bz) + bz := types.GetValidatorQueueKey(ts, height) + rTs, rHeight, err := types.ParseValidatorQueueKey(bz) require.NoError(t, err) require.Equal(t, ts.UTC(), rTs.UTC()) require.Equal(t, rHeight, height) @@ -105,11 +106,11 @@ func TestTestGetValidatorQueueKeyOrder(t *testing.T) { ts := time.Now().UTC() height := int64(1000) - endKey := GetValidatorQueueKey(ts, height) + endKey := types.GetValidatorQueueKey(ts, height) - keyA := GetValidatorQueueKey(ts.Add(-10*time.Minute), height-10) - keyB := GetValidatorQueueKey(ts.Add(-5*time.Minute), height+50) - keyC := GetValidatorQueueKey(ts.Add(10*time.Minute), height+100) + keyA := types.GetValidatorQueueKey(ts.Add(-10*time.Minute), height-10) + keyB := types.GetValidatorQueueKey(ts.Add(-5*time.Minute), height+50) + keyC := types.GetValidatorQueueKey(ts.Add(10*time.Minute), height+100) require.Equal(t, -1, bytes.Compare(keyA, endKey)) // keyA <= endKey require.Equal(t, -1, bytes.Compare(keyB, endKey)) // keyB <= endKey diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 51e19ac263..85d0c1d3c2 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -3,9 +3,8 @@ package types import ( "bytes" - "github.com/tendermint/tendermint/crypto" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -32,7 +31,7 @@ var ( // NewMsgCreateValidator creates a new MsgCreateValidator instance. // Delegator address and validator address are the same. func NewMsgCreateValidator( - valAddr sdk.ValAddress, pubKey crypto.PubKey, selfDelegation sdk.Coin, + valAddr sdk.ValAddress, pubKey cryptotypes.PubKey, selfDelegation sdk.Coin, description Description, commission CommissionRates, minSelfDelegation sdk.Int, ) (*MsgCreateValidator, error) { pkAny, err := codectypes.PackAny(pubKey) @@ -140,7 +139,7 @@ func (msg MsgCreateValidator) ValidateBasic() error { // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var pubKey crypto.PubKey + var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.Pubkey, &pubKey) } diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index eb83b33162..3b858a64dd 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -1,10 +1,9 @@ -package types +package types_test import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -12,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) var ( @@ -22,7 +22,7 @@ var ( func TestMsgDecode(t *testing.T) { registry := codectypes.NewInterfaceRegistry() cryptocodec.RegisterInterfaces(registry) - RegisterInterfaces(registry) + types.RegisterInterfaces(registry) cdc := codec.NewProtoCodec(registry) // firstly we start testing the pubkey serialization @@ -36,8 +36,8 @@ func TestMsgDecode(t *testing.T) { // now let's try to serialize the whole message - commission1 := NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - msg, err := NewMsgCreateValidator(valAddr1, pk1, coinPos, Description{}, commission1, sdk.OneInt()) + commission1 := types.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + msg, err := types.NewMsgCreateValidator(valAddr1, pk1, coinPos, types.Description{}, commission1, sdk.OneInt()) require.NoError(t, err) msgSerialized, err := codec.MarshalAny(cdc, msg) require.NoError(t, err) @@ -45,7 +45,7 @@ func TestMsgDecode(t *testing.T) { var msgUnmarshaled sdk.Msg err = codec.UnmarshalAny(cdc, &msgUnmarshaled, msgSerialized) require.NoError(t, err) - msg2, ok := msgUnmarshaled.(*MsgCreateValidator) + msg2, ok := msgUnmarshaled.(*types.MsgCreateValidator) require.True(t, ok) require.True(t, msg.Value.IsEqual(msg2.Value)) require.True(t, msg.Pubkey.Equal(msg2.Pubkey)) @@ -53,15 +53,15 @@ func TestMsgDecode(t *testing.T) { // test ValidateBasic for MsgCreateValidator func TestMsgCreateValidator(t *testing.T) { - commission1 := NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - commission2 := NewCommissionRates(sdk.NewDec(5), sdk.NewDec(5), sdk.NewDec(5)) + commission1 := types.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + commission2 := types.NewCommissionRates(sdk.NewDec(5), sdk.NewDec(5), sdk.NewDec(5)) tests := []struct { name, moniker, identity, website, securityContact, details string - CommissionRates CommissionRates + CommissionRates types.CommissionRates minSelfDelegation sdk.Int validatorAddr sdk.ValAddress - pubkey crypto.PubKey + pubkey cryptotypes.PubKey bond sdk.Coin expectPass bool }{ @@ -79,8 +79,8 @@ func TestMsgCreateValidator(t *testing.T) { for _, tc := range tests { t.Logf("Test: %s, pk=%t", tc.name, tc.pubkey) - description := NewDescription(tc.moniker, tc.identity, tc.website, tc.securityContact, tc.details) - msg, err := NewMsgCreateValidator(tc.validatorAddr, tc.pubkey, tc.bond, description, tc.CommissionRates, tc.minSelfDelegation) + description := types.NewDescription(tc.moniker, tc.identity, tc.website, tc.securityContact, tc.details) + msg, err := types.NewMsgCreateValidator(tc.validatorAddr, tc.pubkey, tc.bond, description, tc.CommissionRates, tc.minSelfDelegation) require.NoError(t, err) if tc.expectPass { require.Nil(t, msg.ValidateBasic(), "test: %v", tc.name) @@ -106,10 +106,10 @@ func TestMsgEditValidator(t *testing.T) { } for _, tc := range tests { - description := NewDescription(tc.moniker, tc.identity, tc.website, tc.securityContact, tc.details) + description := types.NewDescription(tc.moniker, tc.identity, tc.website, tc.securityContact, tc.details) newRate := sdk.ZeroDec() - msg := NewMsgEditValidator(tc.validatorAddr, description, &newRate, &tc.minSelfDelegation) + msg := types.NewMsgEditValidator(tc.validatorAddr, description, &newRate, &tc.minSelfDelegation) if tc.expectPass { require.Nil(t, msg.ValidateBasic(), "test: %v", tc.name) } else { @@ -136,7 +136,7 @@ func TestMsgDelegate(t *testing.T) { } for _, tc := range tests { - msg := NewMsgDelegate(tc.delegatorAddr, tc.validatorAddr, tc.bond) + msg := types.NewMsgDelegate(tc.delegatorAddr, tc.validatorAddr, tc.bond) if tc.expectPass { require.Nil(t, msg.ValidateBasic(), "test: %v", tc.name) } else { @@ -164,7 +164,7 @@ func TestMsgBeginRedelegate(t *testing.T) { } for _, tc := range tests { - msg := NewMsgBeginRedelegate(tc.delegatorAddr, tc.validatorSrcAddr, tc.validatorDstAddr, tc.amount) + msg := types.NewMsgBeginRedelegate(tc.delegatorAddr, tc.validatorSrcAddr, tc.validatorDstAddr, tc.amount) if tc.expectPass { require.Nil(t, msg.ValidateBasic(), "test: %v", tc.name) } else { @@ -190,7 +190,7 @@ func TestMsgUndelegate(t *testing.T) { } for _, tc := range tests { - msg := NewMsgUndelegate(tc.delegatorAddr, tc.validatorAddr, tc.amount) + msg := types.NewMsgUndelegate(tc.delegatorAddr, tc.validatorAddr, tc.amount) if tc.expectPass { require.Nil(t, msg.ValidateBasic(), "test: %v", tc.name) } else { diff --git a/x/staking/types/params_test.go b/x/staking/types/params_test.go index c18700ef43..05a7ea956f 100644 --- a/x/staking/types/params_test.go +++ b/x/staking/types/params_test.go @@ -1,14 +1,15 @@ -package types +package types_test import ( "testing" + "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" ) func TestParamsEqual(t *testing.T) { - p1 := DefaultParams() - p2 := DefaultParams() + p1 := types.DefaultParams() + p2 := types.DefaultParams() ok := p1.Equal(p2) require.True(t, ok) diff --git a/x/staking/types/staking.pb.go b/x/staking/types/staking.pb.go index 865953c9dd..4dbe0e3e30 100644 --- a/x/staking/types/staking.pb.go +++ b/x/staking/types/staking.pb.go @@ -1216,606 +1216,608 @@ func (this *Pool) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_ func StakingDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) { d := &github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet{} var gzipped = []byte{ - // 9578 bytes of a gzipped FileDescriptorSet + // 9603 bytes of a gzipped FileDescriptorSet 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x7d, 0x6d, 0x70, 0x24, 0xd7, - 0x71, 0xd8, 0xcd, 0x7e, 0x00, 0xbb, 0x8d, 0x05, 0xb0, 0x78, 0xc0, 0xdd, 0xed, 0x2d, 0x8f, 0x00, - 0x38, 0xfc, 0x3a, 0x1e, 0x49, 0x80, 0x3c, 0xf2, 0x8e, 0xe4, 0x9e, 0x44, 0x1a, 0x0b, 0xec, 0xe1, - 0xc0, 0xc3, 0x17, 0x07, 0xc0, 0x91, 0xfa, 0x70, 0xb6, 0x06, 0xb3, 0x0f, 0x8b, 0x21, 0x76, 0x67, - 0x86, 0x33, 0xb3, 0x77, 0x07, 0x4a, 0xaa, 0xa2, 0x25, 0x45, 0x91, 0xe8, 0x38, 0x92, 0x2c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x21, 0x39, 0x9d, 0x3c, 0x95, 0x55, 0x02, 0x10, 0xf4, 0x20, 0x8c, 0x59, - 0xad, 0xed, 0x86, 0xae, 0x55, 0x03, 0x68, 0x30, 0x9d, 0x3c, 0x95, 0x56, 0xf2, 0xec, 0xc1, 0x82, - 0x8f, 0x7c, 0x3f, 0x8c, 0x5e, 0xc5, 0xea, 0x5e, 0x10, 0x75, 0x88, 0xa2, 0x8e, 0x10, 0x70, 0x00, - 0x71, 0x1e, 0x72, 0x4d, 0xec, 0x38, 0x6a, 0x1d, 0x57, 0xdd, 0x7d, 0x0b, 0x17, 0x52, 0x54, 0xfb, - 0xe9, 0x36, 0xed, 0xa3, 0x9a, 0x0f, 0x71, 0xaa, 0xcd, 0x7d, 0x0b, 0xa3, 0x39, 0xc8, 0x62, 0xa3, - 0xd5, 0x64, 0x1c, 0xd2, 0x5d, 0xec, 0x57, 0x31, 0x5a, 0xcd, 0x28, 0x97, 0x0c, 0x21, 0xe3, 0x2c, - 0x06, 0x1d, 0x6c, 0x5f, 0xd1, 0x35, 0x5c, 0x18, 0xa0, 0x0c, 0xee, 0x6f, 0x63, 0xb0, 0xc1, 0x9e, - 0x47, 0x79, 0x08, 0x3a, 0x34, 0x0f, 0x59, 0x7c, 0xcd, 0xc5, 0x86, 0xa3, 0x9b, 0x46, 0x61, 0x90, - 0x32, 0xb9, 0xb7, 0xc3, 0x28, 0xe2, 0x46, 0x2d, 0xca, 0xc2, 0xa7, 0x43, 0xe7, 0x60, 0xd0, 0xb4, - 0x5c, 0xdd, 0x34, 0x9c, 0x42, 0x66, 0x5a, 0x3a, 0x35, 0x74, 0xe6, 0x64, 0x47, 0x47, 0x58, 0x63, - 0x38, 0x8a, 0x40, 0x46, 0x4b, 0x90, 0x77, 0xcc, 0x96, 0xad, 0xe1, 0xaa, 0x66, 0xd6, 0x70, 0x55, - 0x37, 0x76, 0xcc, 0x42, 0x96, 0x32, 0x98, 0x6a, 0x57, 0x84, 0x22, 0xce, 0x9b, 0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xa7, 0x61, 0xa0, 0x89, 0xdd, 0x5d, 0x53, 0x64, - 0x4b, 0xf7, 0x75, 0x58, 0x83, 0xc9, 0xe3, 0xe8, 0x60, 0x73, 0xaa, 0xe0, 0x22, 0x9e, 0xec, 0x96, - 0xee, 0x31, 0x69, 0xda, 0x24, 0xfd, 0x40, 0x02, 0x8e, 0x76, 0x64, 0xde, 0x51, 0xd0, 0x3b, 0x01, - 0x74, 0xc3, 0x6a, 0xb9, 0x2c, 0x23, 0x62, 0x01, 0x36, 0x4b, 0x21, 0x34, 0x78, 0x91, 0xe0, 0xd9, - 0x72, 0xbd, 0xe7, 0x49, 0xfa, 0x1c, 0x18, 0x88, 0x22, 0x3c, 0xe9, 0x0b, 0x9a, 0xa2, 0x82, 0x4e, - 0x76, 0xd1, 0xb4, 0xcd, 0x31, 0x1f, 0x81, 0xbc, 0xd6, 0xd0, 0xb1, 0xe1, 0x56, 0x1d, 0xd7, 0xc6, - 0x6a, 0x53, 0x37, 0xea, 0x74, 0x05, 0xc9, 0x94, 0xd2, 0x3b, 0x6a, 0xc3, 0xc1, 0xca, 0x28, 0x7b, - 0xbc, 0x21, 0x9e, 0x12, 0x0a, 0xea, 0x40, 0x76, 0x80, 0x62, 0x20, 0x44, 0xc1, 0x1e, 0x7b, 0x14, - 0xf2, 0xcf, 0x66, 0x61, 0x28, 0x90, 0x57, 0xa3, 0xbb, 0x20, 0xf7, 0xa2, 0x7a, 0x45, 0xad, 0x8a, - 0xbd, 0x12, 0xb3, 0xc4, 0x10, 0x81, 0xad, 0xf3, 0xfd, 0xd2, 0x23, 0x30, 0x41, 0x51, 0xcc, 0x96, - 0x8b, 0xed, 0xaa, 0xd6, 0x50, 0x1d, 0x87, 0x1a, 0x2d, 0x43, 0x51, 0x11, 0x79, 0xb6, 0x46, 0x1e, - 0xcd, 0x8b, 0x27, 0xe8, 0x2c, 0x8c, 0x53, 0x8a, 0x66, 0xab, 0xe1, 0xea, 0x56, 0x03, 0x57, 0xc9, - 0xee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72, 0xda, - 0xad, 0xed, 0x7d, 0xcf, 0xb3, 0x1e, 0x66, 0x72, 0x12, 0x98, 0xf0, 0xad, 0xdb, 0x96, 0x74, 0xcb, - 0x25, 0xc8, 0x05, 0x1d, 0x1f, 0x65, 0x81, 0xb9, 0x7e, 0x5e, 0x22, 0x59, 0xd0, 0xfc, 0xda, 0x02, - 0xc9, 0x5f, 0xde, 0x5a, 0xc9, 0x27, 0x48, 0x1e, 0xb5, 0xbc, 0xb4, 0x59, 0xa9, 0x2a, 0x5b, 0xab, - 0x9b, 0x4b, 0x2b, 0x95, 0x7c, 0x32, 0x90, 0xb0, 0x3f, 0x9b, 0xca, 0xdc, 0x97, 0xbf, 0x5f, 0xfe, - 0x46, 0x02, 0x46, 0xc2, 0x3b, 0x30, 0xf4, 0x26, 0x38, 0x2e, 0xca, 0x25, 0x0e, 0x76, 0xab, 0x57, - 0x75, 0x9b, 0xce, 0xc8, 0xa6, 0xca, 0x56, 0x47, 0xcf, 0x27, 0x26, 0x38, 0xd6, 0x06, 0x76, 0x9f, - 0xd7, 0x6d, 0x32, 0xdf, 0x9a, 0xaa, 0x8b, 0x96, 0x61, 0xca, 0x30, 0xab, 0x8e, 0xab, 0x1a, 0x35, - 0xd5, 0xae, 0x55, 0xfd, 0x42, 0x55, 0x55, 0xd5, 0x34, 0xec, 0x38, 0x26, 0x5b, 0x09, 0x3d, 0x2e, - 0x27, 0x0d, 0x73, 0x83, 0x23, 0xfb, 0x4b, 0xc4, 0x1c, 0x47, 0x8d, 0xf8, 0x6f, 0xb2, 0x9b, 0xff, - 0xde, 0x01, 0xd9, 0xa6, 0x6a, 0x55, 0xb1, 0xe1, 0xda, 0xfb, 0x34, 0xef, 0xce, 0x28, 0x99, 0xa6, - 0x6a, 0x55, 0x48, 0xfb, 0x87, 0xb2, 0xfd, 0x79, 0x36, 0x95, 0xc9, 0xe4, 0xb3, 0xcf, 0xa6, 0x32, - 0xd9, 0x3c, 0xc8, 0xaf, 0x27, 0x21, 0x17, 0xcc, 0xc3, 0xc9, 0xb6, 0x46, 0xa3, 0x4b, 0x96, 0x44, - 0x83, 0xda, 0xdd, 0x3d, 0xb3, 0xf6, 0x99, 0x79, 0xb2, 0x96, 0x95, 0x06, 0x58, 0x76, 0xac, 0x30, - 0x4a, 0x92, 0x47, 0x10, 0x67, 0xc3, 0x2c, 0x1b, 0xc9, 0x28, 0xbc, 0x85, 0x16, 0x61, 0xe0, 0x45, - 0x87, 0xf2, 0x1e, 0xa0, 0xbc, 0xef, 0xe9, 0xcd, 0xfb, 0xd9, 0x0d, 0xca, 0x3c, 0xfb, 0xec, 0x46, - 0x75, 0x75, 0x4d, 0x59, 0x99, 0x5b, 0x56, 0x38, 0x39, 0x3a, 0x01, 0xa9, 0x86, 0xfa, 0xf2, 0x7e, - 0x78, 0xd5, 0xa3, 0xa0, 0x7e, 0x07, 0xe1, 0x04, 0xa4, 0xae, 0x62, 0x75, 0x2f, 0xbc, 0xd6, 0x50, - 0xd0, 0x6d, 0x9c, 0x0c, 0xb3, 0x90, 0xa6, 0xf6, 0x42, 0x00, 0xdc, 0x62, 0xf9, 0x23, 0x28, 0x03, - 0xa9, 0xf9, 0x35, 0x85, 0x4c, 0x88, 0x3c, 0xe4, 0x18, 0xb4, 0xba, 0xbe, 0x54, 0x99, 0xaf, 0xe4, - 0x13, 0xf2, 0x59, 0x18, 0x60, 0x46, 0x20, 0x93, 0xc5, 0x33, 0x43, 0xfe, 0x08, 0x6f, 0x72, 0x1e, - 0x92, 0x78, 0xba, 0xb5, 0x52, 0xae, 0x28, 0xf9, 0x44, 0x78, 0xa8, 0x53, 0xf9, 0xb4, 0xec, 0x40, - 0x2e, 0x98, 0x88, 0xff, 0x70, 0x36, 0xd9, 0x5f, 0x96, 0x60, 0x28, 0x90, 0x58, 0x93, 0x8c, 0x48, - 0x6d, 0x34, 0xcc, 0xab, 0x55, 0xb5, 0xa1, 0xab, 0x0e, 0x77, 0x0d, 0xa0, 0xa0, 0x39, 0x02, 0xe9,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, 0x84, 0x10, 0x04, 0x74, 0xfa, - 0xaa, 0x04, 0x43, 0x0b, 0x81, 0x93, 0x5e, 0x05, 0x18, 0x6c, 0x9a, 0x86, 0xbe, 0xc7, 0xfd, 0x31, - 0xab, 0x88, 0x26, 0x2a, 0x42, 0x86, 0x5d, 0xba, 0x73, 0xf7, 0x45, 0x29, 0x54, 0xb4, 0x09, 0xd5, - 0x55, 0xbc, 0xed, 0xe8, 0x62, 0x34, 0x14, 0xd1, 0x44, 0x17, 0x20, 0xef, 0x60, 0xad, 0x65, 0xeb, - 0xee, 0x7e, 0x55, 0x33, 0x0d, 0x57, 0xd5, 0x5c, 0x76, 0x7d, 0xab, 0x7c, 0xc7, 0xcd, 0x1b, 0x53, - 0xc7, 0x99, 0xac, 0x51, 0x0c, 0x59, 0x19, 0x15, 0xa0, 0x79, 0x06, 0x21, 0x3d, 0xd4, 0xb0, 0xab, - 0xea, 0x0d, 0xa7, 0xc0, 0xde, 0x93, 0x89, 0x66, 0x40, 0x97, 0xcf, 0x0f, 0x06, 0x0b, 0x5b, 0x17, - 0x20, 0x6f, 0x5a, 0xd8, 0x0e, 0x25, 0xa2, 0x52, 0xb4, 0xe7, 0x28, 0x86, 0xac, 0x8c, 0x0a, 0x90, - 0x48, 0x52, 0x5d, 0x32, 0xcc, 0x62, 0xa3, 0x68, 0xb5, 0xb6, 0xfd, 0x7a, 0xd8, 0x44, 0xdb, 0x68, - 0xcc, 0x19, 0xfb, 0xe5, 0xc7, 0x7c, 0xee, 0x51, 0x3a, 0xf9, 0x6b, 0x5f, 0x7c, 0x78, 0x82, 0xbb, - 0x86, 0x5f, 0x9f, 0xba, 0x84, 0xf7, 0xc9, 0xf0, 0x73, 0xd4, 0x75, 0x8a, 0x49, 0xd2, 0xce, 0x17, - 0x55, 0xbd, 0x21, 0xae, 0x21, 0x2b, 0xbc, 0x85, 0x4a, 0x30, 0xe0, 0xb8, 0xaa, 0xdb, 0x72, 0xf8, - 0x47, 0xbf, 0xe4, 0x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0xd9, 0x70, 0x55, 0xf7, 0x07, 0xdc, 0x08, - 0x20, 0x87, 0x7f, 0x93, 0x8d, 0x7d, 0x2a, 0xd2, 0xff, 0xf8, 0x61, 0xee, 0x40, 0xd7, 0xb6, 0xd9, - 0x21, 0x41, 0x7e, 0x43, 0x3a, 0xca, 0x4f, 0x66, 0x9f, 0x77, 0xa3, 0x67, 0x17, 0xd8, 0x47, 0x1e, - 0xdf, 0x2b, 0xc1, 0x51, 0x8a, 0xe5, 0xcf, 0x37, 0x8a, 0x29, 0xee, 0xec, 0x75, 0xf5, 0x98, 0x65, - 0x35, 0x50, 0x82, 0x61, 0x9f, 0x65, 0xbc, 0x87, 0xdf, 0x67, 0x39, 0x19, 0xe8, 0x3c, 0xca, 0x56, - 0x56, 0xc6, 0x1b, 0x6d, 0x94, 0x4e, 0x64, 0x5f, 0x9f, 0x3a, 0xfc, 0xbe, 0xfe, 0x59, 0x18, 0x0a, - 0x44, 0xfa, 0x42, 0x3a, 0xe6, 0x9a, 0x69, 0xb4, 0x88, 0x16, 0x24, 0x46, 0xef, 0x93, 0xe0, 0x68, - 0xc7, 0x45, 0x90, 0xfe, 0xaf, 0xda, 0x03, 0x16, 0xe9, 0x22, 0xc6, 0xe9, 0xc8, 0x57, 0x56, 0x26, - 0x5a, 0x9d, 0xb2, 0x89, 0x75, 0x18, 0x0e, 0x2d, 0x60, 0x05, 0xf1, 0x1f, 0xa7, 0xfb, 0xbf, 0x61, - 0x11, 0x66, 0x80, 0x8a, 0x90, 0xc1, 0xd7, 0x2c, 0xd3, 0x76, 0x71, 0x8d, 0x1e, 0x79, 0xc8, 0x28, - 0x5e, 0x5b, 0x5e, 0x05, 0xd4, 0x3e, 0xb8, 0xd1, 0xef, 0x90, 0x66, 0xfd, 0xef, 0x90, 0x4e, 0x40, - 0x3a, 0xf8, 0xa5, 0x4e, 0xd6, 0xf0, 0xeb, 0x14, 0xb7, 0x7a, 0xce, 0xff, 0xdf, 0x00, 0x00, 0x00, - 0xff,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x0d, 0xdd, 0xa8, 0xd1, 0x50, 0x93, 0x2e, 0x0e, 0xec, + 0xaa, 0x75, 0x07, 0x2b, 0x63, 0xac, 0x7a, 0x53, 0xd4, 0x12, 0x0a, 0x6a, 0x40, 0x76, 0x80, 0x62, + 0x30, 0x44, 0xc1, 0xaa, 0x3d, 0x0a, 0xf9, 0xc3, 0x19, 0x18, 0x0e, 0x24, 0xe0, 0xe8, 0x2e, 0xc8, + 0xbe, 0xa8, 0x5e, 0x51, 0x2b, 0x62, 0x51, 0xc5, 0x34, 0x31, 0x4c, 0x60, 0x1b, 0x7c, 0x61, 0xf5, + 0x08, 0x4c, 0x52, 0x14, 0xb3, 0xe9, 0x62, 0xbb, 0xa2, 0xd5, 0x55, 0xc7, 0xa1, 0x4a, 0x4b, 0x53, + 0x54, 0x44, 0xea, 0xd6, 0x49, 0xd5, 0x82, 0xa8, 0x41, 0x67, 0x61, 0x82, 0x52, 0x34, 0x9a, 0x75, + 0x57, 0xb7, 0xea, 0xb8, 0x42, 0x96, 0x79, 0x0e, 0x0d, 0x39, 0x9e, 0x64, 0xe3, 0x04, 0x63, 0x95, + 0x23, 0x10, 0x89, 0x1c, 0xb4, 0x08, 0x77, 0x52, 0xb2, 0x1a, 0x36, 0xb0, 0xad, 0xba, 0xb8, 0x82, + 0x5f, 0x6a, 0xaa, 0x75, 0xa7, 0xa2, 0x1a, 0xd5, 0xca, 0x9e, 0xea, 0xec, 0xe5, 0x27, 0x09, 0x83, + 0x52, 0x22, 0x2f, 0x29, 0x27, 0x08, 0xe2, 0x12, 0xc7, 0x2b, 0x53, 0xb4, 0x79, 0xa3, 0x7a, 0x51, + 0x75, 0xf6, 0x50, 0x11, 0x8e, 0x51, 0x2e, 0x8e, 0x6b, 0xeb, 0x46, 0xad, 0xa2, 0xed, 0x61, 0x6d, + 0xbf, 0xd2, 0x74, 0x77, 0x9f, 0xcc, 0xdf, 0x11, 0x6c, 0x9f, 0x4a, 0xb8, 0x49, 0x71, 0x16, 0x08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ab, 0x58, 0xdd, 0x0f, 0x87, 0x1a, 0x0a, 0xba, 0x8d, 0x93, 0x61, 0x0e, 0x06, 0xa8, + 0xbe, 0x10, 0x00, 0xd7, 0x58, 0xee, 0x08, 0x4a, 0x43, 0x6a, 0x61, 0x5d, 0x21, 0x13, 0x22, 0x07, + 0x59, 0x06, 0xad, 0x6c, 0x2c, 0x97, 0x17, 0xca, 0xb9, 0x84, 0x7c, 0x16, 0x06, 0x99, 0x12, 0xc8, + 0x64, 0xf1, 0xd4, 0x90, 0x3b, 0xc2, 0x8b, 0x9c, 0x87, 0x24, 0x6a, 0xb7, 0x57, 0x4b, 0x65, 0x25, + 0x97, 0x08, 0x0f, 0x75, 0x2a, 0x37, 0x20, 0x3b, 0x90, 0x0d, 0xe6, 0xe1, 0x3f, 0x9c, 0xc5, 0xf8, + 0x97, 0x24, 0x18, 0x0e, 0xe4, 0xd5, 0x24, 0x21, 0x52, 0xeb, 0x75, 0xf3, 0x6a, 0x45, 0xad, 0xeb, + 0xaa, 0xc3, 0x4d, 0x03, 0x28, 0x68, 0x9e, 0x40, 0x7a, 0x1d, 0xba, 0x1f, 0xd2, 0x14, 0x19, 0xc8, + 0x0d, 0xca, 0x9f, 0x90, 0x20, 0x17, 0x4d, 0x6c, 0x23, 0x62, 0x4a, 0x3f, 0x4a, 0x31, 0xe5, 0x8f, + 0x4b, 0x30, 0x1a, 0xce, 0x66, 0x23, 0xe2, 0xdd, 0xf5, 0x23, 0x15, 0xef, 0x0f, 0x12, 0x30, 0x12, + 0xca, 0x61, 0x7b, 0x95, 0xee, 0x25, 0x18, 0xd7, 0xab, 0xb8, 0x61, 0x99, 0x2e, 0x36, 0xb4, 0x83, + 0x4a, 0x1d, 0x5f, 0xc1, 0xf5, 0xbc, 0x4c, 0x9d, 0xc6, 0x5c, 0xf7, 0x2c, 0x79, 0x76, 0xd9, 0xa7, + 0x5b, 0x21, 0x64, 0xc5, 0x89, 0xe5, 0xc5, 0xf2, 0xea, 0xc6, 0xf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51, 0xe1, 0x3f, 0xc3, 0x49, 0x19, 0x7e, 0x71, + 0x01, 0x86, 0x03, 0xd9, 0x49, 0x3c, 0xf9, 0x5f, 0xe3, 0xe4, 0x41, 0x2a, 0x22, 0x3a, 0xcf, 0x4e, + 0xe2, 0x19, 0x7c, 0x50, 0x88, 0xce, 0x29, 0x88, 0xda, 0x44, 0x62, 0x12, 0x4f, 0xfd, 0x21, 0xa1, + 0x75, 0x41, 0x52, 0x7c, 0x06, 0x32, 0x5e, 0xb0, 0x89, 0xa7, 0xff, 0x30, 0xa7, 0xf7, 0x69, 0x88, + 0x06, 0x02, 0xc1, 0x2e, 0x9e, 0xc5, 0x5f, 0x17, 0x1a, 0x08, 0x50, 0x91, 0x69, 0x14, 0x4d, 0x60, + 0xe2, 0x39, 0x7d, 0x44, 0x4c, 0xa3, 0x48, 0xfe, 0x42, 0x46, 0x93, 0xfa, 0xfc, 0x78, 0x16, 0x3f, + 0x2b, 0x46, 0x93, 0xe2, 0x13, 0x31, 0xa2, 0x19, 0x41, 0x3c, 0x8f, 0xbf, 0x21, 0xc4, 0x88, 0x24, + 0x04, 0xc5, 0x0d, 0x40, 0xad, 0xd9, 0x40, 0x3c, 0xbf, 0x8f, 0x72, 0x7e, 0xe3, 0x2d, 0xc9, 0x40, + 0xf1, 0x79, 0x38, 0xd6, 0x3e, 0x13, 0x88, 0xe7, 0xfa, 0xb1, 0xef, 0x45, 0xd6, 0x6e, 0xc1, 0x44, + 0xa0, 0xb8, 0xe5, 0x87, 0x94, 0x60, 0x16, 0x10, 0xcf, 0xf6, 0xb5, 0xef, 0x85, 0x1d, 0x77, 0x30, + 0x09, 0x28, 0xce, 0x03, 0xf8, 0x01, 0x38, 0x9e, 0xd7, 0xc7, 0x39, 0xaf, 0x00, 0x11, 0x99, 0x1a, + 0x3c, 0xfe, 0xc6, 0xd3, 0x5f, 0x17, 0x53, 0x83, 0x53, 0x90, 0xa9, 0x21, 0x42, 0x6f, 0x3c, 0xf5, + 0x27, 0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f4, 0x04, 0x91, 0x7c, 0x41, 0xd0, 0x2a, 0x8c, + 0x59, 0xaa, 0xed, 0xd2, 0xab, 0xfb, 0x7b, 0xb4, 0x17, 0xdc, 0xd6, 0xa7, 0x5b, 0x67, 0x5e, 0xa8, + 0xb3, 0xbc, 0x95, 0x11, 0x2b, 0x08, 0x94, 0xff, 0x30, 0x05, 0x83, 0x5c, 0x19, 0x6f, 0x86, 0x21, + 0xae, 0x56, 0x6e, 0x9d, 0x77, 0xce, 0xb6, 0x06, 0xa6, 0x59, 0x2f, 0x80, 0x70, 0x7e, 0x82, 0x06, + 0xdd, 0x07, 0x69, 0x6d, 0x4f, 0xd5, 0x8d, 0x8a, 0x5e, 0x15, 0x69, 0xde, 0xeb, 0x37, 0xa6, 0x87, + 0x16, 0x08, 0x6c, 0x79, 0x51, 0x19, 0xa2, 0x95, 0xcb, 0x55, 0x92, 0x09, 0xec, 0x61, 0xbd, 0xb6, + 0xe7, 0xf2, 0x19, 0xc6, 0x4b, 0xe8, 0x49, 0x48, 0x11, 0x83, 0xe0, 0x0f, 0xbb, 0x0a, 0x2d, 0xc9, + 0xb6, 0xb7, 0xe2, 0x29, 0xa5, 0x49, 0xc3, 0x1f, 0xfa, 0xfd, 0x69, 0x49, 0xa1, 0x14, 0x68, 0x01, + 0x46, 0xea, 0xaa, 0xe3, 0x56, 0x68, 0x04, 0x23, 0xcd, 0x0f, 0x50, 0x16, 0x27, 0x5a, 0x15, 0xc2, + 0x15, 0xcb, 0x45, 0x1f, 0x26, 0x54, 0x0c, 0x54, 0x45, 0xa7, 0x20, 0x47, 0x99, 0x68, 0x66, 0xa3, + 0xa1, 0xbb, 0x2c, 0xb7, 0x1a, 0xa4, 0x7a, 0x1f, 0x25, 0xf0, 0x05, 0x0a, 0xa6, 0x19, 0xd6, 0x1d, + 0x90, 0xa1, 0x4f, 0x49, 0x28, 0x0a, 0xbb, 0x36, 0x99, 0x26, 0x00, 0x5a, 0x79, 0x3f, 0x8c, 0xf9, + 0xfe, 0x91, 0xa1, 0xa4, 0x19, 0x17, 0x1f, 0x4c, 0x11, 0x1f, 0x81, 0x49, 0x03, 0x5f, 0xa3, 0x17, + 0x39, 0x43, 0xd8, 0x19, 0x8a, 0x8d, 0x48, 0xdd, 0xe5, 0x30, 0xc5, 0xbd, 0x30, 0xaa, 0x09, 0xe5, + 0x33, 0x5c, 0xa0, 0xb8, 0x23, 0x1e, 0x94, 0xa2, 0x9d, 0x80, 0xb4, 0x6a, 0x59, 0x0c, 0x61, 0x98, + 0xfb, 0x47, 0xcb, 0xa2, 0x55, 0xa7, 0x61, 0x9c, 0xf6, 0xd1, 0xc6, 0x4e, 0xb3, 0xee, 0x72, 0x26, + 0x59, 0x8a, 0x33, 0x46, 0x2a, 0x14, 0x06, 0xa7, 0xb8, 0x77, 0xc3, 0x08, 0xbe, 0xa2, 0x57, 0xb1, + 0xa1, 0x61, 0x86, 0x37, 0x42, 0xf1, 0xb2, 0x02, 0x48, 0x91, 0x1e, 0x00, 0xcf, 0xef, 0x55, 0x84, + 0x4f, 0x1e, 0x65, 0xfc, 0x04, 0x7c, 0x9e, 0x81, 0xe5, 0x3c, 0xa4, 0x16, 0x55, 0x57, 0x25, 0x09, + 0x86, 0x7b, 0x8d, 0x05, 0x9a, 0xac, 0x42, 0x7e, 0xca, 0x6f, 0x24, 0x20, 0x75, 0xd9, 0x74, 0x31, + 0x7a, 0x2c, 0x90, 0x00, 0x8e, 0xb6, 0xb3, 0xe7, 0x4d, 0xbd, 0x66, 0xe0, 0xea, 0xaa, 0x53, 0x0b, + 0xbc, 0xfb, 0xf6, 0xcd, 0x29, 0x11, 0x32, 0xa7, 0x49, 0x18, 0xb0, 0xcd, 0xa6, 0x51, 0x15, 0x37, + 0x0e, 0x69, 0x01, 0x95, 0x21, 0xed, 0x59, 0x49, 0x2a, 0xce, 0x4a, 0xc6, 0x88, 0x95, 0x10, 0x1b, + 0xe6, 0x00, 0x65, 0x68, 0x87, 0x1b, 0x4b, 0x09, 0x32,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x3d, + 0x42, 0x74, 0x40, 0x83, 0xa3, 0xd4, 0x1a, 0x7b, 0x99, 0xd8, 0x0c, 0x53, 0xe1, 0x78, 0x84, 0x82, + 0xb9, 0xfe, 0x76, 0xab, 0xe0, 0xa0, 0x59, 0x2a, 0x1c, 0x4f, 0xfe, 0x39, 0x09, 0x60, 0x85, 0x68, + 0x96, 0xf6, 0x97, 0x44, 0x21, 0x87, 0x8a, 0x50, 0x09, 0xb5, 0x3c, 0xd5, 0x69, 0xd0, 0x78, 0xfb, + 0x59, 0x27, 0x28, 0xf7, 0x02, 0x8c, 0xf8, 0xc6, 0xe8, 0x60, 0x21, 0xcc, 0x54, 0x97, 0xac, 0x7a, + 0x13, 0xbb, 0x4a, 0xf6, 0x4a, 0xa0, 0x24, 0xff, 0x33, 0x09, 0x32, 0x54, 0xa6, 0x55, 0xec, 0xaa, + 0xa1, 0x31, 0x94, 0x0e, 0x3f, 0x86, 0x77, 0x02, 0x30, 0x36, 0x8e, 0xfe, 0x32, 0xe6, 0x96, 0x95, + 0xa1, 0x90, 0x4d, 0xfd, 0x65, 0x8c, 0xce, 0x79, 0x0a, 0x4f, 0x76, 0x57, 0xb8, 0xc8, 0xba, 0xb9, + 0xda, 0x8f, 0xc3, 0x10, 0xfd, 0x94, 0xce, 0x35, 0x87, 0x27, 0xd2, 0x83, 0x46, 0xb3, 0xb1, 0x75, + 0xcd, 0x91, 0x5f, 0x84, 0xa1, 0xad, 0x6b, 0x6c, 0x6f, 0xe4, 0x0e, 0xc8, 0xd8, 0xa6, 0xc9, 0x63, + 0x32, 0xcb, 0x85, 0xd2, 0x04, 0x40, 0x43, 0x90, 0xd8, 0x0f, 0x48, 0xf8, 0xfb, 0x01, 0xfe, 0x86, + 0x46, 0xb2, 0xa7, 0x0d, 0x8d, 0xd3, 0xff, 0x4e, 0x82, 0xe1, 0x80, 0x7f, 0x40, 0x8f, 0xc2, 0xd1, + 0xd2, 0xca, 0xfa, 0xc2, 0xa5, 0xca, 0xf2, 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0x04, 0x41, 0x56, 0x46, 0x05, + 0x84, 0x47, 0x8f, 0x1a, 0x90, 0xb4, 0x8f, 0x98, 0x1d, 0xc1, 0xea, 0x31, 0xcf, 0x93, 0x79, 0xf8, + 0x10, 0x8d, 0x84, 0x19, 0xb0, 0xf8, 0x31, 0xea, 0x43, 0x69, 0x00, 0x79, 0x09, 0xc6, 0x74, 0x43, + 0x77, 0x75, 0xb5, 0x5e, 0xd9, 0x51, 0xeb, 0xaa, 0xa1, 0x1d, 0x26, 0x6b, 0x66, 0x2e, 0x9f, 0x37, + 0x1b, 0x61, 0x27, 0x2b, 0xa3, 0x1c, 0x52, 0x62, 0x00, 0x74, 0x11, 0x86, 0x44, 0x53, 0xa9, 0x43, + 0x65, 0x1b, 0x82, 0x3c, 0x90, 0xe0, 0xfd, 0x4c, 0x12, 0xc6, 0x15, 0x5c, 0xfd, 0xff, 0x43, 0xd1, + 0xdf, 0x50, 0xac, 0x02, 0xb0, 0xe9, 0x4e, 0x1c, 0xec, 0x21, 0x46, 0x83, 0x38, 0x8c, 0x0c, 0xe3, + 0xb0, 0xe8, 0xb8, 0x81, 0xf1, 0xb8, 0x91, 0x80, 0x6c, 0x70, 0x3c, 0xfe, 0x82, 0x46, 0x25, 0xb4, + 0xec, 0x7b, 0xa2, 0x14, 0xff, 0x44, 0x68, 0x07, 0x4f, 0xd4, 0x62, 0xbd, 0xdd, 0x5d, 0xd0, 0xff, + 0x48, 0xc0, 0xe0, 0x86, 0x6a, 0xab, 0x0d, 0x07, 0x69, 0x2d, 0x99, 0xa6, 0xd8, 0x7e, 0x6c, 0xf9, + 0x10, 0x34, 0xdf, 0xed, 0x88, 0x49, 0x34, 0x3f, 0xda, 0x26, 0xd1, 0xfc, 0x09, 0x18, 0x25, 0xcb, + 0xe1, 0xc0, 0x15, 0x06, 0xa2, 0xed, 0x91, 0xd2, 0x09, 0x9f, 0x4b, 0xb8, 0x9e, 0xad, 0x96, 0x2f, + 0x07, 0xef, 0x30, 0x0c, 0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0x8d, 0xbf, 0x39, 0x00, + 0x47, 0xf9, 0x09, 0x9d, 0x6a, 0xe9, 0x73, 0x7b, 0xae, 0x2b, 0x5e, 0x09, 0x01, 0x4f, 0x75, 0x55, + 0x4b, 0x97, 0x0f, 0x20, 0x75, 0xd1, 0x75, 0x2d, 0x74, 0x1a, 0x06, 0xec, 0x66, 0x1d, 0x8b, 0x1d, + 0x1f, 0x6f, 0x4f, 0x5e, 0xb5, 0xf4, 0x59, 0x82, 0xa0, 0x34, 0xeb, 0x58, 0x61, 0x28, 0xa8, 0x0c, + 0xd3, 0xbb, 0xcd, 0x7a, 0xfd, 0xa0, 0x52, 0xc5, 0xf4, 0x7f, 0xf7, 0x78, 0x5f, 0xbf, 0xc7, 0xd7, + 0x2c, 0x55, 0x7c, 0x43, 0x8f, 0xe8, 0xe6, 0x24, 0x45, 0x5b, 0xa4, 0x58, 0xe2, 0xcb, 0xf7, 0x65, + 0x81, 0x23, 0xff, 0x5e, 0x02, 0xd2, 0x82, 0x35, 0xbd, 0x21, 0x8e, 0xeb, 0x58, 0x73, 0x4d, 0x71, + 0x62, 0xe2, 0x95, 0x11, 0x82, 0x64, 0x8d, 0x0f, 0x51, 0xe6, 0xe2, 0x11, 0x85, 0x14, 0x08, 0xcc, + 0xbb, 0xb7, 0x4f, 0x60, 0x56, 0x93, 0x8c, 0x5a, 0xca, 0x32, 0xc5, 0xd2, 0xec, 0xe2, 0x11, 0x85, + 0x96, 0x50, 0x1e, 0x06, 0xc9, 0xcc, 0x70, 0xd9, 0x87, 0x09, 0x09, 0x9c, 0x97, 0xd1, 0x31, 0x18, + 0xb0, 0x54, 0x57, 0x63, 0x57, 0xea, 0x48, 0x05, 0x2b, 0xa2, 0x27, 0x60, 0x90, 0x3d, 0x08, 0x8d, + 0xfe, 0x63, 0x0c, 0xa2, 0x0c, 0xf6, 0xe5, 0x2d, 0x22, 0xf7, 0x86, 0xea, 0xba, 0xd8, 0x36, 0x08, + 0x43, 0x86, 0x8e, 0x10,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 0xbb, 0x0b, 0x47, 0x43, 0x3d, 0xbd, 0x4d, 0x2a, 0x3d, 0xf3, 0x5a, 0x0a, 0x92, 0xab, 0x4e, 0x0d, + 0xbd, 0x04, 0x63, 0xd1, 0xa4, 0xa1, 0x63, 0x2e, 0xd8, 0x1a, 0x11, 0x3a, 0xaf, 0xd7, 0x3a, 0x47, + 0x0f, 0xb4, 0x0f, 0x23, 0xe1, 0xc8, 0x71, 0xaa, 0x0b, 0x93, 0x10, 0x66, 0xe1, 0x91, 0x5e, 0x31, + 0xbd, 0xc6, 0xde, 0x0e, 0x69, 0xcf, 0xe9, 0xdd, 0xdd, 0x85, 0x5a, 0x20, 0x75, 0xce, 0x6e, 0xdb, + 0xb8, 0x15, 0xa2, 0xbd, 0xa8, 0x4b, 0xe9, 0xa6, 0xbd, 0x08, 0x6e, 0x57, 0xed, 0x75, 0x9a, 0x5a, + 0x3b, 0x00, 0x81, 0x79, 0x70, 0x6f, 0x17, 0x0e, 0x3e, 0x5a, 0xe1, 0xe1, 0x9e, 0xd0, 0xbc, 0x43, + 0xa7, 0x5b, 0x9c, 0x8c, 0xff, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xca, 0x34, 0x9e, 0x6a, + 0x94, 0x00, 0x00, } r := bytes.NewReader(gzipped) gzipr, err := compress_gzip.NewReader(r) diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 19e032dbab..c99aafd4c3 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -8,13 +8,12 @@ import ( "time" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/encoding" - tmtypes "github.com/tendermint/tendermint/types" + tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -40,7 +39,7 @@ var _ ValidatorI = Validator{} // NewValidator constructs a new Validator //nolint:interfacer -func NewValidator(operator sdk.ValAddress, pubKey crypto.PubKey, description Description) (Validator, error) { +func NewValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, description Description) (Validator, error) { pkAny, err := codectypes.PackAny(pubKey) if err != nil { return Validator{}, err @@ -78,7 +77,7 @@ func (v Validators) String() (out string) { return strings.TrimSpace(out) } -// ToSDKValidators - convenience function convert []Validators to []sdk.Validators +// ToSDKValidators - convenience function convert []Validator to []sdk.ValidatorI func (v Validators) ToSDKValidators() (validators []ValidatorI) { for _, val := range v { validators = append(validators, val) @@ -87,20 +86,6 @@ func (v Validators) ToSDKValidators() (validators []ValidatorI) { return validators } -// ToTmValidators casts all validators to the corresponding tendermint type. -func (v Validators) ToTmValidators() ([]*tmtypes.Validator, error) { - validators := make([]*tmtypes.Validator, len(v)) - var err error - for i, val := range v { - validators[i], err = val.ToTmValidator() - if err != nil { - return nil, err - } - } - - return validators, nil -} - // Sort Validators sorts validator array in ascending operator address order func (v Validators) Sort() { sort.Sort(v) @@ -273,17 +258,13 @@ func (d Description) EnsureLength() (Description, error) { // ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator type // with the full validator power func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { - consPk, err := v.TmConsPubKey() - if err != nil { - panic(err) - } - pk, err := encoding.PubKeyToProto(consPk) + tmProtoPk, err := v.TmConsPublicKey() if err != nil { panic(err) } return abci.ValidatorUpdate{ - PubKey: pk, + PubKey: tmProtoPk, Power: v.ConsensusPower(), } } @@ -291,30 +272,17 @@ func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { // ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staking validator type // with zero power used for validator updates. func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate { - consPk, err := v.TmConsPubKey() - if err != nil { - panic(err) - } - pk, err := encoding.PubKeyToProto(consPk) + tmProtoPk, err := v.TmConsPublicKey() if err != nil { panic(err) } return abci.ValidatorUpdate{ - PubKey: pk, + PubKey: tmProtoPk, Power: 0, } } -// ToTmValidator casts an SDK validator to a tendermint type Validator. -func (v Validator) ToTmValidator() (*tmtypes.Validator, error) { - consPk, err := v.TmConsPubKey() - if err != nil { - return nil, err - } - return tmtypes.NewValidator(consPk, v.ConsensusPower()), nil -} - // SetInitialCommission attempts to set a validator's initial commission. An // error is returned if the commission is invalid. func (v Validator) SetInitialCommission(commission Commission) (Validator, error) { @@ -379,8 +347,8 @@ func (v Validator) BondedTokens() sdk.Int { return sdk.ZeroInt() } -// get the consensus-engine power -// a reduction of 10^6 from validator tokens is applied +// ConsensusPower gets the consensus-engine power. Aa reduction of 10^6 from +// validator tokens is applied func (v Validator) ConsensusPower() int64 { if v.IsBonded() { return v.PotentialConsensusPower() @@ -389,7 +357,7 @@ func (v Validator) ConsensusPower() int64 { return 0 } -// potential consensus-engine power +// PotentialConsensusPower returns the potential consensus-engine power. func (v Validator) PotentialConsensusPower() int64 { return sdk.TokensToConsensusPower(v.Tokens) } @@ -501,30 +469,39 @@ func (v Validator) GetOperator() sdk.ValAddress { return addr } -// TmConsPubKey casts Validator.ConsensusPubkey to crypto.PubKey -func (v Validator) TmConsPubKey() (crypto.PubKey, error) { +// ConsPubKey returns the validator PubKey as a cryptotypes.PubKey. +func (v Validator) ConsPubKey() (cryptotypes.PubKey, error) { pk, ok := v.ConsensusPubkey.GetCachedValue().(cryptotypes.PubKey) if !ok { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "Expecting crypto.PubKey, got %T", pk) + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expecting cryptotypes.PubKey, got %T", pk) } - // The way things are refactored now, v.ConsensusPubkey is sometimes a TM - // ed25519 pubkey, sometimes our own ed25519 pubkey. This is very ugly and - // inconsistent. - // Luckily, here we coerce it into a TM ed25519 pubkey always, as this - // pubkey will be passed into TM (eg calling encoding.PubKeyToProto). - if intoTmPk, ok := pk.(cryptotypes.IntoTmPubKey); ok { - return intoTmPk.AsTmPubKey(), nil + return pk, nil + +} + +// TmConsPublicKey casts Validator.ConsensusPubkey to tmprotocrypto.PubKey. +func (v Validator) TmConsPublicKey() (tmprotocrypto.PublicKey, error) { + pk, err := v.ConsPubKey() + if err != nil { + return tmprotocrypto.PublicKey{}, err } - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "Logic error: ConsensusPubkey must be an SDK key and SDK PubKey types must be convertible to tendermint PubKey; got: %T", pk) + + tmPk, err := cryptocodec.ToTmProtoPublicKey(pk) + if err != nil { + return tmprotocrypto.PublicKey{}, err + } + + return tmPk, nil } // GetConsAddr extracts Consensus key address func (v Validator) GetConsAddr() (sdk.ConsAddress, error) { - pk, err := v.TmConsPubKey() - if err != nil { - return sdk.ConsAddress{}, err + pk, ok := v.ConsensusPubkey.GetCachedValue().(cryptotypes.PubKey) + if !ok { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expecting cryptotypes.PubKey, got %T", pk) } + return sdk.ConsAddress(pk.Address()), nil } @@ -537,6 +514,6 @@ func (v Validator) GetDelegatorShares() sdk.Dec { return v.DelegatorShares } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var pk crypto.PubKey + var pk cryptotypes.PubKey return unpacker.UnpackAny(v.ConsensusPubkey, &pk) } diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 64afc97681..08204215d5 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -1,4 +1,4 @@ -package types +package types_test import ( "math/rand" @@ -7,14 +7,15 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/teststaking" + "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestValidatorTestEquivalent(t *testing.T) { @@ -27,19 +28,19 @@ func TestValidatorTestEquivalent(t *testing.T) { } func TestUpdateDescription(t *testing.T) { - d1 := Description{ + d1 := types.Description{ Website: "https://validator.cosmos", Details: "Test validator", } - d2 := Description{ - Moniker: DoNotModifyDesc, - Identity: DoNotModifyDesc, - Website: DoNotModifyDesc, - Details: DoNotModifyDesc, + d2 := types.Description{ + Moniker: types.DoNotModifyDesc, + Identity: types.DoNotModifyDesc, + Website: types.DoNotModifyDesc, + Details: types.DoNotModifyDesc, } - d3 := Description{ + d3 := types.Description{ Moniker: "", Identity: "", Website: "", @@ -58,9 +59,7 @@ func TestUpdateDescription(t *testing.T) { func TestABCIValidatorUpdate(t *testing.T) { validator := newValidator(t, valAddr1, pk1) abciVal := validator.ABCIValidatorUpdate() - consPk, err := validator.TmConsPubKey() - require.NoError(t, err) - pk, err := encoding.PubKeyToProto(consPk) + pk, err := validator.TmConsPublicKey() require.NoError(t, err) require.Equal(t, pk, abciVal.PubKey) require.Equal(t, validator.BondedTokens().Int64(), abciVal.Power) @@ -69,9 +68,7 @@ func TestABCIValidatorUpdate(t *testing.T) { func TestABCIValidatorUpdateZero(t *testing.T) { validator := newValidator(t, valAddr1, pk1) abciVal := validator.ABCIValidatorUpdateZero() - consPk, err := validator.TmConsPubKey() - require.NoError(t, err) - pk, err := encoding.PubKeyToProto(consPk) + pk, err := validator.TmConsPublicKey() require.NoError(t, err) require.Equal(t, pk, abciVal.PubKey) require.Equal(t, int64(0), abciVal.Power) @@ -94,8 +91,8 @@ func TestRemoveTokens(t *testing.T) { require.Equal(t, int64(90), validator.Tokens.Int64()) // update validator to from bonded -> unbonded - validator = validator.UpdateStatus(Unbonded) - require.Equal(t, Unbonded, validator.Status) + validator = validator.UpdateStatus(types.Unbonded) + require.Equal(t, types.Unbonded, validator.Status) validator = validator.RemoveTokens(sdk.NewInt(10)) require.Panics(t, func() { validator.RemoveTokens(sdk.NewInt(-1)) }) @@ -104,7 +101,7 @@ func TestRemoveTokens(t *testing.T) { func TestAddTokensValidatorBonded(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator = validator.UpdateStatus(Bonded) + validator = validator.UpdateStatus(types.Bonded) validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) @@ -114,11 +111,11 @@ func TestAddTokensValidatorBonded(t *testing.T) { func TestAddTokensValidatorUnbonding(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator = validator.UpdateStatus(Unbonding) + validator = validator.UpdateStatus(types.Unbonding) validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) - assert.Equal(t, Unbonding, validator.Status) + assert.Equal(t, types.Unbonding, validator.Status) assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -126,21 +123,21 @@ func TestAddTokensValidatorUnbonding(t *testing.T) { func TestAddTokensValidatorUnbonded(t *testing.T) { validator := newValidator(t, valAddr1, pk1) - validator = validator.UpdateStatus(Unbonded) + validator = validator.UpdateStatus(types.Unbonded) validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) - assert.Equal(t, Unbonded, validator.Status) + assert.Equal(t, types.Unbonded, validator.Status) assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } // TODO refactor to make simpler like the AddToken tests above func TestRemoveDelShares(t *testing.T) { - valA := Validator{ + valA := types.Validator{ OperatorAddress: valAddr1.String(), ConsensusPubkey: pk1Any, - Status: Bonded, + Status: types.Bonded, Tokens: sdk.NewInt(100), DelegatorShares: sdk.NewDec(100), } @@ -175,20 +172,20 @@ func TestAddTokensFromDel(t *testing.T) { func TestUpdateStatus(t *testing.T) { validator := newValidator(t, valAddr1, pk1) validator, _ = validator.AddTokensFromDel(sdk.NewInt(100)) - require.Equal(t, Unbonded, validator.Status) + require.Equal(t, types.Unbonded, validator.Status) require.Equal(t, int64(100), validator.Tokens.Int64()) // Unbonded to Bonded - validator = validator.UpdateStatus(Bonded) - require.Equal(t, Bonded, validator.Status) + validator = validator.UpdateStatus(types.Bonded) + require.Equal(t, types.Bonded, validator.Status) // Bonded to Unbonding - validator = validator.UpdateStatus(Unbonding) - require.Equal(t, Unbonding, validator.Status) + validator = validator.UpdateStatus(types.Unbonding) + require.Equal(t, types.Unbonding, validator.Status) // Unbonding to Bonded - validator = validator.UpdateStatus(Bonded) - require.Equal(t, Bonded, validator.Status) + validator = validator.UpdateStatus(types.Bonded) + require.Equal(t, types.Bonded, validator.Status) } func TestPossibleOverflow(t *testing.T) { @@ -205,8 +202,8 @@ func TestValidatorMarshalUnmarshalJSON(t *testing.T) { js, err := legacy.Cdc.MarshalJSON(validator) require.NoError(t, err) require.NotEmpty(t, js) - require.Contains(t, string(js), "\"consensus_pubkey\":{\"type\":\"cosmos/PubKeyEd25519\"") - got := &Validator{} + require.Contains(t, string(js), "\"consensus_pubkey\":{\"type\":\"tendermint/PubKeyEd25519\"") + got := &types.Validator{} err = legacy.Cdc.UnmarshalJSON(js, got) assert.NoError(t, err) assert.True(t, validator.Equal(got)) @@ -215,17 +212,17 @@ func TestValidatorMarshalUnmarshalJSON(t *testing.T) { func TestValidatorSetInitialCommission(t *testing.T) { val := newValidator(t, valAddr1, pk1) testCases := []struct { - validator Validator - commission Commission + validator types.Validator + commission types.Commission expectedErr bool }{ - {val, NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), false}, - {val, NewCommission(sdk.ZeroDec(), sdk.NewDecWithPrec(-1, 1), sdk.ZeroDec()), true}, - {val, NewCommission(sdk.ZeroDec(), sdk.NewDec(15000000000), sdk.ZeroDec()), true}, - {val, NewCommission(sdk.NewDecWithPrec(-1, 1), sdk.ZeroDec(), sdk.ZeroDec()), true}, - {val, NewCommission(sdk.NewDecWithPrec(2, 1), sdk.NewDecWithPrec(1, 1), sdk.ZeroDec()), true}, - {val, NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.NewDecWithPrec(-1, 1)), true}, - {val, NewCommission(sdk.ZeroDec(), sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(2, 1)), true}, + {val, types.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), false}, + {val, types.NewCommission(sdk.ZeroDec(), sdk.NewDecWithPrec(-1, 1), sdk.ZeroDec()), true}, + {val, types.NewCommission(sdk.ZeroDec(), sdk.NewDec(15000000000), sdk.ZeroDec()), true}, + {val, types.NewCommission(sdk.NewDecWithPrec(-1, 1), sdk.ZeroDec(), sdk.ZeroDec()), true}, + {val, types.NewCommission(sdk.NewDecWithPrec(2, 1), sdk.NewDecWithPrec(1, 1), sdk.ZeroDec()), true}, + {val, types.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.NewDecWithPrec(-1, 1)), true}, + {val, types.NewCommission(sdk.ZeroDec(), sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(2, 1)), true}, } for i, tc := range testCases { @@ -248,8 +245,8 @@ func TestValidatorSetInitialCommission(t *testing.T) { // Check that sort will create deterministic ordering of validators func TestValidatorsSortDeterminism(t *testing.T) { - vals := make([]Validator, 10) - sortedVals := make([]Validator, 10) + vals := make([]types.Validator, 10) + sortedVals := make([]types.Validator, 10) // Create random validator slice for i := range vals { @@ -258,7 +255,7 @@ func TestValidatorsSortDeterminism(t *testing.T) { } // Save sorted copy - sort.Sort(Validators(vals)) + sort.Sort(types.Validators(vals)) copy(sortedVals, vals) // Randomly shuffle validators, sort, and check it is equal to original sort @@ -269,20 +266,20 @@ func TestValidatorsSortDeterminism(t *testing.T) { vals[j] = it }) - Validators(vals).Sort() + types.Validators(vals).Sort() require.Equal(t, sortedVals, vals, "Validator sort returned different slices") } } // Check SortTendermint sorts the same as tendermint func TestValidatorsSortTendermint(t *testing.T) { - vals := make([]Validator, 100) + vals := make([]types.Validator, 100) for i := range vals { pk := ed25519.GenPrivKey().PubKey() pk2 := ed25519.GenPrivKey().PubKey() vals[i] = newValidator(t, sdk.ValAddress(pk2.Address()), pk) - vals[i].Status = Bonded + vals[i].Status = types.Bonded vals[i].Tokens = sdk.NewInt(rand.Int63()) } // create some validators with the same power @@ -290,62 +287,64 @@ func TestValidatorsSortTendermint(t *testing.T) { vals[i].Tokens = sdk.NewInt(1000000) } - valz := Validators(vals) + valz := types.Validators(vals) // create expected tendermint validators by converting to tendermint then sorting - expectedVals, err := valz.ToTmValidators() + expectedVals, err := teststaking.ToTmValidators(valz) require.NoError(t, err) sort.Sort(tmtypes.ValidatorsByVotingPower(expectedVals)) // sort in SDK and then convert to tendermint - sort.Sort(ValidatorsByVotingPower(valz)) - actualVals, err := valz.ToTmValidators() + sort.Sort(types.ValidatorsByVotingPower(valz)) + actualVals, err := teststaking.ToTmValidators(valz) require.NoError(t, err) require.Equal(t, expectedVals, actualVals, "sorting in SDK is not the same as sorting in Tendermint") } func TestValidatorToTm(t *testing.T) { - vals := make(Validators, 10) + vals := make(types.Validators, 10) expected := make([]*tmtypes.Validator, 10) for i := range vals { pk := ed25519.GenPrivKey().PubKey() val := newValidator(t, sdk.ValAddress(pk.Address()), pk) - val.Status = Bonded + val.Status = types.Bonded val.Tokens = sdk.NewInt(rand.Int63()) vals[i] = val - expected[i] = tmtypes.NewValidator(pk.(cryptotypes.IntoTmPubKey).AsTmPubKey(), val.ConsensusPower()) + tmPk, err := cryptocodec.ToTmPubKeyInterface(pk) + require.NoError(t, err) + expected[i] = tmtypes.NewValidator(tmPk, val.ConsensusPower()) } - vs, err := vals.ToTmValidators() + vs, err := teststaking.ToTmValidators(vals) require.NoError(t, err) require.Equal(t, expected, vs) } func TestBondStatus(t *testing.T) { - require.False(t, Unbonded == Bonded) - require.False(t, Unbonded == Unbonding) - require.False(t, Bonded == Unbonding) - require.Equal(t, BondStatus(4).String(), "4") - require.Equal(t, BondStatusUnspecified, Unspecified.String()) - require.Equal(t, BondStatusUnbonded, Unbonded.String()) - require.Equal(t, BondStatusBonded, Bonded.String()) - require.Equal(t, BondStatusUnbonding, Unbonding.String()) + require.False(t, types.Unbonded == types.Bonded) + require.False(t, types.Unbonded == types.Unbonding) + require.False(t, types.Bonded == types.Unbonding) + require.Equal(t, types.BondStatus(4).String(), "4") + require.Equal(t, types.BondStatusUnspecified, types.Unspecified.String()) + require.Equal(t, types.BondStatusUnbonded, types.Unbonded.String()) + require.Equal(t, types.BondStatusBonded, types.Bonded.String()) + require.Equal(t, types.BondStatusUnbonding, types.Unbonding.String()) } -func mkValidator(tokens int64, shares sdk.Dec) Validator { - return Validator{ +func mkValidator(tokens int64, shares sdk.Dec) types.Validator { + return types.Validator{ OperatorAddress: valAddr1.String(), ConsensusPubkey: pk1Any, - Status: Bonded, + Status: types.Bonded, Tokens: sdk.NewInt(tokens), DelegatorShares: shares, } } // Creates a new validators and asserts the error check. -func newValidator(t *testing.T, operator sdk.ValAddress, pubKey crypto.PubKey) Validator { - v, err := NewValidator(operator, pubKey, Description{}) +func newValidator(t *testing.T, operator sdk.ValAddress, pubKey cryptotypes.PubKey) types.Validator { + v, err := types.NewValidator(operator, pubKey, types.Description{}) require.NoError(t, err) return v } diff --git a/x/upgrade/types/storeloader.go b/x/upgrade/types/storeloader.go index 0ff168dcc3..00538e0715 100644 --- a/x/upgrade/types/storeloader.go +++ b/x/upgrade/types/storeloader.go @@ -10,9 +10,9 @@ import ( // pattern. This is useful for custom upgrade loading logic. func UpgradeStoreLoader(upgradeHeight int64, storeUpgrades *store.StoreUpgrades) baseapp.StoreLoader { return func(ms sdk.CommitMultiStore) error { - if upgradeHeight == ms.LastCommitID().Version { + if upgradeHeight == ms.LastCommitID().Version+1 { // Check if the current commit version and upgrade height matches - if len(storeUpgrades.Renamed) > 0 || len(storeUpgrades.Deleted) > 0 { + if len(storeUpgrades.Renamed) > 0 || len(storeUpgrades.Deleted) > 0 || len(storeUpgrades.Added) > 0 { return ms.LoadLatestVersionAndUpgrade(storeUpgrades) } } diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index f1afa4176b..ec2bfa824d 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -65,11 +65,13 @@ func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte // Test that we can make commits and then reload old versions. // Test that LoadLatestVersion actually does. func TestSetLoader(t *testing.T) { + upgradeHeight := int64(5) + // set a temporary home dir homeDir := t.TempDir() upgradeInfoFilePath := filepath.Join(homeDir, "upgrade-info.json") upgradeInfo := &store.UpgradeInfo{ - Name: "test", Height: 0, + Name: "test", Height: upgradeHeight, } data, err := json.Marshal(upgradeInfo) @@ -92,7 +94,7 @@ func TestSetLoader(t *testing.T) { loadStoreKey: "foo", }, "rename with inline opts": { - setLoader: useUpgradeLoader(0, &store.StoreUpgrades{ + setLoader: useUpgradeLoader(upgradeHeight, &store.StoreUpgrades{ Renamed: []store.StoreRename{{ OldKey: "foo", NewKey: "bar", @@ -116,25 +118,36 @@ func TestSetLoader(t *testing.T) { // load the app with the existing db opts := []func(*baseapp.BaseApp){baseapp.SetPruning(store.PruneNothing)} + + origapp := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...) + origapp.MountStores(sdk.NewKVStoreKey(tc.origStoreKey)) + err := origapp.LoadLatestVersion() + require.Nil(t, err) + + for i := int64(2); i <= upgradeHeight-1; i++ { + origapp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: i}}) + res := origapp.Commit() + require.NotNil(t, res.Data) + } + if tc.setLoader != nil { opts = append(opts, tc.setLoader) } + // load the new app with the original app db app := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...) - capKey := sdk.NewKVStoreKey("main") - app.MountStores(capKey) app.MountStores(sdk.NewKVStoreKey(tc.loadStoreKey)) - err := app.LoadLatestVersion() + err = app.LoadLatestVersion() require.Nil(t, err) // "execute" one block - app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}}) + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: upgradeHeight}}) res := app.Commit() require.NotNil(t, res.Data) // check db is properly updated - checkStore(t, db, 2, tc.loadStoreKey, k, v) - checkStore(t, db, 2, tc.loadStoreKey, []byte("foo"), nil) + checkStore(t, db, upgradeHeight, tc.loadStoreKey, k, v) + checkStore(t, db, upgradeHeight, tc.loadStoreKey, []byte("foo"), nil) }) } }