Skip to content

Commit ed4bd87

Browse files
committed
#303 Upgrade Cosmos-SDK to v0.47.3
- Update version of linter - Fix linter errors Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com> Signed-off-by: Abdulbois <abdulbois123@gmail.com>
1 parent f6b40e9 commit ed4bd87

File tree

108 files changed

+341
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+341
-243
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
- name: Set up Go 1.x
132132
uses: actions/setup-go@v3
133133
with:
134-
go-version: ^1.16
134+
go-version: ^1.20
135135

136136
- name: Check out code into the Go module directory
137137
uses: actions/checkout@v2

.github/workflows/verify.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
steps:
8888
- uses: actions/setup-go@v3
8989
with:
90-
go-version: ^1.17
90+
go-version: ^1.20
9191
- uses: actions/checkout@v3
9292
- uses: actions/cache@v3
9393
if: ${{ !env.ACT }}
@@ -113,7 +113,7 @@ jobs:
113113
steps:
114114
- uses: actions/setup-go@v3
115115
with:
116-
go-version: ^1.17
116+
go-version: ^1.20
117117
- uses: actions/checkout@v3
118118
- uses: actions/cache@v3
119119
with:
@@ -136,11 +136,11 @@ jobs:
136136
- uses: actions/checkout@v3
137137
- uses: actions/setup-go@v3
138138
with:
139-
go-version: 1.17
139+
go-version: 1.20
140140
- name: golangci-lint
141141
uses: golangci/golangci-lint-action@v3.6.0
142142
with:
143-
version: v1.46.0
143+
version: 1.55.2
144144
args: --timeout 5m0s
145145
check:
146146
if: always()

app/app.go

+36-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"path/filepath"
88

9-
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
109
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
1110
dbm "github.com/cometbft/cometbft-db"
1211
abci "github.com/cometbft/cometbft/abci/types"
@@ -42,7 +41,7 @@ import (
4241
dclpkitypes "github.com/zigbee-alliance/distributed-compliance-ledger/types/pki"
4342
compliancemodule "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance"
4443
compliancemodulekeeper "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/keeper"
45-
compliancetypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types"
44+
dclcompliancetypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types"
4645
dclauthmodule "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth"
4746
"github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/ante"
4847
baseauthmodulekeeper "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/base/keeper"
@@ -55,7 +54,7 @@ import (
5554
dclupgrademoduletypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclupgrade/types"
5655
modelmodule "github.com/zigbee-alliance/distributed-compliance-ledger/x/model"
5756
modelmodulekeeper "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/keeper"
58-
modelmoduletypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types"
57+
dclmodeltypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/model/types"
5958
pkimodule "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki"
6059
pkimodulekeeper "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/keeper"
6160
validatormodule "github.com/zigbee-alliance/distributed-compliance-ledger/x/validator"
@@ -275,8 +274,8 @@ func New(
275274
dclupgrademoduletypes.StoreKey,
276275
dclpkitypes.StoreKey,
277276
vendorinfomoduletypes.StoreKey,
278-
modelmoduletypes.StoreKey,
279-
compliancetypes.StoreKey,
277+
dclmodeltypes.StoreKey,
278+
dclcompliancetypes.StoreKey,
280279
// this line is used by starport scaffolding # stargate/app/storeKey
281280
)
282281
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
@@ -438,17 +437,17 @@ func New(
438437

439438
app.ModelKeeper = *modelmodulekeeper.NewKeeper(
440439
appCodec,
441-
keys[modelmoduletypes.StoreKey],
442-
keys[modelmoduletypes.MemStoreKey],
440+
keys[dclmodeltypes.StoreKey],
441+
keys[dclmodeltypes.MemStoreKey],
443442

444443
app.DclauthKeeper,
445444
app.ComplianceKeeper,
446445
)
447446

448447
app.ComplianceKeeper = *compliancemodulekeeper.NewKeeper(
449448
appCodec,
450-
keys[compliancetypes.StoreKey],
451-
keys[compliancetypes.MemStoreKey],
449+
keys[dclcompliancetypes.StoreKey],
450+
keys[dclcompliancetypes.MemStoreKey],
452451
app.DclauthKeeper,
453452
app.ModelKeeper,
454453
)
@@ -529,12 +528,31 @@ func New(
529528

530529
app.mm.SetOrderBeginBlockers(
531530
// TODO [issue 99] verify the order
532-
upgradetypes.ModuleName,
531+
dclauthmoduletypes.ModuleName,
533532
validatormoduletypes.ModuleName,
533+
dclgenutilmoduletypes.ModuleName,
534+
dclupgrademoduletypes.ModuleName,
535+
upgradetypes.ModuleName,
536+
dclpkitypes.ModuleName,
537+
dclauthmoduletypes.ModuleName,
538+
dclmodeltypes.ModuleName,
539+
dclcompliancetypes.ModuleName,
540+
vendorinfomoduletypes.ModuleName,
541+
paramstypes.ModuleName,
534542
)
535543

536544
app.mm.SetOrderEndBlockers(
545+
dclauthmoduletypes.ModuleName,
537546
validatormoduletypes.ModuleName,
547+
dclgenutilmoduletypes.ModuleName,
548+
dclupgrademoduletypes.ModuleName,
549+
upgradetypes.ModuleName,
550+
dclpkitypes.ModuleName,
551+
dclauthmoduletypes.ModuleName,
552+
dclmodeltypes.ModuleName,
553+
dclcompliancetypes.ModuleName,
554+
vendorinfomoduletypes.ModuleName,
555+
paramstypes.ModuleName,
538556
)
539557

540558
// NOTE: The genutils module must occur after staking so that pools are
@@ -565,8 +583,11 @@ func New(
565583
dclupgrademoduletypes.ModuleName,
566584
dclpkitypes.ModuleName,
567585
vendorinfomoduletypes.ModuleName,
568-
modelmoduletypes.ModuleName,
569-
compliancetypes.ModuleName,
586+
dclmodeltypes.ModuleName,
587+
dclcompliancetypes.ModuleName,
588+
paramstypes.ModuleName,
589+
upgradetypes.ModuleName,
590+
dclupgrademoduletypes.ModuleName,
570591
// this line is used by starport scaffolding # stargate/app/initGenesis
571592
)
572593

@@ -576,7 +597,7 @@ func New(
576597
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
577598
app.mm.RegisterServices(app.configurator)
578599

579-
autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))
600+
// autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))
580601
reflectionSvc, err := runtimeservices.NewReflectionService()
581602
if err != nil {
582603
panic(err)
@@ -832,8 +853,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
832853
paramsKeeper.Subspace(dclupgrademoduletypes.ModuleName)
833854
paramsKeeper.Subspace(dclpkitypes.ModuleName)
834855
paramsKeeper.Subspace(vendorinfomoduletypes.ModuleName)
835-
paramsKeeper.Subspace(modelmoduletypes.ModuleName)
836-
paramsKeeper.Subspace(compliancetypes.ModuleName)
856+
paramsKeeper.Subspace(dclmodeltypes.ModuleName)
857+
paramsKeeper.Subspace(dclcompliancetypes.ModuleName)
837858
// this line is used by starport scaffolding # stargate/app/paramSubspace
838859

839860
return paramsKeeper

integration_tests/utils/common.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import (
2121
"time"
2222
)
2323

24-
// nolint
2524
func RandString() string {
26-
rand.Seed(time.Now().UnixNano())
25+
rand.Seed(time.Now().UnixNano()) //nolint:staticcheck
2726

2827
chars := []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
2928

integration_tests/utils/grpc_rest.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
//nolint:staticcheck
2626
"github.com/golang/protobuf/proto"
2727
"github.com/stretchr/testify/require"
28+
"google.golang.org/grpc"
29+
"google.golang.org/grpc/credentials/insecure"
2830

2931
sdkerrors "cosmossdk.io/errors"
3032
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
@@ -35,7 +37,6 @@ import (
3537
"github.com/zigbee-alliance/distributed-compliance-ledger/app"
3638
appparams "github.com/zigbee-alliance/distributed-compliance-ledger/app/params"
3739
dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types"
38-
"google.golang.org/grpc"
3940
)
4041

4142
// NOTE
@@ -55,8 +56,8 @@ type TestSuite struct {
5556
func (suite *TestSuite) GetGRPCConn() *grpc.ClientConn {
5657
// Create a connection to the gRPC server.
5758
grpcConn, err := grpc.Dial(
58-
"127.0.0.1:26630", // Or your gRPC server address.
59-
grpc.WithInsecure(), // The SDK doesn't support any transport security mechanism.
59+
"127.0.0.1:26630", // Or your gRPC server address.
60+
grpc.WithTransportCredentials(insecure.NewCredentials()), // The SDK doesn't support any transport security mechanism.
6061
)
6162
require.NoError(suite.T, err)
6263

testutil/network/network.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//nolint:blank-imports,staticcheck
1+
//nolint:staticcheck
22
package network
33

44
import (
@@ -43,10 +43,10 @@ import (
4343
"github.com/cosmos/cosmos-sdk/testutil"
4444
"github.com/cosmos/cosmos-sdk/testutil/network"
4545
sdk "github.com/cosmos/cosmos-sdk/types"
46-
_ "github.com/cosmos/cosmos-sdk/x/auth"
46+
_ "github.com/cosmos/cosmos-sdk/x/auth" //nolint: nolintlint
4747
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
4848
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
49-
_ "github.com/cosmos/cosmos-sdk/x/bank"
49+
_ "github.com/cosmos/cosmos-sdk/x/bank" //nolint: nolintlint
5050
_ "github.com/cosmos/cosmos-sdk/x/consensus"
5151
_ "github.com/cosmos/cosmos-sdk/x/params"
5252
_ "github.com/cosmos/cosmos-sdk/x/staking"

x/compliance/handler.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package compliance
33
import (
44
"fmt"
55

6+
"cosmossdk.io/errors"
67
sdk "github.com/cosmos/cosmos-sdk/types"
78
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
9+
810
"github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/keeper"
911
"github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types"
1012
)
@@ -41,7 +43,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
4143
default:
4244
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
4345

44-
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
46+
return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
4547
}
4648
}
4749
}

x/compliance/handler_delete_compliance_info_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func (setup *TestSetup) deleteComplianceInfo(vid int32, pid int32, softwareVersi
2929
}
3030

3131
func (setup *TestSetup) checkComplianceInfoDeleted(t *testing.T, deleteComplInfoMsg *types.MsgDeleteComplianceInfo) {
32+
t.Helper()
3233
vid := deleteComplInfoMsg.Vid
3334
pid := deleteComplInfoMsg.Pid
3435
softwareVersion := deleteComplInfoMsg.SoftwareVersion

x/compliance/handler_provision_model_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
func setupProvisionModel(t *testing.T) (*TestSetup, int32, int32, uint32, string, string) {
16+
t.Helper()
1617
setup := setup(t)
1718

1819
vid, pid, softwareVersion, softwareVersionString := setup.addModelVersion(
@@ -48,6 +49,7 @@ func (setup *TestSetup) provisionModelWithAllOptionalFlags(vid int32, pid int32,
4849
}
4950

5051
func (setup *TestSetup) checkComplianceInfoEqualsProvisionModelMsgData(t *testing.T, provisionModelMsg *types.MsgProvisionModel) {
52+
t.Helper()
5153
vid := provisionModelMsg.Vid
5254
pid := provisionModelMsg.Pid
5355
softwareVersion := provisionModelMsg.SoftwareVersion
@@ -59,6 +61,7 @@ func (setup *TestSetup) checkComplianceInfoEqualsProvisionModelMsgData(t *testin
5961
}
6062

6163
func (setup *TestSetup) checkModelProvisioned(t *testing.T, provisionModelMsg *types.MsgProvisionModel) {
64+
t.Helper()
6265
vid := provisionModelMsg.Vid
6366
pid := provisionModelMsg.Pid
6467
softwareVersion := provisionModelMsg.SoftwareVersion

x/compliance/handler_revoke_model_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
func setupRevokeModel(t *testing.T) (*TestSetup, int32, int32, uint32, string, string) {
18+
t.Helper()
1819
setup := setup(t)
1920

2021
vid, pid, softwareVersion, softwareVersionString := setup.addModelVersion(
@@ -32,6 +33,7 @@ func (setup *TestSetup) revokeModel(vid int32, pid int32, softwareVersion uint32
3233
}
3334

3435
func (setup *TestSetup) checkModelRevoked(t *testing.T, revokeModelMsg *types.MsgRevokeModel) {
36+
t.Helper()
3537
vid := revokeModelMsg.Vid
3638
pid := revokeModelMsg.Pid
3739
softwareVersion := revokeModelMsg.SoftwareVersion
@@ -48,6 +50,7 @@ func (setup *TestSetup) checkModelRevoked(t *testing.T, revokeModelMsg *types.Ms
4850
}
4951

5052
func (setup *TestSetup) checkModelStatusChangedToRevoked(t *testing.T, revokeModelMsg *types.MsgRevokeModel) {
53+
t.Helper()
5154
vid := revokeModelMsg.Vid
5255
pid := revokeModelMsg.Pid
5356
softwareVersion := revokeModelMsg.SoftwareVersion
@@ -64,6 +67,7 @@ func (setup *TestSetup) checkModelStatusChangedToRevoked(t *testing.T, revokeMod
6467
}
6568

6669
func (setup *TestSetup) checkRevokedModelInfoEqualsMessageData(t *testing.T, revokeModelMsg *types.MsgRevokeModel) *types.ComplianceInfo {
70+
t.Helper()
6771
vid := revokeModelMsg.Vid
6872
pid := revokeModelMsg.Pid
6973
softwareVersion := revokeModelMsg.SoftwareVersion

x/compliance/handler_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ func checkRevokedModelInfo(
370370
}
371371

372372
func assertNotFound(t *testing.T, err error) {
373+
t.Helper()
373374
require.Error(t, err)
374375
require.Equal(t, codes.NotFound, status.Code(err))
375376
}

x/compliance/handler_update_compliance_info_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func (setup *TestSetup) checkAllComplianceInfoFieldsUpdated(t *testing.T, originalComplianceInfo *types.ComplianceInfo, updatedComplianceInfo *types.ComplianceInfo) {
15+
t.Helper()
1516
require.Equal(t, originalComplianceInfo.Vid, updatedComplianceInfo.Vid)
1617
require.Equal(t, originalComplianceInfo.Pid, updatedComplianceInfo.Pid)
1718
require.Equal(t, originalComplianceInfo.SoftwareVersion, updatedComplianceInfo.SoftwareVersion)
@@ -33,6 +34,7 @@ func (setup *TestSetup) checkAllComplianceInfoFieldsUpdated(t *testing.T, origin
3334
}
3435

3536
func (setup *TestSetup) checkDeviceSoftwareComplianceUpdated(t *testing.T, originalComplianceInfo *types.ComplianceInfo, updatedDeviceSoftwareCompliance *types.DeviceSoftwareCompliance, isUpdatedMinimally bool) {
37+
t.Helper()
3638
isFound := false
3739

3840
for _, complianceInfo := range updatedDeviceSoftwareCompliance.ComplianceInfo {
@@ -57,6 +59,7 @@ func (setup *TestSetup) checkDeviceSoftwareComplianceUpdated(t *testing.T, origi
5759
}
5860

5961
func setupUpdateComplianceInfo(t *testing.T) (*TestSetup, int32, int32, uint32, string, string, *types.ComplianceInfo, *types.DeviceSoftwareCompliance) {
62+
t.Helper()
6063
setup := setup(t)
6164

6265
vid, pid, softwareVersion, softwareVersionString := setup.addModelVersion(

x/compliance/keeper/msg_server_certify_model.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"time"
77

8+
"cosmossdk.io/errors"
89
sdk "github.com/cosmos/cosmos-sdk/types"
910
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
1011

@@ -18,13 +19,13 @@ func (k msgServer) CertifyModel(goCtx context.Context, msg *types.MsgCertifyMode
1819

1920
signerAddr, err := sdk.AccAddressFromBech32(msg.Signer)
2021
if err != nil {
21-
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid Address: (%s)", err)
22+
return nil, errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid Address: (%s)", err)
2223
}
2324

2425
// check if sender has enough rights to certify model
2526
// sender must have CertificationCenter role to certify/revoke model
2627
if !k.dclauthKeeper.HasRole(ctx, signerAddr, dclauthtypes.CertificationCenter) {
27-
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized,
28+
return nil, errors.Wrapf(sdkerrors.ErrUnauthorized,
2829
"MsgAddTestingResult transaction should be signed by an account with the %s role",
2930
dclauthtypes.CertificationCenter,
3031
)

x/compliance/keeper/msg_server_delete_compliance_info.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package keeper
33
import (
44
"context"
55

6+
"cosmossdk.io/errors"
67
sdk "github.com/cosmos/cosmos-sdk/types"
78
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
9+
810
"github.com/zigbee-alliance/distributed-compliance-ledger/x/compliance/types"
911
dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types"
1012
)
@@ -14,13 +16,13 @@ func (k msgServer) DeleteComplianceInfo(goCtx context.Context, msg *types.MsgDel
1416

1517
signerAddr, err := sdk.AccAddressFromBech32(msg.Creator)
1618
if err != nil {
17-
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid Address: (%s)", err)
19+
return nil, errors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid Address: (%s)", err)
1820
}
1921

2022
// check if sender has enough rights to delete model
2123
// sender must have CertificationCenter role to certify/revoke model
2224
if !k.dclauthKeeper.HasRole(ctx, signerAddr, dclauthtypes.CertificationCenter) {
23-
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized,
25+
return nil, errors.Wrapf(sdkerrors.ErrUnauthorized,
2426
"MsgDeleteComplianceInfo transaction should be signed by an account with the %s role",
2527
dclauthtypes.CertificationCenter,
2628
)

0 commit comments

Comments
 (0)