Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cosmos/ibc-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: notional-labs/ibc-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: hoa/fix-lint
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 10 commits
  • 28 files changed
  • 1 contributor

Commits on May 11, 2024

  1. chore: add errorlint and refactor check error

    hoank101 committed May 11, 2024
    Copy the full SHA
    8727d71 View commit details

Commits on May 14, 2024

  1. Merge branch 'main' into hoa/fix-lint

    hoank101 authored May 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    52d4520 View commit details

Commits on May 16, 2024

  1. Copy the full SHA
    68d50d5 View commit details
  2. Copy the full SHA
    16c54e6 View commit details

Commits on May 23, 2024

  1. Merge branch 'main' of https://github.com/cosmos/ibc-go into hoa/fix-…

    …lint
    hoank101 committed May 23, 2024
    Copy the full SHA
    e046277 View commit details

Commits on Jun 3, 2024

  1. Merge branch 'main' of https://github.com/cosmos/ibc-go into hoa/fix-…

    …lint
    
    # Conflicts:
    #	modules/apps/transfer/keeper/relay.go
    hoank101 committed Jun 3, 2024
    Copy the full SHA
    fc59283 View commit details
  2. refactor

    hoank101 committed Jun 3, 2024
    Copy the full SHA
    e919191 View commit details

Commits on Jun 4, 2024

  1. Merge branch 'main' of https://github.com/cosmos/ibc-go into hoa/fix-…

    …lint
    
    # Conflicts:
    #	modules/apps/transfer/module.go
    hoank101 committed Jun 4, 2024
    Copy the full SHA
    62f4f60 View commit details
  2. Merge branch 'main' into hoa/fix-lint

    hoank101 authored Jun 4, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4878528 View commit details

Commits on Jun 6, 2024

  1. Merge branch 'main' into hoa/fix-lint

    hoank101 authored Jun 6, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a7f16fb View commit details
Showing with 90 additions and 79 deletions.
  1. +1 −0 .golangci.yml
  2. +3 −3 cmd/build_test_matrix/main.go
  3. +1 −1 docs/docs/03-light-clients/04-wasm/03-integration.md
  4. +1 −1 docs/versioned_docs/version-v7.5.x/03-light-clients/04-wasm/03-integration.md
  5. +1 −1 docs/versioned_docs/version-v8.3.x/03-light-clients/04-wasm/03-integration.md
  6. +2 −2 e2e/dockerutil/dockerutil.go
  7. +2 −2 e2e/testsuite/testconfig.go
  8. +2 −2 e2e/testsuite/testsuite.go
  9. +1 −1 modules/apps/27-interchain-accounts/controller/keeper/genesis.go
  10. +2 −2 modules/apps/27-interchain-accounts/host/keeper/genesis.go
  11. +2 −2 modules/apps/27-interchain-accounts/module.go
  12. +1 −1 modules/apps/29-fee/module.go
  13. +4 −5 modules/apps/callbacks/ibc_middleware_test.go
  14. +1 −1 modules/apps/transfer/keeper/genesis.go
  15. +2 −2 modules/apps/transfer/keeper/relay.go
  16. +4 −4 modules/apps/transfer/module.go
  17. +1 −1 modules/core/02-client/genesis.go
  18. +3 −1 modules/core/04-channel/keeper/upgrade.go
  19. +11 −5 modules/core/04-channel/keeper/upgrade_test.go
  20. +8 −6 modules/core/ante/ante.go
  21. +12 −12 modules/core/keeper/msg_server.go
  22. +1 −1 modules/core/module.go
  23. +14 −14 modules/light-clients/06-solomachine/light_client_module_test.go
  24. +1 −1 modules/light-clients/08-wasm/keeper/keeper_vm.go
  25. +2 −1 modules/light-clients/08-wasm/keeper/snapshotter.go
  26. +4 −4 modules/light-clients/08-wasm/light_client_module_test.go
  27. +2 −2 modules/light-clients/08-wasm/module.go
  28. +1 −1 modules/light-clients/08-wasm/testing/simapp/app.go
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ linters:
disable-all: true
enable:
- exportloopref
- errorlint
- errcheck
- gci
- goconst
6 changes: 3 additions & 3 deletions cmd/build_test_matrix/main.go
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ func getGithubActionMatrixForTests(e2eRootDirectory, testName string, suite stri
fset := token.NewFileSet()
err := filepath.Walk(e2eRootDirectory, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error walking e2e directory: %s", err)
return fmt.Errorf("error walking e2e directory: %w", err)
}

// only look at test files
@@ -107,12 +107,12 @@ func getGithubActionMatrixForTests(e2eRootDirectory, testName string, suite stri

f, err := parser.ParseFile(fset, path, nil, 0)
if err != nil {
return fmt.Errorf("failed parsing file: %s", err)
return fmt.Errorf("failed parsing file: %w", err)
}

suiteNameForFile, testCases, err := extractSuiteAndTestNames(f)
if err != nil {
return fmt.Errorf("failed extracting test suite name and test cases: %s", err)
return fmt.Errorf("failed extracting test suite name and test cases: %w", err)
}

if testName != "" && contains(testName, testCases) {
2 changes: 1 addition & 1 deletion docs/docs/03-light-clients/04-wasm/03-integration.md
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ func NewSimApp(
ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmClientKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
panic(fmt.Errorf("failed to register snapshot extension: %w", err))
}
}
...
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ func NewSimApp(
ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmClientKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
panic(fmt.Errorf("failed to register snapshot extension: %w", err))
}
}
...
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ func NewSimApp(
ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmClientKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
panic(fmt.Errorf("failed to register snapshot extension: %w", err))
}
}
...
4 changes: 2 additions & 2 deletions e2e/dockerutil/dockerutil.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ func GetTestContainers(ctx context.Context, t *testing.T, dc *dockerclient.Clien
),
})
if err != nil {
return nil, fmt.Errorf("failed listing containers: %s", err)
return nil, fmt.Errorf("failed listing containers: %w", err)
}

return testContainers, nil
@@ -41,7 +41,7 @@ func GetContainerLogs(ctx context.Context, dc *dockerclient.Client, containerNam
ShowStderr: true,
})
if err != nil {
return nil, fmt.Errorf("failed reading logs in test cleanup: %s", err)
return nil, fmt.Errorf("failed reading logs in test cleanup: %w", err)
}
return io.ReadAll(readCloser)
}
4 changes: 2 additions & 2 deletions e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
@@ -683,7 +683,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte

govModuleBytes, err := json.Marshal(appStateMap[govtypes.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to extract gov genesis bytes: %s", err)
return nil, fmt.Errorf("failed to extract gov genesis bytes: %w", err)
}

govModuleGenesisBytes, err := modifyGovv1Beta1AppState(chainConfig, govModuleBytes)
@@ -700,7 +700,7 @@ func defaultGovv1Beta1ModifyGenesis(version string) func(ibc.ChainConfig, []byte
if !testvalues.AllowAllClientsWildcardFeatureReleases.IsSupported(version) {
ibcModuleBytes, err := json.Marshal(appStateMap[ibcexported.ModuleName])
if err != nil {
return nil, fmt.Errorf("failed to extract ibc genesis bytes: %s", err)
return nil, fmt.Errorf("failed to extract ibc genesis bytes: %w", err)
}

ibcGenesisBytes, err := modifyClientGenesisAppState(ibcModuleBytes)
4 changes: 2 additions & 2 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
@@ -315,10 +315,10 @@ func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, ibcrelayer ibc
chainA, chainB := s.GetChains()

if err := chainA.RecoverKey(ctx, ChainARelayerName, chainARelayerWallet.Mnemonic()); err != nil {
return fmt.Errorf("could not recover relayer wallet on chain A: %s", err)
return fmt.Errorf("could not recover relayer wallet on chain A: %w", err)
}
if err := chainB.RecoverKey(ctx, ChainBRelayerName, chainBRelayerWallet.Mnemonic()); err != nil {
return fmt.Errorf("could not recover relayer wallet on chain B: %s", err)
return fmt.Errorf("could not recover relayer wallet on chain B: %w", err)
}
return nil
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.ControllerGe

// use the controller scoped keeper to claim the port capability
if err := keeper.ClaimCapability(ctx, capability, host.PortPath(portID)); err != nil {
panic(fmt.Errorf("could not claim port capability: %v", err))
panic(fmt.Errorf("could not claim port capability: %w", err))
}
}
}
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/host/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.HostGenesisS

// use the host scoped keeper to claim the port capability
if err := keeper.ClaimCapability(ctx, capability, host.PortPath(state.Port)); err != nil {
panic(fmt.Errorf("could not claim port capability: %v", err))
panic(fmt.Errorf("could not claim port capability: %w", err))
}
}

@@ -34,7 +34,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.HostGenesisS
}

if err := state.Params.Validate(); err != nil {
panic(fmt.Errorf("could not set ica host params at genesis: %v", err))
panic(fmt.Errorf("could not set ica host params at genesis: %w", err))
}
keeper.SetParams(ctx, state.Params)
}
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

controllerMigrator := controllerkeeper.NewMigrator(am.controllerKeeper)
if err := cfg.RegisterMigration(types.ModuleName, 1, controllerMigrator.AssertChannelCapabilityMigrations); err != nil {
panic(fmt.Errorf("failed to migrate interchainaccounts app from version 1 to 2 (channel capabilities owned by controller submodule check): %v", err))
panic(fmt.Errorf("failed to migrate interchainaccounts app from version 1 to 2 (channel capabilities owned by controller submodule check): %w", err))
}

hostMigrator := hostkeeper.NewMigrator(am.hostKeeper)
@@ -145,7 +145,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
}
return controllerMigrator.MigrateParams(ctx)
}); err != nil {
panic(fmt.Errorf("failed to migrate interchainaccounts app from version 2 to 3 (self-managed params migration): %v", err))
panic(fmt.Errorf("failed to migrate interchainaccounts app from version 2 to 3 (self-managed params migration): %w", err))
}
}

2 changes: 1 addition & 1 deletion modules/apps/29-fee/module.go
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

m := keeper.NewMigrator(am.keeper)
if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil {
panic(fmt.Errorf("failed to migrate ibc-fee module from version 1 to 2 (refund leftover fees): %v", err))
panic(fmt.Errorf("failed to migrate ibc-fee module from version 1 to 2 (refund leftover fees): %w", err))
}
}

9 changes: 4 additions & 5 deletions modules/apps/callbacks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package ibccallbacks_test

import (
"encoding/json"
"errors"
"fmt"

errorsmod "cosmossdk.io/errors"
@@ -349,18 +350,16 @@ func (s *CallbacksTestSuite) TestOnAcknowledgementPacket() {
return transferStack.OnAcknowledgementPacket(ctx, packet, ack, s.chainA.SenderAccount.GetAddress())
}

switch tc.expError {
case nil:
switch {
case tc.expError == nil:
err := onAcknowledgementPacket()
s.Require().Nil(err)

case panicError:
case errors.Is(tc.expError, panicError):
s.Require().PanicsWithValue(storetypes.ErrorOutOfGas{
Descriptor: fmt.Sprintf("ibc %s callback out of gas; commitGasLimit: %d", types.CallbackTypeAcknowledgementPacket, userGasLimit),
}, func() {
_ = onAcknowledgementPacket()
})

default:
err := onAcknowledgementPacket()
s.Require().ErrorIs(err, tc.expError)
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
// and claims the returned capability
err := k.BindPort(ctx, state.PortId)
if err != nil {
panic(fmt.Errorf("could not claim port capability: %v", err))
panic(fmt.Errorf("could not claim port capability: %w", err))
}
}

4 changes: 2 additions & 2 deletions modules/apps/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ func (k Keeper) sendTransfer(
// NOTE: should not happen as the module account was
// retrieved on the step above and it has enough balance
// to burn.
panic(fmt.Errorf("cannot burn coins after a successful send to a module account: %v", err))
panic(fmt.Errorf("cannot burn coins after a successful send to a module account: %w", err))
}
}

@@ -321,7 +321,7 @@ func (k Keeper) refundPacketTokens(ctx sdk.Context, packet channeltypes.Packet,
}

if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, sdk.NewCoins(coin)); err != nil {
panic(fmt.Errorf("unable to send coins from module to account despite previously minting coins to module account: %v", err))
panic(fmt.Errorf("unable to send coins from module to account despite previously minting coins to module account: %w", err))
}
}

8 changes: 4 additions & 4 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
@@ -122,19 +122,19 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

m := keeper.NewMigrator(am.keeper)
if err := cfg.RegisterMigration(types.ModuleName, 2, m.MigrateTotalEscrowForDenom); err != nil {
panic(fmt.Errorf("failed to migrate transfer app from version 2 to 3 (total escrow entry migration): %v", err))
panic(fmt.Errorf("failed to migrate transfer app from version 2 to 3 (total escrow entry migration): %w", err))
}

if err := cfg.RegisterMigration(types.ModuleName, 3, m.MigrateParams); err != nil {
panic(fmt.Errorf("failed to migrate transfer app version 3 to 4 (self-managed params migration): %v", err))
panic(fmt.Errorf("failed to migrate transfer app version 3 to 4 (self-managed params migration): %w", err))
}

if err := cfg.RegisterMigration(types.ModuleName, 4, m.MigrateDenomMetadata); err != nil {
panic(fmt.Errorf("failed to migrate transfer app from version 4 to 5 (set denom metadata migration): %v", err))
panic(fmt.Errorf("failed to migrate transfer app from version 4 to 5 (set denom metadata migration): %w", err))
}

if err := cfg.RegisterMigration(types.ModuleName, 5, m.MigrateDenomTraceToDenom); err != nil {
panic(fmt.Errorf("failed to migrate transfer app from version 5 to 6 (migrate DenomTrace to Denom): %v", err))
panic(fmt.Errorf("failed to migrate transfer app from version 5 to 6 (migrate DenomTrace to Denom): %w", err))
}
}

2 changes: 1 addition & 1 deletion modules/core/02-client/genesis.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (
// state.
func InitGenesis(ctx sdk.Context, k *keeper.Keeper, gs types.GenesisState) {
if err := gs.Params.Validate(); err != nil {
panic(fmt.Errorf("invalid ibc client genesis state parameters: %v", err))
panic(fmt.Errorf("invalid ibc client genesis state parameters: %w", err))
}
k.SetParams(ctx, gs.Params)

4 changes: 3 additions & 1 deletion modules/core/04-channel/keeper/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"errors"
"fmt"
"reflect"
"slices"
@@ -980,7 +981,8 @@ func (k *Keeper) abortUpgrade(ctx sdk.Context, portID, channelID string, err err

// in the case of application callbacks, the error may not be an upgrade error.
// in this case we need to construct one in order to write the error receipt.
upgradeError, ok := err.(*types.UpgradeError)
var upgradeError *types.UpgradeError
ok := errors.As(err, &upgradeError)
if !ok {
upgradeError = types.NewUpgradeError(channel.UpgradeSequence, err)
}
16 changes: 11 additions & 5 deletions modules/core/04-channel/keeper/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper_test

import (
"errors"
"fmt"
"math"
"testing"
@@ -511,8 +512,10 @@ func (suite *KeeperTestSuite) TestChanUpgrade_CrossingHellos_UpgradeSucceeds_Aft
)
suite.Require().Error(err)
suite.assertUpgradeError(err, types.NewUpgradeError(4, types.ErrInvalidUpgradeSequence))

suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, err.(*types.UpgradeError))
var upgradeErr *types.UpgradeError
if errors.As(err, &upgradeErr) {
suite.chainB.GetSimApp().IBCKeeper.ChannelKeeper.WriteErrorReceipt(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, upgradeErr)
}
suite.coordinator.CommitBlock(suite.chainB)
})

@@ -2378,8 +2381,10 @@ func (suite *KeeperTestSuite) TestValidateUpgradeFields() {
func (suite *KeeperTestSuite) assertUpgradeError(actualError, expError error) {
suite.Require().Error(actualError)

if expUpgradeError, ok := expError.(*types.UpgradeError); ok {
upgradeError, ok := actualError.(*types.UpgradeError)
var expUpgradeError *types.UpgradeError
if errors.As(expError, &expUpgradeError) {
var upgradeError *types.UpgradeError
ok := errors.As(actualError, &upgradeError)
suite.Require().True(ok)
suite.Require().Equal(expUpgradeError.GetErrorReceipt(), upgradeError.GetErrorReceipt())
}
@@ -2470,7 +2475,8 @@ func (suite *KeeperTestSuite) TestAbortUpgrade() {
errorReceipt, found := channelKeeper.GetUpgradeErrorReceipt(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
suite.Require().True(found, "error receipt should be found")

if ue, ok := upgradeError.(*types.UpgradeError); ok {
var ue *types.UpgradeError
if errors.As(upgradeError, &ue) {
suite.Require().Equal(ue.GetErrorReceipt(), errorReceipt, "error receipt does not match expected error receipt")
}
} else {
14 changes: 8 additions & 6 deletions modules/core/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ante

import (
"errors"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
@@ -119,10 +121,10 @@ func (rrd RedundantRelayDecorator) recvPacketCheckTx(ctx sdk.Context, msg *chann
cacheCtx, writeFn := ctx.CacheContext()
err = rrd.k.ChannelKeeper.RecvPacket(cacheCtx, capability, msg.Packet, msg.ProofCommitment, msg.ProofHeight)

switch err {
case nil:
switch {
case err == nil:
writeFn()
case channeltypes.ErrNoOpMsg:
case errors.Is(err, channeltypes.ErrNoOpMsg):
return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.NOOP}, nil
default:
return nil, errorsmod.Wrap(err, "receive packet verification failed")
@@ -139,10 +141,10 @@ func (rrd RedundantRelayDecorator) recvPacketReCheckTx(ctx sdk.Context, msg *cha
cacheCtx, writeFn := ctx.CacheContext()
err := rrd.k.ChannelKeeper.RecvPacketReCheckTx(cacheCtx, msg.Packet)

switch err {
case nil:
switch {
case err == nil:
writeFn()
case channeltypes.ErrNoOpMsg:
case errors.Is(err, channeltypes.ErrNoOpMsg):
return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.NOOP}, nil
default:
return nil, errorsmod.Wrap(err, "receive packet verification failed")
24 changes: 12 additions & 12 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
@@ -476,10 +476,10 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack
cacheCtx, writeFn := ctx.CacheContext()
err = k.ChannelKeeper.RecvPacket(cacheCtx, capability, msg.Packet, msg.ProofCommitment, msg.ProofHeight)

switch err {
case nil:
switch {
case err == nil:
writeFn()
case channeltypes.ErrNoOpMsg:
case errors.Is(err, channeltypes.ErrNoOpMsg):
// no-ops do not need event emission as they will be ignored
ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel)
return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.NOOP}, nil
@@ -557,10 +557,10 @@ func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*
cacheCtx, writeFn := ctx.CacheContext()
err = k.ChannelKeeper.TimeoutPacket(cacheCtx, msg.Packet, msg.ProofUnreceived, msg.ProofHeight, msg.NextSequenceRecv)

switch err {
case nil:
switch {
case err == nil:
writeFn()
case channeltypes.ErrNoOpMsg:
case errors.Is(err, channeltypes.ErrNoOpMsg):
// no-ops do not need event emission as they will be ignored
ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel)
return &channeltypes.MsgTimeoutResponse{Result: channeltypes.NOOP}, nil
@@ -629,10 +629,10 @@ func (k *Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTime
cacheCtx, writeFn := ctx.CacheContext()
err = k.ChannelKeeper.TimeoutOnClose(cacheCtx, capability, msg.Packet, msg.ProofUnreceived, msg.ProofClose, msg.ProofHeight, msg.NextSequenceRecv, msg.CounterpartyUpgradeSequence)

switch err {
case nil:
switch {
case err == nil:
writeFn()
case channeltypes.ErrNoOpMsg:
case errors.Is(err, channeltypes.ErrNoOpMsg):
// no-ops do not need event emission as they will be ignored
ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel)
return &channeltypes.MsgTimeoutOnCloseResponse{Result: channeltypes.NOOP}, nil
@@ -704,10 +704,10 @@ func (k *Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAck
cacheCtx, writeFn := ctx.CacheContext()
err = k.ChannelKeeper.AcknowledgePacket(cacheCtx, capability, msg.Packet, msg.Acknowledgement, msg.ProofAcked, msg.ProofHeight)

switch err {
case nil:
switch {
case err == nil:
writeFn()
case channeltypes.ErrNoOpMsg:
case errors.Is(err, channeltypes.ErrNoOpMsg):
// no-ops do not need event emission as they will be ignored
ctx.Logger().Debug("no-op on redundant relay", "port-id", msg.Packet.SourcePort, "channel-id", msg.Packet.SourceChannel)
return &channeltypes.MsgAcknowledgementResponse{Result: channeltypes.NOOP}, nil
2 changes: 1 addition & 1 deletion modules/core/module.go
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.Ra
var gs types.GenesisState
err := cdc.UnmarshalJSON(bz, &gs)
if err != nil {
panic(fmt.Errorf("failed to unmarshal %s genesis state: %s", exported.ModuleName, err))
panic(fmt.Errorf("failed to unmarshal %s genesis state: %w", exported.ModuleName, err))
}
InitGenesis(ctx, *am.keeper, &gs)
}
28 changes: 14 additions & 14 deletions modules/light-clients/06-solomachine/light_client_module_test.go
Original file line number Diff line number Diff line change
@@ -564,7 +564,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {
clientState = solomachine.NewClientState(sm.Sequence, consensusState)
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, clientState)
},
fmt.Errorf("the consensus state timestamp is greater than the signature timestamp (11 >= 10): %s", solomachine.ErrInvalidProof),
fmt.Errorf("the consensus state timestamp is greater than the signature timestamp (11 >= 10): %w", solomachine.ErrInvalidProof),
},
{
"failure: signature data is nil",
@@ -577,15 +577,15 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {
proof, err = suite.chainA.Codec.Marshal(signatureDoc)
suite.Require().NoError(err)
},
fmt.Errorf("signature data cannot be empty: %s", solomachine.ErrInvalidProof),
fmt.Errorf("signature data cannot be empty: %w", solomachine.ErrInvalidProof),
},
{
"failure: consensus state public key is nil",
func() {
clientState.ConsensusState.PublicKey = nil
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, clientState)
},
fmt.Errorf("consensus state PublicKey cannot be nil: %s", clienttypes.ErrInvalidConsensus),
fmt.Errorf("consensus state PublicKey cannot be nil: %w", clienttypes.ErrInvalidConsensus),
},
{
"failure: malformed signature data fails to unmarshal",
@@ -605,7 +605,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {
func() {
proof = nil
},
fmt.Errorf("proof cannot be empty: %s", solomachine.ErrInvalidProof),
fmt.Errorf("proof cannot be empty: %w", solomachine.ErrInvalidProof),
},
{
"failure: proof verification failed",
@@ -619,7 +619,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {
func() {
path = commitmenttypes.MerklePath{}
},
fmt.Errorf("path must be of length 2: []: %s", host.ErrInvalidPath),
fmt.Errorf("path must be of length 2: []: %w", host.ErrInvalidPath),
},
}

@@ -784,7 +784,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() {
clientState = solomachine.NewClientState(sm.Sequence, consensusState)
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, clientState)
},
fmt.Errorf("the consensus state timestamp is greater than the signature timestamp (11 >= 10): %s", solomachine.ErrInvalidProof),
fmt.Errorf("the consensus state timestamp is greater than the signature timestamp (11 >= 10): %w", solomachine.ErrInvalidProof),
},
{
"failure: signature data is nil",
@@ -797,15 +797,15 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() {
proof, err = suite.chainA.Codec.Marshal(signatureDoc)
suite.Require().NoError(err)
},
fmt.Errorf("signature data cannot be empty: %s", solomachine.ErrInvalidProof),
fmt.Errorf("signature data cannot be empty: %w", solomachine.ErrInvalidProof),
},
{
"failure: consensus state public key is nil",
func() {
clientState.ConsensusState.PublicKey = nil
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, clientState)
},
fmt.Errorf("consensus state PublicKey cannot be nil: %s", clienttypes.ErrInvalidConsensus),
fmt.Errorf("consensus state PublicKey cannot be nil: %w", clienttypes.ErrInvalidConsensus),
},
{
"failure: malformed signature data fails to unmarshal",
@@ -825,7 +825,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() {
func() {
proof = nil
},
fmt.Errorf("proof cannot be empty: %s", solomachine.ErrInvalidProof),
fmt.Errorf("proof cannot be empty: %w", solomachine.ErrInvalidProof),
},
{
"failure: proof verification failed",
@@ -1055,7 +1055,7 @@ func (suite *SoloMachineTestSuite) TestUpdateState() {
func() {
clientID = unusedSmClientID
},
fmt.Errorf("%s: %s", unusedSmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedSmClientID, clienttypes.ErrClientNotFound),
},
}

@@ -1149,7 +1149,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() {
clientID = unusedSmClientID
},
false,
fmt.Errorf("%s: %s", unusedSmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedSmClientID, clienttypes.ErrClientNotFound),
},
}

@@ -1207,7 +1207,7 @@ func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() {
func() {
clientID = unusedSmClientID
},
fmt.Errorf("%s: %s", unusedSmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedSmClientID, clienttypes.ErrClientNotFound),
},
}

@@ -1385,7 +1385,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() {
func() {
clientID = unusedSmClientID
},
fmt.Errorf("%s: %s", unusedSmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedSmClientID, clienttypes.ErrClientNotFound),
},
}

@@ -1631,7 +1631,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() {
func() {
clientID = unusedSmClientID
},
fmt.Errorf("%s: %s", unusedSmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedSmClientID, clienttypes.ErrClientNotFound),
},
}

2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/keeper/keeper_vm.go
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ func NewKeeperWithConfig(
) Keeper {
vm, err := wasmvm.NewVM(wasmConfig.DataDir, wasmConfig.SupportedCapabilities, types.ContractMemoryLimit, wasmConfig.ContractDebugMode, types.MemoryCacheSize)
if err != nil {
panic(fmt.Errorf("failed to instantiate new Wasm VM instance: %v", err))
panic(fmt.Errorf("failed to instantiate new Wasm VM instance: %w", err))
}

return NewKeeperWithVM(cdc, storeService, clientKeeper, authority, vm, queryRouter, opts...)
3 changes: 2 additions & 1 deletion modules/light-clients/08-wasm/keeper/snapshotter.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package keeper

import (
"encoding/hex"
"errors"
"io"

errorsmod "cosmossdk.io/errors"
@@ -131,7 +132,7 @@ func (ws *WasmSnapshotter) processAllItems(
ctx := sdk.NewContext(ws.cms, cmtproto.Header{Height: int64(height)}, false, nil)
for {
payload, err := payloadReader()
if err == io.EOF {
if errors.Is(err, io.EOF) {
break
} else if err != nil {
return err
8 changes: 4 additions & 4 deletions modules/light-clients/08-wasm/light_client_module_test.go
Original file line number Diff line number Diff line change
@@ -1030,7 +1030,7 @@ func (suite *WasmTestSuite) TestCheckForMisbehaviour() {
clientID = unusedWasmClientID
},
false, // not applicable
fmt.Errorf("%s: %s", unusedWasmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedWasmClientID, clienttypes.ErrClientNotFound),
},
{
"failure: response fails to unmarshal",
@@ -1162,7 +1162,7 @@ func (suite *WasmTestSuite) TestUpdateState() {
func() {
clientID = unusedWasmClientID
},
fmt.Errorf("08-wasm-100: %s", clienttypes.ErrClientNotFound),
fmt.Errorf("08-wasm-100: %w", clienttypes.ErrClientNotFound),
nil,
},
{
@@ -1191,7 +1191,7 @@ func (suite *WasmTestSuite) TestUpdateState() {
return &wasmvmtypes.ContractResult{Ok: &wasmvmtypes.Response{Data: []byte("invalid json")}}, wasmtesting.DefaultGasUsed, nil
})
},
fmt.Errorf("invalid character 'i' looking for beginning of value: %s", types.ErrWasmInvalidResponseData),
fmt.Errorf("invalid character 'i' looking for beginning of value: %w", types.ErrWasmInvalidResponseData),
nil,
},
{
@@ -1324,7 +1324,7 @@ func (suite *WasmTestSuite) TestUpdateStateOnMisbehaviour() {
func() {
clientID = unusedWasmClientID
},
fmt.Errorf("%s: %s", unusedWasmClientID, clienttypes.ErrClientNotFound),
fmt.Errorf("%s: %w", unusedWasmClientID, clienttypes.ErrClientNotFound),
nil,
},
{
4 changes: 2 additions & 2 deletions modules/light-clients/08-wasm/module.go
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

wasmMigrator := keeper.NewMigrator(am.keeper)
if err := cfg.RegisterMigration(types.ModuleName, 1, wasmMigrator.MigrateChecksums); err != nil {
panic(fmt.Errorf("failed to migrate 08-wasm module from version 1 to 2 (checksums migration to collections): %v", err))
panic(fmt.Errorf("failed to migrate 08-wasm module from version 1 to 2 (checksums migration to collections): %w", err))
}
}

@@ -130,7 +130,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.Ra
var gs types.GenesisState
err := cdc.UnmarshalJSON(bz, &gs)
if err != nil {
panic(fmt.Errorf("failed to unmarshal %s genesis state: %s", am.Name(), err))
panic(fmt.Errorf("failed to unmarshal %s genesis state: %w", am.Name(), err))
}
err = am.keeper.InitGenesis(ctx, gs)
if err != nil {
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/testing/simapp/app.go
Original file line number Diff line number Diff line change
@@ -802,7 +802,7 @@ func NewSimApp(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmClientKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
panic(fmt.Errorf("failed to register snapshot extension: %w", err))
}
}