diff --git a/.golangci.yml b/.golangci.yml index 03eff284c..f5779c294 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,7 +10,7 @@ linters: - deadcode - depguard - dogsled - # - errcheck + - errcheck - goconst - gocritic - gofmt diff --git a/app/app.go b/app/app.go index 1d1a358c1..f7d2ad341 100644 --- a/app/app.go +++ b/app/app.go @@ -990,14 +990,14 @@ func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) { func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey store.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) - paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) - paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) - paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) - paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) - paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1types.ParamKeyTable()) - paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) + paramsKeeper.Subspace(authtypes.ModuleName).WithKeyTable(authtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(banktypes.ModuleName).WithKeyTable(banktypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(stakingtypes.ModuleName).WithKeyTable(stakingtypes.ParamKeyTable()) //nolint:staticcheck,nolintlint + paramsKeeper.Subspace(minttypes.ModuleName).WithKeyTable(minttypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(distrtypes.ModuleName).WithKeyTable(distrtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1types.ParamKeyTable()) //nolint:staticcheck + paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) //nolint:staticcheck paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(icacontrollertypes.SubModuleName) diff --git a/app/export.go b/app/export.go index eaf7e8d59..4106d17a1 100644 --- a/app/export.go +++ b/app/export.go @@ -104,7 +104,7 @@ func (app *PstakeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) app.DistrKeeper.SetFeePool(ctx, feePool) - app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + _ = app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) return false }) @@ -116,8 +116,8 @@ func (app *PstakeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs } delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress) - app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) - app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) + _ = app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) + _ = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) } // reset context height diff --git a/docker/exposer/node.go b/docker/exposer/node.go index 3062f643c..fc898d924 100644 --- a/docker/exposer/node.go +++ b/docker/exposer/node.go @@ -38,13 +38,13 @@ func executeCommand(name string, arg ...string) string { func getNodeIDHandler(w http.ResponseWriter, r *http.Request) { homeDir := os.Getenv(homeDirKey) clientName := os.Getenv(clientNameKey) - io.WriteString(w, executeCommand(clientName, "tendermint", "show-node-id", "--home", homeDir)) + _, _ = io.WriteString(w, executeCommand(clientName, "tendermint", "show-node-id", "--home", homeDir)) } func getPubKeyHandler(w http.ResponseWriter, r *http.Request) { homeDir := os.Getenv(homeDirKey) clientName := os.Getenv(clientNameKey) - io.WriteString(w, executeCommand(clientName, "tendermint", "show-validator", "--home", homeDir)) + _, _ = io.WriteString(w, executeCommand(clientName, "tendermint", "show-validator", "--home", homeDir)) } func getGenesisHandler(w http.ResponseWriter, r *http.Request) { @@ -59,7 +59,7 @@ func getGenesisHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") - w.Write(byteValue) + _, _ = w.Write(byteValue) } func main() { diff --git a/docker/pstake/Dockerfile b/docker/pstake/Dockerfile index fb02e27c7..298bffd92 100644 --- a/docker/pstake/Dockerfile +++ b/docker/pstake/Dockerfile @@ -1,7 +1,7 @@ FROM golang:1.19-alpine AS build-env # Set up dependencies -ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 +RUN apk add --no-cache curl make git libc-dev bash gcc linux-headers eudev-dev python3 # Set working directory for the build WORKDIR /go/src/github.com/persistenceOne/pstake-native @@ -10,17 +10,18 @@ WORKDIR /go/src/github.com/persistenceOne/pstake-native COPY . . # Install minimum necessary dependencies, build Cosmos SDK, remove packages -RUN apk add --no-cache $PACKAGES && \ - make install +RUN make install # Final image FROM alpine:edge # Install ca-certificates -RUN apk add --update ca-certificates jq bash curl +RUN apk add --update ca-certificates jq bash curl perl + +# Set working directory WORKDIR /root # Copy over binaries from the build-env COPY --from=build-env /go/bin/pstaked /usr/bin/pstaked -EXPOSE 26657 +EXPOSE 26657 \ No newline at end of file diff --git a/x/lscosmos/client/cli/query.go b/x/lscosmos/client/cli/query.go index 9b3ef3a23..48a1dcadb 100644 --- a/x/lscosmos/client/cli/query.go +++ b/x/lscosmos/client/cli/query.go @@ -56,7 +56,7 @@ func CmdQueryHostChainParams() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.HostChainParams(context.Background(), &types.QueryHostChainParamsRequest{}) if err != nil { @@ -81,7 +81,7 @@ func CmdQueryAllState() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.AllState(context.Background(), &types.QueryAllStateRequest{}) if err != nil { @@ -106,7 +106,7 @@ func CmdQueryDelegationState() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.DelegationState(context.Background(), &types.QueryDelegationStateRequest{}) if err != nil { @@ -131,7 +131,7 @@ func CmdQueryAllowListedValidators() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.AllowListedValidators(context.Background(), &types.QueryAllowListedValidatorsRequest{}) if err != nil { @@ -156,7 +156,7 @@ func CmdQueryCValue() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.CValue(context.Background(), &types.QueryCValueRequest{}) if err != nil { @@ -181,7 +181,7 @@ func CmdQueryModuleState() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.ModuleState(context.Background(), &types.QueryModuleStateRequest{}) if err != nil { @@ -206,7 +206,7 @@ func CmdQueryIBCTransientStore() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.IBCTransientStore(context.Background(), &types.QueryIBCTransientStoreRequest{}) if err != nil { @@ -231,7 +231,7 @@ func CmdQueryUnclaimed() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck delegatorAddress, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -261,7 +261,7 @@ func CmdQueryFailedUnbondings() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck _, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -291,7 +291,7 @@ func CmdQueryPendingUnbondings() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck _, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -321,7 +321,7 @@ func CmdQueryUnbondingEpoch() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck epochNumber, err := strconv.ParseInt(args[0], 10, 64) if err != nil { @@ -351,7 +351,7 @@ func CmdQueryHostAccountUndelegation() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck epochNumber, err := strconv.ParseInt(args[0], 10, 64) if err != nil { @@ -381,7 +381,7 @@ func CmdQueryDelegatorUnbodingEpochEntry() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck delegatorAddress, err := sdk.AccAddressFromBech32(args[0]) if err != nil { @@ -416,7 +416,7 @@ func CmdQueryHostAccounts() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.HostAccounts(context.Background(), &types.QueryHostAccountsRequest{}) if err != nil { @@ -441,7 +441,7 @@ func CmdQueryDepositModuleAccount() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.DepositModuleAccount(context.Background(), &types.QueryDepositModuleAccountRequest{}) if err != nil { @@ -466,7 +466,7 @@ func CmdDelegatorUnbondingEpochEntries() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck delegatorAddress, err := sdk.AccAddressFromBech32(args[0]) if err != nil { diff --git a/x/lscosmos/client/cli/query_params.go b/x/lscosmos/client/cli/query_params.go index 5439f5463..9583b6291 100644 --- a/x/lscosmos/client/cli/query_params.go +++ b/x/lscosmos/client/cli/query_params.go @@ -18,7 +18,7 @@ func CmdQueryParams() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) //nolint:staticcheck res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) if err != nil { diff --git a/x/lscosmos/keeper/governance_proposal.go b/x/lscosmos/keeper/governance_proposal.go index 829699802..bf1103c59 100644 --- a/x/lscosmos/keeper/governance_proposal.go +++ b/x/lscosmos/keeper/governance_proposal.go @@ -6,16 +6,16 @@ import ( ) // HandleMinDepositAndFeeChangeProposal changes host chain params for desired min-deposit and protocol fee -func HandleMinDepositAndFeeChangeProposal(ctx sdk.Context, k Keeper, content types.MinDepositAndFeeChangeProposal) error { +func HandleMinDepositAndFeeChangeProposal(ctx sdk.Context, k Keeper, content types.MinDepositAndFeeChangeProposal) error { //nolint:staticcheck return types.ErrDeprecated } // HandlePstakeFeeAddressChangeProposal changes fee collector address -func HandlePstakeFeeAddressChangeProposal(ctx sdk.Context, k Keeper, content types.PstakeFeeAddressChangeProposal) error { +func HandlePstakeFeeAddressChangeProposal(ctx sdk.Context, k Keeper, content types.PstakeFeeAddressChangeProposal) error { //nolint:staticcheck return types.ErrDeprecated } // HandleAllowListedValidatorSetChangeProposal changes the allowList validator set -func HandleAllowListedValidatorSetChangeProposal(ctx sdk.Context, k Keeper, content types.AllowListedValidatorSetChangeProposal) error { +func HandleAllowListedValidatorSetChangeProposal(ctx sdk.Context, k Keeper, content types.AllowListedValidatorSetChangeProposal) error { //nolint:staticcheck return types.ErrDeprecated } diff --git a/x/lscosmos/keeper/grpc_query.go b/x/lscosmos/keeper/grpc_query.go index 8cc2f83c8..60775830b 100644 --- a/x/lscosmos/keeper/grpc_query.go +++ b/x/lscosmos/keeper/grpc_query.go @@ -7,7 +7,7 @@ import ( "github.com/persistenceOne/pstake-native/v2/x/lscosmos/types" ) -var _ types.QueryServer = Keeper{} +var _ types.QueryServer = Keeper{} //nolint:staticcheck // AllState returns genesis state func (k Keeper) AllState(c context.Context, request *types.QueryAllStateRequest) (*types.QueryAllStateResponse, error) { diff --git a/x/lscosmos/keeper/migrate_module.go b/x/lscosmos/keeper/migrate_module.go index 186966773..07a66d254 100644 --- a/x/lscosmos/keeper/migrate_module.go +++ b/x/lscosmos/keeper/migrate_module.go @@ -36,7 +36,7 @@ func (k Keeper) Migrate(ctx sdk.Context) error { } // set validators - var validators []*liquidstakeibctypes.Validator + var validators []*liquidstakeibctypes.Validator //nolint:prealloc for _, delval := range delegationState.HostAccountDelegations { allowlistedVal := types.AllowListedValidator{ ValidatorAddress: delval.ValidatorAddress, diff --git a/x/lscosmos/keeper/msg_server.go b/x/lscosmos/keeper/msg_server.go index 74f91d1e2..01b3d5206 100644 --- a/x/lscosmos/keeper/msg_server.go +++ b/x/lscosmos/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "github.com/persistenceOne/pstake-native/v2/x/lscosmos/types" ) @@ -11,11 +12,11 @@ type msgServer struct { // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { +func NewMsgServerImpl(keeper Keeper) types.MsgServer { //nolint:staticcheck return &msgServer{Keeper: keeper} } -var _ types.MsgServer = msgServer{} +var _ types.MsgServer = msgServer{} //nolint:staticcheck // LiquidStake defines a method for liquid staking tokens func (m msgServer) LiquidStake(goCtx context.Context, msg *types.MsgLiquidStake) (*types.MsgLiquidStakeResponse, error) { diff --git a/x/lscosmos/module.go b/x/lscosmos/module.go index 30cba0fc0..66e9846b4 100644 --- a/x/lscosmos/module.go +++ b/x/lscosmos/module.go @@ -74,7 +74,10 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { // this line is used by starport scaffolding # 2 - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:staticcheck + if err != nil { + panic(err) + } } @@ -127,8 +130,8 @@ func (AppModule) QuerierRoute() string { return types.QuerierRoute } // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) //TODO remove in next version, kept to give proper error messages. - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) //nolint:staticcheck //TODO remove in next version, kept to give proper error messages. + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) //nolint:staticcheck } // RegisterInvariants registers the capability module's invariants. diff --git a/x/lscosmos/types/genesis.go b/x/lscosmos/types/genesis.go index 1e53b9af1..81f2cfda2 100644 --- a/x/lscosmos/types/genesis.go +++ b/x/lscosmos/types/genesis.go @@ -3,7 +3,6 @@ package types // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), ModuleEnabled: false, diff --git a/x/lspersistence/keeper/genesis.go b/x/lspersistence/keeper/genesis.go index 6d8cb896f..05a5d940e 100644 --- a/x/lspersistence/keeper/genesis.go +++ b/x/lspersistence/keeper/genesis.go @@ -17,7 +17,10 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { if genState.Params.WhitelistedValidators == nil || len(genState.Params.WhitelistedValidators) == 0 { genState.Params.WhitelistedValidators = []types.WhitelistedValidator{} } - k.SetParams(ctx, genState.Params) + err := k.SetParams(ctx, genState.Params) + if err != nil { + panic(err) + } for _, lv := range genState.LiquidValidators { k.SetLiquidValidator(ctx, lv) diff --git a/x/lspersistence/keeper/msg_server.go b/x/lspersistence/keeper/msg_server.go index f4be058f6..687d71362 100644 --- a/x/lspersistence/keeper/msg_server.go +++ b/x/lspersistence/keeper/msg_server.go @@ -90,7 +90,10 @@ func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam return nil, errorsmod.Wrapf(sdkerrors.ErrorInvalidSigner, "invalid authority; expected %s or %s, got %s", k.authority, params.AdminAddress, msg.Authority) } - k.SetParams(ctx, msg.Params) + err := k.SetParams(ctx, msg.Params) + if err != nil { + return nil, err + } ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( diff --git a/x/lspersistence/simulation/proposals.go b/x/lspersistence/simulation/proposals.go index 51fd91235..33120d5c9 100644 --- a/x/lspersistence/simulation/proposals.go +++ b/x/lspersistence/simulation/proposals.go @@ -68,7 +68,7 @@ func SimulateAddWhitelistValidatorsProposal(sk types.StakingKeeper, k keeper.Kee TargetWeight: genTargetWeight(r), }) // manually set params for simulation - k.SetParams(ctx, params) + _ = k.SetParams(ctx, params) break } } @@ -87,7 +87,7 @@ func SimulateUpdateWhitelistValidatorsProposal(sk types.StakingKeeper, k keeper. if params.WhitelistedValidators[i].ValidatorAddress == targetVal.OperatorAddress { params.WhitelistedValidators[i].TargetWeight = genTargetWeight(r) // manually set params for simulation - k.SetParams(ctx, params) + _ = k.SetParams(ctx, params) break } } @@ -111,7 +111,7 @@ func SimulateDeleteWhitelistValidatorsProposal(sk types.StakingKeeper, k keeper. if params.WhitelistedValidators[i].ValidatorAddress == targetVal.OperatorAddress { params.WhitelistedValidators[i].TargetWeight = genTargetWeight(r) params.WhitelistedValidators = remove(params.WhitelistedValidators, i) - k.SetParams(ctx, params) + _ = k.SetParams(ctx, params) break } }