diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index 04483100946..ce49a707781 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.4.0 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 71c6947158d..9afa25dfd83 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/account.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/account.go @@ -61,8 +61,8 @@ func (k Keeper) registerInterchainAccount(ctx sdk.Context, connectionID, portID, case k.portKeeper.IsBound(ctx, portID) && !k.HasCapability(ctx, portID): return "", errorsmod.Wrapf(icatypes.ErrPortAlreadyBound, "another module has claimed capability for and bound port with portID: %s", portID) case !k.portKeeper.IsBound(ctx, portID): - cap := k.BindPort(ctx, portID) - if err := k.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { + 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) } } 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 a018d5d8c14..ca5d37fdcb3 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/genesis.go @@ -13,8 +13,8 @@ import ( func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.ControllerGenesisState) { for _, portID := range state.Ports { if !keeper.HasCapability(ctx, portID) { - cap := keeper.BindPort(ctx, portID) - if err := keeper.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { + capability := keeper.BindPort(ctx, portID) + if err := keeper.ClaimCapability(ctx, capability, host.PortPath(portID)); err != nil { 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 9f80aa507e0..b751f876608 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 ff3718ad9be..5f7a96277a3 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 6a31978d589..b4ba0ed6cf2 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/genesis.go +++ b/modules/apps/27-interchain-accounts/host/keeper/genesis.go @@ -13,8 +13,8 @@ import ( // InitGenesis initializes the interchain accounts host application state from a provided genesis state func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.HostGenesisState) { if !keeper.HasCapability(ctx, state.Port) { - cap := keeper.BindPort(ctx, state.Port) - if err := keeper.ClaimCapability(ctx, cap, host.PortPath(state.Port)); err != nil { + capability := keeper.BindPort(ctx, state.Port) + if err := keeper.ClaimCapability(ctx, capability, host.PortPath(state.Port)); err != nil { 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 e6dad73e5b2..78a83e37644 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 4d6d76833e4..86cb8fb51a2 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 81948ebdcbc..9edf8b564c6 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -31,11 +31,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 0828beba868..d867ed757c5 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -133,11 +133,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 @@ -173,11 +169,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 49f828f021e..655d74b9f4e 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -73,8 +73,8 @@ func (k Keeper) HasCapability(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 ba4d2000db3..ca5ced6b7fa 100644 --- a/modules/apps/transfer/keeper/mbt_relay_test.go +++ b/modules/apps/transfer/keeper/mbt_relay_test.go @@ -114,8 +114,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 9ef5dffaf63..51d61affcae 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,13 +58,13 @@ func handleSolomachineMigration(ctx sdk.Context, store sdk.KVStore, cdc codec.Bi return errorsmod.Wrapf(clienttypes.ErrClientNotFound, "clientID %s", clientID) } - var any codectypes.Any - if err := cdc.Unmarshal(bz, &any); err != nil { + 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(any.Value, &clientState); err != nil { + if err := cdc.Unmarshal(protoAny.Value, &clientState); err != nil { return errorsmod.Wrap(err, "failed to unmarshal client state bytes into solo machine client state") } 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 fe3fff7b171..ecc6fad2fbe 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -257,15 +257,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. @@ -340,15 +335,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 e62db6e1b2a..b9b11c771ea 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 3ac5cd5be4f..07c91deabc2 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 15eb5411580..a2c93c59c09 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, errorsmod.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, errorsmod.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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.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, errorsmod.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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -318,7 +318,7 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC } // Perform 04-channel verification - if err = k.ChannelKeeper.ChanOpenConfirm(ctx, msg.PortId, msg.ChannelId, cap, msg.ProofAck, msg.ProofHeight); err != nil { + 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") } @@ -341,7 +341,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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -359,7 +359,7 @@ func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgCha return nil, errorsmod.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, errorsmod.Wrap(err, "channel handshake close init failed") @@ -375,7 +375,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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -393,7 +393,7 @@ func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Msg return nil, errorsmod.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, errorsmod.Wrap(err, "channel handshake close confirm failed") @@ -415,7 +415,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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -433,7 +433,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 +464,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 } } @@ -496,7 +496,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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -535,7 +535,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 } @@ -567,7 +567,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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -585,7 +585,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: @@ -609,7 +609,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 } @@ -641,7 +641,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", errorsmod.Wrap(err, "could not retrieve module from port-id")) return nil, errorsmod.Wrap(err, "could not retrieve module from port-id") @@ -659,7 +659,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 7e8b3822410..f65f3c95350 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 dce10ad1522..2d2dfecdb44 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -245,11 +245,7 @@ func (cs ClientState) VerifyMembership( return errorsmod.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. @@ -291,11 +287,7 @@ func (cs ClientState) VerifyNonMembership( return errorsmod.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 667ca30f735..4162442c4f0 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 e32d65967b3..dbabe49a678 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -538,11 +538,11 @@ 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 - cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) + 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(), cap, host.PortPath(portID)) + err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, host.PortPath(portID)) require.NoError(chain.TB, err) } @@ -552,10 +552,10 @@ 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 { - cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) + capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) require.True(chain.TB, ok) - return cap + return capability } // CreateChannelCapability binds and claims a capability for the given portID and channelID @@ -566,9 +566,9 @@ 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 { - cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) + capability, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) require.NoError(chain.TB, err) - err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName) + err = scopedKeeper.ClaimCapability(chain.GetContext(), capability, capName) require.NoError(chain.TB, err) } @@ -578,10 +578,10 @@ 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 { - cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) + capability, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) require.True(chain.TB, ok) - 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 3e0f240c19d..98c8d22f6f6 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")