From b95018169d4c5e0e4c99b8b42cb3e8ddfb869629 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 23 May 2023 07:00:38 +0700 Subject: [PATCH 1/5] begin linting akash; ibrage ibc to v4.4.0 --- .golangci.yaml | 128 ++++++++++++++++-- app/app.go | 34 ++--- app/app_configure.go | 4 +- app/config.go | 87 ++++++------ app/export.go | 4 +- app/mac.go | 2 +- app/sim_test.go | 12 +- app/types/app.go | 8 +- app/upgrades.go | 2 +- client/broadcaster/broadcast.go | 3 +- client/broadcaster/client.go | 6 +- cmd/akash/cmd/root.go | 5 +- cmd/akash/cmd/testnetify/cmd.go | 10 +- cmd/akash/cmd/testnetify/state.go | 48 +++---- cmd/akash/cmd/testnetify/util.go | 4 +- cmd/common/util.go | 1 + cmd/common/util_test.go | 3 +- events/cmd/root.go | 4 +- events/publish.go | 1 - go.mod | 2 +- go.sum | 4 +- pubsub/bus_test.go | 2 - sdl/coin_test.go | 3 +- sdl/cpu_test.go | 2 +- sdl/sdl.go | 1 - sdl/storage_test.go | 18 +-- sdl/units.go | 4 +- sdl/units_test.go | 1 - sdl/util/util_test.go | 1 - sdl/v2.go | 8 +- sdl/v2_ip_test.go | 2 - sdl/v2_test.go | 27 ++-- testutil/deployment.go | 2 +- testutil/ids.go | 12 +- testutil/network_suite.go | 4 +- testutil/sdk.go | 4 +- testutil/types.go | 6 +- .../v0.15.0/proto_compatibility_test.go | 12 +- upgrades/software/v0.15.0/upgrade.go | 4 +- upgrades/software/v0.18.0/upgrade.go | 8 +- upgrades/software/v0.20.0/upgrade.go | 6 +- upgrades/types/types.go | 6 +- upgrades/upgrades.go | 5 +- util/cli/configs.go | 4 +- util/metrics/metrics.go | 8 +- util/wsutil/wsutil.go | 3 +- util/wsutil/wsutil_test.go | 5 +- x/audit/alias.go | 6 +- x/audit/keeper/grpc_query.go | 4 +- x/audit/keeper/grpc_query_test.go | 1 - x/audit/keeper/keeper.go | 5 +- x/audit/module.go | 1 - x/audit/query/client.go | 3 +- x/cert/alias.go | 6 +- x/cert/client/cli/errors.go | 4 +- x/cert/client/cli/tx.go | 1 - x/cert/errors/certificate_errors.go | 4 +- x/cert/keeper/grpc_query.go | 6 +- x/cert/keeper/keeper.go | 2 +- x/cert/module.go | 2 - x/cert/utils/key_pair_manager.go | 4 +- x/deployment/alias.go | 6 +- x/deployment/client/cli/query.go | 1 - x/deployment/client/rest/rest.go | 2 - x/deployment/handler/handler_test.go | 1 - x/deployment/keeper/grpc_query.go | 2 +- x/deployment/keeper/grpc_query_test.go | 5 +- x/deployment/keeper/keeper.go | 1 - x/deployment/keeper/key.go | 2 +- x/deployment/query/path.go | 4 +- x/deployment/simulation/operations.go | 15 +- x/escrow/client/cli/query.go | 1 - x/escrow/keeper/keeper.go | 11 +- x/escrow/keeper/keeper_settle_test.go | 2 +- x/escrow/keeper/keeper_test.go | 1 - x/escrow/module.go | 1 - x/gov/alias.go | 6 +- x/gov/module.go | 1 - x/gov/simulation/operations.go | 3 +- x/inflation/alias.go | 6 +- x/inflation/module.go | 1 - x/market/alias.go | 6 +- x/market/client/cli/query.go | 1 - x/market/client/cli/test_helpers.go | 12 +- x/market/client/rest/rest.go | 3 - x/market/handler/server.go | 1 - x/market/keeper/grpc_query.go | 6 +- x/market/keeper/grpc_query_test.go | 12 +- x/market/keeper/keeper.go | 1 - x/market/simulation/operations.go | 13 +- x/provider/alias.go | 6 +- x/provider/config/config.go | 4 +- x/provider/handler/handler_test.go | 3 - x/provider/handler/server.go | 6 +- x/provider/keeper/grpc_query.go | 2 +- x/provider/keeper/grpc_query_test.go | 1 - x/provider/module.go | 3 +- x/provider/simulation/operations.go | 11 +- x/staking/alias.go | 6 +- x/staking/simulation/operations.go | 3 +- 100 files changed, 407 insertions(+), 344 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index dd60ad4a3b..57902631c7 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,13 +1,125 @@ -issues: - exclude: - - comment on exported (method|function|type|const|var) - exclude-use-default: true - -# Skip generated k8s code run: + tests: true + timeout: 10m + sort-results: true + allow-parallel-runners: true + exclude-dir: testutil/testdata skip-dirs: - pkg/client - ".*/mocks" - - # Skip vendor/ etc + skip-files: + - server/grpc/gogoreflection/fix_registration.go skip-dirs-use-default: true + +linters: + disable-all: true + enable: + - depguard + - dogsled + - exportloopref + - goconst + - gocritic + - gofumpt + - gosec + - gosimple + - govet + - ineffassign + - misspell + - nakedret + - nolintlint + - staticcheck + - revive + - stylecheck + - typecheck + - unconvert + - unused + +issues: + exclude-use-default: true + exclude-rules: + - text: "Use of weak random number generator" + linters: + - gosec + - text: "ST1003:" + linters: + - stylecheck + # FIXME: Disabled until golangci-lint updates stylecheck with this fix: + # https://github.com/dominikh/go-tools/issues/389 + - text: "ST1016:" + linters: + - stylecheck + - path: "migrations" + text: "SA1019:" + linters: + - staticcheck + - text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out + linters: + - staticcheck + - text: "leading space" + linters: + - nolintlint + + max-issues-per-linter: 10000 + max-same-issues: 10000 + +linters-settings: + gosec: + # To select a subset of rules to run. + # Available rules: https://github.com/securego/gosec#available-rules + # Default: [] - means include all rules + includes: + # - G101 # Look for hard coded credentials + - G102 # Bind to all interfaces + - G103 # Audit the use of unsafe block + - G104 # Audit errors not checked + - G106 # Audit the use of ssh.InsecureIgnoreHostKey + - G107 # Url provided to HTTP request as taint input + - G108 # Profiling endpoint automatically exposed on /debug/pprof + - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 + - G110 # Potential DoS vulnerability via decompression bomb + - G111 # Potential directory traversal + - G112 # Potential slowloris attack + - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) + - G114 # Use of net/http serve function that has no support for setting timeouts + - G201 # SQL query construction using format string + - G202 # SQL query construction using string concatenation + - G203 # Use of unescaped data in HTML templates + - G204 # Audit use of command execution + - G301 # Poor file permissions used when creating a directory + - G302 # Poor file permissions used with chmod + - G303 # Creating tempfile using a predictable path + - G304 # File path provided as taint input + - G305 # File traversal when extracting zip/tar archive + - G306 # Poor file permissions used when writing to a new file + - G307 # Deferring a method which returns an error + - G401 # Detect the usage of DES, RC4, MD5 or SHA1 + - G402 # Look for bad TLS connection settings + - G403 # Ensure minimum RSA key length of 2048 bits + - G404 # Insecure random number source (rand) + - G501 # Import blocklist: crypto/md5 + - G502 # Import blocklist: crypto/des + - G503 # Import blocklist: crypto/rc4 + - G504 # Import blocklist: net/http/cgi + - G505 # Import blocklist: crypto/sha1 + - G601 # Implicit memory aliasing of items from a range statement + misspell: + locale: US + gofumpt: + extra-rules: true + dogsled: + max-blank-identifiers: 5 + maligned: + suggest-new: true + nolintlint: + allow-unused: false + allow-leading-space: true + require-explanation: true + require-specific: false + gosimple: + checks: ["all"] + + gocritic: + disabled-checks: + - regexpMust + - appendAssign + - ifElseChain diff --git a/app/app.go b/app/app.go index 14d9607288..81a146a650 100644 --- a/app/app.go +++ b/app/app.go @@ -81,18 +81,18 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/ibc-go/v3/modules/apps/transfer" - ibc "github.com/cosmos/ibc-go/v3/modules/core" - porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" - - icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" - ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client" - ibcclienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibc "github.com/cosmos/ibc-go/v4/modules/core" + porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types" + + icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" apptypes "github.com/akash-network/node/app/types" utypes "github.com/akash-network/node/upgrades/types" @@ -350,7 +350,7 @@ func NewApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) app.MM = module.NewManager( append([]module.AppModule{ @@ -475,7 +475,7 @@ func NewApp( return app } -func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { // nolint: unused,deadcode +func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { // nolint: unused,deadcode // we'd like to preserve this unused code if v := appOpts.Get("GenesisTime"); v != nil { // in tests, GenesisTime is supplied using appOpts genTime, ok := v.(time.Time) @@ -527,7 +527,8 @@ func (app *AkashApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) a // EndBlocker is a function in which application updates every end block func (app *AkashApp) EndBlocker( - ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { + ctx sdk.Context, req abci.RequestEndBlock, +) abci.ResponseEndBlock { return app.MM.EndBlock(ctx, req) } @@ -634,7 +635,8 @@ func (app *AkashApp) LoadHeight(height int64) error { // initParamsKeeper init params keeper and its subspaces func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, - tkey sdk.StoreKey) paramskeeper.Keeper { + tkey sdk.StoreKey, +) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) paramsKeeper.Subspace(authtypes.ModuleName) diff --git a/app/app_configure.go b/app/app_configure.go index a4e67cce83..45e1f0d1dd 100644 --- a/app/app_configure.go +++ b/app/app_configure.go @@ -20,8 +20,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" + transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" audittypes "github.com/akash-network/akash-api/go/node/audit/v1beta3" certtypes "github.com/akash-network/akash-api/go/node/cert/v1beta3" diff --git a/app/config.go b/app/config.go index 2ee33ffe0b..9748de61c0 100644 --- a/app/config.go +++ b/app/config.go @@ -37,54 +37,52 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/cosmos/ibc-go/v3/modules/apps/transfer" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v3/modules/core" - ibcclient "github.com/cosmos/ibc-go/v3/modules/core/02-client/client" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" + "github.com/cosmos/ibc-go/v4/modules/apps/transfer" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibc "github.com/cosmos/ibc-go/v4/modules/core" + ibcclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" appparams "github.com/akash-network/node/app/params" ) -var ( - mbasics = module.NewBasicManager( - append([]module.AppModuleBasic{ - // accounts, fees. - auth.AppModuleBasic{}, - // authorizations - authzmodule.AppModuleBasic{}, - // genesis utilities - genutil.AppModuleBasic{}, - // tokens, token balance. - bank.AppModuleBasic{}, - capability.AppModuleBasic{}, - // validator staking - staking.AppModuleBasic{}, - // inflation - mint.AppModuleBasic{}, - // distribution of fess and inflation - distr.AppModuleBasic{}, - // governance functionality (voting) - gov.NewAppModuleBasic( - paramsclient.ProposalHandler, distrclient.ProposalHandler, - upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, - ibcclient.UpdateClientProposalHandler, ibcclient.UpgradeProposalHandler, - ), - // chain parameters - params.AppModuleBasic{}, - crisis.AppModuleBasic{}, - slashing.AppModuleBasic{}, - ibc.AppModuleBasic{}, - upgrade.AppModuleBasic{}, - evidence.AppModuleBasic{}, - transfer.AppModuleBasic{}, - vesting.AppModuleBasic{}, - feegrantmodule.AppModuleBasic{}, - }, - // akash - akashModuleBasics()..., - )..., - ) +var mbasics = module.NewBasicManager( + append([]module.AppModuleBasic{ + // accounts, fees. + auth.AppModuleBasic{}, + // authorizations + authzmodule.AppModuleBasic{}, + // genesis utilities + genutil.AppModuleBasic{}, + // tokens, token balance. + bank.AppModuleBasic{}, + capability.AppModuleBasic{}, + // validator staking + staking.AppModuleBasic{}, + // inflation + mint.AppModuleBasic{}, + // distribution of fess and inflation + distr.AppModuleBasic{}, + // governance functionality (voting) + gov.NewAppModuleBasic( + paramsclient.ProposalHandler, distrclient.ProposalHandler, + upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, + ibcclient.UpdateClientProposalHandler, ibcclient.UpgradeProposalHandler, + ), + // chain parameters + params.AppModuleBasic{}, + crisis.AppModuleBasic{}, + slashing.AppModuleBasic{}, + ibc.AppModuleBasic{}, + upgrade.AppModuleBasic{}, + evidence.AppModuleBasic{}, + transfer.AppModuleBasic{}, + vesting.AppModuleBasic{}, + feegrantmodule.AppModuleBasic{}, + }, + // akash + akashModuleBasics()..., + )..., ) // ModuleBasics returns all app modules basics @@ -134,5 +132,4 @@ func transientStoreKeys() map[string]*sdk.TransientStoreKey { func memStoreKeys() map[string]*sdk.MemoryStoreKey { return sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - } diff --git a/app/export.go b/app/export.go index 807d6196bf..a7a4c28654 100644 --- a/app/export.go +++ b/app/export.go @@ -59,7 +59,7 @@ func (app *AkashApp) ExportAppStateAndValidators( // prepForZeroHeightGenesis prepare for fresh start at zero height // NOTE zero height genesis is a temporary feature which will be deprecated // -// in favour of export at a block height +// in favor of export at a block height func (app *AkashApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { applyAllowedAddrs := false @@ -229,7 +229,7 @@ func Setup(isCheckTx bool) *AkashApp { } func OptsWithGenesisTime(seed int64) servertypes.AppOptions { - r := rand.New(rand.NewSource(seed)) // nolint: gosec + r := rand.New(rand.NewSource(seed)) genTime := simulation.RandTimestamp(r) appOpts := viper.New() diff --git a/app/mac.go b/app/mac.go index e6441410a1..5546923678 100644 --- a/app/mac.go +++ b/app/mac.go @@ -6,7 +6,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" escrowtypes "github.com/akash-network/akash-api/go/node/escrow/v1beta3" ) diff --git a/app/sim_test.go b/app/sim_test.go index 67d32cb1c0..ec77f06563 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -30,8 +30,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/simulation" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" + ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" ) // Get flags every time the simulator is run @@ -159,11 +159,13 @@ func TestAppImportExport(t *testing.T) { storeKeysPrefixes := []StoreKeysPrefixes{ {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, - {app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], + { + app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], [][]byte{ stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, stakingtypes.HistoricalInfoKey, - }}, // ordering may change but it doesn't matter + }, + }, // ordering may change but it doesn't matter {app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}}, {app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}}, {app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}}, @@ -265,7 +267,7 @@ func TestAppStateDeterminism(t *testing.T) { appHashList := make([]json.RawMessage, numTimesToRunPerSeed) for i := 0; i < numSeeds; i++ { - config.Seed = rand.Int63() // nolint:gosec + config.Seed = rand.Int63() for j := 0; j < numTimesToRunPerSeed; j++ { var logger log.Logger diff --git a/app/types/app.go b/app/types/app.go index 837655568e..a8c52ec45c 100644 --- a/app/types/app.go +++ b/app/types/app.go @@ -20,8 +20,8 @@ import ( slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - ibctransferkeeper "github.com/cosmos/ibc-go/v3/modules/apps/transfer/keeper" - ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + ibctransferkeeper "github.com/cosmos/ibc-go/v4/modules/apps/transfer/keeper" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" akeeper "github.com/akash-network/node/x/audit/keeper" ckeeper "github.com/akash-network/node/x/cert/keeper" @@ -34,9 +34,7 @@ import ( astakingkeeper "github.com/akash-network/node/x/staking/keeper" ) -var ( - ErrEmptyFieldName = errors.New("empty field name") -) +var ErrEmptyFieldName = errors.New("empty field name") type AppKeepers struct { Cosmos struct { diff --git a/app/upgrades.go b/app/upgrades.go index de636c080b..806a003c88 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -6,7 +6,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" utypes "github.com/akash-network/node/upgrades/types" - // nolint: revive + _ "github.com/akash-network/node/upgrades" ) diff --git a/client/broadcaster/broadcast.go b/client/broadcaster/broadcast.go index 4f731b4c65..865dc71d7a 100644 --- a/client/broadcaster/broadcast.go +++ b/client/broadcaster/broadcast.go @@ -92,7 +92,6 @@ func BroadcastTX(ctx context.Context, cctx sdkclient.Context, flags *pflag.FlagS } return cctx.PrintProto(res) - } // PrepareFactory has been copied from cosmos-sdk to make it public. @@ -190,7 +189,7 @@ func confirmTx(ctx sdkclient.Context, txb sdkclient.TxBuilder) (bool, error) { ok, err := input.GetConfirmation("confirm transaction before signing and broadcasting", buf, os.Stderr) if err != nil || !ok { - _, _ = fmt.Fprintf(os.Stderr, "%s\n", "cancelled transaction") + _, _ = fmt.Fprintf(os.Stderr, "%s\n", "canceled transaction") return false, err } diff --git a/client/broadcaster/client.go b/client/broadcaster/client.go index cded814743..0fcd6bde49 100644 --- a/client/broadcaster/client.go +++ b/client/broadcaster/client.go @@ -11,10 +11,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - // ErrBroadcastTx is used when a broadcast fails due to tendermint errors - ErrBroadcastTx = errors.New("broadcast tx error") -) +// ErrBroadcastTx is used when a broadcast fails due to tendermint errors +var ErrBroadcastTx = errors.New("broadcast tx error") //go:generate mockery --name Client --output ./mocks type Client interface { diff --git a/cmd/akash/cmd/root.go b/cmd/akash/cmd/root.go index e2f4ee577d..a9fd21ebef 100644 --- a/cmd/akash/cmd/root.go +++ b/cmd/akash/cmd/root.go @@ -130,7 +130,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { rootCmd.AddCommand( server.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Marshaler)) - } func addModuleInitFlags(startCmd *cobra.Command) { @@ -183,8 +182,8 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty } func createAppAndExport( - logger log.Logger, db dbm.DB, tio io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) { - + logger log.Logger, db dbm.DB, tio io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, +) (servertypes.ExportedApp, error) { var akashApp *app.AkashApp if height != -1 { diff --git a/cmd/akash/cmd/testnetify/cmd.go b/cmd/akash/cmd/testnetify/cmd.go index 368d21c53d..ed13ea5bb5 100644 --- a/cmd/akash/cmd/testnetify/cmd.go +++ b/cmd/akash/cmd/testnetify/cmd.go @@ -16,8 +16,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - ibccltypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibcchtypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibccltypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchtypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ) const ( @@ -26,10 +26,8 @@ const ( denomDecimalPlaces = 1e6 ) -var ( - // yeah, I know - cdc codec.Codec -) +// yeah, I know +var cdc codec.Codec func Cmd() *cobra.Command { cmd := &cobra.Command{ diff --git a/cmd/akash/cmd/testnetify/state.go b/cmd/akash/cmd/testnetify/state.go index 129f7f0f4d..a18b9edfd6 100644 --- a/cmd/akash/cmd/testnetify/state.go +++ b/cmd/akash/cmd/testnetify/state.go @@ -23,8 +23,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibccoretypes "github.com/cosmos/ibc-go/v3/modules/core/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibccoretypes "github.com/cosmos/ibc-go/v4/modules/core/types" atypes "github.com/akash-network/akash-api/go/node/audit/v1beta3" ctypes "github.com/akash-network/akash-api/go/node/cert/v1beta3" @@ -40,8 +40,10 @@ import ( "github.com/akash-network/node/x/provider" ) -type GenesisValidators []tmtypes.GenesisValidator -type StakingValidators []stakingtypes.Validator +type ( + GenesisValidators []tmtypes.GenesisValidator + StakingValidators []stakingtypes.Validator +) type iState interface { pack(cdc codec.Codec) error @@ -51,9 +53,11 @@ type iState interface { func (u GenesisValidators) Len() int { return len(u) } + func (u GenesisValidators) Swap(i, j int) { u[i], u[j] = u[j], u[i] } + func (u GenesisValidators) Less(i, j int) bool { return u[i].Power < u[j].Power } @@ -61,9 +65,11 @@ func (u GenesisValidators) Less(i, j int) bool { func (u StakingValidators) Len() int { return len(u) } + func (u StakingValidators) Swap(i, j int) { u[i], u[j] = u[j], u[i] } + func (u StakingValidators) Less(i, j int) bool { return u[i].DelegatorShares.LT(u[j].DelegatorShares) } @@ -148,19 +154,21 @@ type ProviderState struct { once sync.Once } -var _ iState = (*AuthState)(nil) -var _ iState = (*BankState)(nil) -var _ iState = (*DistributionState)(nil) -var _ iState = (*IBCState)(nil) -var _ iState = (*GovState)(nil) -var _ iState = (*StakingState)(nil) -var _ iState = (*SlashingState)(nil) -var _ iState = (*AuditState)(nil) -var _ iState = (*CertState)(nil) -var _ iState = (*DeploymentState)(nil) -var _ iState = (*EscrowState)(nil) -var _ iState = (*MarketState)(nil) -var _ iState = (*ProviderState)(nil) +var ( + _ iState = (*AuthState)(nil) + _ iState = (*BankState)(nil) + _ iState = (*DistributionState)(nil) + _ iState = (*IBCState)(nil) + _ iState = (*GovState)(nil) + _ iState = (*StakingState)(nil) + _ iState = (*SlashingState)(nil) + _ iState = (*AuditState)(nil) + _ iState = (*CertState)(nil) + _ iState = (*DeploymentState)(nil) + _ iState = (*EscrowState)(nil) + _ iState = (*MarketState)(nil) + _ iState = (*ProviderState)(nil) +) type GenesisState struct { doc *tmtypes.GenesisDoc @@ -549,7 +557,6 @@ func (ga *DistributionState) pack(cdc codec.Codec) error { return nil } -// nolint: unused func (ga *AuditState) unpack(cdc codec.Codec) error { ga.once.Do(func() { ga.state = audit.GetGenesisStateFromAppState(cdc, ga.gstate) @@ -573,7 +580,6 @@ func (ga *AuditState) pack(cdc codec.Codec) error { return nil } -// nolint: unused func (ga *CertState) unpack(cdc codec.Codec) error { ga.once.Do(func() { ga.state = cert.GetGenesisStateFromAppState(cdc, ga.gstate) @@ -597,7 +603,6 @@ func (ga *CertState) pack(cdc codec.Codec) error { return nil } -// nolint: unused func (ga *DeploymentState) unpack(cdc codec.Codec) error { ga.once.Do(func() { ga.state = deployment.GetGenesisStateFromAppState(cdc, ga.gstate) @@ -621,7 +626,6 @@ func (ga *DeploymentState) pack(cdc codec.Codec) error { return nil } -// nolint: unused func (ga *EscrowState) unpack(cdc codec.Codec) error { ga.once.Do(func() { ga.state = escrow.GetGenesisStateFromAppState(cdc, ga.gstate) @@ -645,7 +649,6 @@ func (ga *EscrowState) pack(cdc codec.Codec) error { return nil } -// nolint: unused func (ga *MarketState) unpack(cdc codec.Codec) error { ga.once.Do(func() { ga.state = market.GetGenesisStateFromAppState(cdc, ga.gstate) @@ -669,7 +672,6 @@ func (ga *MarketState) pack(cdc codec.Codec) error { return nil } -// nolint: unused func (ga *ProviderState) unpack(cdc codec.Codec) error { ga.once.Do(func() { ga.state = provider.GetGenesisStateFromAppState(cdc, ga.gstate) diff --git a/cmd/akash/cmd/testnetify/util.go b/cmd/akash/cmd/testnetify/util.go index 752ed81961..12c2a6a246 100644 --- a/cmd/akash/cmd/testnetify/util.go +++ b/cmd/akash/cmd/testnetify/util.go @@ -7,8 +7,8 @@ import ( distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibccoretypes "github.com/cosmos/ibc-go/v3/modules/core/types" + ibchost "github.com/cosmos/ibc-go/v4/modules/core/24-host" + ibccoretypes "github.com/cosmos/ibc-go/v4/modules/core/types" ) func GetIBCGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *ibccoretypes.GenesisState { diff --git a/cmd/common/util.go b/cmd/common/util.go index 291362daac..e8bf5cbe31 100644 --- a/cmd/common/util.go +++ b/cmd/common/util.go @@ -3,6 +3,7 @@ package common import ( "bytes" "encoding/json" + "github.com/cosmos/cosmos-sdk/client" ) diff --git a/cmd/common/util_test.go b/cmd/common/util_test.go index 83d5818ac4..f2cbf38d3c 100644 --- a/cmd/common/util_test.go +++ b/cmd/common/util_test.go @@ -1,8 +1,9 @@ package common import ( - "github.com/cosmos/cosmos-sdk/client" "testing" + + "github.com/cosmos/cosmos-sdk/client" ) func TestPrintJSONStdoutStruct(t *testing.T) { diff --git a/events/cmd/root.go b/events/cmd/root.go index 6badae951d..cc0e57ffaa 100644 --- a/events/cmd/root.go +++ b/events/cmd/root.go @@ -11,7 +11,6 @@ import ( "golang.org/x/sync/errgroup" "github.com/akash-network/node/cmd/common" - cmdcommon "github.com/akash-network/node/cmd/common" "github.com/akash-network/node/events" "github.com/akash-network/node/pubsub" ) @@ -49,7 +48,6 @@ func getEvents(ctx context.Context, cmd *cobra.Command, _ []string) error { group, ctx := errgroup.WithContext(ctx) subscriber, err := bus.Subscribe() - if err != nil { return err } @@ -64,7 +62,7 @@ func getEvents(ctx context.Context, cmd *cobra.Command, _ []string) error { case <-subscriber.Done(): return nil case ev := <-subscriber.Events(): - if err := cmdcommon.PrintJSON(cctx, ev); err != nil { + if err := common.PrintJSON(cctx, ev); err != nil { return err } } diff --git a/events/publish.go b/events/publish.go index d8c5b66b55..9248e640d2 100644 --- a/events/publish.go +++ b/events/publish.go @@ -23,7 +23,6 @@ import ( // Publish events using tm buses to clients. Waits on context // shutdown signals to exit. func Publish(ctx context.Context, tmbus tmclient.EventsClient, name string, bus pubsub.Bus) (err error) { - const ( queuesz = 100 ) diff --git a/go.mod b/go.mod index 5db355203e..bb6ef4c677 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/blang/semver/v4 v4.0.0 github.com/boz/go-lifecycle v0.1.0 github.com/cosmos/cosmos-sdk v0.45.15 - github.com/cosmos/ibc-go/v3 v3.4.0 + github.com/cosmos/ibc-go/v4 v4.4.0 github.com/gogo/protobuf v1.3.3 github.com/google/go-github/v52 v52.0.0 github.com/gorilla/mux v1.8.0 diff --git a/go.sum b/go.sum index 07dfff3571..cb9dc1c2e1 100644 --- a/go.sum +++ b/go.sum @@ -254,8 +254,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-go/v3 v3.4.0 h1:ha3cqEG36pqMWqA1D+kxDWBTZXpeFMd/aZIQF7I0xro= -github.com/cosmos/ibc-go/v3 v3.4.0/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= +github.com/cosmos/ibc-go/v4 v4.4.0 h1:OEsSLBP1yoLzONQ/1Tf44ateEgS2YHyhTkecvuenk7k= +github.com/cosmos/ibc-go/v4 v4.4.0/go.mod h1:FYZ7ublN6jMojaRND1ST0bTfLKfQnlaxqJbUn7WhzvU= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= diff --git a/pubsub/bus_test.go b/pubsub/bus_test.go index 4af2730383..7efd4b5766 100644 --- a/pubsub/bus_test.go +++ b/pubsub/bus_test.go @@ -73,7 +73,6 @@ func TestBus(t *testing.T) { } assert.Equal(t, pubsub.ErrNotRunning, bus.Publish(ev)) - } func TestClone(t *testing.T) { @@ -139,7 +138,6 @@ func TestClone(t *testing.T) { case <-pubsub.AfterThreadStart(t): require.Fail(t, "time out closing sub1") } - } type testEvent []byte diff --git a/sdl/coin_test.go b/sdl/coin_test.go index e44dcdebd9..6f98641c87 100644 --- a/sdl/coin_test.go +++ b/sdl/coin_test.go @@ -1,9 +1,10 @@ package sdl import ( - "github.com/stretchr/testify/require" "testing" + "github.com/stretchr/testify/require" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "gopkg.in/yaml.v3" diff --git a/sdl/cpu_test.go b/sdl/cpu_test.go index 2e896f1abd..5be4c2ea1a 100644 --- a/sdl/cpu_test.go +++ b/sdl/cpu_test.go @@ -8,7 +8,7 @@ import ( ) func TestV2ResourceCPU_Valid(t *testing.T) { - var stream = ` + stream := ` units: 0.1 attributes: arch: amd64 diff --git a/sdl/sdl.go b/sdl/sdl.go index 3f6b478db7..22fdd7c568 100644 --- a/sdl/sdl.go +++ b/sdl/sdl.go @@ -54,7 +54,6 @@ func (s *sdl) UnmarshalYAML(node *yaml.Node) error { return errSDLInvalidNoVersion } - // nolint: gocritic if result.Version.GE(semver.MustParse("2.0.0")) && result.Version.LT(semver.MustParse("3.0.0")) { var decoded v2 if err := node.Decode(&decoded); err != nil { diff --git a/sdl/storage_test.go b/sdl/storage_test.go index b7bcf2fb98..506ab44d3f 100644 --- a/sdl/storage_test.go +++ b/sdl/storage_test.go @@ -11,7 +11,7 @@ import ( ) func TestStorage_LegacyValid(t *testing.T) { - var stream = ` + stream := ` size: 1Gi ` var p v2ResourceStorageArray @@ -25,7 +25,7 @@ size: 1Gi } func TestStorage_ArraySingleElemValid(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi ` var p v2ResourceStorageArray @@ -39,7 +39,7 @@ func TestStorage_ArraySingleElemValid(t *testing.T) { } func TestStorage_AttributesPersistentValidClass(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi attributes: persistent: true @@ -60,7 +60,7 @@ func TestStorage_AttributesPersistentValidClass(t *testing.T) { } func TestStorage_AttributesUnknown(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi attributes: somefield: foo @@ -72,7 +72,7 @@ func TestStorage_AttributesUnknown(t *testing.T) { } func TestStorage_MultipleUnnamedEphemeral(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi - size: 2Gi ` @@ -83,7 +83,7 @@ func TestStorage_MultipleUnnamedEphemeral(t *testing.T) { } func TestStorage_EphemeralNoClass(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi ` var p v2ResourceStorageArray @@ -93,7 +93,7 @@ func TestStorage_EphemeralNoClass(t *testing.T) { } func TestStorage_EphemeralClass(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi attributes: class: foo @@ -106,7 +106,7 @@ func TestStorage_EphemeralClass(t *testing.T) { } func TestStorage_PersistentDefaultClass(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi attributes: persistent: true @@ -123,7 +123,7 @@ func TestStorage_PersistentDefaultClass(t *testing.T) { } func TestStorage_PersistentClass(t *testing.T) { - var stream = ` + stream := ` - size: 1Gi attributes: persistent: true diff --git a/sdl/units.go b/sdl/units.go index 33fe7cdbbe..2146784c98 100644 --- a/sdl/units.go +++ b/sdl/units.go @@ -10,9 +10,7 @@ import ( "github.com/akash-network/akash-api/go/node/types/unit" ) -var ( - errNegativeValue = fmt.Errorf("invalid: negative value not allowed") -) +var errNegativeValue = fmt.Errorf("invalid: negative value not allowed") var unitSuffixes = []struct { symbol string diff --git a/sdl/units_test.go b/sdl/units_test.go index 559bef3932..82009707fb 100644 --- a/sdl/units_test.go +++ b/sdl/units_test.go @@ -10,7 +10,6 @@ import ( ) func TestCPUQuantity(t *testing.T) { - type vtype struct { Val cpuQuantity `yaml:"val"` } diff --git a/sdl/util/util_test.go b/sdl/util/util_test.go index cd1dcaae1a..c3b1492b9e 100644 --- a/sdl/util/util_test.go +++ b/sdl/util/util_test.go @@ -42,7 +42,6 @@ func TestShouldBeIngress(t *testing.T) { } func TestComputeCommittedResources(t *testing.T) { - rv := atypes.NewResourceValue(100) // Negative factor returns original value require.Equal(t, uint64(100), util.ComputeCommittedResources(-1.0, rv).Val.Uint64()) diff --git a/sdl/v2.go b/sdl/v2.go index ca539e7de4..e74388ea87 100644 --- a/sdl/v2.go +++ b/sdl/v2.go @@ -195,7 +195,6 @@ func (sdl *v2) computeEndpointSequenceNumbers() map[string]uint32 { var endpointNames []string for _, serviceName := range v2DeploymentSvcNames(sdl.Deployments) { - for _, expose := range sdl.Services[serviceName].Expose { for _, to := range expose.To { if to.Global && len(to.IP) == 0 { @@ -292,8 +291,10 @@ func (sdl *v2) DeploymentGroups() ([]*dtypes.GroupSpec, error) { seqNo := ipEndpointNames[v.IP] v.EndpointSequenceNumber = seqNo endpoints = append(endpoints, - types.Endpoint{Kind: types.Endpoint_LEASED_IP, - SequenceNumber: seqNo}) + types.Endpoint{ + Kind: types.Endpoint_LEASED_IP, + SequenceNumber: seqNo, + }) } kind := types.Endpoint_RANDOM_PORT @@ -546,7 +547,6 @@ func (sdl *v2) validate() error { } portsUsed[portKey] = svcName } - } } diff --git a/sdl/v2_ip_test.go b/sdl/v2_ip_test.go index d4e5008183..48943d82a8 100644 --- a/sdl/v2_ip_test.go +++ b/sdl/v2_ip_test.go @@ -167,7 +167,6 @@ func TestV2Parse_MultipleGroupsIP(t *testing.T) { require.Len(t, resources, 1) resource = resources[0] require.Equal(t, findFirstIPEndpoint(t, resource.Resources.Endpoints).SequenceNumber, ipEndpointSecondGroup.SequenceNumber) - } func TestV2Parse_IPEndpointNaming(t *testing.T) { @@ -255,5 +254,4 @@ endpoints: require.Error(t, err) require.ErrorIs(t, err, errSDLInvalid) require.Contains(t, err.Error(), "not a valid name") - } diff --git a/sdl/v2_test.go b/sdl/v2_test.go index 1ef1561485..3d0302e1f2 100644 --- a/sdl/v2_test.go +++ b/sdl/v2_test.go @@ -14,7 +14,7 @@ import ( ) func TestV2Expose(t *testing.T) { - var stream = ` + stream := ` - port: 80 as: 80 accept: @@ -115,7 +115,8 @@ func Test_v1_Parse_simple_gpu(t *testing.T) { }, Count: 2, Expose: []manifest.ServiceExpose{ - {Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, HTTPOptions: manifest.ServiceExposeHTTPOptions{ MaxBodySize: 1048576, ReadTimeout: 60000, @@ -123,8 +124,10 @@ func Test_v1_Parse_simple_gpu(t *testing.T) { NextTries: 3, NextTimeout: 0, NextCases: []string{"error", "timeout"}, - }}, - {Port: 12345, Global: true, Proto: manifest.UDP, + }, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, HTTPOptions: manifest.ServiceExposeHTTPOptions{ MaxBodySize: 1048576, ReadTimeout: 60000, @@ -132,7 +135,8 @@ func Test_v1_Parse_simple_gpu(t *testing.T) { NextTries: 3, NextTimeout: 0, NextCases: []string{"error", "timeout"}, - }}, + }, + }, }, }, }, @@ -206,7 +210,6 @@ func Test_V2_Cross_Validates(t *testing.T) { // These should always agree with each other err = manifest.ValidateManifestWithGroupSpecs(&m, dgroups) require.NoError(t, err) - } func Test_v1_Parse_simple(t *testing.T) { @@ -288,7 +291,8 @@ func Test_v1_Parse_simple(t *testing.T) { }, Count: 2, Expose: []manifest.ServiceExpose{ - {Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, + { + Port: 80, Global: true, Proto: manifest.TCP, Hosts: expectedHosts, HTTPOptions: manifest.ServiceExposeHTTPOptions{ MaxBodySize: 1048576, ReadTimeout: 60000, @@ -296,8 +300,10 @@ func Test_v1_Parse_simple(t *testing.T) { NextTries: 3, NextTimeout: 0, NextCases: []string{"error", "timeout"}, - }}, - {Port: 12345, Global: true, Proto: manifest.UDP, + }, + }, + { + Port: 12345, Global: true, Proto: manifest.UDP, HTTPOptions: manifest.ServiceExposeHTTPOptions{ MaxBodySize: 1048576, ReadTimeout: 60000, @@ -305,7 +311,8 @@ func Test_v1_Parse_simple(t *testing.T) { NextTries: 3, NextTimeout: 0, NextCases: []string{"error", "timeout"}, - }}, + }, + }, }, }, }, diff --git a/testutil/deployment.go b/testutil/deployment.go index 9e12036a9b..9035b1034c 100644 --- a/testutil/deployment.go +++ b/testutil/deployment.go @@ -52,7 +52,7 @@ func GroupSpec(t testing.TB) dtypes.GroupSpec { // DeploymentGroups returns a set of deployment groups generated by DeploymentGroup func DeploymentGroups(t testing.TB, did dtypes.DeploymentID, gseq uint32) []dtypes.Group { t.Helper() - count := rand.Intn(5) + 5 // nolint:gosec + count := rand.Intn(5) + 5 vals := make([]dtypes.Group, 0, count) for i := 0; i < count; i++ { vals = append(vals, DeploymentGroup(t, did, gseq+uint32(i))) diff --git a/testutil/ids.go b/testutil/ids.go index b3ab8f2379..2645bfaec0 100644 --- a/testutil/ids.go +++ b/testutil/ids.go @@ -37,7 +37,7 @@ func DeploymentID(t testing.TB) dtypes.DeploymentID { t.Helper() return dtypes.DeploymentID{ Owner: AccAddress(t).String(), - DSeq: uint64(rand.Uint32()), // nolint: gosec + DSeq: uint64(rand.Uint32()), } } @@ -45,7 +45,7 @@ func DeploymentIDForAccount(t testing.TB, addr sdk.Address) dtypes.DeploymentID t.Helper() return dtypes.DeploymentID{ Owner: addr.String(), - DSeq: uint64(rand.Uint32()), // nolint: gosec + DSeq: uint64(rand.Uint32()), } } @@ -63,22 +63,22 @@ func DeploymentVersion(t testing.TB) []byte { func GroupID(t testing.TB) dtypes.GroupID { t.Helper() - return dtypes.MakeGroupID(DeploymentID(t), rand.Uint32()) // nolint: gosec + return dtypes.MakeGroupID(DeploymentID(t), rand.Uint32()) } func GroupIDForAccount(t testing.TB, addr sdk.Address) dtypes.GroupID { t.Helper() - return dtypes.MakeGroupID(DeploymentIDForAccount(t, addr), rand.Uint32()) // nolint: gosec + return dtypes.MakeGroupID(DeploymentIDForAccount(t, addr), rand.Uint32()) } func OrderID(t testing.TB) mtypes.OrderID { t.Helper() - return mtypes.MakeOrderID(GroupID(t), rand.Uint32()) // nolint: gosec + return mtypes.MakeOrderID(GroupID(t), rand.Uint32()) } func OrderIDForAccount(t testing.TB, addr sdk.Address) mtypes.OrderID { t.Helper() - return mtypes.MakeOrderID(GroupIDForAccount(t, addr), rand.Uint32()) // nolint: gosec + return mtypes.MakeOrderID(GroupIDForAccount(t, addr), rand.Uint32()) } func BidID(t testing.TB) mtypes.BidID { diff --git a/testutil/network_suite.go b/testutil/network_suite.go index 5182d3a80b..e23c3711c8 100644 --- a/testutil/network_suite.go +++ b/testutil/network_suite.go @@ -16,7 +16,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - cosmosauthtx "github.com/cosmos/cosmos-sdk/x/auth/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/gogo/protobuf/jsonpb" "github.com/spf13/pflag" @@ -142,7 +141,6 @@ func (nts *NetworkTestSuite) SetupSuite() { break } require.NoError(nts.T(), lctx.Err()) - } func (nts *NetworkTestSuite) Validator(idxT ...int) *sdknetworktest.Validator { @@ -218,7 +216,7 @@ func (nts *NetworkTestSuite) ValidateTx(resultData []byte) string { require.NoError(nts.T(), err, "failed trying to unmarshal JSON transaction result") for { - res, err := cosmosauthtx.QueryTx(nts.ContextForTest(), resp.TxHash) + res, err := authtx.QueryTx(nts.ContextForTest(), resp.TxHash) if err != nil { ctxDone := nts.GoContextForTest().Err() != nil if ctxDone { diff --git a/testutil/sdk.go b/testutil/sdk.go index dad6a47882..714804affb 100644 --- a/testutil/sdk.go +++ b/testutil/sdk.go @@ -8,12 +8,12 @@ import ( func Coin(t testing.TB) sdk.Coin { t.Helper() - return sdk.NewCoin("testcoin", sdk.NewInt(int64(RandRangeInt(1, 1000)))) // nolint: gosec + return sdk.NewCoin("testcoin", sdk.NewInt(int64(RandRangeInt(1, 1000)))) } func DecCoin(t testing.TB) sdk.DecCoin { t.Helper() - return sdk.NewDecCoin("testcoin", sdk.NewInt(int64(RandRangeInt(1, 1000)))) // nolint: gosec + return sdk.NewDecCoin("testcoin", sdk.NewInt(int64(RandRangeInt(1, 1000)))) } // AkashCoin provides simple interface to the Akash sdk.Coin type. diff --git a/testutil/types.go b/testutil/types.go index bb7999c2c3..27e2d99a55 100644 --- a/testutil/types.go +++ b/testutil/types.go @@ -27,18 +27,18 @@ import ( ) func RandRangeInt(min, max int) int { - return rand.Intn(max-min) + min // nolint: gosec + return rand.Intn(max-min) + min } func RandRangeUint(min, max uint) uint { - val := rand.Uint64() // nolint: gosec + val := rand.Uint64() val %= uint64(max - min) val += uint64(min) return uint(val) } func RandRangeUint64(min, max uint64) uint64 { - val := rand.Uint64() // nolint: gosec + val := rand.Uint64() val %= max - min val += min return val diff --git a/upgrades/software/v0.15.0/proto_compatibility_test.go b/upgrades/software/v0.15.0/proto_compatibility_test.go index b460078ca1..f72bfae766 100644 --- a/upgrades/software/v0.15.0/proto_compatibility_test.go +++ b/upgrades/software/v0.15.0/proto_compatibility_test.go @@ -19,9 +19,7 @@ import ( "github.com/akash-network/node/app" ) -var ( - cdc = app.MakeEncodingConfig().Marshaler.(codec.BinaryCodec) -) +var cdc = app.MakeEncodingConfig().Marshaler.(codec.BinaryCodec) func TestDeployment_DeploymentProto_IsCompatible(t *testing.T) { oldProto := dv1beta1.Deployment{ @@ -130,7 +128,7 @@ func TestEscrow_AccountProto_IsNotCompatible(t *testing.T) { var actualProto ev1beta2.Account cdc.MustUnmarshal(cdc.MustMarshal(&oldProto), &actualProto) // although it unmarshalls require.NotEqual(t, expectedProto, actualProto) // but the result isn't equal - require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshalled bytes + require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshaled bytes } func TestEscrow_PaymentProto_IsNotCompatible(t *testing.T) { @@ -163,7 +161,7 @@ func TestEscrow_PaymentProto_IsNotCompatible(t *testing.T) { var actualProto ev1beta2.FractionalPayment cdc.MustUnmarshal(cdc.MustMarshal(&oldProto), &actualProto) // although it unmarshalls require.NotEqual(t, expectedProto, actualProto) // but the result isn't equal - require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshalled bytes + require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshaled bytes } func TestMarket_BidProto_IsNotCompatible(t *testing.T) { @@ -196,7 +194,7 @@ func TestMarket_BidProto_IsNotCompatible(t *testing.T) { var actualProto mv1beta2.Bid cdc.MustUnmarshal(cdc.MustMarshal(&oldProto), &actualProto) // although it unmarshalls require.NotEqual(t, expectedProto, actualProto) // but the result isn't equal - require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshalled bytes + require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshaled bytes } func TestMarket_LeaseProto_IsNotCompatible(t *testing.T) { @@ -229,7 +227,7 @@ func TestMarket_LeaseProto_IsNotCompatible(t *testing.T) { var actualProto mv1beta2.Lease cdc.MustUnmarshal(cdc.MustMarshal(&oldProto), &actualProto) // although it unmarshalls require.NotEqual(t, expectedProto, actualProto) // but the result isn't equal - require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshalled bytes + require.NotEqual(t, cdc.MustMarshal(&oldProto), cdc.MustMarshal(&expectedProto)) // neither is marshaled bytes } func TestMarket_OrderProto_IsNotCompatible(t *testing.T) { diff --git a/upgrades/software/v0.15.0/upgrade.go b/upgrades/software/v0.15.0/upgrade.go index 81f8651d2b..90a1b6c7e7 100644 --- a/upgrades/software/v0.15.0/upgrade.go +++ b/upgrades/software/v0.15.0/upgrade.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/authz" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcconnectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" - ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + ibcconnectiontypes "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types" + ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper" "github.com/tendermint/tendermint/libs/log" apptypes "github.com/akash-network/node/app/types" diff --git a/upgrades/software/v0.18.0/upgrade.go b/upgrades/software/v0.18.0/upgrade.go index 99e3bfdf1d..172ec79da7 100644 --- a/upgrades/software/v0.18.0/upgrade.go +++ b/upgrades/software/v0.18.0/upgrade.go @@ -9,10 +9,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts" - icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" + ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" + icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" "github.com/tendermint/tendermint/libs/log" apptypes "github.com/akash-network/node/app/types" diff --git a/upgrades/software/v0.20.0/upgrade.go b/upgrades/software/v0.20.0/upgrade.go index 93028cf675..5e92347e65 100644 --- a/upgrades/software/v0.20.0/upgrade.go +++ b/upgrades/software/v0.20.0/upgrade.go @@ -7,9 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" + icacontrollertypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/controller/types" + icahosttypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/types" + icatypes "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/types" "github.com/tendermint/tendermint/libs/log" apptypes "github.com/akash-network/node/app/types" diff --git a/upgrades/types/types.go b/upgrades/types/types.go index 469146f1ca..b937d85c24 100644 --- a/upgrades/types/types.go +++ b/upgrades/types/types.go @@ -34,8 +34,10 @@ var ( } ) -type UpgradeInitFn func(log.Logger, *apptypes.App) (IUpgrade, error) -type NewMigrationFn func(Migrator) Migration +type ( + UpgradeInitFn func(log.Logger, *apptypes.App) (IUpgrade, error) + NewMigrationFn func(Migrator) Migration +) type moduleMigrations map[uint64]NewMigrationFn diff --git a/upgrades/upgrades.go b/upgrades/upgrades.go index a9540b0dc3..3351407b07 100644 --- a/upgrades/upgrades.go +++ b/upgrades/upgrades.go @@ -1,10 +1,9 @@ package upgrades import ( - // nolint: revive _ "github.com/akash-network/node/upgrades/software/v0.24.0" - // nolint: revive + _ "github.com/akash-network/node/upgrades/software/v0.20.0" - // nolint: revive + _ "github.com/akash-network/node/upgrades/software/v0.15.0" ) diff --git a/util/cli/configs.go b/util/cli/configs.go index 60e76482ae..962f5fc4c1 100644 --- a/util/cli/configs.go +++ b/util/cli/configs.go @@ -26,9 +26,7 @@ const ( FlagLogTimestamp = "log_timestamp" ) -var ( - ErrEmptyEnvPrefix = errors.New("envPrefixes parameter must contain at least one prefix") -) +var ErrEmptyEnvPrefix = errors.New("envPrefixes parameter must contain at least one prefix") // InterceptConfigsPreRunHandler performs a pre-run function for the root daemon // application command. It will create a Viper literal and a default server diff --git a/util/metrics/metrics.go b/util/metrics/metrics.go index 144f8a144e..9aa407f46a 100644 --- a/util/metrics/metrics.go +++ b/util/metrics/metrics.go @@ -7,9 +7,11 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -const SuccessLabel = "success" -const FailLabel = "fail" -const OpenLabel = "open" +const ( + SuccessLabel = "success" + FailLabel = "fail" + OpenLabel = "open" +) func IncCounterVecWithLabelValues(counter *prometheus.CounterVec, name string, err error) { label := SuccessLabel diff --git a/util/wsutil/wsutil.go b/util/wsutil/wsutil.go index 1226867fd7..b06664d963 100644 --- a/util/wsutil/wsutil.go +++ b/util/wsutil/wsutil.go @@ -2,9 +2,10 @@ package wsutil import ( "bytes" - "github.com/gorilla/websocket" "io" "sync" + + "github.com/gorilla/websocket" ) // This type exposes the single method that this wrapper uses diff --git a/util/wsutil/wsutil_test.go b/util/wsutil/wsutil_test.go index 42eff5c8d7..1b5c1ea8f1 100644 --- a/util/wsutil/wsutil_test.go +++ b/util/wsutil/wsutil_test.go @@ -1,11 +1,12 @@ package wsutil import ( - "github.com/gorilla/websocket" - "github.com/stretchr/testify/require" "io" "sync" "testing" + + "github.com/gorilla/websocket" + "github.com/stretchr/testify/require" ) type dummyConnection struct { diff --git a/x/audit/alias.go b/x/audit/alias.go index e566c57275..47abaadd66 100644 --- a/x/audit/alias.go +++ b/x/audit/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of provider module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of provider module +var NewKeeper = keeper.NewKeeper diff --git a/x/audit/keeper/grpc_query.go b/x/audit/keeper/grpc_query.go index 51e68b237a..28aff92ddf 100644 --- a/x/audit/keeper/grpc_query.go +++ b/x/audit/keeper/grpc_query.go @@ -31,7 +31,7 @@ func (q Querier) AllProvidersAttributes( store := ctx.KVStore(q.skey) - pageRes, err := sdkquery.Paginate(store, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := sdkquery.Paginate(store, req.Pagination, func(key, value []byte) error { var provider types.Provider err := q.cdc.Unmarshal(value, &provider) @@ -125,7 +125,7 @@ func (q Querier) AuditorAttributes( store := ctx.KVStore(q.skey) - pageRes, err := sdkquery.Paginate(store, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := sdkquery.Paginate(store, req.Pagination, func(key, value []byte) error { var provider types.Provider err := q.cdc.Unmarshal(value, &provider) diff --git a/x/audit/keeper/grpc_query_test.go b/x/audit/keeper/grpc_query_test.go index fb0425b99d..8b8de8b304 100644 --- a/x/audit/keeper/grpc_query_test.go +++ b/x/audit/keeper/grpc_query_test.go @@ -104,7 +104,6 @@ func TestGRPCQueryProvider(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } diff --git a/x/audit/keeper/keeper.go b/x/audit/keeper/keeper.go index 15cf20908c..e1fa890a72 100644 --- a/x/audit/keeper/keeper.go +++ b/x/audit/keeper/keeper.go @@ -10,7 +10,6 @@ import ( types "github.com/akash-network/akash-api/go/node/audit/v1beta3" akashtypes "github.com/akash-network/akash-api/go/node/types/v1beta3" - atypes "github.com/akash-network/akash-api/go/node/types/v1beta3" ) // TODO: use interfaces for keepers, queriers @@ -114,7 +113,7 @@ func (k Keeper) CreateOrUpdateProviderAttributes(ctx sdk.Context, id types.Provi attr = akashtypes.Attributes{} for ky, val := range kv { - attr = append(attr, atypes.Attribute{ + attr = append(attr, akashtypes.Attribute{ Key: ky, Value: val, }) @@ -176,7 +175,7 @@ func (k Keeper) DeleteProviderAttributes(ctx sdk.Context, id types.ProviderID, k var attr akashtypes.Attributes for ky, val := range kv { - attr = append(attr, atypes.Attribute{ + attr = append(attr, akashtypes.Attribute{ Key: ky, Value: val, }) diff --git a/x/audit/module.go b/x/audit/module.go index 90ad98f291..6d8cc3efbc 100644 --- a/x/audit/module.go +++ b/x/audit/module.go @@ -242,7 +242,6 @@ func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange { // RegisterStoreDecoder registers a decoder for staking module's types func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - } // WeightedOperations returns the all the staking module operations with their respective weights. diff --git a/x/audit/query/client.go b/x/audit/query/client.go index 7e52af6e2b..cb59d3716d 100644 --- a/x/audit/query/client.go +++ b/x/audit/query/client.go @@ -1,5 +1,4 @@ package query // Client interface -type Client interface { -} +type Client interface{} diff --git a/x/cert/alias.go b/x/cert/alias.go index 13f0af11d3..7097bdd0f1 100644 --- a/x/cert/alias.go +++ b/x/cert/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of provider module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of provider module +var NewKeeper = keeper.NewKeeper diff --git a/x/cert/client/cli/errors.go b/x/cert/client/cli/errors.go index 9c2be34ea3..ea723b40bc 100644 --- a/x/cert/client/cli/errors.go +++ b/x/cert/client/cli/errors.go @@ -4,6 +4,4 @@ import ( "github.com/pkg/errors" ) -var ( - errInvalidSerialFlag = errors.New("invalid value in serial flag. expected integer") -) +var errInvalidSerialFlag = errors.New("invalid value in serial flag. expected integer") diff --git a/x/cert/client/cli/tx.go b/x/cert/client/cli/tx.go index 9abe188ac5..3d148cd2c9 100644 --- a/x/cert/client/cli/tx.go +++ b/x/cert/client/cli/tx.go @@ -145,7 +145,6 @@ func doPublishCmd(cmd *cobra.Command) error { Pubkey: msg.Pubkey, }, }) - } return broadcaster.BroadcastTX(cmd.Context(), cctx, cmd.Flags(), msg) diff --git a/x/cert/errors/certificate_errors.go b/x/cert/errors/certificate_errors.go index 3bf4512b2a..876300853c 100644 --- a/x/cert/errors/certificate_errors.go +++ b/x/cert/errors/certificate_errors.go @@ -2,6 +2,4 @@ package errors import "errors" -var ( - ErrCertificate = errors.New("certificate error") -) +var ErrCertificate = errors.New("certificate error") diff --git a/x/cert/keeper/grpc_query.go b/x/cert/keeper/grpc_query.go index a310e53e03..9d7f0104d9 100644 --- a/x/cert/keeper/grpc_query.go +++ b/x/cert/keeper/grpc_query.go @@ -65,7 +65,7 @@ func (q querier) Certificates(c context.Context, req *types.QueryCertificatesReq } } else { ownerStore := prefix.NewStore(store, certificatePrefix(owner)) - pageRes, err = sdkquery.FilteredPaginate(ownerStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err = sdkquery.FilteredPaginate(ownerStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { // prefixed store returns key without prefix key = append(certificatePrefix(owner), key...) item, err := q.unmarshalIterator(key, value) @@ -84,7 +84,7 @@ func (q querier) Certificates(c context.Context, req *types.QueryCertificatesReq }) } } else { - pageRes, err = sdkquery.FilteredPaginate(store, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err = sdkquery.FilteredPaginate(store, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { item, err := q.unmarshalIterator(key, value) if err != nil { return true, err @@ -111,6 +111,6 @@ func (q querier) Certificates(c context.Context, req *types.QueryCertificatesReq }, nil } -func filterCertByState(state types.Certificate_State, cert types.Certificate_State) bool { +func filterCertByState(state, cert types.Certificate_State) bool { return (state == types.CertificateStateInvalid) || (cert == state) } diff --git a/x/cert/keeper/keeper.go b/x/cert/keeper/keeper.go index ed11117586..3f8332baad 100644 --- a/x/cert/keeper/keeper.go +++ b/x/cert/keeper/keeper.go @@ -48,7 +48,7 @@ func (k keeper) StoreKey() sdk.StoreKey { return k.skey } -func (k keeper) CreateCertificate(ctx sdk.Context, owner sdk.Address, crt []byte, pubkey []byte) error { +func (k keeper) CreateCertificate(ctx sdk.Context, owner sdk.Address, crt, pubkey []byte) error { store := ctx.KVStore(k.skey) cert, err := types.ParseAndValidateCertificate(owner, crt, pubkey) diff --git a/x/cert/module.go b/x/cert/module.go index 8170106b1f..30de39a7e7 100644 --- a/x/cert/module.go +++ b/x/cert/module.go @@ -83,7 +83,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo // RegisterRESTRoutes registers rest routes for this module func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { - } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the provider module. @@ -220,7 +219,6 @@ func (AppModuleSimulation) RandomizedParams(_ *rand.Rand) []sim.ParamChange { // RegisterStoreDecoder registers a decoder for staking module's types func (AppModuleSimulation) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { - } // WeightedOperations returns the all the staking module operations with their respective weights. diff --git a/x/cert/utils/key_pair_manager.go b/x/cert/utils/key_pair_manager.go index e7892e8790..f051f03bcb 100644 --- a/x/cert/utils/key_pair_manager.go +++ b/x/cert/utils/key_pair_manager.go @@ -112,7 +112,7 @@ func (kpm *keyPairManager) KeyExists() (bool, error) { func (kpm *keyPairManager) Generate(notBefore, notAfter time.Time, domains []string) error { var err error var pemOut *os.File - if pemOut, err = os.OpenFile(kpm.getKeyPath(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600); err != nil { + if pemOut, err = os.OpenFile(kpm.getKeyPath(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600); err != nil { return err } @@ -266,7 +266,7 @@ func (kpm *keyPairManager) readImpl(fin io.Reader) ([]byte, []byte, []byte, erro var privKeyPlaintext []byte // PKCS#8 header defined in RFC7468 section 11 - // nolint: gocritic + if block.Type == "ENCRYPTED PRIVATE KEY" { privKeyPlaintext, err = pemutil.DecryptPKCS8PrivateKey(block.Bytes, kpm.passwordBytes) } else if block.Headers["Proc-Type"] == "4,ENCRYPTED" { diff --git a/x/deployment/alias.go b/x/deployment/alias.go index ad74d2dd8e..cbc8b19b71 100644 --- a/x/deployment/alias.go +++ b/x/deployment/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of deployment module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of deployment module +var NewKeeper = keeper.NewKeeper diff --git a/x/deployment/client/cli/query.go b/x/deployment/client/cli/query.go index fd05eae6cc..cca0a6626c 100644 --- a/x/deployment/client/cli/query.go +++ b/x/deployment/client/cli/query.go @@ -12,7 +12,6 @@ import ( // GetQueryCmd returns the query commands for the deployment module func GetQueryCmd() *cobra.Command { - cmd := &cobra.Command{ Use: types.ModuleName, Short: "Deployment query commands", diff --git a/x/deployment/client/rest/rest.go b/x/deployment/client/rest/rest.go index c4ee5fdbf9..482c71cd96 100644 --- a/x/deployment/client/rest/rest.go +++ b/x/deployment/client/rest/rest.go @@ -43,7 +43,6 @@ func listDeploymentsHandler(ctx client.Context, ns string) http.HandlerFunc { func getDeploymentHandler(ctx client.Context, ns string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - id, errMsg := DeploymentIDFromRequest(r) if len(errMsg) != 0 { @@ -62,7 +61,6 @@ func getDeploymentHandler(ctx client.Context, ns string) http.HandlerFunc { func getGroupHandler(ctx client.Context, ns string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - id, errMsg := GroupIDFromRequest(r) if len(errMsg) != 0 { diff --git a/x/deployment/handler/handler_test.go b/x/deployment/handler/handler_test.go index 1dc2252b21..052a82b73a 100644 --- a/x/deployment/handler/handler_test.go +++ b/x/deployment/handler/handler_test.go @@ -235,7 +235,6 @@ func TestUpdateDeploymentExisting(t *testing.T) { res, err = suite.handler(suite.ctx, msgUpdate) require.Error(t, err) require.Contains(t, err.Error(), "Invalid: deployment version") - } func TestCloseDeploymentNonExisting(t *testing.T) { diff --git a/x/deployment/keeper/grpc_query.go b/x/deployment/keeper/grpc_query.go index cf37ab4473..6cb73aaaa3 100644 --- a/x/deployment/keeper/grpc_query.go +++ b/x/deployment/keeper/grpc_query.go @@ -43,7 +43,7 @@ func (k Querier) Deployments(c context.Context, req *types.QueryDeploymentsReque depStore := prefix.NewStore(ctx.KVStore(k.skey), searchPrefix) - pageRes, err := sdkquery.FilteredPaginate(depStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := sdkquery.FilteredPaginate(depStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { var deployment types.Deployment err := k.cdc.Unmarshal(value, &deployment) diff --git a/x/deployment/keeper/grpc_query_test.go b/x/deployment/keeper/grpc_query_test.go index 33d3797554..e16c6efc1b 100644 --- a/x/deployment/keeper/grpc_query_test.go +++ b/x/deployment/keeper/grpc_query_test.go @@ -128,7 +128,6 @@ func TestGRPCQueryDeployment(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } @@ -169,7 +168,8 @@ func TestGRPCQueryDeployments(t *testing.T) { Filters: types.DeploymentFilters{ DSeq: 37, State: types.DeploymentClosed.String(), - }} + }, + } }, 0, }, @@ -472,7 +472,6 @@ func TestGRPCQueryGroup(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } diff --git a/x/deployment/keeper/keeper.go b/x/deployment/keeper/keeper.go index ec1506cdb4..6368f14809 100644 --- a/x/deployment/keeper/keeper.go +++ b/x/deployment/keeper/keeper.go @@ -42,7 +42,6 @@ type Keeper struct { // NewKeeper creates and returns an instance for deployment keeper func NewKeeper(cdc codec.BinaryCodec, skey sdk.StoreKey, pspace paramtypes.Subspace, ekeeper EscrowKeeper) IKeeper { - if !pspace.HasKeyTable() { pspace = pspace.WithKeyTable(types.ParamKeyTable()) } diff --git a/x/deployment/keeper/key.go b/x/deployment/keeper/key.go index 5cc6b1e33e..8d6e4dff2f 100644 --- a/x/deployment/keeper/key.go +++ b/x/deployment/keeper/key.go @@ -19,7 +19,7 @@ func deploymentKey(id types.DeploymentID) []byte { return buf.Bytes() } -// groupKey provides prefixed key for a Group's marshalled data. +// groupKey provides prefixed key for a Group's marshaled data. func groupKey(id types.GroupID) []byte { buf := bytes.NewBuffer(types.GroupPrefix()) buf.Write(address.MustLengthPrefix(sdkutil.MustAccAddressFromBech32(id.Owner))) diff --git a/x/deployment/query/path.go b/x/deployment/query/path.go index 342704b79b..b72fa2a520 100644 --- a/x/deployment/query/path.go +++ b/x/deployment/query/path.go @@ -14,9 +14,7 @@ const ( groupPath = "group" ) -var ( - ErrInvalidPath = errors.New("query: invalid path") -) +var ErrInvalidPath = errors.New("query: invalid path") // getDeploymentsPath returns deployments path for queries func getDeploymentsPath(dfilters DeploymentFilters) string { diff --git a/x/deployment/simulation/operations.go b/x/deployment/simulation/operations.go index 8cf73721b4..3c1f062278 100644 --- a/x/deployment/simulation/operations.go +++ b/x/deployment/simulation/operations.go @@ -32,7 +32,8 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak govtypes.AccountKeeper, - bk bankkeeper.Keeper, k keeper.IKeeper) simulation.WeightedOperations { + bk bankkeeper.Keeper, k keeper.IKeeper, +) simulation.WeightedOperations { var ( weightMsgCreateDeployment int weightMsgUpdateDeployment int @@ -87,7 +88,8 @@ func WeightedOperations( // SimulateMsgCreateDeployment generates a MsgCreate with random values func SimulateMsgCreateDeployment(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accounts) dID := types.DeploymentID{ @@ -163,7 +165,8 @@ func SimulateMsgCreateDeployment(ak govtypes.AccountKeeper, bk bankkeeper.Keeper // SimulateMsgUpdateDeployment generates a MsgUpdate with random values func SimulateMsgUpdateDeployment(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var deployments []types.Deployment k.WithDeployments(ctx, func(deployment types.Deployment) bool { @@ -243,7 +246,8 @@ func SimulateMsgUpdateDeployment(ak govtypes.AccountKeeper, bk bankkeeper.Keeper // SimulateMsgCloseDeployment generates a MsgClose with random values func SimulateMsgCloseDeployment(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var deployments []types.Deployment k.WithDeployments(ctx, func(deployment types.Deployment) bool { @@ -310,7 +314,8 @@ func SimulateMsgCloseDeployment(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, // SimulateMsgCloseGroup generates a MsgCloseGroup for a random deployment func SimulateMsgCloseGroup(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var deployments []types.Deployment k.WithDeployments(ctx, func(deployment types.Deployment) bool { diff --git a/x/escrow/client/cli/query.go b/x/escrow/client/cli/query.go index 3ed4c837cd..0946721e48 100644 --- a/x/escrow/client/cli/query.go +++ b/x/escrow/client/cli/query.go @@ -128,7 +128,6 @@ func cmdBlocksRemaining() *cobra.Command { } return clientCtx.PrintBytes(data) - }, } diff --git a/x/escrow/keeper/keeper.go b/x/escrow/keeper/keeper.go index ce90d42542..4e9d31bf92 100644 --- a/x/escrow/keeper/keeper.go +++ b/x/escrow/keeper/keeper.go @@ -8,8 +8,10 @@ import ( types "github.com/akash-network/akash-api/go/node/escrow/v1beta3" ) -type AccountHook func(sdk.Context, types.Account) -type PaymentHook func(sdk.Context, types.FractionalPayment) +type ( + AccountHook func(sdk.Context, types.Account) + PaymentHook func(sdk.Context, types.FractionalPayment) +) type Keeper interface { Codec() codec.BinaryCodec @@ -246,7 +248,6 @@ func (k *keeper) PaymentWithdraw(ctx sdk.Context, id types.AccountID, pid string } func (k *keeper) PaymentClose(ctx sdk.Context, id types.AccountID, pid string) error { - payment, err := k.GetPayment(ctx, id, pid) if err != nil { return err @@ -257,7 +258,6 @@ func (k *keeper) PaymentClose(ctx sdk.Context, id types.AccountID, pid string) e } od, err := k.AccountSettle(ctx, id) - if err != nil { return err } @@ -294,7 +294,6 @@ func (k *keeper) AddOnPaymentClosedHook(hook PaymentHook) Keeper { } func (k *keeper) GetAccount(ctx sdk.Context, id types.AccountID) (types.Account, error) { - store := ctx.KVStore(k.skey) key := accountKey(id) @@ -364,7 +363,6 @@ func (k *keeper) WithPayments(ctx sdk.Context, fn func(types.FractionalPayment) func (k *keeper) doAccountSettle(ctx sdk.Context, id types.AccountID) (types.Account, []types.FractionalPayment, bool, error) { account, err := k.GetAccount(ctx, id) - if err != nil { return account, nil, false, err } @@ -613,7 +611,6 @@ func accountSettleDistributeWeighted( []types.FractionalPayment, sdk.DecCoin, ) { - actualTransferred := sdk.ZeroDec() // distribute remaining balance weighted by rate diff --git a/x/escrow/keeper/keeper_settle_test.go b/x/escrow/keeper/keeper_settle_test.go index bc28d57ee7..673849adb6 100644 --- a/x/escrow/keeper/keeper_settle_test.go +++ b/x/escrow/keeper/keeper_settle_test.go @@ -268,7 +268,7 @@ func setupDistTest(cfg distTestConfig) (types.Account, []types.FractionalPayment return account, payments, sdk.NewInt(cfg.blocks), sdk.NewInt64DecCoin(denom, blockRate) } -func assertCoinsEqual(t testing.TB, c1 sdk.DecCoin, c2 sdk.DecCoin, msg string) { +func assertCoinsEqual(t testing.TB, c1, c2 sdk.DecCoin, msg string) { t.Helper() if c1.IsZero() { if !c2.IsZero() { diff --git a/x/escrow/keeper/keeper_test.go b/x/escrow/keeper/keeper_test.go index 29b8d4fac0..28e68b47fa 100644 --- a/x/escrow/keeper/keeper_test.go +++ b/x/escrow/keeper/keeper_test.go @@ -181,7 +181,6 @@ func Test_Payment_Overdraw(t *testing.T) { assert.Equal(t, amt, payment.Withdrawn) assert.Equal(t, testutil.AkashDecCoin(t, 0), payment.Balance) } - } func Test_PaymentCreate_later(t *testing.T) { diff --git a/x/escrow/module.go b/x/escrow/module.go index fce046fc44..b0aaa617e0 100644 --- a/x/escrow/module.go +++ b/x/escrow/module.go @@ -235,7 +235,6 @@ func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange { // RegisterStoreDecoder registers a decoder for staking module's types func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - } // WeightedOperations returns the all the staking module operations with their respective weights. diff --git a/x/gov/alias.go b/x/gov/alias.go index c30bd8fdef..911ab110ce 100644 --- a/x/gov/alias.go +++ b/x/gov/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of provider module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of provider module +var NewKeeper = keeper.NewKeeper diff --git a/x/gov/module.go b/x/gov/module.go index cfb7b0b05c..7d8c071fcf 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -43,7 +43,6 @@ func (AppModuleBasic) Name() string { // RegisterLegacyAminoCodec registers the provider module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - } // RegisterInterfaces registers the module's interface types diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 2d71a519bf..b4be4a3287 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -10,7 +10,8 @@ import ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.IKeeper) simulation.WeightedOperations { + appParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.IKeeper, +) simulation.WeightedOperations { return nil // var ( // weightMsgCreate int diff --git a/x/inflation/alias.go b/x/inflation/alias.go index 048570023a..2a7bc3de7d 100644 --- a/x/inflation/alias.go +++ b/x/inflation/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.IKeeper ) -var ( - // NewKeeper creates new keeper instance of inflation module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of inflation module +var NewKeeper = keeper.NewKeeper diff --git a/x/inflation/module.go b/x/inflation/module.go index 3ada36d820..ffe3ac1db3 100644 --- a/x/inflation/module.go +++ b/x/inflation/module.go @@ -47,7 +47,6 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterInterfaces registers the module's interface types func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - } // DefaultGenesis returns default genesis state as raw bytes for the inflation diff --git a/x/market/alias.go b/x/market/alias.go index cdf2fc16e9..0c14a30854 100644 --- a/x/market/alias.go +++ b/x/market/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of market module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of market module +var NewKeeper = keeper.NewKeeper diff --git a/x/market/client/cli/query.go b/x/market/client/cli/query.go index eb28061163..cf3dd1cd74 100644 --- a/x/market/client/cli/query.go +++ b/x/market/client/cli/query.go @@ -9,7 +9,6 @@ import ( // GetQueryCmd returns the transaction commands for the market module func GetQueryCmd() *cobra.Command { - cmd := &cobra.Command{ Use: types.ModuleName, Short: "Market query commands", diff --git a/x/market/client/cli/test_helpers.go b/x/market/client/cli/test_helpers.go index 0461cc6805..64d9bbd313 100644 --- a/x/market/client/cli/test_helpers.go +++ b/x/market/client/cli/test_helpers.go @@ -16,7 +16,8 @@ const key string = types.StoreKey // TxCreateBidExec is used for testing create bid tx func TxCreateBidExec(clientCtx client.Context, orderID types.OrderID, price, from fmt.Stringer, - extraArgs ...string) (sdktest.BufferWriter, error) { + extraArgs ...string, +) (sdktest.BufferWriter, error) { args := []string{ fmt.Sprintf("--from=%s", from.String()), fmt.Sprintf("--owner=%s", orderID.Owner), @@ -33,7 +34,8 @@ func TxCreateBidExec(clientCtx client.Context, orderID types.OrderID, price, fro // TxCloseBidExec is used for testing close bid tx func TxCloseBidExec(clientCtx client.Context, orderID types.OrderID, from fmt.Stringer, - extraArgs ...string) (sdktest.BufferWriter, error) { + extraArgs ...string, +) (sdktest.BufferWriter, error) { args := []string{ fmt.Sprintf("--from=%s", from.String()), fmt.Sprintf("--owner=%v", orderID.Owner), @@ -49,7 +51,8 @@ func TxCloseBidExec(clientCtx client.Context, orderID types.OrderID, from fmt.St // TxCreateLeaseExec is used for creating a lease func TxCreateLeaseExec(clientCtx client.Context, bid types.BidID, from fmt.Stringer, - extraArgs ...string) (sdktest.BufferWriter, error) { + extraArgs ...string, +) (sdktest.BufferWriter, error) { args := []string{ fmt.Sprintf("--from=%s", from.String()), fmt.Sprintf("--dseq=%v", bid.DSeq), @@ -65,7 +68,8 @@ func TxCreateLeaseExec(clientCtx client.Context, bid types.BidID, from fmt.Strin // TxCloseLeaseExec is used for testing close order tx func TxCloseLeaseExec(clientCtx client.Context, orderID types.OrderID, from fmt.Stringer, - extraArgs ...string) (sdktest.BufferWriter, error) { + extraArgs ...string, +) (sdktest.BufferWriter, error) { args := []string{ fmt.Sprintf("--from=%s", from.String()), fmt.Sprintf("--owner=%s", orderID.Owner), diff --git a/x/market/client/rest/rest.go b/x/market/client/rest/rest.go index 1c5ec8527c..a2c45d1bc1 100644 --- a/x/market/client/rest/rest.go +++ b/x/market/client/rest/rest.go @@ -87,7 +87,6 @@ func listLeasesHandler(ctx client.Context, ns string) http.HandlerFunc { func getOrderHandler(ctx client.Context, ns string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - id, errMsg := OrderIDFromRequest(r) if len(errMsg) != 0 { @@ -106,7 +105,6 @@ func getOrderHandler(ctx client.Context, ns string) http.HandlerFunc { func getBidHandler(ctx client.Context, ns string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - id, errMsg := BidIDFromRequest(r) if len(errMsg) != 0 { @@ -125,7 +123,6 @@ func getBidHandler(ctx client.Context, ns string) http.HandlerFunc { func getLeaseHandler(ctx client.Context, ns string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - id, errMsg := LeaseIDFromRequest(r) if len(errMsg) != 0 { diff --git a/x/market/handler/server.go b/x/market/handler/server.go index 4cd8f11c55..1b37659a0f 100644 --- a/x/market/handler/server.go +++ b/x/market/handler/server.go @@ -294,5 +294,4 @@ func (ms msgServer) CloseLease(goCtx context.Context, msg *types.MsgCloseLease) return &types.MsgCloseLeaseResponse{}, err } return &types.MsgCloseLeaseResponse{}, nil - } diff --git a/x/market/keeper/grpc_query.go b/x/market/keeper/grpc_query.go index cd457c04f9..12986b0419 100644 --- a/x/market/keeper/grpc_query.go +++ b/x/market/keeper/grpc_query.go @@ -46,7 +46,7 @@ func (k Querier) Orders(c context.Context, req *types.QueryOrdersRequest) (*type orderStore := prefix.NewStore(store, searchPrefix) - pageRes, err := sdkquery.FilteredPaginate(orderStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := sdkquery.FilteredPaginate(orderStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { var order types.Order err := k.cdc.Unmarshal(value, &order) @@ -118,7 +118,7 @@ func (k Querier) Bids(c context.Context, req *types.QueryBidsRequest) (*types.Qu bidStore := prefix.NewStore(store, searchPrefix) - pageRes, err := sdkquery.FilteredPaginate(bidStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := sdkquery.FilteredPaginate(bidStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { var bid types.Bid err := k.cdc.Unmarshal(value, &bid) @@ -209,7 +209,7 @@ func (k Querier) Leases(c context.Context, req *types.QueryLeasesRequest) (*type } searchedStore := prefix.NewStore(store, searchPrefix) - pageRes, err := sdkquery.FilteredPaginate(searchedStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := sdkquery.FilteredPaginate(searchedStore, req.Pagination, func(key, value []byte, accumulate bool) (bool, error) { var lease types.Lease if isSecondaryPrefix { diff --git a/x/market/keeper/grpc_query_test.go b/x/market/keeper/grpc_query_test.go index 4dd83a7daa..1951289b66 100644 --- a/x/market/keeper/grpc_query_test.go +++ b/x/market/keeper/grpc_query_test.go @@ -115,7 +115,6 @@ func TestGRPCQueryOrder(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } @@ -149,7 +148,8 @@ func TestGRPCQueryOrders(t *testing.T) { Filters: types.OrderFilters{ OSeq: 37, State: types.OrderActive.String(), - }} + }, + } }, 0, }, @@ -929,7 +929,6 @@ func TestGRPCQueryBid(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } @@ -964,7 +963,8 @@ func TestGRPCQueryBids(t *testing.T) { OSeq: 37, State: types.BidLost.String(), Provider: testutil.AccAddress(t).String(), - }} + }, + } }, 0, }, @@ -1070,7 +1070,6 @@ func TestGRPCQueryLease(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } @@ -1110,7 +1109,8 @@ func TestGRPCQueryLeases(t *testing.T) { OSeq: 37, State: types.LeaseClosed.String(), Provider: testutil.AccAddress(t).String(), - }} + }, + } }, 0, }, diff --git a/x/market/keeper/keeper.go b/x/market/keeper/keeper.go index 4c1fd2cc8c..83e0ab6239 100644 --- a/x/market/keeper/keeper.go +++ b/x/market/keeper/keeper.go @@ -52,7 +52,6 @@ type Keeper struct { // NewKeeper creates and returns an instance for Market keeper func NewKeeper(cdc codec.BinaryCodec, skey sdk.StoreKey, pspace paramtypes.Subspace, ekeeper EscrowKeeper) IKeeper { - if !pspace.HasKeyTable() { pspace = pspace.WithKeyTable(types.ParamKeyTable()) } diff --git a/x/market/simulation/operations.go b/x/market/simulation/operations.go index e1f68656f3..1f6b270109 100644 --- a/x/market/simulation/operations.go +++ b/x/market/simulation/operations.go @@ -30,7 +30,8 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak govtypes.AccountKeeper, - ks keepers.Keepers) simulation.WeightedOperations { + ks keepers.Keepers, +) simulation.WeightedOperations { var ( weightMsgCreateBid int weightMsgCloseBid int @@ -74,7 +75,8 @@ func WeightedOperations( // SimulateMsgCreateBid generates a MsgCreateBid with random values func SimulateMsgCreateBid(ak govtypes.AccountKeeper, ks keepers.Keepers) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { orders := getOrdersWithState(ctx, ks, types.OrderOpen) if len(orders) == 0 { return simtypes.NoOpMsg(types.ModuleName, types.MsgTypeCreateBid, "no open orders found"), nil, nil @@ -150,14 +152,14 @@ func SimulateMsgCreateBid(ak govtypes.AccountKeeper, ks keepers.Keepers) simtype default: return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver mock tx"), nil, err } - } } // SimulateMsgCloseBid generates a MsgCloseBid with random values func SimulateMsgCloseBid(ak govtypes.AccountKeeper, ks keepers.Keepers) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var bids []types.Bid ks.Market.WithBids(ctx, func(bid types.Bid) bool { @@ -227,7 +229,8 @@ func SimulateMsgCloseBid(ak govtypes.AccountKeeper, ks keepers.Keepers) simtypes // SimulateMsgCloseLease generates a MsgCloseLease with random values func SimulateMsgCloseLease(ak govtypes.AccountKeeper, ks keepers.Keepers) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { // orders := getOrdersWithState(ctx, ks, types.OrderActive) // if len(orders) == 0 { // return simtypes.NoOpMsg(types.ModuleName, types.MsgTypeCloseLease, "no orders with state matched found"), nil, nil diff --git a/x/provider/alias.go b/x/provider/alias.go index e67402a720..a47c6195bd 100644 --- a/x/provider/alias.go +++ b/x/provider/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of provider module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of provider module +var NewKeeper = keeper.NewKeeper diff --git a/x/provider/config/config.go b/x/provider/config/config.go index 38aea9d632..a47d3903c8 100644 --- a/x/provider/config/config.go +++ b/x/provider/config/config.go @@ -11,9 +11,7 @@ import ( types "github.com/akash-network/akash-api/go/node/types/v1beta3" ) -var ( - ErrDuplicatedAttribute = errors.New("provider: duplicated attribute") -) +var ErrDuplicatedAttribute = errors.New("provider: duplicated attribute") // Config is the struct that stores provider config type Config struct { diff --git a/x/provider/handler/handler_test.go b/x/provider/handler/handler_test.go index a1dd914a1b..ba83c0ff0e 100644 --- a/x/provider/handler/handler_test.go +++ b/x/provider/handler/handler_test.go @@ -67,7 +67,6 @@ func TestProviderCreate(t *testing.T) { require.NoError(t, err) t.Run("ensure event created", func(t *testing.T) { - iev := testutil.ParseProviderEvent(t, res.Events) require.IsType(t, types.EventProviderCreated{}, iev) @@ -99,7 +98,6 @@ func TestProviderCreateWithInfo(t *testing.T) { require.NoError(t, err) t.Run("ensure event created", func(t *testing.T) { - iev := testutil.ParseProviderEvent(t, res.Events) require.IsType(t, types.EventProviderCreated{}, iev) @@ -245,7 +243,6 @@ func TestProviderUpdateAttributes(t *testing.T) { require.NotNil(t, res) t.Run("ensure event created", func(t *testing.T) { - iev := testutil.ParseProviderEvent(t, res.Events[4:]) require.IsType(t, types.EventProviderUpdated{}, iev) diff --git a/x/provider/handler/server.go b/x/provider/handler/server.go index eddf8f8102..333aaa0809 100644 --- a/x/provider/handler/server.go +++ b/x/provider/handler/server.go @@ -15,10 +15,8 @@ import ( "github.com/akash-network/node/x/provider/keeper" ) -var ( - // ErrInternal defines registered error code for internal error - ErrInternal = sdkerrors.Register(types.ModuleName, 10, "internal error") -) +// ErrInternal defines registered error code for internal error +var ErrInternal = sdkerrors.Register(types.ModuleName, 10, "internal error") type msgServer struct { provider keeper.IKeeper diff --git a/x/provider/keeper/grpc_query.go b/x/provider/keeper/grpc_query.go index cd4825e1f4..192f1bdf09 100644 --- a/x/provider/keeper/grpc_query.go +++ b/x/provider/keeper/grpc_query.go @@ -30,7 +30,7 @@ func (k Querier) Providers(c context.Context, req *types.QueryProvidersRequest) store := ctx.KVStore(k.skey) - pageRes, err := sdkquery.Paginate(store, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := sdkquery.Paginate(store, req.Pagination, func(key, value []byte) error { var provider types.Provider err := k.cdc.Unmarshal(value, &provider) diff --git a/x/provider/keeper/grpc_query_test.go b/x/provider/keeper/grpc_query_test.go index 649918aaac..36292fa8c4 100644 --- a/x/provider/keeper/grpc_query_test.go +++ b/x/provider/keeper/grpc_query_test.go @@ -102,7 +102,6 @@ func TestGRPCQueryProvider(t *testing.T) { require.Error(t, err) require.Nil(t, res) } - }) } } diff --git a/x/provider/module.go b/x/provider/module.go index 8aa692e618..f2219f7fd9 100644 --- a/x/provider/module.go +++ b/x/provider/module.go @@ -117,7 +117,8 @@ type AppModule struct { // NewAppModule creates a new AppModule object func NewAppModule(cdc codec.Codec, k keeper.IKeeper, bkeeper bankkeeper.Keeper, - mkeeper mkeeper.IKeeper) AppModule { + mkeeper mkeeper.IKeeper, +) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: k, diff --git a/x/provider/simulation/operations.go b/x/provider/simulation/operations.go index ff15eb72e1..4280fa28f7 100644 --- a/x/provider/simulation/operations.go +++ b/x/provider/simulation/operations.go @@ -30,7 +30,8 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak govtypes.AccountKeeper, - bk bankkeeper.Keeper, k keeper.IKeeper) simulation.WeightedOperations { + bk bankkeeper.Keeper, k keeper.IKeeper, +) simulation.WeightedOperations { var ( weightMsgCreate int weightMsgUpdate int @@ -64,7 +65,8 @@ func WeightedOperations( // nolint:funlen func SimulateMsgCreate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accounts) // ensure the provider doesn't exist already @@ -99,7 +101,6 @@ func SimulateMsgCreate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper []uint64{account.GetSequence()}, simAccount.PrivKey, ) - if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } @@ -117,7 +118,8 @@ func SimulateMsgCreate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper // nolint:funlen func SimulateMsgUpdate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, - chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var providers []types.Provider k.WithProviders(ctx, func(provider types.Provider) bool { @@ -170,7 +172,6 @@ func SimulateMsgUpdate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper []uint64{account.GetSequence()}, simAccount.PrivKey, ) - if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } diff --git a/x/staking/alias.go b/x/staking/alias.go index bd338c800e..fd0e497944 100644 --- a/x/staking/alias.go +++ b/x/staking/alias.go @@ -18,7 +18,5 @@ type ( Keeper = keeper.Keeper ) -var ( - // NewKeeper creates new keeper instance of provider module - NewKeeper = keeper.NewKeeper -) +// NewKeeper creates new keeper instance of provider module +var NewKeeper = keeper.NewKeeper diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 4f41281156..b8ab30f7eb 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -10,7 +10,8 @@ import ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.IKeeper) simulation.WeightedOperations { + appParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.IKeeper, +) simulation.WeightedOperations { return nil // var ( // weightMsgCreate int From f1c00a75e5501331f12f56f60772855bf88ff0ea Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 23 May 2023 07:04:01 +0700 Subject: [PATCH 2/5] remove superfluous nolints --- app/types/app.go | 4 +-- cmd/akash/cmd/testnetify/cmd.go | 2 +- cmd/akash/cmd/testnetify/config.go | 2 +- cmd/akash/cmd/testnetify/state.go | 48 ++++++++++++++-------------- upgrades/software/v0.18.0/upgrade.go | 2 +- upgrades/software/v0.24.0/upgrade.go | 4 +-- util/cli/configs.go | 10 +++--- x/audit/client/cli/tx.go | 3 +- 8 files changed, 37 insertions(+), 38 deletions(-) diff --git a/app/types/app.go b/app/types/app.go index a8c52ec45c..90eb9a996e 100644 --- a/app/types/app.go +++ b/app/types/app.go @@ -94,14 +94,14 @@ func FindStructField[C any](obj interface{}, fieldName string) (C, error) { field := rValue.Elem().FieldByName(fieldName) if !field.IsValid() { - return *new(C), fmt.Errorf("interface `%s` does not have the field `%s`", // nolint: goerr113 + return *new(C), fmt.Errorf("interface `%s` does not have the field `%s`", rValue.Type(), fieldName) } res, valid := field.Interface().(C) if !valid { - return *new(C), fmt.Errorf( // nolint: goerr113 + return *new(C), fmt.Errorf( "object's `%s` expected type `%s` does not match actual `%s`", fieldName, reflect.TypeOf(*new(C)), field.Type().String()) diff --git a/cmd/akash/cmd/testnetify/cmd.go b/cmd/akash/cmd/testnetify/cmd.go index ed13ea5bb5..52849468e7 100644 --- a/cmd/akash/cmd/testnetify/cmd.go +++ b/cmd/akash/cmd/testnetify/cmd.go @@ -44,7 +44,7 @@ func Cmd() *cobra.Command { } if sID < 0 || sID > 90 { - return fmt.Errorf("invalid value %d for --spinner. expecting 0..90", sID) // nolint: goerr113 + return fmt.Errorf("invalid value %d for --spinner. expecting 0..90", sID) } return nil diff --git a/cmd/akash/cmd/testnetify/config.go b/cmd/akash/cmd/testnetify/config.go index 1662d80635..ddbefc42d7 100644 --- a/cmd/akash/cmd/testnetify/config.go +++ b/cmd/akash/cmd/testnetify/config.go @@ -92,7 +92,7 @@ func (t *VotingPeriod) UnmarshalJSON(data []byte) error { val := TrimQuotes(string(data)) if !strings.HasSuffix(val, "s") { - return fmt.Errorf("invalid format of voting period. must contain time unit. Valid time units are ns|us(µs)|ms|s|m|h") // nolint: goerr113 + return fmt.Errorf("invalid format of voting period. must contain time unit. Valid time units are ns|us(µs)|ms|s|m|h") } var err error diff --git a/cmd/akash/cmd/testnetify/state.go b/cmd/akash/cmd/testnetify/state.go index a18b9edfd6..69075a6f98 100644 --- a/cmd/akash/cmd/testnetify/state.go +++ b/cmd/akash/cmd/testnetify/state.go @@ -224,17 +224,17 @@ func NewGenesisState(sp *yacspin.Spinner, state map[string]json.RawMessage, doc var err error st.moduleAddresses.bondedPool, err = st.findModuleAccount(cdc, "bonded_tokens_pool") if err != nil { - return nil, fmt.Errorf("couldn't find bonded_tokens_pool account") // nolint: goerr113 + return nil, fmt.Errorf("couldn't find bonded_tokens_pool account") } st.moduleAddresses.notBondedPool, err = st.findModuleAccount(cdc, "not_bonded_tokens_pool") if err != nil { - return nil, fmt.Errorf("couldn't find not_bonded_tokens_pool account") // nolint: goerr113 + return nil, fmt.Errorf("couldn't find not_bonded_tokens_pool account") } st.moduleAddresses.distribution, err = st.findModuleAccount(cdc, "distribution") if err != nil { - return nil, fmt.Errorf("couldn't find distribution account") // nolint: goerr113 + return nil, fmt.Errorf("couldn't find distribution account") } _ = sp.Stop() @@ -317,7 +317,7 @@ func (ga *AuthState) unpack(cdc codec.Codec) error { ga.accs, err = authtypes.UnpackAccounts(ga.state.Accounts) if err != nil { - err = fmt.Errorf("failed to get accounts from any: %s", err.Error()) // nolint: goerr113 + err = fmt.Errorf("failed to get accounts from any: %s", err.Error()) } ga.accs = authtypes.SanitizeGenesisAccounts(ga.accs) @@ -365,12 +365,12 @@ func (ga *AuthState) pack(cdc codec.Codec) error { var err error ga.state.Accounts, err = authtypes.PackAccounts(ga.accs) if err != nil { - return fmt.Errorf("failed to convert accounts into any's: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to convert accounts into any's: %s", err.Error()) } stateBz, err := cdc.MarshalJSON(&ga.state) if err != nil { - return fmt.Errorf("failed to marshal auth genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal auth genesis state: %s", err.Error()) } ga.gstate[authtypes.ModuleName] = stateBz @@ -401,7 +401,7 @@ func (ga *BankState) pack(cdc codec.Codec) error { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal bank genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal bank genesis state: %s", err.Error()) } ga.gstate[banktypes.ModuleName] = stateBz @@ -430,7 +430,7 @@ func (ga *GovState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal gov genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal gov genesis state: %s", err.Error()) } ga.gstate[govtypes.ModuleName] = stateBz @@ -459,7 +459,7 @@ func (ga *IBCState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal ibc genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal ibc genesis state: %s", err.Error()) } ga.gstate[ibchost.ModuleName] = stateBz @@ -488,7 +488,7 @@ func (ga *StakingState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal staking genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal staking genesis state: %s", err.Error()) } ga.gstate[stakingtypes.ModuleName] = stateBz @@ -517,7 +517,7 @@ func (ga *SlashingState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal staking genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal staking genesis state: %s", err.Error()) } ga.gstate[slashingtypes.ModuleName] = stateBz @@ -546,7 +546,7 @@ func (ga *DistributionState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal distribution genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal distribution genesis state: %s", err.Error()) } ga.gstate[distributiontypes.ModuleName] = stateBz @@ -569,7 +569,7 @@ func (ga *AuditState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal audit genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal audit genesis state: %s", err.Error()) } ga.gstate[atypes.ModuleName] = stateBz @@ -592,7 +592,7 @@ func (ga *CertState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal cert genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal cert genesis state: %s", err.Error()) } ga.gstate[ctypes.ModuleName] = stateBz @@ -615,7 +615,7 @@ func (ga *DeploymentState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal deployment genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal deployment genesis state: %s", err.Error()) } ga.gstate[dtypes.ModuleName] = stateBz @@ -638,7 +638,7 @@ func (ga *EscrowState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal escrow genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal escrow genesis state: %s", err.Error()) } ga.gstate[etypes.ModuleName] = stateBz @@ -661,7 +661,7 @@ func (ga *MarketState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal market genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal market genesis state: %s", err.Error()) } ga.gstate[mtypes.ModuleName] = stateBz @@ -684,7 +684,7 @@ func (ga *ProviderState) pack(cdc codec.Codec) error { if ga.state != nil { stateBz, err := cdc.MarshalJSON(ga.state) if err != nil { - return fmt.Errorf("failed to marshal provider genesis state: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to marshal provider genesis state: %s", err.Error()) } ga.gstate[ptypes.ModuleName] = stateBz @@ -750,7 +750,7 @@ func (ga *GenesisState) decreaseSupply(cdc codec.Codec, coins ...sdk.Coin) error } if !found { - return fmt.Errorf("cannot decrease supply for not existing token") // nolint: goerr113 + return fmt.Errorf("cannot decrease supply for not existing token") } } @@ -773,7 +773,7 @@ func (ga *GenesisState) IncreaseBalances(cdc codec.Codec, addr sdk.AccAddress, c } if balance == nil { - return fmt.Errorf("no balances found for account (%s)", addr.String()) // nolint: goerr113 + return fmt.Errorf("no balances found for account (%s)", addr.String()) } for _, coin := range coins { @@ -814,7 +814,7 @@ func (ga *GenesisState) DecreaseBalances(cdc codec.Codec, addr sdk.AccAddress, c } if balance == nil { - return fmt.Errorf("no balances found for account (%s)", addr.String()) // nolint: goerr113 + return fmt.Errorf("no balances found for account (%s)", addr.String()) } for _, coin := range coins { @@ -858,7 +858,7 @@ func (ga *GenesisState) IncreaseDelegatorStake( } if sVal == nil { - return fmt.Errorf("staking validator (%s) does not exists", val.String()) // nolint: goerr113 + return fmt.Errorf("staking validator (%s) does not exists", val.String()) } for idx, d := range ga.app.StakingState.state.Delegations { @@ -1031,13 +1031,13 @@ func (ga *GenesisState) AddNewAccount(cdc codec.Codec, addr sdk.AccAddress, pubk } if ga.app.AuthState.accs.Contains(addr) { - return fmt.Errorf("account (%s) already exists", addr.String()) // nolint: goerr113 + return fmt.Errorf("account (%s) already exists", addr.String()) } genAccount := authtypes.NewBaseAccount(addr, pubkey, ga.app.AuthState.nextAccountNumber(), 0) if err := genAccount.Validate(); err != nil { - return fmt.Errorf("failed to validate new genesis account: %s", err.Error()) // nolint: goerr113 + return fmt.Errorf("failed to validate new genesis account: %s", err.Error()) } ga.app.AuthState.accs = append(ga.app.AuthState.accs, genAccount) diff --git a/upgrades/software/v0.18.0/upgrade.go b/upgrades/software/v0.18.0/upgrade.go index 172ec79da7..39bf0c5b9b 100644 --- a/upgrades/software/v0.18.0/upgrade.go +++ b/upgrades/software/v0.18.0/upgrade.go @@ -35,7 +35,7 @@ func initUpgrade(_ log.Logger, app *apptypes.App) (utypes.IUpgrade, error) { } if _, exists := up.MM.Modules[icatypes.ModuleName]; !exists { - return nil, fmt.Errorf("module %s has not been initialized", icatypes.ModuleName) // nolint: goerr113 + return nil, fmt.Errorf("module %s has not been initialized", icatypes.ModuleName) } return up, nil diff --git a/upgrades/software/v0.24.0/upgrade.go b/upgrades/software/v0.24.0/upgrade.go index e7952bda8a..09fe95fae6 100644 --- a/upgrades/software/v0.24.0/upgrade.go +++ b/upgrades/software/v0.24.0/upgrade.go @@ -40,11 +40,11 @@ func initUpgrade(log log.Logger, app *apptypes.App) (utypes.IUpgrade, error) { } if _, exists := up.MM.Modules[agov.ModuleName]; !exists { - return nil, fmt.Errorf("module %s has not been initialized", agov.ModuleName) // nolint: goerr113 + return nil, fmt.Errorf("module %s has not been initialized", agov.ModuleName) } if _, exists := up.MM.Modules[astaking.ModuleName]; !exists { - return nil, fmt.Errorf("module %s has not been initialized", astaking.ModuleName) // nolint: goerr113 + return nil, fmt.Errorf("module %s has not been initialized", astaking.ModuleName) } return up, nil diff --git a/util/cli/configs.go b/util/cli/configs.go index 962f5fc4c1..0fc6cf5d48 100644 --- a/util/cli/configs.go +++ b/util/cli/configs.go @@ -185,7 +185,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo tmcfg.EnsureRoot(rootDir) if err = conf.ValidateBasic(); err != nil { - return nil, fmt.Errorf("error in config file: %v", err) // nolint: goerr113 + return nil, fmt.Errorf("error in config file: %v", err) } conf.RPC.PprofListenAddress = "localhost:6060" @@ -203,7 +203,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo rootViper.AddConfigPath(configPath) if err := rootViper.ReadInConfig(); err != nil { - return nil, fmt.Errorf("failed to read in %s: %w", tmCfgFile, err) // nolint: goerr113 + return nil, fmt.Errorf("failed to read in %s: %w", tmCfgFile, err) } } @@ -222,14 +222,14 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo config.SetConfigTemplate(customAppTemplate) if err = rootViper.Unmarshal(&customConfig); err != nil { - return nil, fmt.Errorf("failed to parse %s: %w", appCfgFilePath, err) // nolint: goerr113 + return nil, fmt.Errorf("failed to parse %s: %w", appCfgFilePath, err) } config.WriteConfigFile(appCfgFilePath, customConfig) } else { appConf, err := config.ParseConfig(rootViper) if err != nil { - return nil, fmt.Errorf("failed to parse %s: %w", appCfgFilePath, err) // nolint: goerr113 + return nil, fmt.Errorf("failed to parse %s: %w", appCfgFilePath, err) } config.WriteConfigFile(appCfgFilePath, appConf) @@ -241,7 +241,7 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo rootViper.AddConfigPath(configPath) if err := rootViper.MergeInConfig(); err != nil { - return nil, fmt.Errorf("failed to merge configuration: %w", err) // nolint: goerr113 + return nil, fmt.Errorf("failed to merge configuration: %w", err) } return conf, nil diff --git a/x/audit/client/cli/tx.go b/x/audit/client/cli/tx.go index 9e79520143..b3a327bef1 100644 --- a/x/audit/client/cli/tx.go +++ b/x/audit/client/cli/tx.go @@ -12,7 +12,6 @@ import ( types "github.com/akash-network/akash-api/go/node/audit/v1beta3" ptypes "github.com/akash-network/akash-api/go/node/provider/v1beta3" akashtypes "github.com/akash-network/akash-api/go/node/types/v1beta3" - atypes "github.com/akash-network/akash-api/go/node/types/v1beta3" "github.com/akash-network/node/client/broadcaster" ) @@ -152,7 +151,7 @@ func readAttributes(cmd *cobra.Command, cctx client.Context, provider string, ar if len(args) != 0 { for i := 0; i < len(args); i += 2 { - attr = append(attr, atypes.Attribute{ + attr = append(attr, akashtypes.Attribute{ Key: args[i], Value: args[i+1], }) From cc73741f5c4cb29dab5fbd1e58cd2a4446345531 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 23 May 2023 10:17:50 +0700 Subject: [PATCH 3/5] fix all lint issues before pursuing larger upgrade --- .golangci.yaml | 9 --------- app/app.go | 2 +- app/upgrades.go | 2 +- sdl/storage.go | 2 +- sdl/util/util.go | 2 +- sdl/v2.go | 8 ++++---- testutil/rand.go | 2 +- upgrades/software/v0.15.0/audit.go | 3 +-- upgrades/software/v0.15.0/cert.go | 4 +--- upgrades/software/v0.15.0/deployment.go | 4 +--- upgrades/software/v0.15.0/escrow.go | 4 +--- upgrades/software/v0.15.0/helpers.go | 4 +--- upgrades/software/v0.15.0/init.go | 4 +--- upgrades/software/v0.15.0/market.go | 4 +--- upgrades/software/v0.15.0/provider.go | 3 +-- upgrades/software/v0.15.0/upgrade.go | 3 +-- upgrades/software/v0.18.0/init.go | 3 +-- upgrades/software/v0.18.0/upgrade.go | 3 +-- upgrades/software/v0.20.0/init.go | 3 +-- upgrades/software/v0.20.0/upgrade.go | 3 +-- upgrades/software/v0.24.0/deployment.go | 5 +---- upgrades/software/v0.24.0/init.go | 3 +-- upgrades/software/v0.24.0/market.go | 4 +--- upgrades/software/v0.24.0/upgrade.go | 4 +--- upgrades/upgrades.go | 6 +++--- util/cli/configs.go | 2 +- x/cert/utils/key_pair_manager.go | 6 ++---- x/deployment/keeper/keeper.go | 2 +- x/deployment/simulation/operations.go | 8 ++++---- x/market/keeper/keys/v1beta1/key.go | 11 ++++------- x/market/simulation/operations.go | 8 +++++--- x/provider/simulation/operations.go | 8 ++++---- 32 files changed, 50 insertions(+), 89 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 57902631c7..ad8e5554b8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -3,12 +3,9 @@ run: timeout: 10m sort-results: true allow-parallel-runners: true - exclude-dir: testutil/testdata skip-dirs: - pkg/client - ".*/mocks" - skip-files: - - server/grpc/gogoreflection/fix_registration.go skip-dirs-use-default: true linters: @@ -117,9 +114,3 @@ linters-settings: require-specific: false gosimple: checks: ["all"] - - gocritic: - disabled-checks: - - regexpMust - - appendAssign - - ifElseChain diff --git a/app/app.go b/app/app.go index 81a146a650..fac35f5c31 100644 --- a/app/app.go +++ b/app/app.go @@ -475,7 +475,7 @@ func NewApp( return app } -func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { // nolint: unused,deadcode // we'd like to preserve this unused code +func getGenesisTime(appOpts servertypes.AppOptions, homePath string) time.Time { //nolint:unused,deadcode // we'd like to preserve this unused code if v := appOpts.Get("GenesisTime"); v != nil { // in tests, GenesisTime is supplied using appOpts genTime, ok := v.(time.Time) diff --git a/app/upgrades.go b/app/upgrades.go index 806a003c88..913911d486 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -7,7 +7,7 @@ import ( utypes "github.com/akash-network/node/upgrades/types" - _ "github.com/akash-network/node/upgrades" + _ "github.com/akash-network/node/upgrades" // import all upgrades ) func (app *AkashApp) registerUpgradeHandlers() error { diff --git a/sdl/storage.go b/sdl/storage.go index ddd20c2df9..876a526734 100644 --- a/sdl/storage.go +++ b/sdl/storage.go @@ -75,7 +75,7 @@ func validateAttributeStorageClass(_ string, val *string) error { // UnmarshalYAML unmarshal storage config // data can be present either as single entry mapping or an array of them -// nolint: gofmt +// nolint: gofmt // this is yaml code // e.g // single entity // ```yaml diff --git a/sdl/util/util.go b/sdl/util/util.go index e6a67d59d4..4ce3d8ed1a 100644 --- a/sdl/util/util.go +++ b/sdl/util/util.go @@ -10,7 +10,7 @@ import ( ) func ShouldBeIngress(expose manifest.ServiceExpose) bool { - return expose.Proto == manifest.TCP && expose.Global && 80 == ExposeExternalPort(expose) + return expose.Proto == manifest.TCP && expose.Global && ExposeExternalPort(expose) == 80 } func ExposeExternalPort(expose manifest.ServiceExpose) int32 { diff --git a/sdl/v2.go b/sdl/v2.go index e74388ea87..2dd0ed5db5 100644 --- a/sdl/v2.go +++ b/sdl/v2.go @@ -77,28 +77,28 @@ type v2HTTPOptions struct { func (ho v2HTTPOptions) asManifest() (manifest.ServiceExposeHTTPOptions, error) { maxBodySize := ho.MaxBodySize - if 0 == maxBodySize { + if maxBodySize == 0 { maxBodySize = defaultMaxBodySize } else if maxBodySize > upperLimitBodySize { return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: body size cannot be greater than %d bytes", errHTTPOptionNotAllowed, upperLimitBodySize) } readTimeout := ho.ReadTimeout - if 0 == readTimeout { + if readTimeout == 0 { readTimeout = defaultReadTimeout } else if readTimeout > upperLimitReadTimeout { return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: read timeout cannot be greater than %d ms", errHTTPOptionNotAllowed, upperLimitReadTimeout) } sendTimeout := ho.SendTimeout - if 0 == sendTimeout { + if sendTimeout == 0 { sendTimeout = defaultSendTimeout } else if sendTimeout > upperLimitSendTimeout { return manifest.ServiceExposeHTTPOptions{}, fmt.Errorf("%w: send timeout cannot be greater than %d ms", errHTTPOptionNotAllowed, upperLimitSendTimeout) } nextTries := ho.NextTries - if 0 == nextTries { + if nextTries == 0 { nextTries = defaultNextTries } diff --git a/testutil/rand.go b/testutil/rand.go index 00e2f36058..70bd33021e 100644 --- a/testutil/rand.go +++ b/testutil/rand.go @@ -8,5 +8,5 @@ import ( // non-constant random seed for math/rand functions func init() { - rand.Seed(time.Now().Unix()) // nolint: staticcheck + rand.Seed(time.Now().Unix()) //nolint:staticcheck // ignore deprecation of math/rand.Seed } diff --git a/upgrades/software/v0.15.0/audit.go b/upgrades/software/v0.15.0/audit.go index 27b1cf17b8..b6fd895b89 100644 --- a/upgrades/software/v0.15.0/audit.go +++ b/upgrades/software/v0.15.0/audit.go @@ -1,6 +1,5 @@ // Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/upgrades/software/v0.15.0/cert.go b/upgrades/software/v0.15.0/cert.go index dd3997458b..a4984b1697 100644 --- a/upgrades/software/v0.15.0/cert.go +++ b/upgrades/software/v0.15.0/cert.go @@ -1,6 +1,4 @@ -// Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/upgrades/software/v0.15.0/deployment.go b/upgrades/software/v0.15.0/deployment.go index 6d14e49acb..02c5f1450d 100644 --- a/upgrades/software/v0.15.0/deployment.go +++ b/upgrades/software/v0.15.0/deployment.go @@ -1,6 +1,4 @@ -// Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( dv1beta1 "github.com/akash-network/akash-api/go/node/deployment/v1beta1" diff --git a/upgrades/software/v0.15.0/escrow.go b/upgrades/software/v0.15.0/escrow.go index 8ec2a73ce6..54ecd360d7 100644 --- a/upgrades/software/v0.15.0/escrow.go +++ b/upgrades/software/v0.15.0/escrow.go @@ -1,6 +1,4 @@ -// Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/upgrades/software/v0.15.0/helpers.go b/upgrades/software/v0.15.0/helpers.go index efd54ae40b..39a7c051b0 100644 --- a/upgrades/software/v0.15.0/helpers.go +++ b/upgrades/software/v0.15.0/helpers.go @@ -1,6 +1,4 @@ -// Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "github.com/cosmos/cosmos-sdk/store/prefix" diff --git a/upgrades/software/v0.15.0/init.go b/upgrades/software/v0.15.0/init.go index 2e3d4e4e8a..8bc75d5549 100644 --- a/upgrades/software/v0.15.0/init.go +++ b/upgrades/software/v0.15.0/init.go @@ -1,6 +1,4 @@ -// Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( av1beta2 "github.com/akash-network/akash-api/go/node/audit/v1beta2" diff --git a/upgrades/software/v0.15.0/market.go b/upgrades/software/v0.15.0/market.go index 230b5b04bb..65e450f9d8 100644 --- a/upgrades/software/v0.15.0/market.go +++ b/upgrades/software/v0.15.0/market.go @@ -1,6 +1,4 @@ -// Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/upgrades/software/v0.15.0/provider.go b/upgrades/software/v0.15.0/provider.go index e6f803c51d..c0010dd521 100644 --- a/upgrades/software/v0.15.0/provider.go +++ b/upgrades/software/v0.15.0/provider.go @@ -1,6 +1,5 @@ // Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/upgrades/software/v0.15.0/upgrade.go b/upgrades/software/v0.15.0/upgrade.go index 90a1b6c7e7..e8764f0ca5 100644 --- a/upgrades/software/v0.15.0/upgrade.go +++ b/upgrades/software/v0.15.0/upgrade.go @@ -1,6 +1,5 @@ // Package v0_15_0 -// nolint revive -package v0_15_0 +package v0_15_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( inflationtypes "github.com/akash-network/akash-api/go/node/inflation/v1beta3" diff --git a/upgrades/software/v0.18.0/init.go b/upgrades/software/v0.18.0/init.go index 5eef63ed6f..dd327e72b8 100644 --- a/upgrades/software/v0.18.0/init.go +++ b/upgrades/software/v0.18.0/init.go @@ -1,6 +1,5 @@ // Package v0_18_0 -// nolint revive -package v0_18_0 +package v0_18_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( utypes "github.com/akash-network/node/upgrades/types" diff --git a/upgrades/software/v0.18.0/upgrade.go b/upgrades/software/v0.18.0/upgrade.go index 39bf0c5b9b..6329ea2826 100644 --- a/upgrades/software/v0.18.0/upgrade.go +++ b/upgrades/software/v0.18.0/upgrade.go @@ -1,6 +1,5 @@ // Package v0_18_0 -// nolint revive -package v0_18_0 +package v0_18_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "fmt" diff --git a/upgrades/software/v0.20.0/init.go b/upgrades/software/v0.20.0/init.go index 4ed992e4a1..465d5efc3f 100644 --- a/upgrades/software/v0.20.0/init.go +++ b/upgrades/software/v0.20.0/init.go @@ -1,6 +1,5 @@ // Package v0_20_0 -// nolint revive -package v0_20_0 +package v0_20_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( utypes "github.com/akash-network/node/upgrades/types" diff --git a/upgrades/software/v0.20.0/upgrade.go b/upgrades/software/v0.20.0/upgrade.go index 5e92347e65..e1fbdde14f 100644 --- a/upgrades/software/v0.20.0/upgrade.go +++ b/upgrades/software/v0.20.0/upgrade.go @@ -1,6 +1,5 @@ // Package v0_20_0 -// nolint revive -package v0_20_0 +package v0_20_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" diff --git a/upgrades/software/v0.24.0/deployment.go b/upgrades/software/v0.24.0/deployment.go index 88587c989c..4faa2e18be 100644 --- a/upgrades/software/v0.24.0/deployment.go +++ b/upgrades/software/v0.24.0/deployment.go @@ -1,6 +1,4 @@ -// Package v0_24_0 -// nolint revive -package v0_24_0 +package v0_24_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "github.com/cosmos/cosmos-sdk/codec" @@ -30,7 +28,6 @@ func (m deploymentMigrations) handler(ctx sdk.Context) error { store := ctx.KVStore(m.StoreKey()) err := utypes.MigrateValue(store, m.Codec(), dv1beta2.GroupPrefix(), migrateDeploymentGroup) - if err != nil { return err } diff --git a/upgrades/software/v0.24.0/init.go b/upgrades/software/v0.24.0/init.go index 0b464e0469..4b877bc0ae 100644 --- a/upgrades/software/v0.24.0/init.go +++ b/upgrades/software/v0.24.0/init.go @@ -1,6 +1,5 @@ // Package v0_24_0 -// nolint revive -package v0_24_0 +package v0_24_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( dv1beta3 "github.com/akash-network/akash-api/go/node/deployment/v1beta3" diff --git a/upgrades/software/v0.24.0/market.go b/upgrades/software/v0.24.0/market.go index 93dd3708f8..d0332ce5c9 100644 --- a/upgrades/software/v0.24.0/market.go +++ b/upgrades/software/v0.24.0/market.go @@ -1,6 +1,5 @@ // Package v0_24_0 -// nolint revive -package v0_24_0 +package v0_24_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "github.com/cosmos/cosmos-sdk/codec" @@ -31,7 +30,6 @@ func (m marketMigrations) handler(ctx sdk.Context) error { store := ctx.KVStore(m.StoreKey()) err := utypes.MigrateValue(store, m.Codec(), mv1beta3.OrderPrefix(), migrateOrder) - if err != nil { return err } diff --git a/upgrades/software/v0.24.0/upgrade.go b/upgrades/software/v0.24.0/upgrade.go index 09fe95fae6..3916b538f1 100644 --- a/upgrades/software/v0.24.0/upgrade.go +++ b/upgrades/software/v0.24.0/upgrade.go @@ -1,6 +1,4 @@ -// Package v0_24_0 -// nolint revive -package v0_24_0 +package v0_24_0 //nolint:revive // this package is named this way becauase it is part of an upgrade import ( "fmt" diff --git a/upgrades/upgrades.go b/upgrades/upgrades.go index 3351407b07..9e056500ec 100644 --- a/upgrades/upgrades.go +++ b/upgrades/upgrades.go @@ -1,9 +1,9 @@ package upgrades import ( - _ "github.com/akash-network/node/upgrades/software/v0.24.0" + _ "github.com/akash-network/node/upgrades/software/v0.24.0" // import all parts of the v0.24.0 upgrade - _ "github.com/akash-network/node/upgrades/software/v0.20.0" + _ "github.com/akash-network/node/upgrades/software/v0.20.0" // import all parts of the v0.20.0 upgrade - _ "github.com/akash-network/node/upgrades/software/v0.15.0" + _ "github.com/akash-network/node/upgrades/software/v0.15.0" // import all parts of the v0.15.0 upgrade ) diff --git a/util/cli/configs.go b/util/cli/configs.go index 0fc6cf5d48..16eca3a278 100644 --- a/util/cli/configs.go +++ b/util/cli/configs.go @@ -128,7 +128,7 @@ func parseTimestampFormat(val string) (string, error) { return time.Kitchen, nil } - return "", fmt.Errorf("invalid timestamp format (%s)", val) // nolint goerr113 + return "", fmt.Errorf("invalid timestamp format (%s)", val) } func bindFlags(cmd *cobra.Command, v *viper.Viper, envPrefixes []string) error { diff --git a/x/cert/utils/key_pair_manager.go b/x/cert/utils/key_pair_manager.go index f051f03bcb..b98a34aa83 100644 --- a/x/cert/utils/key_pair_manager.go +++ b/x/cert/utils/key_pair_manager.go @@ -270,11 +270,9 @@ func (kpm *keyPairManager) readImpl(fin io.Reader) ([]byte, []byte, []byte, erro if block.Type == "ENCRYPTED PRIVATE KEY" { privKeyPlaintext, err = pemutil.DecryptPKCS8PrivateKey(block.Bytes, kpm.passwordBytes) } else if block.Headers["Proc-Type"] == "4,ENCRYPTED" { - // nolint: staticcheck - privKeyPlaintext, err = x509.DecryptPEMBlock(block, kpm.passwordBytes) + privKeyPlaintext, err = x509.DecryptPEMBlock(block, kpm.passwordBytes) //nolint:staticcheck // we need to use this for kube compatibility if errors.Is(err, x509.IncorrectPasswordError) { - // nolint: staticcheck - privKeyPlaintext, err = x509.DecryptPEMBlock(block, kpm.passwordLegacy) + privKeyPlaintext, err = x509.DecryptPEMBlock(block, kpm.passwordLegacy) //nolint:staticcheck // we need to use this for kube compatibility } } else { return nil, nil, nil, errUnsupportedEncryptedPEM diff --git a/x/deployment/keeper/keeper.go b/x/deployment/keeper/keeper.go index 6368f14809..173712bed3 100644 --- a/x/deployment/keeper/keeper.go +++ b/x/deployment/keeper/keeper.go @@ -302,7 +302,7 @@ func (k Keeper) updateDeployment(ctx sdk.Context, obj types.Deployment) { store.Set(key, k.cdc.MustMarshal(&obj)) } -// nolint: unused +//nolint:unused // this will be used in the future func (k Keeper) updateGroup(ctx sdk.Context, group types.Group) { store := ctx.KVStore(k.skey) key := groupKey(group.ID()) diff --git a/x/deployment/simulation/operations.go b/x/deployment/simulation/operations.go index 3c1f062278..bb89502dd3 100644 --- a/x/deployment/simulation/operations.go +++ b/x/deployment/simulation/operations.go @@ -23,10 +23,10 @@ import ( // Simulation operation weights constants const ( - OpWeightMsgCreateDeployment = "op_weight_msg_create_deployment" // nolint gosec - OpWeightMsgUpdateDeployment = "op_weight_msg_update_deployment" // nolint gosec - OpWeightMsgCloseDeployment = "op_weight_msg_close_deployment" // nolint gosec - OpWeightMsgCloseGroup = "op_weight_msg_close_group" // nolint gosec + OpWeightMsgCreateDeployment = "op_weight_msg_create_deployment" + OpWeightMsgUpdateDeployment = "op_weight_msg_update_deployment" + OpWeightMsgCloseDeployment = "op_weight_msg_close_deployment" + OpWeightMsgCloseGroup = "op_weight_msg_close_group" ) // WeightedOperations returns all the operations from the module with their respective weights diff --git a/x/market/keeper/keys/v1beta1/key.go b/x/market/keeper/keys/v1beta1/key.go index e76fdbab41..8ddf847488 100644 --- a/x/market/keeper/keys/v1beta1/key.go +++ b/x/market/keeper/keys/v1beta1/key.go @@ -11,11 +11,10 @@ import ( var ( orderPrefix = []byte{0x01, 0x00} bidPrefix = []byte{0x02, 0x00} - leasePrefix = []byte{0x03, 0x00} // nolint: unused + leasePrefix = []byte{0x03, 0x00} //nolint:unused // this will be used in the future ) -// nolint: unused -func orderKey(id types.OrderID) []byte { +func orderKey(id types.OrderID) []byte { //nolint:unused // this will be used in the future buf := bytes.NewBuffer(orderPrefix) buf.Write([]byte(id.Owner)) if err := binary.Write(buf, binary.BigEndian, id.DSeq); err != nil { @@ -30,8 +29,7 @@ func orderKey(id types.OrderID) []byte { return buf.Bytes() } -// nolint: unused -func bidKey(id types.BidID) []byte { +func bidKey(id types.BidID) []byte { //nolint:unused // this will be used in the future buf := bytes.NewBuffer(bidPrefix) buf.Write([]byte(id.Owner)) if err := binary.Write(buf, binary.BigEndian, id.DSeq); err != nil { @@ -47,8 +45,7 @@ func bidKey(id types.BidID) []byte { return buf.Bytes() } -// nolint: unused -func leaseKey(id types.LeaseID) []byte { +func leaseKey(id types.LeaseID) []byte { //nolint:unused // this will be used in the future buf := bytes.NewBuffer(leasePrefix) buf.Write([]byte(id.Owner)) if err := binary.Write(buf, binary.BigEndian, id.DSeq); err != nil { diff --git a/x/market/simulation/operations.go b/x/market/simulation/operations.go index 1f6b270109..740336115c 100644 --- a/x/market/simulation/operations.go +++ b/x/market/simulation/operations.go @@ -21,10 +21,12 @@ import ( ) // Simulation operation weights constants +// + const ( - OpWeightMsgCreateBid = "op_weight_msg_create_bid" // nolint gosec - OpWeightMsgCloseBid = "op_weight_msg_close_bid" // nolint gosec - OpWeightMsgCloseLease = "op_weight_msg_close_lease" // nolint gosec + OpWeightMsgCreateBid = "op_weight_msg_create_bid" + OpWeightMsgCloseBid = "op_weight_msg_close_bid" + OpWeightMsgCloseLease = "op_weight_msg_close_lease" ) // WeightedOperations returns all the operations from the module with their respective weights diff --git a/x/provider/simulation/operations.go b/x/provider/simulation/operations.go index 4280fa28f7..a6998cc2d3 100644 --- a/x/provider/simulation/operations.go +++ b/x/provider/simulation/operations.go @@ -22,9 +22,11 @@ import ( ) // Simulation operation weights constants +// + const ( - OpWeightMsgCreate = "op_weight_msg_create" // nolint gosec - OpWeightMsgUpdate = "op_weight_msg_update" // nolint gosec + OpWeightMsgCreate = "op_weight_msg_create" + OpWeightMsgUpdate = "op_weight_msg_update" ) // WeightedOperations returns all the operations from the module with their respective weights @@ -62,7 +64,6 @@ func WeightedOperations( } // SimulateMsgCreate generates a MsgCreateProvider with random values -// nolint:funlen func SimulateMsgCreate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, @@ -115,7 +116,6 @@ func SimulateMsgCreate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper } // SimulateMsgUpdate generates a MsgUpdateProvider with random values -// nolint:funlen func SimulateMsgUpdate(ak govtypes.AccountKeeper, bk bankkeeper.Keeper, k keeper.IKeeper) simtypes.Operation { return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, From 51691c73b15c2d8ac630b40e5dd2ac7396b8c8b7 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 23 May 2023 11:39:23 +0700 Subject: [PATCH 4/5] convert if-else to switch --- x/cert/utils/key_pair_manager.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/x/cert/utils/key_pair_manager.go b/x/cert/utils/key_pair_manager.go index b98a34aa83..de19673639 100644 --- a/x/cert/utils/key_pair_manager.go +++ b/x/cert/utils/key_pair_manager.go @@ -267,14 +267,15 @@ func (kpm *keyPairManager) readImpl(fin io.Reader) ([]byte, []byte, []byte, erro // PKCS#8 header defined in RFC7468 section 11 - if block.Type == "ENCRYPTED PRIVATE KEY" { + switch { + case block.Type == "ENCRYPTED PRIVATE KEY": privKeyPlaintext, err = pemutil.DecryptPKCS8PrivateKey(block.Bytes, kpm.passwordBytes) - } else if block.Headers["Proc-Type"] == "4,ENCRYPTED" { + case block.Headers["Proc-Type"] == "4,ENCRYPTED": privKeyPlaintext, err = x509.DecryptPEMBlock(block, kpm.passwordBytes) //nolint:staticcheck // we need to use this for kube compatibility if errors.Is(err, x509.IncorrectPasswordError) { privKeyPlaintext, err = x509.DecryptPEMBlock(block, kpm.passwordLegacy) //nolint:staticcheck // we need to use this for kube compatibility } - } else { + default: return nil, nil, nil, errUnsupportedEncryptedPEM } From d683d3759a070b0d7c28263057b0d2d1ef997b62 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 23 May 2023 11:39:48 +0700 Subject: [PATCH 5/5] repository fully linted, ibc v4 set up --- .github/workflows/lint.yml | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..bf347e7ac1 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,47 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: false + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # args: --issues-exit-code=0 + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true then the all caching functionality will be complete disabled, + # takes precedence over all other caching options. + # skip-cache: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true