Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: address last linter findings and upgrade golanci-lint to latest version (1.57.2) #6169

Merged
merged 19 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/callbacks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.57.2
args: --timeout 5m
working-directory: modules/apps/callbacks

Expand Down Expand Up @@ -60,4 +60,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: modules/apps/callbacks/
projectBaseDir: modules/apps/callbacks/
4 changes: 2 additions & 2 deletions .github/workflows/e2emodule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.57.2
args: --timeout 5m
working-directory: e2e/

Expand All @@ -30,4 +30,4 @@ jobs:
- name: Go Test
run: |
cd e2e
go test -v -mod=readonly ./... -tags='test_e2e'
go test -v -mod=readonly ./... -tags='test_e2e'
4 changes: 2 additions & 2 deletions .github/workflows/golangci-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.54.2
args: --timeout 10m
version: v1.57.2
args: --timeout 10m
2 changes: 1 addition & 1 deletion .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.57.2
DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
args: --timeout 10m
2 changes: 1 addition & 1 deletion .github/workflows/wasm-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.57.2
args: --timeout 10m
working-directory: modules/light-clients/08-wasm

Expand Down
8 changes: 5 additions & 3 deletions modules/core/migrations/v7/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
v7 "github.com/cosmos/ibc-go/v8/modules/core/migrations/v7"
"github.com/cosmos/ibc-go/v8/modules/core/migrations/v7"
"github.com/cosmos/ibc-go/v8/modules/core/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
)
Expand Down Expand Up @@ -94,7 +94,8 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() {

// set in store for ease of determining expected genesis
clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), sm.ClientID)
cdc := suite.chainA.App.AppCodec().(*codec.ProtoCodec)
cdc, ok := suite.chainA.App.AppCodec().(*codec.ProtoCodec)
suite.Require().True(ok)
clientv7.RegisterInterfaces(cdc.InterfaceRegistry())

bz, err := cdc.MarshalInterface(legacyClientState)
Expand Down Expand Up @@ -137,7 +138,8 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() {
suite.Require().NoError(err)
expectedClientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper)

cdc := suite.chainA.App.AppCodec().(*codec.ProtoCodec)
cdc, ok := suite.chainA.App.AppCodec().(*codec.ProtoCodec)
suite.Require().True(ok)

// NOTE: these lines are added in comparison to 02-client/migrations/v7/genesis_test.go
// generate appState with old ibc genesis state
Expand Down
20 changes: 14 additions & 6 deletions modules/light-clients/07-tendermint/light_client_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func (suite *TendermintTestSuite) TestStatus() {
{
"client status without consensus state",
func() {
clientState.LatestHeight = clientState.LatestHeight.Increment().(clienttypes.Height)
var ok bool
clientState.LatestHeight, ok = clientState.LatestHeight.Increment().(clienttypes.Height)
suite.Require().True(ok)
path.EndpointA.SetClientState(clientState)
},
exported.Expired,
Expand Down Expand Up @@ -87,7 +89,9 @@ func (suite *TendermintTestSuite) TestStatus() {
lightClientModule, found := suite.chainA.App.GetIBCKeeper().ClientKeeper.Route(path.EndpointA.ClientID)
suite.Require().True(found)

clientState = path.EndpointA.GetClientState().(*ibctm.ClientState)
var ok bool
clientState, ok = path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)

tc.malleate()

Expand Down Expand Up @@ -126,7 +130,8 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() {
{
"failure: consensus state not found for height",
func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
height = clientState.LatestHeight.Increment()
},
clienttypes.ErrConsensusStateNotFound,
Expand All @@ -141,7 +146,8 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() {
path = ibctesting.NewPath(suite.chainA, suite.chainB)
path.SetupClients()

clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
height = clientState.LatestHeight

// grab consensusState from store and update with a predefined timestamp
Expand Down Expand Up @@ -555,7 +561,8 @@ func (suite *TendermintTestSuite) TestVerifyMembership() {

proof, proofHeight = suite.chainB.QueryProof(key)

consensusState := testingpath.EndpointB.GetConsensusState(latestHeight).(*ibctm.ConsensusState)
consensusState, ok := testingpath.EndpointB.GetConsensusState(latestHeight).(*ibctm.ConsensusState)
suite.Require().True(ok)
value, err = suite.chainB.Codec.MarshalInterface(consensusState)
suite.Require().NoError(err)
},
Expand Down Expand Up @@ -764,7 +771,8 @@ func (suite *TendermintTestSuite) TestVerifyMembership() {

proof, proofHeight = suite.chainB.QueryProof(key)

clientState := testingpath.EndpointB.GetClientState().(*ibctm.ClientState)
clientState, ok := testingpath.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
value, err = suite.chainB.Codec.MarshalInterface(clientState)
suite.Require().NoError(err)

Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/08-wasm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

types "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func (suite *KeeperTestSuite) TestWasmInstantiate() {
err := json.Unmarshal(initMsg, &payload)
suite.Require().NoError(err)

wrappedClientState := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
wrappedClientState, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
suite.Require().True(ok)

clientState := types.NewClientState(payload.ClientState, payload.Checksum, wrappedClientState.LatestHeight)
clientStateBz := clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), clientState)
Expand Down Expand Up @@ -147,7 +148,8 @@ func (suite *KeeperTestSuite) TestWasmInstantiate() {
suite.Require().NoError(err)

// Change the checksum to something else.
wrappedClientState := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
wrappedClientState, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
suite.Require().True(ok)
clientState := types.NewClientState(payload.ClientState, []byte("new checksum"), wrappedClientState.LatestHeight)
store.Set(host.ClientStateKey(), clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), clientState))

Expand Down
3 changes: 2 additions & 1 deletion modules/light-clients/08-wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ func (suite *KeeperTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[
err := json.Unmarshal(initMsg, &payload)
suite.Require().NoError(err)

wrappedClientState := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
wrappedClientState, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
suite.Require().True(ok)

clientState := types.NewClientState(payload.ClientState, payload.Checksum, wrappedClientState.LatestHeight)
clientStateBz := clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), clientState)
Expand Down
6 changes: 4 additions & 2 deletions modules/light-clients/08-wasm/light_client_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ func (suite *WasmTestSuite) TestInitialize() {

suite.Require().Equal(env.Contract.Address, wasmClientID)

wrappedClientState := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
wrappedClientState, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
suite.Require().True(ok)

clientState := types.NewClientState(payload.ClientState, payload.Checksum, wrappedClientState.LatestHeight)
clientStateBz := clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), clientState)
Expand Down Expand Up @@ -824,7 +825,8 @@ func (suite *WasmTestSuite) TestVerifyUpgradeAndUpdateState() {
suite.Require().NoError(err)

// set new client state and consensus state
wrappedUpgradedClient := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), expectedUpgradedClient.Data).(*ibctm.ClientState)
wrappedUpgradedClient, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), expectedUpgradedClient.Data).(*ibctm.ClientState)
suite.Require().True(ok)
store.Set(host.ClientStateKey(), clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), upgradedClient))
store.Set(host.ConsensusStateKey(wrappedUpgradedClient.LatestHeight), clienttypes.MustMarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState))

Expand Down
8 changes: 6 additions & 2 deletions modules/light-clients/08-wasm/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ import (
ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee"
ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
Expand Down Expand Up @@ -565,8 +565,12 @@ func NewSimApp(

// initialize ICA module with mock module as the authentication module on the controller side
var icaControllerStack porttypes.IBCModule
var ok bool
icaControllerStack = ibcmock.NewIBCModule(&mockModule, ibcmock.NewIBCApp("", scopedICAMockKeeper))
app.ICAAuthModule = icaControllerStack.(ibcmock.IBCModule)
app.ICAAuthModule, ok = icaControllerStack.(ibcmock.IBCModule)
if !ok {
panic(fmt.Errorf("cannot convert %T into %T", icaControllerStack, app.ICAAuthModule))
}
icaControllerStack = icacontroller.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper)
icaControllerStack = ibcfee.NewIBCMiddleware(icaControllerStack, app.IBCFeeKeeper)

Expand Down
10 changes: 5 additions & 5 deletions modules/light-clients/08-wasm/testing/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
testing "github.com/cosmos/ibc-go/v8/testing"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
DimitrisJim marked this conversation as resolved.
Show resolved Hide resolved
)

var (
Expand All @@ -37,12 +37,12 @@ func CreateMockTendermintClientState(height clienttypes.Height) *ibctm.ClientSta
return ibctm.NewClientState(
"chain-id",
ibctm.DefaultTrustLevel,
testing.TrustingPeriod,
testing.UnbondingPeriod,
testing.MaxClockDrift,
ibctesting.TrustingPeriod,
ibctesting.UnbondingPeriod,
ibctesting.MaxClockDrift,
height,
commitmenttypes.GetSDKSpecs(),
testing.UpgradePath,
ibctesting.UpgradePath,
)
}

Expand Down
8 changes: 7 additions & 1 deletion modules/light-clients/08-wasm/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"bytes"
"errors"
"fmt"
"io"

wasmvm "github.com/CosmWasm/wasmvm/v2"
Expand Down Expand Up @@ -35,7 +36,12 @@
}

clientStateI := clienttypes.MustUnmarshalClientState(cdc, bz)
return clientStateI.(*ClientState), true
var clientState *ClientState
clientState, ok := clientStateI.(*ClientState)
if !ok {
panic(fmt.Errorf("cannot convert %T into %T", clientStateI, clientState))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
return clientState, ok
}

// Checksum is a type alias used for wasm byte code checksums.
Expand Down
5 changes: 3 additions & 2 deletions modules/light-clients/08-wasm/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing"
simapp "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
Expand Down Expand Up @@ -90,7 +90,8 @@ func (suite *TypesTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[s
err := json.Unmarshal(initMsg, &payload)
suite.Require().NoError(err)

wrappedClientState := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
wrappedClientState, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
suite.Require().True(ok)

clientState := types.NewClientState(payload.ClientState, payload.Checksum, wrappedClientState.LatestHeight)
clientStateBz := clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), clientState)
Expand Down
5 changes: 3 additions & 2 deletions modules/light-clients/08-wasm/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing"
simapp "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp"
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
Expand Down Expand Up @@ -85,7 +85,8 @@ func (suite *WasmTestSuite) setupWasmWithMockVM() (ibctesting.TestingApp, map[st
err := json.Unmarshal(initMsg, &payload)
suite.Require().NoError(err)

wrappedClientState := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
wrappedClientState, ok := clienttypes.MustUnmarshalClientState(suite.chainA.App.AppCodec(), payload.ClientState).(*ibctm.ClientState)
suite.Require().True(ok)

clientState := types.NewClientState(payload.ClientState, payload.Checksum, wrappedClientState.LatestHeight)
clientStateBz := clienttypes.MustMarshalClientState(suite.chainA.App.AppCodec(), clientState)
Expand Down
Loading