diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index 9d08d91ad50..ddd205a7256 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -22,5 +22,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.3.1 with: - version: latest + version: v1.52.0 args: --timeout 5m diff --git a/.golangci.yml b/.golangci.yml index 76204d5471c..123234d42f2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,6 +29,9 @@ linters: issues: exclude-rules: + - text: "unused-parameter" + linters: + - revive - text: "SA1019:" linters: - staticcheck diff --git a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go index 3826dea0c79..7f2e3d4d725 100644 --- a/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go +++ b/modules/apps/27-interchain-accounts/controller/ibc_middleware_test.go @@ -107,11 +107,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { return err } - if err := path.EndpointB.ChanOpenConfirm(); err != nil { - return err - } - - return nil + return path.EndpointB.ChanOpenConfirm() } func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account.go b/modules/apps/27-interchain-accounts/controller/keeper/account.go index c1418595508..3dd8d7653ca 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -60,9 +60,15 @@ func (k Keeper) registerInterchainAccount(ctx sdk.Context, connectionID, portID, case k.portKeeper.IsBound(ctx, portID) && !k.IsBound(ctx, portID): return "", sdkerrors.Wrapf(icatypes.ErrPortAlreadyBound, "another module has claimed capability for and bound port with portID: %s", portID) case !k.portKeeper.IsBound(ctx, portID): +<<<<<<< HEAD cap := k.BindPort(ctx, portID) if err := k.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { return "", sdkerrors.Wrapf(err, "unable to bind to newly generated portID: %s", portID) +======= + capability := k.BindPort(ctx, portID) + if err := k.ClaimCapability(ctx, capability, host.PortPath(portID)); err != nil { + return "", errorsmod.Wrapf(err, "unable to bind to newly generated portID: %s", portID) +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) } } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go index 33ec4d6448f..5498b3c593a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account_test.go @@ -25,8 +25,8 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount() { { "port is already bound for owner but capability is claimed by another module", func() { - cap := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), TestPortID) - err := suite.chainA.GetSimApp().TransferKeeper.ClaimCapability(suite.chainA.GetContext(), cap, host.PortPath(TestPortID)) + capability := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), TestPortID) + err := suite.chainA.GetSimApp().TransferKeeper.ClaimCapability(suite.chainA.GetContext(), capability, host.PortPath(TestPortID)) suite.Require().NoError(err) }, false, diff --git a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go index ea5cbd822cd..d501cf034ae 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go @@ -12,9 +12,15 @@ import ( // InitGenesis initializes the interchain accounts controller application state from a provided genesis state func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.ControllerGenesisState) { for _, portID := range state.Ports { +<<<<<<< HEAD if !keeper.IsBound(ctx, portID) { cap := keeper.BindPort(ctx, portID) if err := keeper.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { +======= + if !keeper.HasCapability(ctx, portID) { + capability := keeper.BindPort(ctx, portID) + if err := keeper.ClaimCapability(ctx, capability, host.PortPath(portID)); err != nil { +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) panic(fmt.Sprintf("could not claim port capability: %v", err)) } } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go index 0583912165b..98c1779aa6a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go @@ -72,11 +72,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { return err } - if err := path.EndpointB.ChanOpenConfirm(); err != nil { - return err - } - - return nil + return path.EndpointB.ChanOpenConfirm() } // RegisterInterchainAccount is a helper function for starting the channel handshake diff --git a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go index 934db7395a3..cf2bdcd0020 100644 --- a/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go +++ b/modules/apps/27-interchain-accounts/controller/migrations/v6/migrations_test.go @@ -54,11 +54,7 @@ func (suite *MigrationsTestSuite) SetupPath() error { return err } - if err := suite.path.EndpointB.ChanOpenConfirm(); err != nil { - return err - } - - return nil + return suite.path.EndpointB.ChanOpenConfirm() } func (suite *MigrationsTestSuite) RegisterInterchainAccount(endpoint *ibctesting.Endpoint, owner string) error { @@ -101,22 +97,22 @@ func (suite *MigrationsTestSuite) TestMigrateICS27ChannelCapability() { // note: suite.SetupPath() now claims the chanel capability using icacontroller for "channel-0" capName := host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, channeltypes.FormatChannelIdentifier(1)) - cap, err := suite.chainA.GetSimApp().ScopedIBCKeeper.NewCapability(suite.chainA.GetContext(), capName) + capability, err := suite.chainA.GetSimApp().ScopedIBCKeeper.NewCapability(suite.chainA.GetContext(), capName) suite.Require().NoError(err) - err = suite.chainA.GetSimApp().ScopedICAMockKeeper.ClaimCapability(suite.chainA.GetContext(), cap, capName) + err = suite.chainA.GetSimApp().ScopedICAMockKeeper.ClaimCapability(suite.chainA.GetContext(), capability, capName) suite.Require().NoError(err) // assert the capability is owned by the mock module - cap, found := suite.chainA.GetSimApp().ScopedICAMockKeeper.GetCapability(suite.chainA.GetContext(), capName) - suite.Require().NotNil(cap) + capability, found := suite.chainA.GetSimApp().ScopedICAMockKeeper.GetCapability(suite.chainA.GetContext(), capName) + suite.Require().NotNil(capability) suite.Require().True(found) - isAuthenticated := suite.chainA.GetSimApp().ScopedICAMockKeeper.AuthenticateCapability(suite.chainA.GetContext(), cap, capName) + isAuthenticated := suite.chainA.GetSimApp().ScopedICAMockKeeper.AuthenticateCapability(suite.chainA.GetContext(), capability, capName) suite.Require().True(isAuthenticated) - cap, found = suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), capName) - suite.Require().Nil(cap) + capability, found = suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), capName) + suite.Require().Nil(capability) suite.Require().False(found) suite.ResetMemStore() // empty the x/capability in-memory store @@ -132,24 +128,24 @@ func (suite *MigrationsTestSuite) TestMigrateICS27ChannelCapability() { suite.Require().NoError(err) // assert the capability is now owned by the ICS27 controller submodule - cap, found = suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), capName) - suite.Require().NotNil(cap) + capability, found = suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), capName) + suite.Require().NotNil(capability) suite.Require().True(found) - isAuthenticated = suite.chainA.GetSimApp().ScopedICAControllerKeeper.AuthenticateCapability(suite.chainA.GetContext(), cap, capName) + isAuthenticated = suite.chainA.GetSimApp().ScopedICAControllerKeeper.AuthenticateCapability(suite.chainA.GetContext(), capability, capName) suite.Require().True(isAuthenticated) - cap, found = suite.chainA.GetSimApp().ScopedICAMockKeeper.GetCapability(suite.chainA.GetContext(), capName) - suite.Require().Nil(cap) + capability, found = suite.chainA.GetSimApp().ScopedICAMockKeeper.GetCapability(suite.chainA.GetContext(), capName) + suite.Require().Nil(capability) suite.Require().False(found) // ensure channel capability for "channel-0" is still owned by the controller capName = host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - cap, found = suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), capName) - suite.Require().NotNil(cap) + capability, found = suite.chainA.GetSimApp().ScopedICAControllerKeeper.GetCapability(suite.chainA.GetContext(), capName) + suite.Require().NotNil(capability) suite.Require().True(found) - isAuthenticated = suite.chainA.GetSimApp().ScopedICAControllerKeeper.AuthenticateCapability(suite.chainA.GetContext(), cap, capName) + isAuthenticated = suite.chainA.GetSimApp().ScopedICAControllerKeeper.AuthenticateCapability(suite.chainA.GetContext(), capability, capName) suite.Require().True(isAuthenticated) suite.AssertMockCapabiltiesUnchanged() @@ -159,29 +155,29 @@ func (suite *MigrationsTestSuite) TestMigrateICS27ChannelCapability() { // 1. A capability with a single owner // 2. A capability with two owners, neither of which is "ibc" func (suite *MigrationsTestSuite) CreateMockCapabilities() { - cap, err := suite.chainA.GetSimApp().ScopedIBCMockKeeper.NewCapability(suite.chainA.GetContext(), "mock_one") + capability, err := suite.chainA.GetSimApp().ScopedIBCMockKeeper.NewCapability(suite.chainA.GetContext(), "mock_one") suite.Require().NoError(err) - suite.Require().NotNil(cap) + suite.Require().NotNil(capability) - cap, err = suite.chainA.GetSimApp().ScopedICAMockKeeper.NewCapability(suite.chainA.GetContext(), "mock_two") + capability, err = suite.chainA.GetSimApp().ScopedICAMockKeeper.NewCapability(suite.chainA.GetContext(), "mock_two") suite.Require().NoError(err) - suite.Require().NotNil(cap) + suite.Require().NotNil(capability) - err = suite.chainA.GetSimApp().ScopedIBCMockKeeper.ClaimCapability(suite.chainA.GetContext(), cap, "mock_two") + err = suite.chainA.GetSimApp().ScopedIBCMockKeeper.ClaimCapability(suite.chainA.GetContext(), capability, "mock_two") suite.Require().NoError(err) } // AssertMockCapabiltiesUnchanged authenticates the mock capabilities created at the start of the test to ensure they remain unchanged func (suite *MigrationsTestSuite) AssertMockCapabiltiesUnchanged() { - cap, found := suite.chainA.GetSimApp().ScopedIBCMockKeeper.GetCapability(suite.chainA.GetContext(), "mock_one") + capability, found := suite.chainA.GetSimApp().ScopedIBCMockKeeper.GetCapability(suite.chainA.GetContext(), "mock_one") suite.Require().True(found) - suite.Require().NotNil(cap) + suite.Require().NotNil(capability) - cap, found = suite.chainA.GetSimApp().ScopedIBCMockKeeper.GetCapability(suite.chainA.GetContext(), "mock_two") + capability, found = suite.chainA.GetSimApp().ScopedIBCMockKeeper.GetCapability(suite.chainA.GetContext(), "mock_two") suite.Require().True(found) - suite.Require().NotNil(cap) + suite.Require().NotNil(capability) - isAuthenticated := suite.chainA.GetSimApp().ScopedICAMockKeeper.AuthenticateCapability(suite.chainA.GetContext(), cap, "mock_two") + isAuthenticated := suite.chainA.GetSimApp().ScopedICAMockKeeper.AuthenticateCapability(suite.chainA.GetContext(), capability, "mock_two") suite.Require().True(isAuthenticated) } diff --git a/modules/apps/27-interchain-accounts/controller/types/params.go b/modules/apps/27-interchain-accounts/controller/types/params.go index 5baaaa8b1df..a74b27f045e 100644 --- a/modules/apps/27-interchain-accounts/controller/types/params.go +++ b/modules/apps/27-interchain-accounts/controller/types/params.go @@ -33,11 +33,7 @@ func DefaultParams() Params { // Validate validates all controller submodule parameters func (p Params) Validate() error { - if err := validateEnabledType(p.ControllerEnabled); err != nil { - return err - } - - return nil + return validateEnabledType(p.ControllerEnabled) } // ParamSetPairs implements params.ParamSet diff --git a/modules/apps/27-interchain-accounts/genesis/types/genesis.go b/modules/apps/27-interchain-accounts/genesis/types/genesis.go index f69ae13a00a..553addbe4f7 100644 --- a/modules/apps/27-interchain-accounts/genesis/types/genesis.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis.go @@ -29,11 +29,7 @@ func (gs GenesisState) Validate() error { return err } - if err := gs.HostGenesisState.Validate(); err != nil { - return err - } - - return nil + return gs.HostGenesisState.Validate() } // DefaultControllerGenesis creates and returns the default interchain accounts ControllerGenesisState @@ -81,11 +77,7 @@ func (gs ControllerGenesisState) Validate() error { } } - if err := gs.Params.Validate(); err != nil { - return err - } - - return nil + return gs.Params.Validate() } // DefaultHostGenesis creates and returns the default interchain accounts HostGenesisState @@ -132,9 +124,5 @@ func (gs HostGenesisState) Validate() error { return err } - if err := gs.Params.Validate(); err != nil { - return err - } - - return nil + return gs.Params.Validate() } diff --git a/modules/apps/27-interchain-accounts/host/ibc_module_test.go b/modules/apps/27-interchain-accounts/host/ibc_module_test.go index c0c8c0b3561..8a742f8f474 100644 --- a/modules/apps/27-interchain-accounts/host/ibc_module_test.go +++ b/modules/apps/27-interchain-accounts/host/ibc_module_test.go @@ -106,11 +106,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { return err } - if err := path.EndpointB.ChanOpenConfirm(); err != nil { - return err - } - - return nil + return path.EndpointB.ChanOpenConfirm() } // Test initiating a ChanOpenInit using the host chain instead of the controller chain diff --git a/modules/apps/27-interchain-accounts/host/keeper/genesis.go b/modules/apps/27-interchain-accounts/host/keeper/genesis.go index 6575bac1713..fcc3bab74ec 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis.go @@ -12,9 +12,15 @@ import ( // InitGenesis initializes the interchain accounts host application state from a provided genesis state func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.HostGenesisState) { +<<<<<<< HEAD if !keeper.IsBound(ctx, state.Port) { cap := keeper.BindPort(ctx, state.Port) if err := keeper.ClaimCapability(ctx, cap, host.PortPath(state.Port)); err != nil { +======= + if !keeper.HasCapability(ctx, state.Port) { + capability := keeper.BindPort(ctx, state.Port) + if err := keeper.ClaimCapability(ctx, capability, host.PortPath(state.Port)); err != nil { +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) panic(fmt.Sprintf("could not claim port capability: %v", err)) } } diff --git a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go index c250e046d67..ffc72236248 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go +++ b/modules/apps/27-interchain-accounts/host/keeper/keeper_test.go @@ -72,11 +72,7 @@ func SetupICAPath(path *ibctesting.Path, owner string) error { return err } - if err := path.EndpointB.ChanOpenConfirm(); err != nil { - return err - } - - return nil + return path.EndpointB.ChanOpenConfirm() } // RegisterInterchainAccount is a helper function for starting the channel handshake diff --git a/modules/apps/27-interchain-accounts/host/types/params.go b/modules/apps/27-interchain-accounts/host/types/params.go index af28c413c9e..92a8ca84f46 100644 --- a/modules/apps/27-interchain-accounts/host/types/params.go +++ b/modules/apps/27-interchain-accounts/host/types/params.go @@ -43,11 +43,7 @@ func (p Params) Validate() error { return err } - if err := validateAllowlist(p.AllowMessages); err != nil { - return err - } - - return nil + return validateAllowlist(p.AllowMessages) } // ParamSetPairs implements params.ParamSet diff --git a/modules/apps/27-interchain-accounts/module.go b/modules/apps/27-interchain-accounts/module.go index 8b0c5d90f26..98ef7d7ce42 100644 --- a/modules/apps/27-interchain-accounts/module.go +++ b/modules/apps/27-interchain-accounts/module.go @@ -117,8 +117,8 @@ func (am AppModule) InitModule(ctx sdk.Context, controllerParams controllertypes if am.hostKeeper != nil { am.hostKeeper.SetParams(ctx, hostParams) - cap := am.hostKeeper.BindPort(ctx, types.HostPortID) - if err := am.hostKeeper.ClaimCapability(ctx, cap, ibchost.PortPath(types.HostPortID)); err != nil { + capability := am.hostKeeper.BindPort(ctx, types.HostPortID) + if err := am.hostKeeper.ClaimCapability(ctx, capability, ibchost.PortPath(types.HostPortID)); err != nil { panic(fmt.Sprintf("could not claim port capability: %v", err)) } } diff --git a/modules/apps/29-fee/ibc_middleware.go b/modules/apps/29-fee/ibc_middleware.go index 22290392848..9eb13ca679e 100644 --- a/modules/apps/29-fee/ibc_middleware.go +++ b/modules/apps/29-fee/ibc_middleware.go @@ -180,11 +180,7 @@ func (im IBCMiddleware) OnChanCloseInit( return types.ErrFeeModuleLocked } - if err := im.keeper.RefundFeesOnChannelClosure(ctx, portID, channelID); err != nil { - return err - } - - return nil + return im.keeper.RefundFeesOnChannelClosure(ctx, portID, channelID) } // OnChanCloseConfirm implements the IBCMiddleware interface @@ -205,11 +201,7 @@ func (im IBCMiddleware) OnChanCloseConfirm( return types.ErrFeeModuleLocked } - if err := im.keeper.RefundFeesOnChannelClosure(ctx, portID, channelID); err != nil { - return err - } - - return nil + return im.keeper.RefundFeesOnChannelClosure(ctx, portID, channelID) } // OnRecvPacket implements the IBCMiddleware interface. diff --git a/modules/apps/29-fee/ica_test.go b/modules/apps/29-fee/ica_test.go index b8034b78914..090533cb875 100644 --- a/modules/apps/29-fee/ica_test.go +++ b/modules/apps/29-fee/ica_test.go @@ -59,11 +59,7 @@ func SetupPath(path *ibctesting.Path, owner string) error { return err } - if err := path.EndpointB.ChanOpenConfirm(); err != nil { - return err - } - - return nil + return path.EndpointB.ChanOpenConfirm() } // RegisterInterchainAccount invokes the the InterchainAccounts entrypoint, routes a new MsgChannelOpenInit to the appropriate handler, diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 59f7ad657c1..312bd685eb7 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -30,11 +30,7 @@ func (p PacketFee) Validate() error { return ErrRelayersNotEmpty } - if err := p.Fee.Validate(); err != nil { - return err - } - - return nil + return p.Fee.Validate() } // NewPacketFees creates and returns a new PacketFees struct including a list of type PacketFee diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 047b48b9ec1..c2daf59f29d 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -132,11 +132,7 @@ func (msg MsgPayPacketFee) ValidateBasic() error { return ErrRelayersNotEmpty } - if err := msg.Fee.Validate(); err != nil { - return err - } - - return nil + return msg.Fee.Validate() } // GetSigners implements sdk.Msg @@ -172,11 +168,7 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { return err } - if err := msg.PacketFee.Validate(); err != nil { - return err - } - - return nil + return msg.PacketFee.Validate() } // GetSigners implements sdk.Msg diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 0c2546c6b3a..e45f7d55b83 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -73,8 +73,8 @@ func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { // BindPort defines a wrapper function for the ort Keeper's function in // order to expose it to module's InitGenesis function func (k Keeper) BindPort(ctx sdk.Context, portID string) error { - cap := k.portKeeper.BindPort(ctx, portID) - return k.ClaimCapability(ctx, cap, host.PortPath(portID)) + capability := k.portKeeper.BindPort(ctx, portID) + return k.ClaimCapability(ctx, capability, host.PortPath(portID)) } // GetPort returns the portID for the transfer module. Used in ExportGenesis diff --git a/modules/apps/transfer/keeper/mbt_relay_test.go b/modules/apps/transfer/keeper/mbt_relay_test.go index e6c95b182c6..b94c544e766 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -113,8 +113,10 @@ func AddressFromTla(addr []string) string { func DenomFromTla(denom []string) string { var i int - for i = 0; i+1 < len(denom) && len(denom[i]) == 0 && len(denom[i+1]) == 0; i += 2 { - // skip empty prefixes + for i = 0; i+1 < len(denom); i += 2 { + if !(len(denom[i]) == 0 && len(denom[i+1]) == 0) { + break + } } return strings.Join(denom[i:], "/") } diff --git a/modules/apps/transfer/keeper/relay_test.go b/modules/apps/transfer/keeper/relay_test.go index a09a73037b1..2682e57595d 100644 --- a/modules/apps/transfer/keeper/relay_test.go +++ b/modules/apps/transfer/keeper/relay_test.go @@ -89,10 +89,10 @@ func (suite *KeeperTestSuite) TestSendTransfer() { { "channel capability not found", func() { - cap := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + capability := suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) // Release channel capability - suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), cap) //nolint:errcheck // ignore error for testing + suite.chainA.GetSimApp().ScopedTransferKeeper.ReleaseCapability(suite.chainA.GetContext(), capability) //nolint:errcheck // ignore error for testing }, false, }, { diff --git a/modules/core/02-client/migrations/v7/store.go b/modules/core/02-client/migrations/v7/store.go index b70e541e671..52ae0e27ee2 100644 --- a/modules/core/02-client/migrations/v7/store.go +++ b/modules/core/02-client/migrations/v7/store.go @@ -39,11 +39,7 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar return err } - if err := handleLocalhostMigration(ctx, store, cdc, clientKeeper); err != nil { - return err - } - - return nil + return handleLocalhostMigration(ctx, store, cdc, clientKeeper) } // handleSolomachineMigration iterates over the solo machine clients and migrates client state from @@ -62,6 +58,7 @@ func handleSolomachineMigration(ctx sdk.Context, store sdk.KVStore, cdc codec.Bi return sdkerrors.Wrapf(clienttypes.ErrClientNotFound, "clientID %s", clientID) } +<<<<<<< HEAD var any codectypes.Any if err := cdc.Unmarshal(bz, &any); err != nil { return sdkerrors.Wrap(err, "failed to unmarshal client state bytes into solo machine client state") @@ -70,6 +67,16 @@ func handleSolomachineMigration(ctx sdk.Context, store sdk.KVStore, cdc codec.Bi var clientState ClientState if err := cdc.Unmarshal(any.Value, &clientState); err != nil { return sdkerrors.Wrap(err, "failed to unmarshal client state bytes into solo machine client state") +======= + var protoAny codectypes.Any + if err := cdc.Unmarshal(bz, &protoAny); err != nil { + return errorsmod.Wrap(err, "failed to unmarshal client state bytes into solo machine client state") + } + + var clientState ClientState + if err := cdc.Unmarshal(protoAny.Value, &clientState); err != nil { + return errorsmod.Wrap(err, "failed to unmarshal client state bytes into solo machine client state") +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) } updatedClientState := migrateSolomachine(clientState) diff --git a/modules/core/03-connection/types/genesis.go b/modules/core/03-connection/types/genesis.go index 3a4e5595f35..b1c5e4c0015 100644 --- a/modules/core/03-connection/types/genesis.go +++ b/modules/core/03-connection/types/genesis.go @@ -74,9 +74,5 @@ func (gs GenesisState) Validate() error { return fmt.Errorf("next connection sequence %d must be greater than maximum sequence used in connection identifier %d", gs.NextConnectionSequence, maxSequence) } - if err := gs.Params.Validate(); err != nil { - return err - } - - return nil + return gs.Params.Validate() } diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 94cce64b8f9..a02bb94bc02 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -261,15 +261,10 @@ func (k Keeper) ChanOpenAck( counterpartyHops, counterpartyVersion, ) - if err := k.connectionKeeper.VerifyChannelState( + return k.connectionKeeper.VerifyChannelState( ctx, connectionEnd, proofHeight, proofTry, channel.Counterparty.PortId, counterpartyChannelID, - expectedChannel, - ); err != nil { - return err - } - - return nil + expectedChannel) } // WriteOpenAckChannel writes an updated channel state for the successful OpenAck handshake step. @@ -346,15 +341,10 @@ func (k Keeper) ChanOpenConfirm( counterpartyHops, channel.Version, ) - if err := k.connectionKeeper.VerifyChannelState( + return k.connectionKeeper.VerifyChannelState( ctx, connectionEnd, proofHeight, proofAck, channel.Counterparty.PortId, channel.Counterparty.ChannelId, - expectedChannel, - ); err != nil { - return err - } - - return nil + expectedChannel) } // WriteOpenConfirmChannel writes an updated channel state for the successful OpenConfirm handshake step. diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index 8c721d1f438..432ad472bd5 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -119,7 +119,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { counterparty := types.NewCounterparty(ibctesting.MockPort, ibctesting.FirstChannelID) - channelID, cap, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.ChanOpenInit( + channelID, capability, err := suite.chainA.App.GetIBCKeeper().ChannelKeeper.ChanOpenInit( suite.chainA.GetContext(), path.EndpointA.ChannelConfig.Order, []string{path.EndpointA.ConnectionID}, path.EndpointA.ChannelConfig.PortID, portCap, counterparty, path.EndpointA.ChannelConfig.Version, ) @@ -136,7 +136,7 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { // asserting the channel handshake initiation succeeded if tc.expPass && orderSupported { suite.Require().NoError(err) - suite.Require().NotNil(cap) + suite.Require().NotNil(capability) suite.Require().Equal(types.FormatChannelIdentifier(0), channelID) chanCap, ok := suite.chainA.App.GetScopedIBCKeeper().GetCapability( @@ -144,11 +144,11 @@ func (suite *KeeperTestSuite) TestChanOpenInit() { host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, channelID), ) suite.Require().True(ok, "could not retrieve channel capability after successful ChanOpenInit") - suite.Require().Equal(chanCap.String(), cap.String(), "channel capability is not correct") + suite.Require().Equal(chanCap.String(), capability.String(), "channel capability is not correct") } else { suite.Require().Error(err) suite.Require().Contains(err.Error(), expErrorMsgSubstring) - suite.Require().Nil(cap) + suite.Require().Nil(capability) suite.Require().Equal("", channelID) } } @@ -278,7 +278,7 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { channelKey := host.ChannelKey(counterparty.PortId, counterparty.ChannelId) proof, proofHeight := suite.chainA.QueryProof(channelKey) - channelID, cap, err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.ChanOpenTry( + channelID, capability, err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.ChanOpenTry( suite.chainB.GetContext(), types.ORDERED, []string{path.EndpointB.ConnectionID}, path.EndpointB.ChannelConfig.PortID, portCap, counterparty, path.EndpointA.ChannelConfig.Version, proof, malleateHeight(proofHeight, heightDiff), @@ -286,14 +286,14 @@ func (suite *KeeperTestSuite) TestChanOpenTry() { if tc.expPass { suite.Require().NoError(err) - suite.Require().NotNil(cap) + suite.Require().NotNil(capability) chanCap, ok := suite.chainB.App.GetScopedIBCKeeper().GetCapability( suite.chainB.GetContext(), host.ChannelCapabilityPath(path.EndpointB.ChannelConfig.PortID, channelID), ) suite.Require().True(ok, "could not retrieve channel capapbility after successful ChanOpenTry") - suite.Require().Equal(chanCap.String(), cap.String(), "channel capability is not correct") + suite.Require().Equal(chanCap.String(), capability.String(), "channel capability is not correct") } else { suite.Require().Error(err) } diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 9322210333b..7fcc006eb95 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -470,12 +470,12 @@ func (k Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) // LookupModuleByChannel will return the IBCModule along with the capability associated with a given channel defined by its portID and channelID func (k Keeper) LookupModuleByChannel(ctx sdk.Context, portID, channelID string) (string, *capabilitytypes.Capability, error) { - modules, cap, err := k.scopedKeeper.LookupModules(ctx, host.ChannelCapabilityPath(portID, channelID)) + modules, capability, err := k.scopedKeeper.LookupModules(ctx, host.ChannelCapabilityPath(portID, channelID)) if err != nil { return "", nil, err } - return porttypes.GetModuleOwner(modules), cap, nil + return porttypes.GetModuleOwner(modules), capability, nil } // common functionality for IteratePacketCommitment and IteratePacketAcknowledgement diff --git a/modules/core/05-port/keeper/keeper.go b/modules/core/05-port/keeper/keeper.go index e862e110100..f0e9b2f4aca 100644 --- a/modules/core/05-port/keeper/keeper.go +++ b/modules/core/05-port/keeper/keeper.go @@ -73,10 +73,10 @@ func (k Keeper) Authenticate(ctx sdk.Context, key *capabilitytypes.Capability, p // LookupModuleByPort will return the IBCModule along with the capability associated with a given portID func (k Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *capabilitytypes.Capability, error) { - modules, cap, err := k.scopedKeeper.LookupModules(ctx, host.PortPath(portID)) + modules, capability, err := k.scopedKeeper.LookupModules(ctx, host.PortPath(portID)) if err != nil { return "", nil, err } - return types.GetModuleOwner(modules), cap, nil + return types.GetModuleOwner(modules), capability, nil } diff --git a/modules/core/23-commitment/types/merkle.go b/modules/core/23-commitment/types/merkle.go index 5d263ce1777..65be8498353 100644 --- a/modules/core/23-commitment/types/merkle.go +++ b/modules/core/23-commitment/types/merkle.go @@ -150,10 +150,7 @@ func (proof MerkleProof) VerifyMembership(specs []*ics23.ProofSpec, root exporte // Since every proof in chain is a membership proof we can use verifyChainedMembershipProof from index 0 // to validate entire proof - if err := verifyChainedMembershipProof(root.GetHash(), specs, proof.Proofs, mpath, value, 0); err != nil { - return err - } - return nil + return verifyChainedMembershipProof(root.GetHash(), specs, proof.Proofs, mpath, value, 0) } // VerifyNonMembership verifies the absence of a merkle proof against the given root and path. diff --git a/modules/core/keeper/migrations.go b/modules/core/keeper/migrations.go index 423429092c7..ed7b42d59b0 100644 --- a/modules/core/keeper/migrations.go +++ b/modules/core/keeper/migrations.go @@ -19,9 +19,5 @@ func NewMigrator(keeper Keeper) Migrator { // Migrate2to3 migrates from version 2 to 3. See 02-client keeper function Migrate2to3. func (m Migrator) Migrate2to3(ctx sdk.Context) error { clientMigrator := clientkeeper.NewMigrator(m.keeper.ClientKeeper) - if err := clientMigrator.Migrate2to3(ctx); err != nil { - return err - } - - return nil + return clientMigrator.Migrate2to3(ctx) } diff --git a/modules/core/keeper/msg_server.go b/modules/core/keeper/msg_server.go index 1fd8ec8dcdb..bca2cdcf83c 100644 --- a/modules/core/keeper/msg_server.go +++ b/modules/core/keeper/msg_server.go @@ -181,7 +181,7 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan } // Perform 04-channel verification - channelID, cap, err := k.ChannelKeeper.ChanOpenInit( + channelID, capability, err := k.ChannelKeeper.ChanOpenInit( ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, portCap, msg.Channel.Counterparty, msg.Channel.Version, ) @@ -191,7 +191,7 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan } // Perform application logic callback - version, err := cbs.OnChanOpenInit(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, cap, msg.Channel.Counterparty, msg.Channel.Version) + version, err := cbs.OnChanOpenInit(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, capability, msg.Channel.Counterparty, msg.Channel.Version) if err != nil { ctx.Logger().Error("channel open init callback failed", "port-id", msg.PortId, "channel-id", channelID, "error", err.Error()) return nil, sdkerrors.Wrapf(err, "channel open init callback failed for port ID: %s, channel ID: %s", msg.PortId, channelID) @@ -229,7 +229,7 @@ func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChann } // Perform 04-channel verification - channelID, cap, err := k.ChannelKeeper.ChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, + channelID, capability, err := k.ChannelKeeper.ChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, portCap, msg.Channel.Counterparty, msg.CounterpartyVersion, msg.ProofInit, msg.ProofHeight, ) if err != nil { @@ -238,7 +238,7 @@ func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChann } // Perform application logic callback - version, err := cbs.OnChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, cap, msg.Channel.Counterparty, msg.CounterpartyVersion) + version, err := cbs.OnChanOpenTry(ctx, msg.Channel.Ordering, msg.Channel.ConnectionHops, msg.PortId, channelID, capability, msg.Channel.Counterparty, msg.CounterpartyVersion) if err != nil { ctx.Logger().Error("channel open try callback failed", "port-id", msg.PortId, "channel-id", channelID, "error", err.Error()) return nil, sdkerrors.Wrapf(err, "channel open try callback failed for port ID: %s, channel ID: %s", msg.PortId, channelID) @@ -262,7 +262,7 @@ func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChann ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) if err != nil { ctx.Logger().Error("channel open ack callback failed", "port-id", msg.PortId, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -277,7 +277,7 @@ func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChann // Perform 04-channel verification if err = k.ChannelKeeper.ChanOpenAck( - ctx, msg.PortId, msg.ChannelId, cap, msg.CounterpartyVersion, msg.CounterpartyChannelId, msg.ProofTry, msg.ProofHeight, + ctx, msg.PortId, msg.ChannelId, capability, msg.CounterpartyVersion, msg.CounterpartyChannelId, msg.ProofTry, msg.ProofHeight, ); err != nil { ctx.Logger().Error("channel open ack callback failed", "error", err.Error()) return nil, sdkerrors.Wrap(err, "channel handshake open ack failed") @@ -304,7 +304,7 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) if err != nil { ctx.Logger().Error("channel open confirm callback failed", "port-id", msg.PortId, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -318,9 +318,15 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC } // Perform 04-channel verification +<<<<<<< HEAD if err = k.ChannelKeeper.ChanOpenConfirm(ctx, msg.PortId, msg.ChannelId, cap, msg.ProofAck, msg.ProofHeight); err != nil { ctx.Logger().Error("channel open confirm callback failed", "error", sdkerrors.Wrap(err, "channel handshake open confirm failed")) return nil, sdkerrors.Wrap(err, "channel handshake open confirm failed") +======= + if err = k.ChannelKeeper.ChanOpenConfirm(ctx, msg.PortId, msg.ChannelId, capability, msg.ProofAck, msg.ProofHeight); err != nil { + ctx.Logger().Error("channel open confirm callback failed", "error", errorsmod.Wrap(err, "channel handshake open confirm failed")) + return nil, errorsmod.Wrap(err, "channel handshake open confirm failed") +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) } // Write channel into state @@ -341,7 +347,7 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgChannelCloseInit) (*channeltypes.MsgChannelCloseInitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) if err != nil { ctx.Logger().Error("channel close init callback failed", "port-id", msg.PortId, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -359,7 +365,7 @@ func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgCha return nil, sdkerrors.Wrapf(err, "channel close init callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } - err = k.ChannelKeeper.ChanCloseInit(ctx, msg.PortId, msg.ChannelId, cap) + err = k.ChannelKeeper.ChanCloseInit(ctx, msg.PortId, msg.ChannelId, capability) if err != nil { ctx.Logger().Error("channel handshake close init callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, sdkerrors.Wrap(err, "channel handshake close init failed") @@ -375,7 +381,7 @@ func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Msg ctx := sdk.UnwrapSDKContext(goCtx) // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.PortId, msg.ChannelId) if err != nil { ctx.Logger().Error("channel close confirm callback failed", "port-id", msg.PortId, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -393,7 +399,7 @@ func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Msg return nil, sdkerrors.Wrapf(err, "channel close confirm callback failed for port ID: %s, channel ID: %s", msg.PortId, msg.ChannelId) } - err = k.ChannelKeeper.ChanCloseConfirm(ctx, msg.PortId, msg.ChannelId, cap, msg.ProofInit, msg.ProofHeight) + err = k.ChannelKeeper.ChanCloseConfirm(ctx, msg.PortId, msg.ChannelId, capability, msg.ProofInit, msg.ProofHeight) if err != nil { ctx.Logger().Error("channel handshake close confirm callback failed", "port-id", msg.PortId, "channel-id", msg.ChannelId, "error", err.Error()) return nil, sdkerrors.Wrap(err, "channel handshake close confirm failed") @@ -415,7 +421,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke } // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) if err != nil { ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -433,7 +439,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke // If the packet was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - err = k.ChannelKeeper.RecvPacket(cacheCtx, cap, msg.Packet, msg.ProofCommitment, msg.ProofHeight) + err = k.ChannelKeeper.RecvPacket(cacheCtx, capability, msg.Packet, msg.ProofCommitment, msg.ProofHeight) switch err { case nil: @@ -464,7 +470,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke // NOTE: IBC applications modules may call the WriteAcknowledgement asynchronously if the // acknowledgement is nil. if ack != nil { - if err := k.ChannelKeeper.WriteAcknowledgement(ctx, cap, msg.Packet, ack); err != nil { + if err := k.ChannelKeeper.WriteAcknowledgement(ctx, capability, msg.Packet, ack); err != nil { return nil, err } } @@ -498,7 +504,7 @@ func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*c } // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) if err != nil { ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -537,7 +543,7 @@ func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*c } // Delete packet commitment - if err = k.ChannelKeeper.TimeoutExecuted(ctx, cap, msg.Packet); err != nil { + if err = k.ChannelKeeper.TimeoutExecuted(ctx, capability, msg.Packet); err != nil { return nil, err } @@ -571,7 +577,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo } // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) if err != nil { ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -589,7 +595,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo // If the timeout was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - err = k.ChannelKeeper.TimeoutOnClose(cacheCtx, cap, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv) + err = k.ChannelKeeper.TimeoutOnClose(cacheCtx, capability, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv) switch err { case nil: @@ -613,7 +619,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo } // Delete packet commitment - if err = k.ChannelKeeper.TimeoutExecuted(ctx, cap, msg.Packet); err != nil { + if err = k.ChannelKeeper.TimeoutExecuted(ctx, capability, msg.Packet); err != nil { return nil, err } @@ -647,7 +653,7 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn } // Lookup module by channel capability - module, cap, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) + module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.SourcePort, msg.Packet.SourceChannel) if err != nil { ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel, "error", sdkerrors.Wrap(err, "could not retrieve module from port-id")) return nil, sdkerrors.Wrap(err, "could not retrieve module from port-id") @@ -665,7 +671,7 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn // If the acknowledgement was already received, perform a no-op // Use a cached context to prevent accidental state changes cacheCtx, writeFn := ctx.CacheContext() - err = k.ChannelKeeper.AcknowledgePacket(cacheCtx, cap, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) + err = k.ChannelKeeper.AcknowledgePacket(cacheCtx, capability, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight) switch err { case nil: diff --git a/modules/core/module.go b/modules/core/module.go index 7f0cbfbd0aa..1ca99f17f6a 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -135,11 +135,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { return err } - if err := clientMigrator.Migrate3to4(ctx); err != nil { - return err - } - - return nil + return clientMigrator.Migrate3to4(ctx) }); err != nil { panic(err) } diff --git a/modules/light-clients/06-solomachine/misbehaviour_handle.go b/modules/light-clients/06-solomachine/misbehaviour_handle.go index 1f4aec41489..4aadb719c9c 100644 --- a/modules/light-clients/06-solomachine/misbehaviour_handle.go +++ b/modules/light-clients/06-solomachine/misbehaviour_handle.go @@ -67,9 +67,5 @@ func (cs ClientState) verifySignatureAndData(cdc codec.BinaryCodec, misbehaviour return err } - if err := VerifySignature(publicKey, data, sigData); err != nil { - return err - } - - return nil + return VerifySignature(publicKey, data, sigData) } diff --git a/modules/light-clients/07-tendermint/client_state.go b/modules/light-clients/07-tendermint/client_state.go index 66223775ba2..f92a9ce79a1 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -244,11 +244,7 @@ func (cs ClientState) VerifyMembership( return sdkerrors.Wrap(clienttypes.ErrConsensusStateNotFound, "please ensure the proof was constructed against a height that exists on the client") } - if err := merkleProof.VerifyMembership(cs.ProofSpecs, consensusState.GetRoot(), merklePath, value); err != nil { - return err - } - - return nil + return merkleProof.VerifyMembership(cs.ProofSpecs, consensusState.GetRoot(), merklePath, value) } // VerifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath at a specified height. @@ -290,11 +286,7 @@ func (cs ClientState) VerifyNonMembership( return sdkerrors.Wrap(clienttypes.ErrConsensusStateNotFound, "please ensure the proof was constructed against a height that exists on the client") } - if err := merkleProof.VerifyNonMembership(cs.ProofSpecs, consensusState.GetRoot(), merklePath); err != nil { - return err - } - - return nil + return merkleProof.VerifyNonMembership(cs.ProofSpecs, consensusState.GetRoot(), merklePath) } // verifyDelayPeriodPassed will ensure that at least delayTimePeriod amount of time and delayBlockPeriod number of blocks have passed diff --git a/modules/light-clients/07-tendermint/misbehaviour.go b/modules/light-clients/07-tendermint/misbehaviour.go index a521a750dc1..eb3e60bcd01 100644 --- a/modules/light-clients/07-tendermint/misbehaviour.go +++ b/modules/light-clients/07-tendermint/misbehaviour.go @@ -101,11 +101,8 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { misbehaviour.Header1.Commit, misbehaviour.Header1.ValidatorSet); err != nil { return err } - if err := validCommit(misbehaviour.Header2.Header.ChainID, *blockID2, - misbehaviour.Header2.Commit, misbehaviour.Header2.ValidatorSet); err != nil { - return err - } - return nil + return validCommit(misbehaviour.Header2.Header.ChainID, *blockID2, + misbehaviour.Header2.Commit, misbehaviour.Header2.ValidatorSet) } // validCommit checks if the given commit is a valid commit from the passed-in validatorset diff --git a/testing/chain.go b/testing/chain.go index 4a1a2f5db25..f5e01cc89fe 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -539,12 +539,21 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) if !ok { // create capability using the IBC capability keeper +<<<<<<< HEAD cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) require.NoError(chain.T, err) // claim capability using the scopedKeeper err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, host.PortPath(portID)) require.NoError(chain.T, err) +======= + capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) + require.NoError(chain.TB, err) + + // claim capability using the scopedKeeper + err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, host.PortPath(portID)) + require.NoError(chain.TB, err) +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) } chain.NextBlock() @@ -553,10 +562,15 @@ func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.Scope // GetPortCapability returns the port capability for the given portID. The capability must // exist, otherwise testing will fail. func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability { +<<<<<<< HEAD cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) require.True(chain.T, ok) +======= + capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) + require.True(chain.TB, ok) +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) - return cap + return capability } // CreateChannelCapability binds and claims a capability for the given portID and channelID @@ -567,10 +581,17 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc // check if the portId is already binded, if not bind it _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName) if !ok { +<<<<<<< HEAD cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) require.NoError(chain.T, err) err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName) require.NoError(chain.T, err) +======= + capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) + require.NoError(chain.TB, err) + err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, capName) + require.NoError(chain.TB, err) +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) } chain.NextBlock() @@ -579,10 +600,15 @@ func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.Sc // GetChannelCapability returns the channel capability for the given portID and channelID. // The capability must exist, otherwise testing will fail. func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability { +<<<<<<< HEAD cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) require.True(chain.T, ok) +======= + capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) + require.True(chain.TB, ok) +>>>>>>> 5a67efc4 (chore: fix linter warnings (#3311)) - return cap + return capability } // GetTimeoutHeight is a convenience function which returns a IBC packet timeout height diff --git a/testing/endpoint.go b/testing/endpoint.go index f145804e4db..f645eba9815 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -202,11 +202,7 @@ func (endpoint *Endpoint) UpgradeChain() error { endpoint.Chain.Coordinator.IncrementTime() endpoint.Chain.NextBlock() - if err = endpoint.Counterparty.UpdateClient(); err != nil { - return err - } - - return nil + return endpoint.Counterparty.UpdateClient() } // ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint. diff --git a/testing/mock/mock.go b/testing/mock/mock.go index 9f265300c79..0d327100f94 100644 --- a/testing/mock/mock.go +++ b/testing/mock/mock.go @@ -109,8 +109,8 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. for _, ibcApp := range am.ibcApps { if ibcApp.PortID != "" && !am.portKeeper.IsBound(ctx, ibcApp.PortID) { // bind mock portID - cap := am.portKeeper.BindPort(ctx, ibcApp.PortID) - err := ibcApp.ScopedKeeper.ClaimCapability(ctx, cap, host.PortPath(ibcApp.PortID)) + capability := am.portKeeper.BindPort(ctx, ibcApp.PortID) + err := ibcApp.ScopedKeeper.ClaimCapability(ctx, capability, host.PortPath(ibcApp.PortID)) if err != nil { panic(err) } diff --git a/testing/path.go b/testing/path.go index d3b84a96ca7..4fb605ecbe8 100644 --- a/testing/path.go +++ b/testing/path.go @@ -57,11 +57,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error { return err } - if err := path.EndpointA.AcknowledgePacket(packet, ack); err != nil { - return err - } - - return nil + return path.EndpointA.AcknowledgePacket(packet, ack) } pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) @@ -82,10 +78,7 @@ func (path *Path) RelayPacket(packet channeltypes.Packet) error { return err } - if err := path.EndpointB.AcknowledgePacket(packet, ack); err != nil { - return err - } - return nil + return path.EndpointB.AcknowledgePacket(packet, ack) } return fmt.Errorf("packet commitment does not exist on either endpoint for provided packet")