From 6d8a5721e24b85ad3ec7be81cd0c38b840f0b485 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:27:50 +0200 Subject: [PATCH 1/7] chore(deps): bump cosmossdk.io/x/tx from 0.13.5 to 0.13.6 (#7678) * chore(deps): bump cosmossdk.io/x/tx from 0.13.5 to 0.13.6 Bumps [cosmossdk.io/x/tx](https://github.com/cosmos/cosmos-sdk) from 0.13.5 to 0.13.6. - [Release notes](https://github.com/cosmos/cosmos-sdk/releases) - [Changelog](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/cosmos/cosmos-sdk/compare/x/tx/v0.13.5...x/tx/v0.13.6) --- updated-dependencies: - dependency-name: cosmossdk.io/x/tx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * deps: tidy-all --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: DimitrisJim --- e2e/go.mod | 2 +- e2e/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- modules/apps/callbacks/go.mod | 2 +- modules/apps/callbacks/go.sum | 4 ++-- modules/light-clients/08-wasm/go.mod | 2 +- modules/light-clients/08-wasm/go.sum | 4 ++-- simapp/go.mod | 2 +- simapp/go.sum | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/e2e/go.mod b/e2e/go.mod index 3e8fda79558..eed7a76c819 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -43,7 +43,7 @@ require ( cosmossdk.io/log v1.4.1 // indirect cosmossdk.io/store v1.1.1 // indirect cosmossdk.io/x/feegrant v0.1.1 // indirect - cosmossdk.io/x/tx v0.13.5 // indirect + cosmossdk.io/x/tx v0.13.6 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 910e0100d51..6a8f11fc85e 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -210,8 +210,8 @@ cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4= cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc= cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.6 h1:qCiZJ+yK5MsSdUByjOUrfm3sk7aZk1AuYufX22VLC1M= +cosmossdk.io/x/tx v0.13.6/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/go.mod b/go.mod index dda6da5b4c2..f3f5f5dc1c6 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( cosmossdk.io/log v1.4.1 cosmossdk.io/math v1.4.0 cosmossdk.io/store v1.1.1 - cosmossdk.io/x/tx v0.13.5 + cosmossdk.io/x/tx v0.13.6 cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v0.38.15 github.com/cosmos/cosmos-db v1.1.0 diff --git a/go.sum b/go.sum index e14ce4b497a..c74222d45c1 100644 --- a/go.sum +++ b/go.sum @@ -202,8 +202,8 @@ cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.6 h1:qCiZJ+yK5MsSdUByjOUrfm3sk7aZk1AuYufX22VLC1M= +cosmossdk.io/x/tx v0.13.6/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index ade866feaab..6a865b4002c 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -13,7 +13,7 @@ require ( cosmossdk.io/log v1.4.1 cosmossdk.io/math v1.4.0 cosmossdk.io/store v1.1.1 - cosmossdk.io/x/tx v0.13.5 + cosmossdk.io/x/tx v0.13.6 cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v0.38.15 github.com/cosmos/cosmos-db v1.1.0 diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 9d1d5348ae4..6c776c7753b 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -202,8 +202,8 @@ cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.6 h1:qCiZJ+yK5MsSdUByjOUrfm3sk7aZk1AuYufX22VLC1M= +cosmossdk.io/x/tx v0.13.6/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index f93ccce2263..4ceb785ffeb 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -21,7 +21,7 @@ require ( cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 - cosmossdk.io/x/tx v0.13.5 + cosmossdk.io/x/tx v0.13.6 cosmossdk.io/x/upgrade v0.1.4 github.com/CosmWasm/wasmvm/v2 v2.1.2 github.com/cometbft/cometbft v0.38.15 diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 57bccaf0fe4..9e662472f22 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -212,8 +212,8 @@ cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4= cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc= cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.6 h1:qCiZJ+yK5MsSdUByjOUrfm3sk7aZk1AuYufX22VLC1M= +cosmossdk.io/x/tx v0.13.6/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/simapp/go.mod b/simapp/go.mod index 383443a627c..2108bca0cf7 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -16,7 +16,7 @@ require ( cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 - cosmossdk.io/x/tx v0.13.5 + cosmossdk.io/x/tx v0.13.6 cosmossdk.io/x/upgrade v0.1.4 github.com/cometbft/cometbft v0.38.15 github.com/cosmos/cosmos-db v1.1.0 diff --git a/simapp/go.sum b/simapp/go.sum index 2f5376d64e1..79d4c6f9752 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -212,8 +212,8 @@ cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4= cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc= cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= -cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= -cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= +cosmossdk.io/x/tx v0.13.6 h1:qCiZJ+yK5MsSdUByjOUrfm3sk7aZk1AuYufX22VLC1M= +cosmossdk.io/x/tx v0.13.6/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= From d973191467de88e5c3b497f4b65c0a6080c91976 Mon Sep 17 00:00:00 2001 From: Duong NV Date: Thu, 12 Dec 2024 22:35:44 +0700 Subject: [PATCH 2/7] fix tests: update tests in 04-channel/keeper , use expected errors (#7671) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix tests in 04-channel keeper * lint * fix * fix * TestQueryUpgrade fix channel ID * Update modules/core/04-channel/keeper/packet_test.go --------- Co-authored-by: Đông Liều Co-authored-by: DimitrisJim --- .../core/04-channel/keeper/grpc_query_test.go | 452 ++++++++++++------ .../core/04-channel/keeper/handshake_test.go | 113 +++-- modules/core/04-channel/keeper/keeper_test.go | 19 +- modules/core/04-channel/keeper/packet_test.go | 66 +-- .../core/04-channel/keeper/timeout_test.go | 58 +-- .../core/04-channel/keeper/upgrade_test.go | 50 +- 6 files changed, 482 insertions(+), 276 deletions(-) diff --git a/modules/core/04-channel/keeper/grpc_query_test.go b/modules/core/04-channel/keeper/grpc_query_test.go index 632fda80d09..3b42625120a 100644 --- a/modules/core/04-channel/keeper/grpc_query_test.go +++ b/modules/core/04-channel/keeper/grpc_query_test.go @@ -3,6 +3,11 @@ package keeper_test import ( "fmt" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/types/query" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" @@ -26,14 +31,14 @@ func (suite *KeeperTestSuite) TestQueryChannel() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -43,7 +48,10 @@ func (suite *KeeperTestSuite) TestQueryChannel() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -53,7 +61,10 @@ func (suite *KeeperTestSuite) TestQueryChannel() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -63,7 +74,10 @@ func (suite *KeeperTestSuite) TestQueryChannel() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), + ), }, { "success", @@ -83,7 +97,7 @@ func (suite *KeeperTestSuite) TestQueryChannel() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, } @@ -99,12 +113,13 @@ func (suite *KeeperTestSuite) TestQueryChannel() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.Channel(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(&expChannel, res.Channel) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -119,21 +134,21 @@ func (suite *KeeperTestSuite) TestQueryChannels() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "empty pagination", func() { req = &types.QueryChannelsRequest{} }, - true, + nil, }, { "success", @@ -182,7 +197,7 @@ func (suite *KeeperTestSuite) TestQueryChannels() { }, } }, - true, + nil, }, } @@ -198,13 +213,14 @@ func (suite *KeeperTestSuite) TestQueryChannels() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.Channels(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expChannels, res.Channels) suite.Require().Equal(len(expChannels), int(res.Pagination.Total)) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -219,14 +235,14 @@ func (suite *KeeperTestSuite) TestQueryConnectionChannels() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid connection ID", @@ -235,7 +251,10 @@ func (suite *KeeperTestSuite) TestQueryConnectionChannels() { Connection: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "success", @@ -285,7 +304,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionChannels() { }, } }, - true, + nil, }, { "success, empty response", @@ -302,7 +321,7 @@ func (suite *KeeperTestSuite) TestQueryConnectionChannels() { }, } }, - true, + nil, }, } @@ -318,12 +337,13 @@ func (suite *KeeperTestSuite) TestQueryConnectionChannels() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.ConnectionChannels(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expChannels, res.Channels) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -338,14 +358,14 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -355,7 +375,10 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -365,7 +388,10 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -375,7 +401,10 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id: test-channel-id").Error(), + ), }, { "connection not found", @@ -394,7 +423,10 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { PortId: path.EndpointA.ChannelConfig.PortID, ChannelId: path.EndpointA.ChannelID, } - }, false, + }, status.Error( + codes.NotFound, + errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: doesnotexist").Error(), + ), }, { "client state for channel's connection not found", @@ -409,7 +441,10 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { PortId: path.EndpointA.ChannelConfig.PortID, ChannelId: path.EndpointA.ChannelID, } - }, false, + }, status.Error( + codes.NotFound, + errorsmod.Wrapf(clienttypes.ErrClientNotFound, "client-id: ").Error(), + ), }, { "success", @@ -430,7 +465,7 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, } @@ -446,7 +481,7 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.ChannelClientState(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(&expIdentifiedClientState, res.IdentifiedClientState) @@ -456,6 +491,7 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { suite.Require().NotNil(cachedValue) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -471,14 +507,14 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -490,7 +526,10 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { RevisionHeight: 1, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -502,7 +541,10 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { RevisionHeight: 1, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -514,7 +556,10 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { RevisionHeight: 1, } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), + ), }, { "connection not found", @@ -535,7 +580,10 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { RevisionNumber: 0, RevisionHeight: 1, } - }, false, + }, status.Error( + codes.NotFound, + errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: doesnotexist").Error(), + ), }, { "consensus state for channel's connection not found", @@ -549,7 +597,10 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { RevisionNumber: 0, RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height } - }, false, + }, status.Error( + codes.NotFound, + errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "client-id: 07-tendermint-0").Error(), + ), }, { "success", @@ -573,7 +624,7 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { RevisionHeight: path.EndpointA.GetClientLatestHeight().GetRevisionHeight(), } }, - true, + nil, }, } @@ -589,7 +640,7 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.ChannelConsensusState(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState) @@ -602,6 +653,7 @@ func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { suite.Require().NotNil(cachedValue) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -616,14 +668,14 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -634,7 +686,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -645,7 +700,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid sequence", @@ -656,7 +714,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + fmt.Errorf("packet sequence cannot be 0").Error(), + ), }, { "channel not found", @@ -667,7 +728,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { Sequence: 1, } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (test-port-id) channel ID (test-channel-id)").Error(), + ), }, { "commitment not found", @@ -682,7 +746,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { Sequence: 2, } }, - false, + status.Error( + codes.NotFound, + fmt.Errorf("packet commitment hash not found").Error(), + ), }, { "invalid ID", @@ -692,7 +759,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "success", @@ -708,7 +778,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { Sequence: 1, } }, - true, + nil, }, } @@ -724,12 +794,13 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitment() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.PacketCommitment(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expCommitment, res.Commitment) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -744,14 +815,14 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid ID", @@ -761,7 +832,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -771,7 +845,10 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (test-port-id) channel ID (test-channel-id)").Error(), + ), }, { "success", @@ -797,7 +874,7 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { }, } }, - true, + nil, }, } @@ -813,12 +890,13 @@ func (suite *KeeperTestSuite) TestQueryPacketCommitments() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.PacketCommitments(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expCommitments, res.Commitments) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -833,14 +911,14 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -851,7 +929,10 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { Sequence: 1, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -862,7 +943,10 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { Sequence: 1, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid sequence", @@ -873,7 +957,10 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + fmt.Errorf("packet sequence cannot be 0").Error(), + ), }, { "channel not found", @@ -884,7 +971,10 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { Sequence: 1, } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (test-port-id) channel ID (test-channel-id)").Error(), + ), }, { "success: receipt not found", @@ -900,7 +990,7 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { } expReceived = false }, - true, + nil, }, { "success: receipt found", @@ -916,7 +1006,7 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { } expReceived = true }, - true, + nil, }, } @@ -932,12 +1022,13 @@ func (suite *KeeperTestSuite) TestQueryPacketReceipt() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.PacketReceipt(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expReceived, res.Received) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -952,14 +1043,14 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -970,7 +1061,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -981,7 +1075,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid sequence", @@ -992,7 +1089,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { Sequence: 0, } }, - false, + status.Error( + codes.InvalidArgument, + fmt.Errorf("packet sequence cannot be 0").Error(), + ), }, { "ack not found", @@ -1008,7 +1108,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { Sequence: 2, } }, - false, + status.Error( + codes.NotFound, + fmt.Errorf("packet acknowledgement hash not found").Error(), + ), }, { "channel not found", @@ -1019,7 +1122,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { Sequence: 1, } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (test-port-id) channel ID (test-channel-id)").Error(), + ), }, { "success", @@ -1035,7 +1141,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { Sequence: 1, } }, - true, + nil, }, } @@ -1051,12 +1157,13 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgement() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.PacketAcknowledgement(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expAck, res.Acknowledgement) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1071,14 +1178,14 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid ID", @@ -1088,7 +1195,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -1098,7 +1208,10 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (test-port-id) channel ID (test-channel-id)").Error(), + ), }, { "success, filtered res", @@ -1125,7 +1238,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { Pagination: nil, } }, - true, + nil, }, { "success", @@ -1151,7 +1264,7 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { }, } }, - true, + nil, }, } @@ -1167,12 +1280,13 @@ func (suite *KeeperTestSuite) TestQueryPacketAcknowledgements() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.PacketAcknowledgements(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expAcknowledgements, res.Acknowledgements) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1187,14 +1301,14 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -1204,7 +1318,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -1214,7 +1331,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid seq", @@ -1228,7 +1348,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{0}, } }, - false, + status.Error( + codes.InvalidArgument, + fmt.Errorf("packet sequence 0 cannot be 0").Error(), + ), }, { "invalid seq, ordered channel", @@ -1243,7 +1366,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{0}, } }, - false, + status.Error( + codes.InvalidArgument, + fmt.Errorf("packet sequence 0 cannot be 0").Error(), + ), }, { "channel not found", @@ -1253,7 +1379,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { ChannelId: "invalid-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: invalid-port-id, channel-id invalid-channel-id").Error(), + ), }, { "basic success empty packet commitments", @@ -1268,7 +1397,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{}, } }, - true, + nil, }, { "basic success unreceived packet commitments", @@ -1285,7 +1414,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{1}, } }, - true, + nil, }, { "basic success unreceived packet commitments, nothing to relay", @@ -1302,7 +1431,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{1}, } }, - true, + nil, }, { "success multiple unreceived packet commitments", @@ -1329,7 +1458,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: packetCommitments, } }, - true, + nil, }, { "basic success empty packet commitments, ordered channel", @@ -1345,7 +1474,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{}, } }, - true, + nil, }, { "basic success unreceived packet commitments, ordered channel", @@ -1362,7 +1491,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: []uint64{1}, } }, - true, + nil, }, { "basic success multiple unreceived packet commitments, ordered channel", @@ -1383,7 +1512,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { PacketCommitmentSequences: packetCommitments, } }, - true, + nil, }, } @@ -1399,12 +1528,13 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedPackets() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.UnreceivedPackets(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expSeq, res.Sequences) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1419,14 +1549,14 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -1436,7 +1566,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -1446,7 +1579,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -1456,7 +1592,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (test-port-id) channel ID (test-channel-id)").Error(), + ), }, { "invalid seq", @@ -1470,7 +1609,10 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { PacketAckSequences: []uint64{0}, } }, - false, + status.Error( + codes.InvalidArgument, + fmt.Errorf("packet sequence 0 cannot be 0").Error(), + ), }, { "basic success unreceived packet acks", @@ -1487,7 +1629,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { PacketAckSequences: []uint64{1}, } }, - true, + nil, }, { "basic success unreceived packet acknowledgements, nothing to relay", @@ -1502,7 +1644,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { PacketAckSequences: []uint64{1}, } }, - true, + nil, }, { "success multiple unreceived packet acknowledgements", @@ -1528,7 +1670,7 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { PacketAckSequences: packetAcks, } }, - true, + nil, }, } @@ -1544,12 +1686,13 @@ func (suite *KeeperTestSuite) TestQueryUnreceivedAcks() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.UnreceivedAcks(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expSeq, res.Sequences) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1564,14 +1707,14 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -1581,7 +1724,10 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -1591,7 +1737,10 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -1601,7 +1750,10 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), + ), }, { "basic success on unordered channel returns zero", @@ -1615,7 +1767,7 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, { "basic success on ordered channel returns the set receive sequence", @@ -1633,7 +1785,7 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, } @@ -1649,12 +1801,13 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.NextSequenceReceive(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expSeq, res.NextSequenceReceive) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1669,14 +1822,14 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -1686,7 +1839,10 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -1696,7 +1852,10 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -1706,7 +1865,10 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrSequenceSendNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), + ), }, { "basic success on unordered channel returns the set send sequence", @@ -1722,7 +1884,7 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, { "basic success on ordered channel returns the set send sequence", @@ -1740,7 +1902,7 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, } @@ -1756,12 +1918,13 @@ func (suite *KeeperTestSuite) TestQueryNextSequenceSend() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.NextSequenceSend(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expSeq, res.NextSequenceSend) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1776,14 +1939,14 @@ func (suite *KeeperTestSuite) TestQueryUpgradeError() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -1793,7 +1956,10 @@ func (suite *KeeperTestSuite) TestQueryUpgradeError() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -1803,7 +1969,10 @@ func (suite *KeeperTestSuite) TestQueryUpgradeError() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -1813,7 +1982,10 @@ func (suite *KeeperTestSuite) TestQueryUpgradeError() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), + ), }, { "success", @@ -1828,7 +2000,7 @@ func (suite *KeeperTestSuite) TestQueryUpgradeError() { ChannelId: path.EndpointA.ChannelID, } }, - true, + nil, }, } @@ -1842,12 +2014,13 @@ func (suite *KeeperTestSuite) TestQueryUpgradeError() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.UpgradeError(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(upgradeErr.GetErrorReceipt(), res.ErrorReceipt) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -1862,14 +2035,14 @@ func (suite *KeeperTestSuite) TestQueryUpgrade() { testCases := []struct { msg string malleate func() - expPass bool + expErr error }{ { "empty request", func() { req = nil }, - false, + status.Error(codes.InvalidArgument, "empty request"), }, { "invalid port ID", @@ -1879,7 +2052,10 @@ func (suite *KeeperTestSuite) TestQueryUpgrade() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "invalid channel ID", @@ -1889,7 +2065,10 @@ func (suite *KeeperTestSuite) TestQueryUpgrade() { ChannelId: "", } }, - false, + status.Error( + codes.InvalidArgument, + errorsmod.Wrapf(host.ErrInvalidID, "identifier cannot be blank").Error(), + ), }, { "channel not found", @@ -1899,7 +2078,10 @@ func (suite *KeeperTestSuite) TestQueryUpgrade() { ChannelId: "test-channel-id", } }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: test-port-id, channel-id test-channel-id").Error(), + ), }, { "upgrade not found", @@ -1908,13 +2090,16 @@ func (suite *KeeperTestSuite) TestQueryUpgrade() { kvStore := suite.chainA.GetContext().KVStore(storeKey) kvStore.Delete(host.ChannelUpgradeKey(req.PortId, req.ChannelId)) }, - false, + status.Error( + codes.NotFound, + errorsmod.Wrapf(types.ErrUpgradeNotFound, "port-id: mock, channel-id channel-420").Error(), + ), }, { "success", func() { }, - true, + nil, }, } @@ -1944,12 +2129,13 @@ func (suite *KeeperTestSuite) TestQueryUpgrade() { queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeper) res, err := queryServer.Upgrade(ctx, req) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotNil(res) suite.Require().Equal(expectedUpgrade, res.Upgrade) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index 4ed5b5abbd6..5e42d673a49 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -3,10 +3,14 @@ package keeper_test import ( "fmt" + errorsmod "cosmossdk.io/errors" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" @@ -15,7 +19,7 @@ import ( type testCase = struct { msg string malleate func() - expPass bool + expErr error } // TestChanOpenInit tests the OpenInit handshake call for channels. It uses message passing @@ -32,12 +36,12 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { {"success", func() { path.SetupConnections() features = []string{"ORDER_ORDERED", "ORDER_UNORDERED"} - }, true}, + }, nil}, {"connection doesn't exist", func() { // any non-empty values path.EndpointA.ConnectionID = "connection-0" path.EndpointB.ConnectionID = "connection-0" - }, false}, + }, connectiontypes.ErrConnectionNotFound}, {"connection version not negotiated", func() { path.SetupConnections() @@ -47,7 +51,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { }) features = []string{"ORDER_ORDERED", "ORDER_UNORDERED"} - }, false}, + }, connectiontypes.ErrInvalidVersion}, {"connection does not support ORDERED channels", func() { path.SetupConnections() @@ -58,10 +62,10 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { // NOTE: Opening UNORDERED channels is still expected to pass but ORDERED channels should fail features = []string{"ORDER_UNORDERED"} - }, true}, + }, nil}, { - msg: "unauthorized client", - expPass: false, + msg: "unauthorized client", + expErr: clienttypes.ErrClientNotActive, malleate: func() { expErrorMsgSubstring = "status is Unauthorized" path.SetupConnections() @@ -104,7 +108,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { // Testcase must have expectedPass = true AND channel order supported before // asserting the channel handshake initiation succeeded - if tc.expPass && orderSupported { + if (tc.expErr == nil) && orderSupported { suite.Require().NoError(err) suite.Require().Equal(types.FormatChannelIdentifier(0), channelID) } else { @@ -132,17 +136,17 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { path.SetChannelOrdered() err := path.EndpointA.ChanOpenInit() suite.Require().NoError(err) - }, true}, + }, nil}, {"connection doesn't exist", func() { path.EndpointA.ConnectionID = ibctesting.FirstConnectionID path.EndpointB.ConnectionID = ibctesting.FirstConnectionID - }, false}, + }, connectiontypes.ErrConnectionNotFound}, {"connection is not OPEN", func() { path.SetupClients() err := path.EndpointB.ConnOpenInit() suite.Require().NoError(err) - }, false}, + }, connectiontypes.ErrInvalidConnectionState}, {"consensus state not found", func() { path.SetupConnections() path.SetChannelOrdered() @@ -150,11 +154,11 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { suite.Require().NoError(err) heightDiff = 3 // consensus state doesn't exist at this height - }, false}, + }, errorsmod.Wrap(ibcerrors.ErrInvalidHeight, "")}, {"channel verification failed", func() { // not creating a channel on chainA will result in an invalid proof of existence path.SetupConnections() - }, false}, + }, commitmenttypes.ErrInvalidProof}, {"connection version not negotiated", func() { path.SetupConnections() path.SetChannelOrdered() @@ -165,7 +169,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { path.EndpointB.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.Versions = append(c.Versions, connectiontypes.NewVersion("2", []string{"ORDER_ORDERED", "ORDER_UNORDERED"})) }) - }, false}, + }, connectiontypes.ErrInvalidVersion}, {"connection does not support ORDERED channels", func() { path.SetupConnections() path.SetChannelOrdered() @@ -176,7 +180,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { path.EndpointB.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.Versions = []*connectiontypes.Version{connectiontypes.NewVersion("1", []string{"ORDER_UNORDERED"})} }) - }, false}, + }, connectiontypes.ErrInvalidVersion}, } for _, tc := range testCases { @@ -205,11 +209,12 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { proof, malleateHeight(proofHeight, heightDiff), ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().NotEmpty(channelID) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -234,7 +239,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { err = path.EndpointB.ChanOpenTry() suite.Require().NoError(err) - }, true}, + }, nil}, {"success with empty stored counterparty channel ID", func() { path.SetupConnections() path.SetChannelOrdered() @@ -253,12 +258,12 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { counterpartyChannelID = path.EndpointB.ChannelID suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) - }, true}, - {"channel doesn't exist", func() {}, false}, + }, nil}, + {"channel doesn't exist", func() {}, errorsmod.Wrap(types.ErrChannelNotFound, "")}, {"channel state is not INIT", func() { // create fully open channels on both chains path.Setup() - }, false}, + }, types.ErrInvalidChannelState}, {"connection not found", func() { path.SetupConnections() path.SetChannelOrdered() @@ -272,7 +277,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { channel := path.EndpointA.GetChannel() channel.ConnectionHops[0] = doesnotexist suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"connection is not OPEN", func() { path.SetupClients() @@ -284,7 +289,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { err = path.EndpointA.ChanOpenInit() suite.Require().NoError(err) - }, false}, + }, connectiontypes.ErrInvalidConnectionState}, {"consensus state not found", func() { path.SetupConnections() path.SetChannelOrdered() @@ -296,7 +301,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { suite.Require().NoError(err) heightDiff = 3 // consensus state doesn't exist at this height - }, false}, + }, ibcerrors.ErrInvalidHeight}, {"invalid counterparty channel identifier", func() { path.SetupConnections() path.SetChannelOrdered() @@ -308,7 +313,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { suite.Require().NoError(err) counterpartyChannelID = "otheridentifier" - }, false}, + }, commitmenttypes.ErrInvalidProof}, {"channel verification failed", func() { // chainB is INIT, chainA in TRYOPEN path.SetupConnections() @@ -319,7 +324,7 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { err = path.EndpointA.ChanOpenTry() suite.Require().NoError(err) - }, false}, + }, types.ErrInvalidChannelState}, } for _, tc := range testCases { @@ -350,10 +355,11 @@ func (suite *KeeperTestSuite) TestChanOpenAck() { proof, malleateHeight(proofHeight, heightDiff), ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -380,12 +386,12 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { err = path.EndpointA.ChanOpenAck() suite.Require().NoError(err) - }, true}, - {"channel doesn't exist", func() {}, false}, + }, nil}, + {"channel doesn't exist", func() {}, types.ErrChannelNotFound}, {"channel state is not TRYOPEN", func() { // create fully open channels on both chains path.Setup() - }, false}, + }, types.ErrInvalidChannelState}, {"connection not found", func() { path.SetupConnections() path.SetChannelOrdered() @@ -403,13 +409,13 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { channel := path.EndpointB.GetChannel() channel.ConnectionHops[0] = doesnotexist suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, channel) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"connection is not OPEN", func() { path.SetupClients() err := path.EndpointB.ConnOpenInit() suite.Require().NoError(err) - }, false}, + }, types.ErrChannelNotFound}, {"consensus state not found", func() { path.SetupConnections() path.SetChannelOrdered() @@ -424,7 +430,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { suite.Require().NoError(err) heightDiff = 3 - }, false}, + }, ibcerrors.ErrInvalidHeight}, {"channel verification failed", func() { // chainA is INIT, chainB in TRYOPEN path.SetupConnections() @@ -435,7 +441,7 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { err = path.EndpointB.ChanOpenTry() suite.Require().NoError(err) - }, false}, + }, commitmenttypes.ErrInvalidProof}, } for _, tc := range testCases { @@ -462,10 +468,11 @@ func (suite *KeeperTestSuite) TestChanOpenConfirm() { proof, malleateHeight(proofHeight, heightDiff), ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -482,7 +489,7 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { testCases := []testCase{ {"success", func() { path.Setup() - }, true}, + }, nil}, {"channel doesn't exist", func() { // any non-nil values work for connections path.EndpointA.ConnectionID = ibctesting.FirstConnectionID @@ -490,13 +497,13 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { path.EndpointA.ChannelID = ibctesting.FirstChannelID path.EndpointB.ChannelID = ibctesting.FirstChannelID - }, false}, + }, types.ErrChannelNotFound}, {"channel state is CLOSED", func() { path.Setup() // close channel path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, false}, + }, types.ErrInvalidChannelState}, {"connection not found", func() { path.Setup() @@ -504,7 +511,7 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { channel := path.EndpointA.GetChannel() channel.ConnectionHops[0] = doesnotexist suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"connection is not OPEN", func() { path.SetupClients() @@ -515,10 +522,10 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { path.SetChannelOrdered() err = path.EndpointA.ChanOpenInit() suite.Require().NoError(err) - }, false}, + }, connectiontypes.ErrInvalidConnectionState}, { - msg: "unauthorized client", - expPass: false, + msg: "unauthorized client", + expErr: clienttypes.ErrClientNotActive, malleate: func() { path.Setup() @@ -544,11 +551,12 @@ func (suite *KeeperTestSuite) TestChanCloseInit() { suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) suite.Require().Contains(err.Error(), expErrorMsgSubstring) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -568,7 +576,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { {"success", func() { path.Setup() path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, true}, + }, nil}, {"success with upgrade info", func() { path.Setup() @@ -588,17 +596,17 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { path.EndpointB.SetChannelUpgrade(upgrade) path.EndpointB.SetChannelCounterpartyUpgrade(counterpartyUpgrade) - }, true}, + }, nil}, {"channel doesn't exist", func() { // any non-nil values work for connections path.EndpointA.ChannelID = ibctesting.FirstChannelID path.EndpointB.ChannelID = ibctesting.FirstChannelID - }, false}, + }, errorsmod.Wrap(types.ErrChannelNotFound, "")}, {"channel state is CLOSED", func() { path.Setup() path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, false}, + }, types.ErrInvalidChannelState}, {"connection not found", func() { path.Setup() @@ -606,7 +614,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { channel := path.EndpointB.GetChannel() channel.ConnectionHops[0] = doesnotexist suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetChannel(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, channel) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"connection is not OPEN", func() { path.SetupClients() @@ -617,18 +625,18 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { path.SetChannelOrdered() err = path.EndpointB.ChanOpenInit() suite.Require().NoError(err) - }, false}, + }, connectiontypes.ErrInvalidConnectionState}, {"consensus state not found", func() { path.Setup() path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) heightDiff = 3 - }, false}, + }, ibcerrors.ErrInvalidHeight}, {"channel verification failed", func() { // channel not closed path.Setup() - }, false}, + }, ibcerrors.ErrInvalidHeight}, { "failure: invalid counterparty upgrade sequence", func() { @@ -641,7 +649,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) }, - false, + commitmenttypes.ErrInvalidProof, }, } @@ -664,7 +672,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { proof, malleateHeight(proofHeight, heightDiff), counterpartyUpgradeSequence, ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) // if the channel closed during an upgrade, there should not be any upgrade information @@ -674,6 +682,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { suite.Require().False(found) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } diff --git a/modules/core/04-channel/keeper/keeper_test.go b/modules/core/04-channel/keeper/keeper_test.go index ef264410d19..c323e29457c 100644 --- a/modules/core/04-channel/keeper/keeper_test.go +++ b/modules/core/04-channel/keeper/keeper_test.go @@ -8,6 +8,8 @@ import ( testifysuite "github.com/stretchr/testify/suite" + errorsmod "cosmossdk.io/errors" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" @@ -502,14 +504,14 @@ func (suite *KeeperTestSuite) TestDefaultSetParams() { // TestParams tests that Param setting and retrieval works properly func (suite *KeeperTestSuite) TestParams() { testCases := []struct { - name string - input types.Params - expPass bool + name string + input types.Params + expErr error }{ - {"success: set default params", types.DefaultParams(), true}, - {"success: zero timeout height", types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), 10000)), true}, - {"fail: zero timeout timestamp", types.NewParams(types.NewTimeout(clienttypes.NewHeight(1, 1000), 0)), false}, - {"fail: zero timeout", types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), 0)), false}, + {"success: set default params", types.DefaultParams(), nil}, + {"success: zero timeout height", types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), 10000)), nil}, + {"fail: zero timeout timestamp", types.NewParams(types.NewTimeout(clienttypes.NewHeight(1, 1000), 0)), errorsmod.Wrapf(types.ErrInvalidUpgradeTimeout, "upgrade timeout height must be zero. ")}, + {"fail: zero timeout", types.NewParams(types.NewTimeout(clienttypes.ZeroHeight(), 0)), errorsmod.Wrapf(types.ErrInvalidUpgradeTimeout, "upgrade timeout height must be zero.")}, } for _, tc := range testCases { @@ -520,13 +522,14 @@ func (suite *KeeperTestSuite) TestParams() { ctx := suite.chainA.GetContext() err := tc.input.Validate() suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetParams(ctx, tc.input) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) expected := tc.input p := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetParams(ctx) suite.Require().Equal(expected, p) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 8025eaca3b6..8acb85f67a5 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "fmt" - "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -45,12 +45,12 @@ func (suite *KeeperTestSuite) TestSendPacket() { {"success: UNORDERED channel", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID - }, true}, + }, nil}, {"success: ORDERED channel", func() { path.SetChannelOrdered() path.Setup() sourceChannel = path.EndpointA.ChannelID - }, true}, + }, nil}, {"success with solomachine: UNORDERED channel", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID @@ -60,7 +60,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { path.EndpointA.ClientID = clienttypes.FormatClientIdentifier(exported.Solomachine, 10) path.EndpointA.SetClientState(solomachine.ClientState()) path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.ClientId = path.EndpointA.ClientID }) - }, true}, + }, nil}, {"success with solomachine: ORDERED channel", func() { path.SetChannelOrdered() path.Setup() @@ -72,50 +72,50 @@ func (suite *KeeperTestSuite) TestSendPacket() { path.EndpointA.SetClientState(solomachine.ClientState()) path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.ClientId = path.EndpointA.ClientID }) - }, true}, + }, nil}, {"packet basic validation failed, empty packet data", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID packetData = []byte{} - }, false}, + }, types.ErrInvalidPacket}, {"channel not found", func() { // use wrong channel naming path.Setup() sourceChannel = ibctesting.InvalidID - }, false}, + }, types.ErrChannelNotFound}, {"channel is in CLOSED state", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, false}, + }, types.ErrInvalidChannelState}, {"channel is in INIT state", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.INIT }) - }, false}, + }, types.ErrInvalidChannelState}, {"channel is in TRYOPEN stage", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.TRYOPEN }) - }, false}, + }, types.ErrInvalidChannelState}, {"connection not found", func() { // pass channel check path.Setup() sourceChannel = path.EndpointA.ChannelID path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.ConnectionHops[0] = "invalid-connection" }) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"client state not found", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID // change connection client ID path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.ClientId = ibctesting.InvalidID }) - }, false}, + }, clienttypes.ErrClientNotActive}, {"client state is frozen", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID @@ -128,7 +128,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { // freeze client cs.FrozenHeight = clienttypes.NewHeight(0, 1) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), connection.ClientId, cs) - }, false}, + }, clienttypes.ErrClientNotActive}, {"client state zero height", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID @@ -144,7 +144,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { cs.LatestHeight = clienttypes.ZeroHeight() suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), connection.ClientId, cs) - }, false}, + }, clienttypes.ErrInvalidHeight}, {"timeout height passed", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID @@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { var ok bool timeoutHeight, ok = path.EndpointA.GetClientLatestHeight().(clienttypes.Height) suite.Require().True(ok) - }, false}, + }, types.ErrTimeoutElapsed}, {"timeout timestamp passed", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID @@ -163,7 +163,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { timeoutHeight = disabledTimeoutHeight timeoutTimestamp = timestamp - }, false}, + }, types.ErrTimeoutElapsed}, {"timeout timestamp passed with solomachine", func() { path.Setup() // swap client with solomachine @@ -180,7 +180,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { sourceChannel = path.EndpointA.ChannelID timeoutHeight = disabledTimeoutHeight timeoutTimestamp = timestamp - }, false}, + }, types.ErrTimeoutElapsed}, {"next sequence send not found", func() { path := ibctesting.NewPath(suite.chainA, suite.chainB) sourceChannel = path.EndpointA.ChannelID @@ -192,7 +192,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), []string{path.EndpointA.ConnectionID}, path.EndpointA.ChannelConfig.Version), ) - }, false}, + }, errorsmod.Wrap(types.ErrSequenceSendNotFound, "")}, { "channel is in FLUSH_COMPLETE state", func() { @@ -201,7 +201,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) }, - false, + types.ErrInvalidChannelState, }, { "channel is in FLUSHING state", @@ -217,7 +217,7 @@ func (suite *KeeperTestSuite) TestSendPacket() { err = path.EndpointA.ChanUpgradeTry() suite.Require().NoError(err) }, - false, + types.ErrChannelNotFound, }, } @@ -243,13 +243,14 @@ func (suite *KeeperTestSuite) TestSendPacket() { sequence, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.SendPacket(suite.chainA.GetContext(), sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetData) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) // verify that the returned sequence matches expected value suite.Require().True(ok) suite.Require().Equal(expectedSequence, sequence, "send packet did not return the expected sequence of the outgoing packet") } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -637,7 +638,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) ack = ibcmock.MockAcknowledgement }, - true, + nil, }, { "success: channel flushing", @@ -648,7 +649,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHING }) }, - true, + nil, }, { "success: channel flush complete", @@ -659,21 +660,21 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.FLUSHCOMPLETE }) }, - true, + nil, }, {"channel not found", func() { // use wrong channel naming path.Setup() packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, ibctesting.InvalidID, ibctesting.InvalidID, defaultTimeoutHeight, disabledTimeoutTimestamp) ack = ibcmock.MockAcknowledgement - }, false}, + }, types.ErrChannelNotFound}, {"channel not open", func() { path.Setup() packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) ack = ibcmock.MockAcknowledgement path.EndpointB.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) - }, false}, + }, types.ErrInvalidChannelState}, { "no-op, already acked", func() { @@ -682,7 +683,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { ack = ibcmock.MockAcknowledgement suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetPacketAcknowledgement(suite.chainB.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), ack.Acknowledgement()) }, - false, + types.ErrAcknowledgementExists, }, { "empty acknowledgement", @@ -691,7 +692,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) ack = ibcmock.NewEmptyAcknowledgement() }, - false, + errorsmod.Wrap(types.ErrInvalidAcknowledgement, ""), }, { "acknowledgement is nil", @@ -700,7 +701,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) ack = nil }, - false, + errorsmod.Wrap(types.ErrInvalidAcknowledgement, ""), }, { "packet already received", @@ -715,7 +716,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { // set recv seq start to indicate packet was processed in previous upgrade suite.chainB.App.GetIBCKeeper().ChannelKeeper.SetRecvStartSequence(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, sequence+1) }, - false, + errorsmod.Wrap(types.ErrPacketReceived, ""), }, } for i, tc := range testCases { @@ -728,10 +729,11 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.WriteAcknowledgement(suite.chainB.GetContext(), packet, ack) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -745,7 +747,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() { ack = ibcmock.MockAcknowledgement ) - assertErr := func(errType *errors.Error) func(commitment []byte, channelVersion string, err error) { + assertErr := func(errType *errorsmod.Error) func(commitment []byte, channelVersion string, err error) { return func(commitment []byte, channelVersion string, err error) { suite.Require().Error(err) suite.Require().ErrorIs(err, errType) diff --git a/modules/core/04-channel/keeper/timeout_test.go b/modules/core/04-channel/keeper/timeout_test.go index 163d626e763..d7dc180200c 100644 --- a/modules/core/04-channel/keeper/timeout_test.go +++ b/modules/core/04-channel/keeper/timeout_test.go @@ -13,7 +13,9 @@ import ( clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" connectiontypes "github.com/cosmos/ibc-go/v9/modules/core/03-connection/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" + commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v9/modules/core/24-host" + ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors" "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/ibc-go/v9/testing/mock" @@ -46,7 +48,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // need to update chainA's client representing chainB to prove missing ack err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, true}, + }, nil}, {"success: UNORDERED", func() { ordered = false path.Setup() @@ -59,7 +61,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { // need to update chainA's client representing chainB to prove missing ack err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, true}, + }, nil}, {"packet already timed out: ORDERED", func() { expError = types.ErrNoOpMsg ordered = true @@ -78,7 +80,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) err = path.EndpointA.TimeoutPacket(packet) suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(types.ErrNoOpMsg, "")}, {"packet already timed out: UNORDERED", func() { expError = types.ErrNoOpMsg ordered = false @@ -95,25 +97,25 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) err = path.EndpointA.TimeoutPacket(packet) suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(types.ErrNoOpMsg, "")}, {"channel not found", func() { expError = types.ErrChannelNotFound // use wrong channel naming path.Setup() packet = types.NewPacket(ibctesting.MockPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, types.ErrChannelNotFound}, {"packet destination port ≠ channel counterparty port", func() { expError = types.ErrInvalidPacket path.Setup() // use wrong port for dest packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, ibctesting.InvalidID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(types.ErrInvalidPacket, "")}, {"packet destination channel ID ≠ channel counterparty channel ID", func() { expError = types.ErrInvalidPacket path.Setup() // use wrong channel for dest packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, ibctesting.InvalidID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(types.ErrInvalidPacket, "")}, {"connection not found", func() { expError = connectiontypes.ErrConnectionNotFound // pass channel check @@ -123,7 +125,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), []string{connIDA}, path.EndpointA.ChannelConfig.Version), ) packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"timeout", func() { expError = types.ErrTimeoutNotReached path.Setup() @@ -132,7 +134,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(types.ErrTimeoutNotReached, "")}, {"packet already received ", func() { expError = types.ErrPacketReceived ordered = true @@ -147,7 +149,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, timeoutTimestamp) err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(types.ErrPacketReceived, "")}, {"packet hasn't been sent", func() { expError = types.ErrNoOpMsg ordered = true @@ -157,7 +159,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, uint64(suite.chainB.GetContext().BlockTime().UnixNano())) err := path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(types.ErrNoOpMsg, "")}, {"next seq receive verification failed", func() { // skip error check, error occurs in light-clients @@ -174,7 +176,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "")}, {"packet ack verification failed", func() { // skip error check, error occurs in light-clients @@ -190,7 +192,7 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) err = path.EndpointA.UpdateClient() suite.Require().NoError(err) - }, false}, + }, errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "")}, } for _, tc := range testCases { @@ -221,11 +223,12 @@ func (suite *KeeperTestSuite) TestTimeoutPacket() { channelVersion, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.TimeoutPacket(suite.chainA.GetContext(), packet, proof, proofHeight, nextSeqRecv) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointA.GetChannel().Version, channelVersion) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) suite.Require().Equal("", channelVersion) // only check if expError is set, since not all error codes can be known if expError != nil { @@ -533,7 +536,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - }, true}, + }, nil}, {"success: UNORDERED", func() { ordered = false path.Setup() @@ -548,22 +551,22 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - }, true}, + }, nil}, {"channel not found", func() { // use wrong channel naming path.Setup() packet = types.NewPacket(ibctesting.MockPacketData, 1, ibctesting.InvalidID, ibctesting.InvalidID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, types.ErrChannelNotFound}, {"packet dest port ≠ channel counterparty port", func() { path.Setup() // use wrong port for dest packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, ibctesting.InvalidID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(types.ErrInvalidPacket, "")}, {"packet dest channel ID ≠ channel counterparty channel ID", func() { path.Setup() // use wrong channel for dest packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, ibctesting.InvalidID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(types.ErrInvalidPacket, "")}, {"connection not found", func() { // pass channel check suite.chainA.App.GetIBCKeeper().ChannelKeeper.SetChannel( @@ -572,13 +575,13 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { types.NewChannel(types.OPEN, types.ORDERED, types.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID), []string{connIDA}, path.EndpointA.ChannelConfig.Version), ) packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, "")}, {"packet hasn't been sent ORDERED", func() { path.SetChannelOrdered() path.Setup() packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) - }, false}, + }, errorsmod.Wrap(types.ErrNoOpMsg, "")}, {"packet already received ORDERED", func() { path.SetChannelOrdered() nextSeqRecv = 2 @@ -596,7 +599,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - }, false}, + }, errorsmod.Wrap(types.ErrInvalidPacket, "")}, {"channel verification failed ORDERED", func() { ordered = true path.SetChannelOrdered() @@ -608,7 +611,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, ibctesting.MockPacketData) suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, timeoutTimestamp) - }, false}, + }, ibcerrors.ErrInvalidHeight}, {"next seq receive verification failed ORDERED", func() { // set ordered to false providing the wrong proof for ORDERED case ordered = false @@ -625,7 +628,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), uint64(suite.chainB.GetContext().BlockTime().UnixNano())) - }, false}, + }, errorsmod.Wrap(types.ErrInvalidPacket, "")}, {"packet ack verification failed", func() { // set ordered to true providing the wrong proof for UNORDERED case ordered = true @@ -640,7 +643,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { suite.Require().NoError(err) packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - }, false}, + }, errorsmod.Wrap(commitmenttypes.ErrInvalidProof, "")}, { "failure: invalid counterparty upgrade sequence", func() { @@ -665,7 +668,7 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { packet = types.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) }, - false, + errorsmod.Wrap(commitmenttypes.ErrInvalidProof, ""), }, } @@ -703,12 +706,13 @@ func (suite *KeeperTestSuite) TestTimeoutOnClose() { counterpartyUpgradeSequence, ) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) suite.Require().Equal(path.EndpointA.GetChannel().Version, channelVersion) } else { suite.Require().Error(err) suite.Require().Equal("", channelVersion) + suite.Require().ErrorIs(err, tc.expErr) } }) } diff --git a/modules/core/04-channel/keeper/upgrade_test.go b/modules/core/04-channel/keeper/upgrade_test.go index 8189e2d9bd8..8565f12a195 100644 --- a/modules/core/04-channel/keeper/upgrade_test.go +++ b/modules/core/04-channel/keeper/upgrade_test.go @@ -28,12 +28,12 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success", func() {}, - true, + nil, }, { "success with later upgrade sequence", @@ -41,7 +41,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.UpgradeSequence = 4 }) expSequence = 5 }, - true, + nil, }, { "upgrade fields are identical to channel end", @@ -49,7 +49,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { channel := path.EndpointA.GetChannel() upgradeFields = types.NewUpgradeFields(channel.Ordering, channel.ConnectionHops, channel.Version) }, - false, + errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), }, { "channel not found", @@ -57,21 +57,21 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { path.EndpointA.ChannelID = "invalid-channel" path.EndpointA.ChannelConfig.PortID = "invalid-port" }, - false, + errorsmod.Wrapf(types.ErrChannelNotFound, "port ID (invalid-port) channel ID (invalid-channel)"), }, { "channel state is not in OPEN state", func() { path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) }, - false, + errorsmod.Wrapf(types.ErrInvalidChannelState, "expected STATE_OPEN, got STATE_CLOSED"), }, { "proposed channel connection not found", func() { upgradeFields.ConnectionHops = []string{"connection-100"} }, - false, + errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "failed to retrieve connection: connection-100"), }, { "invalid proposed channel connection state", @@ -79,7 +79,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) upgradeFields.ConnectionHops = []string{"connection-100"} }, - false, + errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "failed to retrieve connection: connection-100"), }, } @@ -101,7 +101,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgradeFields, ) - if tc.expPass { + if tc.expErr == nil { ctx := suite.chainA.GetContext() suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.WriteUpgradeInitChannel(ctx, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, upgrade, upgrade.Fields.Version) channel := path.EndpointA.GetChannel() @@ -112,6 +112,7 @@ func (suite *KeeperTestSuite) TestChanUpgradeInit() { suite.Require().Equal(types.OPEN, channel.State) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -2309,14 +2310,14 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() { tests := []struct { name string malleate func() - expPass bool + expErr error }{ { name: "change channel version", malleate: func() { proposedUpgrade.Version = mock.UpgradeVersion }, - expPass: true, + expErr: nil, }, { name: "change connection hops", @@ -2325,12 +2326,12 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() { path.Setup() proposedUpgrade.ConnectionHops = []string{path.EndpointA.ConnectionID} }, - expPass: true, + expErr: nil, }, { name: "fails with unmodified fields", malleate: func() {}, - expPass: false, + expErr: errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), }, { name: "fails when connection is not set", @@ -2339,14 +2340,14 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() { kvStore := suite.chainA.GetContext().KVStore(storeKey) kvStore.Delete(host.ConnectionKey(ibctesting.FirstConnectionID)) }, - expPass: false, + expErr: errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), }, { name: "fails when connection is not open", malleate: func() { path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) { c.State = connectiontypes.UNINITIALIZED }) }, - expPass: false, + expErr: errorsmod.Wrapf(types.ErrInvalidUpgrade, "existing channel end is identical to proposed upgrade channel end: got {ORDER_UNORDERED [connection-0] mock-version}"), }, { name: "fails when connection versions do not exist", @@ -2358,7 +2359,7 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() { c.Versions = []*connectiontypes.Version{} }) }, - expPass: false, + expErr: errorsmod.Wrapf(connectiontypes.ErrInvalidVersion, "single version must be negotiated on connection before opening channel, got: []"), }, { name: "fails when connection version does not support the new ordering", @@ -2370,7 +2371,7 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() { c.Versions = []*connectiontypes.Version{connectiontypes.NewVersion("1", []string{"ORDER_ORDERED"})} }) }, - expPass: false, + expErr: errorsmod.Wrapf(connectiontypes.ErrInvalidVersion, "connection version identifier:\"1\" features:\"ORDER_ORDERED\" does not support channel ordering: ORDER_UNORDERED"), }, } @@ -2391,10 +2392,11 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() { tc.malleate() err := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.ValidateSelfUpgradeFields(suite.chainA.GetContext(), *proposedUpgrade, existingChannel) - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err) } else { suite.Require().Error(err) + suite.Require().ErrorIs(err, tc.expErr) } }) } @@ -2424,12 +2426,12 @@ func (suite *KeeperTestSuite) TestAbortUpgrade() { tests := []struct { name string malleate func() - expPass bool + expErr error }{ { name: "success", malleate: func() {}, - expPass: true, + expErr: nil, }, { name: "regular error", @@ -2438,21 +2440,21 @@ func (suite *KeeperTestSuite) TestAbortUpgrade() { // i.e. not an instance of `types.UpgradeError` upgradeError = types.ErrInvalidUpgrade }, - expPass: true, + expErr: nil, }, { name: "channel does not exist", malleate: func() { suite.chainA.DeleteKey(host.ChannelKey(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) }, - expPass: false, + expErr: types.ErrChannelNotFound, }, { name: "fails with nil upgrade error", malleate: func() { upgradeError = nil }, - expPass: false, + expErr: types.ErrInvalidUpgradeError, }, } @@ -2476,7 +2478,7 @@ func (suite *KeeperTestSuite) TestAbortUpgrade() { tc.malleate() - if tc.expPass { + if tc.expErr == nil { ctx := suite.chainA.GetContext() From 0d3a7afc799951109180c00448f5660d36dd64d2 Mon Sep 17 00:00:00 2001 From: bmo Date: Thu, 12 Dec 2024 18:43:40 +0200 Subject: [PATCH 3/7] chores: use error in test unmarshal (#7679) Co-authored-by: DimitrisJim --- modules/apps/29-fee/ibc_middleware_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/apps/29-fee/ibc_middleware_test.go b/modules/apps/29-fee/ibc_middleware_test.go index 059a7d28cff..b3b7f3a9d41 100644 --- a/modules/apps/29-fee/ibc_middleware_test.go +++ b/modules/apps/29-fee/ibc_middleware_test.go @@ -1557,17 +1557,17 @@ func (suite *FeeTestSuite) TestAckUnmarshal() { testCases := []struct { name string ackBytes []byte - expPass bool + expError error }{ { "success", []byte(`{"app_acknowledgement": "eyJyZXN1bHQiOiJiVzlqYXlCaFkydHViM2RzWldsblpXMWxiblE9In0=", "forward_relayer_address": "relayer", "underlying_app_success": true}`), - true, + nil, }, { "failure: unknown fields", []byte(`{"app_acknowledgement": "eyJyZXN1bHQiOiJiVzlqYXlCaFkydHViM2RzWldsblpXMWxiblE9In0=", "forward_relayer_address": "relayer", "underlying_app_success": true, "extra_field": "foo"}`), - false, + errors.New("json: unknown field \"extra_field\""), }, } for _, tc := range testCases { @@ -1575,10 +1575,10 @@ func (suite *FeeTestSuite) TestAckUnmarshal() { ack := &types.IncentivizedAcknowledgement{} err := json.Unmarshal(tc.ackBytes, ack) - if tc.expPass { + if tc.expError == nil { suite.Require().NoError(err) } else { - suite.Require().Error(err) + suite.Require().ErrorContains(err, tc.expError.Error()) } }) } From 05efed953dcfdc1c755f003a90bf6e93880b95ae Mon Sep 17 00:00:00 2001 From: Alyak Date: Fri, 13 Dec 2024 14:10:30 +0200 Subject: [PATCH 4/7] use unordered check (#7689) --- modules/core/04-channel/v2/keeper/keeper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/keeper.go b/modules/core/04-channel/v2/keeper/keeper.go index 6397568973d..febc06a1f24 100644 --- a/modules/core/04-channel/v2/keeper/keeper.go +++ b/modules/core/04-channel/v2/keeper/keeper.go @@ -221,8 +221,8 @@ func (k *Keeper) aliasV1Channel(ctx context.Context, portID, channelID string) ( return types.Channel{}, false } // Do not allow channel to be converted into a version 2 channel - // if the channel is not OPEN or if it is ORDERED - if channel.State != channeltypesv1.OPEN || channel.Ordering == channeltypesv1.ORDERED { + // if the channel is not OPEN or if it is not UNORDERED + if channel.State != channeltypesv1.OPEN || channel.Ordering != channeltypesv1.UNORDERED { return types.Channel{}, false } connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) From a8ee5482456c40d75ada0a3739204a5f7a0689ca Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 16 Dec 2024 10:46:00 +0200 Subject: [PATCH 5/7] chore: add telemetry reporting for packet methods (#7673) --- .../core/04-channel/v2/keeper/msg_server.go | 4 ++ modules/core/internal/v2/telemetry/packet.go | 56 ++++++++++++++++--- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index e7fff53b9af..3c80eb9671b 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -226,6 +226,8 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem } } + defer telemetry.ReportAcknowledgePacket(msg.Packet) + return &types.MsgAcknowledgementResponse{Result: types.SUCCESS}, nil } @@ -265,5 +267,7 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types } } + defer telemetry.ReportTimeoutPacket(timeout.Packet) + return &types.MsgTimeoutResponse{Result: types.SUCCESS}, nil } diff --git a/modules/core/internal/v2/telemetry/packet.go b/modules/core/internal/v2/telemetry/packet.go index 7c5c8588247..8d12f785960 100644 --- a/modules/core/internal/v2/telemetry/packet.go +++ b/modules/core/internal/v2/telemetry/packet.go @@ -1,14 +1,56 @@ package telemetry import ( - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + metrics "github.com/hashicorp/go-metrics" + + "github.com/cosmos/cosmos-sdk/telemetry" + + "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibcmetrics "github.com/cosmos/ibc-go/v9/modules/core/metrics" ) -// ReportRecvPacket TODO: https://github.com/cosmos/ibc-go/issues/7437 -func ReportRecvPacket(packet channeltypesv2.Packet) {} +func ReportRecvPacket(packet types.Packet) { + for _, payload := range packet.Payloads { + telemetry.IncrCounterWithLabels( + []string{"tx", "msg", "ibc", types.EventTypeRecvPacket}, + 1, + []metrics.Label{ + telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + }, + ) + } +} -// ReportTimeoutPacket TODO: https://github.com/cosmos/ibc-go/issues/7437 -func ReportTimeoutPacket(packet channeltypesv2.Packet, timeoutType string) {} +func ReportTimeoutPacket(packet types.Packet) { + for _, payload := range packet.Payloads { + telemetry.IncrCounterWithLabels( + []string{"ibc", "timeout", "packet"}, + 1, + []metrics.Label{ + telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + telemetry.NewLabel(ibcmetrics.LabelTimeoutType, "height"), + }, + ) + } +} -// ReportAcknowledgePacket TODO: https://github.com/cosmos/ibc-go/issues/7437 -func ReportAcknowledgePacket(packet channeltypesv2.Packet) {} +func ReportAcknowledgePacket(packet types.Packet) { + for _, payload := range packet.Payloads { + telemetry.IncrCounterWithLabels( + []string{"tx", "msg", "ibc", types.EventTypeAcknowledgePacket}, + 1, + []metrics.Label{ + telemetry.NewLabel(ibcmetrics.LabelSourcePort, payload.SourcePort), + telemetry.NewLabel(ibcmetrics.LabelSourceChannel, packet.SourceChannel), + telemetry.NewLabel(ibcmetrics.LabelDestinationPort, payload.DestinationPort), + telemetry.NewLabel(ibcmetrics.LabelDestinationChannel, packet.DestinationChannel), + }, + ) + } +} From a64877ff603783dd73610a85a6f5425d8785b722 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 16 Dec 2024 12:47:06 +0200 Subject: [PATCH 6/7] chore: remove redundant calls to emit events in cached context. (#7648) --- modules/core/04-channel/v2/keeper/msg_server.go | 2 -- modules/core/04-channel/v2/keeper/packet.go | 5 ----- 2 files changed, 7 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/msg_server.go b/modules/core/04-channel/v2/keeper/msg_server.go index 3c80eb9671b..179e44fd93f 100644 --- a/modules/core/04-channel/v2/keeper/msg_server.go +++ b/modules/core/04-channel/v2/keeper/msg_server.go @@ -209,7 +209,6 @@ func (k *Keeper) Acknowledgement(ctx context.Context, msg *types.MsgAcknowledgem case nil: writeFn() case types.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", msg.Packet.SourceChannel) return &types.MsgAcknowledgementResponse{Result: types.NOOP}, nil default: @@ -251,7 +250,6 @@ func (k *Keeper) Timeout(ctx context.Context, timeout *types.MsgTimeout) (*types case nil: writeFn() case types.ErrNoOpMsg: - // no-ops do not need event emission as they will be ignored sdkCtx.Logger().Debug("no-op on redundant relay", "source-channel", timeout.Packet.SourceChannel) return &types.MsgTimeoutResponse{Result: types.NOOP}, nil default: diff --git a/modules/core/04-channel/v2/keeper/packet.go b/modules/core/04-channel/v2/keeper/packet.go index 868d12a047d..ef396bca6a5 100644 --- a/modules/core/04-channel/v2/keeper/packet.go +++ b/modules/core/04-channel/v2/keeper/packet.go @@ -126,7 +126,6 @@ func (k *Keeper) recvPacket( // on unordered channels. Packet receipts must not be pruned, unless it has been marked stale // by the increase of the recvStartSequence. if k.HasPacketReceipt(ctx, packet.DestinationChannel, packet.Sequence) { - emitRecvPacketEvents(ctx, packet) // This error indicates that the packet has already been relayed. Core IBC will // treat this error as a no-op in order to prevent an entire relay transaction // from failing and consuming unnecessary fees. @@ -221,9 +220,6 @@ func (k *Keeper) acknowledgePacket(ctx context.Context, packet types.Packet, ack commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { - // TODO: signal noop in events? - emitAcknowledgePacketEvents(ctx, packet) - // This error indicates that the acknowledgement has already been relayed // or there is a misconfigured relayer attempting to prove an acknowledgement // for a packet never sent. Core IBC will treat this error as a no-op in order to @@ -300,7 +296,6 @@ func (k *Keeper) timeoutPacket( // check that the commitment has not been cleared and that it matches the packet sent by relayer commitment := k.GetPacketCommitment(ctx, packet.SourceChannel, packet.Sequence) if len(commitment) == 0 { - emitTimeoutPacketEvents(ctx, packet) // This error indicates that the timeout has already been relayed // or there is a misconfigured relayer attempting to prove a timeout // for a packet never sent. Core IBC will treat this error as a no-op in order to From a5b69ec73687dec86e1f6ab5a2aebd9c667a5f3e Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Mon, 16 Dec 2024 13:29:15 +0200 Subject: [PATCH 7/7] chore: add channel consensus state rpc (#7619) --- .../core/04-channel/v2/keeper/grpc_query.go | 32 + .../04-channel/v2/keeper/grpc_query_test.go | 108 ++ .../04-channel/v2/types/expected_keepers.go | 2 + modules/core/04-channel/v2/types/query.go | 16 +- modules/core/04-channel/v2/types/query.pb.go | 925 +++++++++++++++--- .../core/04-channel/v2/types/query.pb.gw.go | 119 +++ proto/ibc/core/channel/v2/query.proto | 31 + 7 files changed, 1088 insertions(+), 145 deletions(-) diff --git a/modules/core/04-channel/v2/keeper/grpc_query.go b/modules/core/04-channel/v2/keeper/grpc_query.go index 2b5e2bab977..93ccb5f41ee 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query.go +++ b/modules/core/04-channel/v2/keeper/grpc_query.go @@ -78,6 +78,38 @@ func (q *queryServer) ChannelClientState(ctx context.Context, req *types.QueryCh return res, nil } +// ChannelConsensusState implements the Query/ChannelConsensusState gRPC method +func (q *queryServer) ChannelConsensusState(ctx context.Context, req *types.QueryChannelConsensusStateRequest) (*types.QueryChannelConsensusStateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if err := host.ChannelIdentifierValidator(req.ChannelId); err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + channel, found := q.GetChannel(ctx, req.ChannelId) + if !found { + return nil, status.Error(codes.NotFound, errorsmod.Wrapf(types.ErrChannelNotFound, "channel-id: %s", req.ChannelId).Error()) + } + + consHeight := clienttypes.NewHeight(req.RevisionNumber, req.RevisionHeight) + consensusState, found := q.ClientKeeper.GetClientConsensusState(ctx, channel.ClientId, consHeight) + if !found { + return nil, status.Error( + codes.NotFound, + errorsmod.Wrapf(clienttypes.ErrConsensusStateNotFound, "client-id: %s", channel.ClientId).Error(), + ) + } + + anyConsensusState, err := clienttypes.PackConsensusState(consensusState) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return types.NewQueryChannelConsensusStateResponse(channel.ClientId, anyConsensusState, nil, clienttypes.GetSelfHeight(ctx)), nil +} + // NextSequenceSend implements the Query/NextSequenceSend gRPC method func (q *queryServer) NextSequenceSend(ctx context.Context, req *types.QueryNextSequenceSendRequest) (*types.QueryNextSequenceSendResponse, error) { if req == nil { diff --git a/modules/core/04-channel/v2/keeper/grpc_query_test.go b/modules/core/04-channel/v2/keeper/grpc_query_test.go index 58c0e3bf810..4af5b3414b5 100644 --- a/modules/core/04-channel/v2/keeper/grpc_query_test.go +++ b/modules/core/04-channel/v2/keeper/grpc_query_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/keeper" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" + "github.com/cosmos/ibc-go/v9/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v9/testing" ) @@ -190,6 +191,113 @@ func (suite *KeeperTestSuite) TestQueryChannelClientState() { } } +func (suite *KeeperTestSuite) TestQueryChannelConsensusState() { + var ( + req *types.QueryChannelConsensusStateRequest + expConsensusState exported.ConsensusState + expClientID string + ) + + testCases := []struct { + msg string + malleate func() + expError error + }{ + { + "success", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + expConsensusState, _ = suite.chainA.GetConsensusState(path.EndpointA.ClientID, path.EndpointA.GetClientLatestHeight()) + suite.Require().NotNil(expConsensusState) + expClientID = path.EndpointA.ClientID + + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: path.EndpointA.ChannelID, + RevisionNumber: path.EndpointA.GetClientLatestHeight().GetRevisionNumber(), + RevisionHeight: path.EndpointA.GetClientLatestHeight().GetRevisionHeight(), + } + }, + nil, + }, + { + "empty request", + func() { + req = nil + }, + status.Error(codes.InvalidArgument, "empty request"), + }, + { + "invalid channel ID", + func() { + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: "", + RevisionNumber: 0, + RevisionHeight: 1, + } + }, + status.Error(codes.InvalidArgument, "identifier cannot be blank: invalid identifier"), + }, + { + "channel not found", + func() { + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: "test-channel-id", + RevisionNumber: 0, + RevisionHeight: 1, + } + }, + status.Error(codes.NotFound, fmt.Sprintf("channel-id: %s: channel not found", "test-channel-id")), + }, + { + "consensus state for channel's connection not found", + func() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + path.SetupV2() + + req = &types.QueryChannelConsensusStateRequest{ + ChannelId: path.EndpointA.ChannelID, + RevisionNumber: 0, + RevisionHeight: uint64(suite.chainA.GetContext().BlockHeight()), // use current height + } + }, + status.Error(codes.NotFound, fmt.Sprintf("client-id: %s: consensus state not found", "07-tendermint-0")), + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + tc.malleate() + ctx := suite.chainA.GetContext() + + queryServer := keeper.NewQueryServer(suite.chainA.App.GetIBCKeeper().ChannelKeeperV2) + res, err := queryServer.ChannelConsensusState(ctx, req) + + expPass := tc.expError == nil + if expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + consensusState, err := clienttypes.UnpackConsensusState(res.ConsensusState) + suite.Require().NoError(err) + suite.Require().Equal(expConsensusState, consensusState) + suite.Require().Equal(expClientID, res.ClientId) + + // ensure UnpackInterfaces is defined + cachedValue := res.ConsensusState.GetCachedValue() + suite.Require().NotNil(cachedValue) + } else { + suite.Require().ErrorIs(err, tc.expError) + suite.Require().Nil(res) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryPacketCommitment() { var ( expCommitment []byte diff --git a/modules/core/04-channel/v2/types/expected_keepers.go b/modules/core/04-channel/v2/types/expected_keepers.go index 9f94668a8a0..32cda94bba8 100644 --- a/modules/core/04-channel/v2/types/expected_keepers.go +++ b/modules/core/04-channel/v2/types/expected_keepers.go @@ -21,4 +21,6 @@ type ClientKeeper interface { GetClientTimestampAtHeight(ctx context.Context, clientID string, height exported.Height) (uint64, error) // GetClientState gets a particular client from the store GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool) + // GetClientConsensusState gets the stored consensus state from a client at a given height. + GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool) } diff --git a/modules/core/04-channel/v2/types/query.go b/modules/core/04-channel/v2/types/query.go index af4b2d7ae45..92913c0ae19 100644 --- a/modules/core/04-channel/v2/types/query.go +++ b/modules/core/04-channel/v2/types/query.go @@ -1,6 +1,10 @@ package types -import clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" +) // NewQueryChannelRequest creates and returns a new channel query request. func NewQueryChannelRequest(channelID string) *QueryChannelRequest { @@ -32,6 +36,16 @@ func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.Identi } } +// NewQueryChannelConsensusStateResponse creates and returns a new ChannelConsensusState query response. +func NewQueryChannelConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, proof []byte, height clienttypes.Height) *QueryChannelConsensusStateResponse { + return &QueryChannelConsensusStateResponse{ + ConsensusState: anyConsensusState, + ClientId: clientID, + Proof: proof, + ProofHeight: height, + } +} + // NewQueryNextSequenceSendRequest creates a new next sequence send query. func NewQueryNextSequenceSendRequest(channelID string) *QueryNextSequenceSendRequest { return &QueryNextSequenceSendRequest{ diff --git a/modules/core/04-channel/v2/types/query.pb.go b/modules/core/04-channel/v2/types/query.pb.go index 37132d2bebc..90f01927af7 100644 --- a/modules/core/04-channel/v2/types/query.pb.go +++ b/modules/core/04-channel/v2/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + types1 "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -234,6 +235,145 @@ func (m *QueryChannelClientStateResponse) GetProofHeight() types.Height { return types.Height{} } +// QueryChannelConsensusStateRequest is the request type for the Query/ConsensusState +// RPC method +type QueryChannelConsensusStateRequest struct { + // channel unique identifier + ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // revision number of the consensus state + RevisionNumber uint64 `protobuf:"varint,2,opt,name=revision_number,json=revisionNumber,proto3" json:"revision_number,omitempty"` + // revision height of the consensus state + RevisionHeight uint64 `protobuf:"varint,3,opt,name=revision_height,json=revisionHeight,proto3" json:"revision_height,omitempty"` +} + +func (m *QueryChannelConsensusStateRequest) Reset() { *m = QueryChannelConsensusStateRequest{} } +func (m *QueryChannelConsensusStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChannelConsensusStateRequest) ProtoMessage() {} +func (*QueryChannelConsensusStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{4} +} +func (m *QueryChannelConsensusStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelConsensusStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelConsensusStateRequest.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 *QueryChannelConsensusStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelConsensusStateRequest.Merge(m, src) +} +func (m *QueryChannelConsensusStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelConsensusStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelConsensusStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelConsensusStateRequest proto.InternalMessageInfo + +func (m *QueryChannelConsensusStateRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryChannelConsensusStateRequest) GetRevisionNumber() uint64 { + if m != nil { + return m.RevisionNumber + } + return 0 +} + +func (m *QueryChannelConsensusStateRequest) GetRevisionHeight() uint64 { + if m != nil { + return m.RevisionHeight + } + return 0 +} + +// QueryChannelConsensusStateResponse is the Response type for the +// Query/QueryChannelConsensusState RPC method +type QueryChannelConsensusStateResponse struct { + // consensus state associated with the channel + ConsensusState *types1.Any `protobuf:"bytes,1,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty"` + // client ID associated with the consensus state + ClientId string `protobuf:"bytes,2,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` + // merkle proof of existence + Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + // height at which the proof was retrieved + ProofHeight types.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"` +} + +func (m *QueryChannelConsensusStateResponse) Reset() { *m = QueryChannelConsensusStateResponse{} } +func (m *QueryChannelConsensusStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChannelConsensusStateResponse) ProtoMessage() {} +func (*QueryChannelConsensusStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_a328cba4986edcab, []int{5} +} +func (m *QueryChannelConsensusStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChannelConsensusStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChannelConsensusStateResponse.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 *QueryChannelConsensusStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChannelConsensusStateResponse.Merge(m, src) +} +func (m *QueryChannelConsensusStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryChannelConsensusStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChannelConsensusStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChannelConsensusStateResponse proto.InternalMessageInfo + +func (m *QueryChannelConsensusStateResponse) GetConsensusState() *types1.Any { + if m != nil { + return m.ConsensusState + } + return nil +} + +func (m *QueryChannelConsensusStateResponse) GetClientId() string { + if m != nil { + return m.ClientId + } + return "" +} + +func (m *QueryChannelConsensusStateResponse) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryChannelConsensusStateResponse) GetProofHeight() types.Height { + if m != nil { + return m.ProofHeight + } + return types.Height{} +} + // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method type QueryNextSequenceSendRequest struct { // channel unique identifier @@ -244,7 +384,7 @@ func (m *QueryNextSequenceSendRequest) Reset() { *m = QueryNextSequenceS func (m *QueryNextSequenceSendRequest) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendRequest) ProtoMessage() {} func (*QueryNextSequenceSendRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{4} + return fileDescriptor_a328cba4986edcab, []int{6} } func (m *QueryNextSequenceSendRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -294,7 +434,7 @@ func (m *QueryNextSequenceSendResponse) Reset() { *m = QueryNextSequence func (m *QueryNextSequenceSendResponse) String() string { return proto.CompactTextString(m) } func (*QueryNextSequenceSendResponse) ProtoMessage() {} func (*QueryNextSequenceSendResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{5} + return fileDescriptor_a328cba4986edcab, []int{7} } func (m *QueryNextSequenceSendResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -356,7 +496,7 @@ func (m *QueryPacketCommitmentRequest) Reset() { *m = QueryPacketCommitm func (m *QueryPacketCommitmentRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentRequest) ProtoMessage() {} func (*QueryPacketCommitmentRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{6} + return fileDescriptor_a328cba4986edcab, []int{8} } func (m *QueryPacketCommitmentRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,7 +553,7 @@ func (m *QueryPacketCommitmentResponse) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentResponse) ProtoMessage() {} func (*QueryPacketCommitmentResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{7} + return fileDescriptor_a328cba4986edcab, []int{9} } func (m *QueryPacketCommitmentResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -475,7 +615,7 @@ func (m *QueryPacketCommitmentsRequest) Reset() { *m = QueryPacketCommit func (m *QueryPacketCommitmentsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsRequest) ProtoMessage() {} func (*QueryPacketCommitmentsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{8} + return fileDescriptor_a328cba4986edcab, []int{10} } func (m *QueryPacketCommitmentsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -532,7 +672,7 @@ func (m *QueryPacketCommitmentsResponse) Reset() { *m = QueryPacketCommi func (m *QueryPacketCommitmentsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketCommitmentsResponse) ProtoMessage() {} func (*QueryPacketCommitmentsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{9} + return fileDescriptor_a328cba4986edcab, []int{11} } func (m *QueryPacketCommitmentsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -594,7 +734,7 @@ func (m *QueryPacketAcknowledgementRequest) Reset() { *m = QueryPacketAc func (m *QueryPacketAcknowledgementRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{10} + return fileDescriptor_a328cba4986edcab, []int{12} } func (m *QueryPacketAcknowledgementRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -651,7 +791,7 @@ func (m *QueryPacketAcknowledgementResponse) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{11} + return fileDescriptor_a328cba4986edcab, []int{13} } func (m *QueryPacketAcknowledgementResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -716,7 +856,7 @@ func (m *QueryPacketAcknowledgementsRequest) Reset() { *m = QueryPacketA func (m *QueryPacketAcknowledgementsRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsRequest) ProtoMessage() {} func (*QueryPacketAcknowledgementsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{12} + return fileDescriptor_a328cba4986edcab, []int{14} } func (m *QueryPacketAcknowledgementsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -780,7 +920,7 @@ func (m *QueryPacketAcknowledgementsResponse) Reset() { *m = QueryPacket func (m *QueryPacketAcknowledgementsResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketAcknowledgementsResponse) ProtoMessage() {} func (*QueryPacketAcknowledgementsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{13} + return fileDescriptor_a328cba4986edcab, []int{15} } func (m *QueryPacketAcknowledgementsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -844,7 +984,7 @@ func (m *QueryPacketReceiptRequest) Reset() { *m = QueryPacketReceiptReq func (m *QueryPacketReceiptRequest) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptRequest) ProtoMessage() {} func (*QueryPacketReceiptRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{14} + return fileDescriptor_a328cba4986edcab, []int{16} } func (m *QueryPacketReceiptRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -908,7 +1048,7 @@ func (m *QueryPacketReceiptResponse) Reset() { *m = QueryPacketReceiptRe func (m *QueryPacketReceiptResponse) String() string { return proto.CompactTextString(m) } func (*QueryPacketReceiptResponse) ProtoMessage() {} func (*QueryPacketReceiptResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{15} + return fileDescriptor_a328cba4986edcab, []int{17} } func (m *QueryPacketReceiptResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -970,7 +1110,7 @@ func (m *QueryUnreceivedPacketsRequest) Reset() { *m = QueryUnreceivedPa func (m *QueryUnreceivedPacketsRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsRequest) ProtoMessage() {} func (*QueryUnreceivedPacketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{16} + return fileDescriptor_a328cba4986edcab, []int{18} } func (m *QueryUnreceivedPacketsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1025,7 +1165,7 @@ func (m *QueryUnreceivedPacketsResponse) Reset() { *m = QueryUnreceivedP func (m *QueryUnreceivedPacketsResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedPacketsResponse) ProtoMessage() {} func (*QueryUnreceivedPacketsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{17} + return fileDescriptor_a328cba4986edcab, []int{19} } func (m *QueryUnreceivedPacketsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1081,7 +1221,7 @@ func (m *QueryUnreceivedAcksRequest) Reset() { *m = QueryUnreceivedAcksR func (m *QueryUnreceivedAcksRequest) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksRequest) ProtoMessage() {} func (*QueryUnreceivedAcksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{18} + return fileDescriptor_a328cba4986edcab, []int{20} } func (m *QueryUnreceivedAcksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1137,7 +1277,7 @@ func (m *QueryUnreceivedAcksResponse) Reset() { *m = QueryUnreceivedAcks func (m *QueryUnreceivedAcksResponse) String() string { return proto.CompactTextString(m) } func (*QueryUnreceivedAcksResponse) ProtoMessage() {} func (*QueryUnreceivedAcksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a328cba4986edcab, []int{19} + return fileDescriptor_a328cba4986edcab, []int{21} } func (m *QueryUnreceivedAcksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1185,6 +1325,8 @@ func init() { proto.RegisterType((*QueryChannelResponse)(nil), "ibc.core.channel.v2.QueryChannelResponse") proto.RegisterType((*QueryChannelClientStateRequest)(nil), "ibc.core.channel.v2.QueryChannelClientStateRequest") proto.RegisterType((*QueryChannelClientStateResponse)(nil), "ibc.core.channel.v2.QueryChannelClientStateResponse") + proto.RegisterType((*QueryChannelConsensusStateRequest)(nil), "ibc.core.channel.v2.QueryChannelConsensusStateRequest") + proto.RegisterType((*QueryChannelConsensusStateResponse)(nil), "ibc.core.channel.v2.QueryChannelConsensusStateResponse") proto.RegisterType((*QueryNextSequenceSendRequest)(nil), "ibc.core.channel.v2.QueryNextSequenceSendRequest") proto.RegisterType((*QueryNextSequenceSendResponse)(nil), "ibc.core.channel.v2.QueryNextSequenceSendResponse") proto.RegisterType((*QueryPacketCommitmentRequest)(nil), "ibc.core.channel.v2.QueryPacketCommitmentRequest") @@ -1206,82 +1348,91 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v2/query.proto", fileDescriptor_a328cba4986edcab) } var fileDescriptor_a328cba4986edcab = []byte{ - // 1197 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xce, 0x64, 0xd3, 0xfc, 0x78, 0x09, 0x34, 0x9d, 0xa6, 0x34, 0x75, 0xd3, 0x4d, 0x6a, 0x24, - 0xd8, 0x56, 0xad, 0x27, 0xd9, 0x44, 0xb4, 0x95, 0x5a, 0xa2, 0x24, 0x94, 0x36, 0x15, 0xa0, 0xe0, - 0x00, 0x12, 0xa8, 0xea, 0xca, 0xeb, 0x9d, 0x38, 0x56, 0x76, 0x3d, 0xee, 0x8e, 0x77, 0x49, 0x55, - 0xe5, 0xc2, 0x81, 0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x9a, 0xd7, 0x48, 0x8d, 0x55, 0x1a, 0x55, 0xca, 0x7d, 0x7a, - 0xf3, 0x4b, 0x97, 0x43, 0x0c, 0xbd, 0x07, 0x2e, 0xe5, 0xe5, 0x61, 0xf1, 0x77, 0xd7, 0xe2, 0x7f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x15, 0x99, 0x77, 0xb3, 0xed, 0x13, 0x00, 0x00, + // 1334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x4f, 0xdc, 0x46, + 0x14, 0x66, 0x58, 0x92, 0xc0, 0x23, 0x0d, 0x30, 0x81, 0x06, 0x0c, 0x59, 0x88, 0x2b, 0x35, 0x9b, + 0x28, 0xb1, 0x61, 0x41, 0x4d, 0x52, 0x41, 0x11, 0xd0, 0x34, 0x21, 0x6a, 0x23, 0x6a, 0xda, 0x4a, + 0xad, 0xa2, 0xac, 0xbc, 0xf6, 0xb0, 0x58, 0xec, 0x8e, 0x9d, 0x1d, 0xef, 0x16, 0x14, 0x71, 0xe9, + 0xa1, 0xe7, 0xaa, 0xe9, 0xa9, 0x7f, 0x41, 0xfb, 0x57, 0x34, 0x52, 0x2f, 0x91, 0xd2, 0x43, 0xa4, + 0x1c, 0x5a, 0xa9, 0x52, 0x7f, 0x40, 0xa5, 0xfe, 0x07, 0x3d, 0x57, 0x3b, 0x1e, 0xef, 0xda, 0xbb, + 0x5e, 0x63, 0x27, 0xa1, 0xea, 0x6d, 0x3d, 0x7e, 0xef, 0xcd, 0xf7, 0x7d, 0xf3, 0x66, 0xe6, 0xf3, + 0xc2, 0xb4, 0x55, 0x34, 0x54, 0xc3, 0xae, 0x12, 0xd5, 0xd8, 0xd6, 0x29, 0x25, 0x65, 0xb5, 0x9e, + 0x57, 0x1f, 0xd4, 0x48, 0x75, 0x4f, 0x71, 0xaa, 0xb6, 0x6b, 0xe3, 0xb3, 0x56, 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c, 0x77, 0xad, 0x20, 0x20, 0xea, 0x70, 0xce, 0x32, 0x09, 0x75, 0xad, + 0x2d, 0x8b, 0x98, 0x05, 0x4f, 0xda, 0x02, 0x6b, 0x84, 0x08, 0xc8, 0x97, 0x02, 0x90, 0x3d, 0xe1, + 0xeb, 0x73, 0xca, 0x7a, 0x33, 0x25, 0x58, 0x73, 0xcc, 0x8a, 0x1a, 0xc6, 0xa3, 0x70, 0xc2, 0xa9, + 0xda, 0xf6, 0xd6, 0x78, 0xef, 0x0c, 0xca, 0x9d, 0xd6, 0xbc, 0x07, 0xbc, 0x06, 0xa7, 0xf9, 0x8f, + 0xc2, 0x36, 0xb1, 0x4a, 0xdb, 0xee, 0x78, 0x86, 0xcf, 0x26, 0x45, 0xcd, 0x76, 0x9b, 0x47, 0x08, + 0x79, 0x06, 0x79, 0x96, 0x37, 0x24, 0x7f, 0x83, 0xe0, 0x42, 0x88, 0x61, 0x83, 0x13, 0x65, 0x35, + 0x96, 0x42, 0x26, 0x7c, 0x11, 0x86, 0xaa, 0xa4, 0x6e, 0x31, 0xcb, 0xa6, 0x05, 0x5a, 0xab, 0x14, + 0x49, 0x95, 0x23, 0xed, 0xd3, 0xce, 0xf8, 0xc3, 0x77, 0xf9, 0x68, 0x28, 0x30, 0x80, 0x3a, 0x10, + 0x28, 0x60, 0xfd, 0x8a, 0x40, 0x8e, 0x83, 0x25, 0xb4, 0x5f, 0x82, 0x21, 0xc3, 0x7f, 0x13, 0xd2, + 0x7c, 0x54, 0xf1, 0xfa, 0x56, 0xf1, 0xfb, 0x56, 0x59, 0xa1, 0x7b, 0xda, 0x19, 0x23, 0x54, 0x06, + 0x4f, 0xc2, 0x80, 0x58, 0x2f, 0xcb, 0xe4, 0x88, 0x07, 0xb4, 0x7e, 0x6f, 0x60, 0xdd, 0x6c, 0x89, + 0x9e, 0x89, 0x13, 0xbd, 0xef, 0x45, 0x44, 0x5f, 0x82, 0x29, 0x4e, 0xee, 0x2e, 0xd9, 0x75, 0x37, + 0x1b, 0x12, 0x53, 0x83, 0x6c, 0x12, 0x6a, 0x26, 0xec, 0xca, 0xef, 0x10, 0x9c, 0xef, 0x92, 0x2f, + 0x74, 0xb9, 0x02, 0x98, 0x92, 0x5d, 0xb7, 0xc0, 0xc4, 0xcb, 0x02, 0x23, 0xd4, 0x2b, 0xd4, 0xa7, + 0x0d, 0xd3, 0xb6, 0xac, 0xe3, 0x6c, 0xaf, 0x4f, 0x05, 0xd3, 0x0d, 0xdd, 0xd8, 0x21, 0xee, 0x9a, + 0x5d, 0xa9, 0x58, 0x6e, 0x85, 0x50, 0x37, 0x61, 0x63, 0x49, 0xd0, 0xef, 0x53, 0x10, 0x1d, 0xd5, + 0x7c, 0x96, 0xbf, 0xf5, 0x55, 0xe8, 0xac, 0x2d, 0x54, 0xc8, 0x02, 0x18, 0xcd, 0x51, 0x5e, 0xfc, + 0xb4, 0x16, 0x18, 0x39, 0x4e, 0xde, 0x5f, 0x76, 0x03, 0xc7, 0x12, 0x32, 0x7f, 0x0f, 0xa0, 0x75, + 0x21, 0x70, 0x80, 0x83, 0xf9, 0x37, 0x15, 0xef, 0xf6, 0x50, 0x1a, 0xb7, 0x87, 0xe2, 0xdd, 0x35, + 0xe2, 0xf6, 0x50, 0x36, 0xf4, 0x92, 0xbf, 0x5b, 0xb5, 0x40, 0xa6, 0xfc, 0x37, 0x12, 0x67, 0x60, + 0x04, 0x10, 0x21, 0xd3, 0x2a, 0x0c, 0xb6, 0x44, 0x61, 0xe3, 0x68, 0x26, 0x93, 0x1b, 0xcc, 0xcf, + 0x44, 0x9e, 0xb3, 0x5e, 0x11, 0x6f, 0x0f, 0x06, 0x93, 0xf0, 0xad, 0x08, 0xb8, 0x17, 0x8f, 0x84, + 0xeb, 0x01, 0x08, 0xe2, 0xc5, 0xd7, 0xe1, 0x64, 0x4a, 0xdd, 0x45, 0xbc, 0x7c, 0x5f, 0x1c, 0x64, + 0x1e, 0xc6, 0x15, 0x63, 0x87, 0xda, 0x9f, 0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 0x92, 0xdc, 0xa2, 0x2c, 0x54, 0x88, 0x66, 0x63, + 0xbf, 0xad, 0x7e, 0xf2, 0xe4, 0x20, 0x8b, 0x9e, 0x1d, 0x64, 0xd1, 0x1f, 0x07, 0x59, 0xf4, 0xd5, + 0x61, 0xb6, 0xe7, 0xd9, 0x61, 0xb6, 0xe7, 0x97, 0xc3, 0x6c, 0xcf, 0x67, 0x8b, 0x25, 0xcb, 0xdd, + 0xae, 0x15, 0x15, 0xc3, 0xae, 0xa8, 0xe2, 0xaf, 0x5d, 0xab, 0x68, 0x5c, 0x2d, 0xd9, 0x6a, 0xfd, + 0x86, 0x5a, 0xb1, 0xcd, 0x5a, 0x99, 0x30, 0x0f, 0xde, 0xec, 0xc2, 0xd5, 0x00, 0x42, 0x77, 0xcf, + 0x21, 0xac, 0x78, 0x92, 0xff, 0x3b, 0x35, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x2a, + 0x4b, 0x9b, 0x4c, 0x16, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1301,6 +1452,9 @@ type QueryClient interface { // ChannelClientState queries for the client state for the channel associated // with the provided channel identifiers. ChannelClientState(ctx context.Context, in *QueryChannelClientStateRequest, opts ...grpc.CallOption) (*QueryChannelClientStateResponse, error) + // ChannelConsensusState queries for the consensus state for the channel associated + // with the provided channel identifiers. + ChannelConsensusState(ctx context.Context, in *QueryChannelConsensusStateRequest, opts ...grpc.CallOption) (*QueryChannelConsensusStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1345,6 +1499,15 @@ func (c *queryClient) ChannelClientState(ctx context.Context, in *QueryChannelCl return out, nil } +func (c *queryClient) ChannelConsensusState(ctx context.Context, in *QueryChannelConsensusStateRequest, opts ...grpc.CallOption) (*QueryChannelConsensusStateResponse, error) { + out := new(QueryChannelConsensusStateResponse) + err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/ChannelConsensusState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) NextSequenceSend(ctx context.Context, in *QueryNextSequenceSendRequest, opts ...grpc.CallOption) (*QueryNextSequenceSendResponse, error) { out := new(QueryNextSequenceSendResponse) err := c.cc.Invoke(ctx, "/ibc.core.channel.v2.Query/NextSequenceSend", in, out, opts...) @@ -1424,6 +1587,9 @@ type QueryServer interface { // ChannelClientState queries for the client state for the channel associated // with the provided channel identifiers. ChannelClientState(context.Context, *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) + // ChannelConsensusState queries for the consensus state for the channel associated + // with the provided channel identifiers. + ChannelConsensusState(context.Context, *QueryChannelConsensusStateRequest) (*QueryChannelConsensusStateResponse, error) // NextSequenceSend returns the next send sequence for a given channel. NextSequenceSend(context.Context, *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) // PacketCommitment queries a stored packet commitment hash. @@ -1452,6 +1618,9 @@ func (*UnimplementedQueryServer) Channel(ctx context.Context, req *QueryChannelR func (*UnimplementedQueryServer) ChannelClientState(ctx context.Context, req *QueryChannelClientStateRequest) (*QueryChannelClientStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ChannelClientState not implemented") } +func (*UnimplementedQueryServer) ChannelConsensusState(ctx context.Context, req *QueryChannelConsensusStateRequest) (*QueryChannelConsensusStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChannelConsensusState not implemented") +} func (*UnimplementedQueryServer) NextSequenceSend(ctx context.Context, req *QueryNextSequenceSendRequest) (*QueryNextSequenceSendResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method NextSequenceSend not implemented") } @@ -1517,6 +1686,24 @@ func _Query_ChannelClientState_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_ChannelConsensusState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChannelConsensusStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ChannelConsensusState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.core.channel.v2.Query/ChannelConsensusState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ChannelConsensusState(ctx, req.(*QueryChannelConsensusStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_NextSequenceSend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryNextSequenceSendRequest) if err := dec(in); err != nil { @@ -1673,6 +1860,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ChannelClientState", Handler: _Query_ChannelClientState_Handler, }, + { + MethodName: "ChannelConsensusState", + Handler: _Query_ChannelConsensusState_Handler, + }, { MethodName: "NextSequenceSend", Handler: _Query_NextSequenceSend_Handler, @@ -1855,6 +2046,105 @@ func (m *QueryChannelClientStateResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *QueryChannelConsensusStateRequest) 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 *QueryChannelConsensusStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelConsensusStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.RevisionHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.RevisionHeight)) + i-- + dAtA[i] = 0x18 + } + if m.RevisionNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.RevisionNumber)) + i-- + dAtA[i] = 0x10 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryChannelConsensusStateResponse) 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 *QueryChannelConsensusStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChannelConsensusStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ProofHeight.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a + } + if len(m.ClientId) > 0 { + i -= len(m.ClientId) + copy(dAtA[i:], m.ClientId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClientId))) + i-- + dAtA[i] = 0x12 + } + if m.ConsensusState != nil { + { + size, err := m.ConsensusState.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 (m *QueryNextSequenceSendRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2216,20 +2506,20 @@ func (m *QueryPacketAcknowledgementsRequest) MarshalToSizedBuffer(dAtA []byte) ( var l int _ = l if len(m.PacketCommitmentSequences) > 0 { - dAtA11 := make([]byte, len(m.PacketCommitmentSequences)*10) - var j10 int + dAtA13 := make([]byte, len(m.PacketCommitmentSequences)*10) + var j12 int for _, num := range m.PacketCommitmentSequences { for num >= 1<<7 { - dAtA11[j10] = uint8(uint64(num)&0x7f | 0x80) + dAtA13[j12] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j10++ + j12++ } - dAtA11[j10] = uint8(num) - j10++ + dAtA13[j12] = uint8(num) + j12++ } - i -= j10 - copy(dAtA[i:], dAtA11[:j10]) - i = encodeVarintQuery(dAtA, i, uint64(j10)) + i -= j12 + copy(dAtA[i:], dAtA13[:j12]) + i = encodeVarintQuery(dAtA, i, uint64(j12)) i-- dAtA[i] = 0x1a } @@ -2427,20 +2717,20 @@ func (m *QueryUnreceivedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, var l int _ = l if len(m.Sequences) > 0 { - dAtA17 := make([]byte, len(m.Sequences)*10) - var j16 int + dAtA19 := make([]byte, len(m.Sequences)*10) + var j18 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA17[j16] = uint8(uint64(num)&0x7f | 0x80) + dAtA19[j18] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j16++ + j18++ } - dAtA17[j16] = uint8(num) - j16++ + dAtA19[j18] = uint8(num) + j18++ } - i -= j16 - copy(dAtA[i:], dAtA17[:j16]) - i = encodeVarintQuery(dAtA, i, uint64(j16)) + i -= j18 + copy(dAtA[i:], dAtA19[:j18]) + i = encodeVarintQuery(dAtA, i, uint64(j18)) i-- dAtA[i] = 0x12 } @@ -2485,20 +2775,20 @@ func (m *QueryUnreceivedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA20 := make([]byte, len(m.Sequences)*10) - var j19 int + dAtA22 := make([]byte, len(m.Sequences)*10) + var j21 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) + dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j19++ + j21++ } - dAtA20[j19] = uint8(num) - j19++ + dAtA22[j21] = uint8(num) + j21++ } - i -= j19 - copy(dAtA[i:], dAtA20[:j19]) - i = encodeVarintQuery(dAtA, i, uint64(j19)) + i -= j21 + copy(dAtA[i:], dAtA22[:j21]) + i = encodeVarintQuery(dAtA, i, uint64(j21)) i-- dAtA[i] = 0xa } @@ -2526,20 +2816,20 @@ func (m *QueryUnreceivedAcksRequest) MarshalToSizedBuffer(dAtA []byte) (int, err var l int _ = l if len(m.PacketAckSequences) > 0 { - dAtA22 := make([]byte, len(m.PacketAckSequences)*10) - var j21 int + dAtA24 := make([]byte, len(m.PacketAckSequences)*10) + var j23 int for _, num := range m.PacketAckSequences { for num >= 1<<7 { - dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) + dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j21++ + j23++ } - dAtA22[j21] = uint8(num) - j21++ + dAtA24[j23] = uint8(num) + j23++ } - i -= j21 - copy(dAtA[i:], dAtA22[:j21]) - i = encodeVarintQuery(dAtA, i, uint64(j21)) + i -= j23 + copy(dAtA[i:], dAtA24[:j23]) + i = encodeVarintQuery(dAtA, i, uint64(j23)) i-- dAtA[i] = 0x12 } @@ -2584,20 +2874,20 @@ func (m *QueryUnreceivedAcksResponse) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x12 if len(m.Sequences) > 0 { - dAtA25 := make([]byte, len(m.Sequences)*10) - var j24 int + dAtA27 := make([]byte, len(m.Sequences)*10) + var j26 int for _, num := range m.Sequences { for num >= 1<<7 { - dAtA25[j24] = uint8(uint64(num)&0x7f | 0x80) + dAtA27[j26] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j24++ + j26++ } - dAtA25[j24] = uint8(num) - j24++ + dAtA27[j26] = uint8(num) + j26++ } - i -= j24 - copy(dAtA[i:], dAtA25[:j24]) - i = encodeVarintQuery(dAtA, i, uint64(j24)) + i -= j26 + copy(dAtA[i:], dAtA27[:j26]) + i = encodeVarintQuery(dAtA, i, uint64(j26)) i-- dAtA[i] = 0xa } @@ -2671,7 +2961,7 @@ func (m *QueryChannelClientStateResponse) Size() (n int) { return n } -func (m *QueryNextSequenceSendRequest) Size() (n int) { +func (m *QueryChannelConsensusStateRequest) Size() (n int) { if m == nil { return 0 } @@ -2681,17 +2971,28 @@ func (m *QueryNextSequenceSendRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + if m.RevisionNumber != 0 { + n += 1 + sovQuery(uint64(m.RevisionNumber)) + } + if m.RevisionHeight != 0 { + n += 1 + sovQuery(uint64(m.RevisionHeight)) + } return n } -func (m *QueryNextSequenceSendResponse) Size() (n int) { +func (m *QueryChannelConsensusStateResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.NextSequenceSend != 0 { - n += 1 + sovQuery(uint64(m.NextSequenceSend)) + if m.ConsensusState != nil { + l = m.ConsensusState.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ClientId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } l = len(m.Proof) if l > 0 { @@ -2702,7 +3003,7 @@ func (m *QueryNextSequenceSendResponse) Size() (n int) { return n } -func (m *QueryPacketCommitmentRequest) Size() (n int) { +func (m *QueryNextSequenceSendRequest) Size() (n int) { if m == nil { return 0 } @@ -2712,8 +3013,39 @@ func (m *QueryPacketCommitmentRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Sequence != 0 { - n += 1 + sovQuery(uint64(m.Sequence)) + return n +} + +func (m *QueryNextSequenceSendResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NextSequenceSend != 0 { + n += 1 + sovQuery(uint64(m.NextSequenceSend)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = m.ProofHeight.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryPacketCommitmentRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) } return n } @@ -3375,6 +3707,311 @@ func (m *QueryChannelClientStateResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryChannelConsensusStateRequest) 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: QueryChannelConsensusStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelConsensusStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RevisionNumber", wireType) + } + m.RevisionNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevisionNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RevisionHeight", wireType) + } + m.RevisionHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RevisionHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChannelConsensusStateResponse) 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: QueryChannelConsensusStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChannelConsensusStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.ConsensusState == nil { + m.ConsensusState = &types1.Any{} + } + if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClientId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeight", 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 err := m.ProofHeight.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) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryNextSequenceSendRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/core/04-channel/v2/types/query.pb.gw.go b/modules/core/04-channel/v2/types/query.pb.gw.go index 47aa5757262..2d87052d3ba 100644 --- a/modules/core/04-channel/v2/types/query.pb.gw.go +++ b/modules/core/04-channel/v2/types/query.pb.gw.go @@ -141,6 +141,78 @@ func local_request_Query_ChannelClientState_0(ctx context.Context, marshaler run } +var ( + filter_Query_ChannelConsensusState_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelConsensusStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChannelConsensusState_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ChannelConsensusState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ChannelConsensusState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChannelConsensusStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChannelConsensusState_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ChannelConsensusState(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_NextSequenceSend_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryNextSequenceSendRequest var metadata runtime.ServerMetadata @@ -789,6 +861,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ChannelConsensusState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + 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_ChannelConsensusState_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChannelConsensusState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1054,6 +1149,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ChannelConsensusState_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_ChannelConsensusState_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_ChannelConsensusState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_NextSequenceSend_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1222,6 +1337,8 @@ var ( 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}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "client_state"}, "", runtime.AssumeColonVerbOpt(false))) + 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}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "consensus_state"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_NextSequenceSend_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", "v2", "channels", "channel_id", "next_sequence_send"}, "", runtime.AssumeColonVerbOpt(false))) 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}, []string{"ibc", "core", "channel", "v2", "channels", "channel_id", "packet_commitments", "sequence"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1244,6 +1361,8 @@ var ( forward_Query_ChannelClientState_0 = runtime.ForwardResponseMessage + forward_Query_ChannelConsensusState_0 = runtime.ForwardResponseMessage + forward_Query_NextSequenceSend_0 = runtime.ForwardResponseMessage forward_Query_PacketCommitment_0 = runtime.ForwardResponseMessage diff --git a/proto/ibc/core/channel/v2/query.proto b/proto/ibc/core/channel/v2/query.proto index 3ca8a2e16ad..9d16a457a9e 100644 --- a/proto/ibc/core/channel/v2/query.proto +++ b/proto/ibc/core/channel/v2/query.proto @@ -9,6 +9,7 @@ import "ibc/core/channel/v2/channel.proto"; import "ibc/core/channel/v2/genesis.proto"; import "ibc/core/client/v1/client.proto"; import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; // Query provides defines the gRPC querier service @@ -24,6 +25,12 @@ service Query { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_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/core/channel/v2/channels/{channel_id}/consensus_state"; + } + // NextSequenceSend returns the next send sequence for a given channel. rpc NextSequenceSend(QueryNextSequenceSendRequest) returns (QueryNextSequenceSendResponse) { option (google.api.http).get = "/ibc/core/channel/v2/channels/{channel_id}/next_sequence_send"; @@ -96,6 +103,30 @@ message QueryChannelClientStateResponse { ibc.core.client.v1.Height proof_height = 3 [(gogoproto.nullable) = false]; } +// QueryChannelConsensusStateRequest is the request type for the Query/ConsensusState +// RPC method +message QueryChannelConsensusStateRequest { + // channel unique identifier + string channel_id = 1; + // revision number of the consensus state + uint64 revision_number = 2; + // revision height of the consensus state + uint64 revision_height = 3; +} + +// QueryChannelConsensusStateResponse is the Response type for the +// Query/QueryChannelConsensusState RPC method +message QueryChannelConsensusStateResponse { + // consensus state associated with the channel + google.protobuf.Any consensus_state = 1; + // client ID associated with the consensus state + string client_id = 2; + // merkle proof of existence + bytes proof = 3; + // height at which the proof was retrieved + ibc.core.client.v1.Height proof_height = 4 [(gogoproto.nullable) = false]; +} + // QueryNextSequenceSendRequest is the request type for the Query/QueryNextSequenceSend RPC method message QueryNextSequenceSendRequest { // channel unique identifier