Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
chore: use math.Int instead of math.Int and apply linting (cosmos…
Browse files Browse the repository at this point in the history
…#12702)

* linting round

* fix changelog

* revert docs changes

* Update CHANGELOG.md

* revert an accidental change to security.md

* Update simapp/integration/client/grpc/tmservice/service_test.go

Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
faddat and julienrbrt authored Jul 25, 2022
1 parent e7bd668 commit 5decd22
Show file tree
Hide file tree
Showing 84 changed files with 310 additions and 263 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ run:
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
Expand All @@ -23,11 +22,9 @@ linters:
- nakedret
- nolintlint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused

issues:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [#12702](https://github.com/cosmos/cosmos-sdk/pull/12702) Linting and tidiness, fixed two minor security warnings.
* [#12668](https://github.com/cosmos/cosmos-sdk/pull/12668) Add `authz_msg_index` event attribute to message events emitted when executing via `MsgExec` through `x/authz`.
* [#12634](https://github.com/cosmos/cosmos-sdk/pull/12634) Move `sdk.Dec` to math package.
* [#12596](https://github.com/cosmos/cosmos-sdk/pull/12596) Remove all imports of the non-existent gogo/protobuf v1.3.3 to ease downstream use and go workspaces.
Expand Down
5 changes: 3 additions & 2 deletions server/grpc/grpc_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func StartGRPCWeb(grpcSrv *grpc.Server, config config.Config) (*http.Server, err

wrappedServer := grpcweb.WrapServer(grpcSrv, options...)
grpcWebSrv := &http.Server{
Addr: config.GRPCWeb.Address,
Handler: wrappedServer,
Addr: config.GRPCWeb.Address,
Handler: wrappedServer,
ReadHeaderTimeout: 500000000, // added because G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
}

errCh := make(chan error)
Expand Down
3 changes: 1 addition & 2 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
"github.com/cosmos/cosmos-sdk/server/rosetta"
Expand Down Expand Up @@ -502,7 +501,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
return WaitForQuitSignals()
}

func startTelemetry(cfg config.Config) (*telemetry.Metrics, error) {
func startTelemetry(cfg serverconfig.Config) (*telemetry.Metrics, error) {
if !cfg.Telemetry.Enabled {
return nil, nil
}
Expand Down
1 change: 0 additions & 1 deletion simapp/integration/client/grpc/tmservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type IntegrationTestSuite struct {
}

func TestIntegrationTestSuite(t *testing.T) {
//t.Skip() // to be re-enabled in https://github.com/cosmos/cosmos-sdk/pull/12482/

suite.Run(t, new(IntegrationTestSuite))
}
Expand Down
3 changes: 2 additions & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"path/filepath"

"cosmossdk.io/math"
"github.com/spf13/cobra"
tmconfig "github.com/tendermint/tendermint/config"
tmos "github.com/tendermint/tendermint/libs/os"
Expand Down Expand Up @@ -297,7 +298,7 @@ func initTestnetFiles(
sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
math.OneInt(),
)
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

sdkmath "cosmossdk.io/math"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
Expand Down Expand Up @@ -88,7 +88,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
panic(err)
}
// compute not bonded balance
notBondedTokens := sdk.ZeroInt()
notBondedTokens := math.ZeroInt()
for _, val := range stakingState.Validators {
if val.Status != stakingtypes.Unbonded {
continue
Expand Down Expand Up @@ -149,11 +149,11 @@ func AppStateRandomizedFn(
// number of bonded accounts
var (
numInitiallyBonded int64
initialStake sdkmath.Int
initialStake math.Int
)
appParams.GetOrGenerate(
cdc, simappparams.StakePerAccount, &initialStake, r,
func(r *rand.Rand) { initialStake = sdkmath.NewInt(r.Int63n(1e12)) },
func(r *rand.Rand) { initialStake = math.NewInt(r.Int63n(1e12)) },
)
appParams.GetOrGenerate(
cdc, simappparams.InitiallyBondedValidators, &numInitiallyBonded, r,
Expand Down
3 changes: 1 addition & 2 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
"github.com/cosmos/cosmos-sdk/testutil/mock"
"github.com/cosmos/cosmos-sdk/testutil/network"
Expand Down Expand Up @@ -366,7 +365,7 @@ func NewTestNetworkFixture() network.TestFixture {
Amino: encodingCfg.Amino,
InterfaceRegistry: encodingCfg.InterfaceRegistry,
}
appCtr := func(val testutil.Validator) servertypes.Application {
appCtr := func(val testutil.Validator) types.Application {
return NewSimApp(
val.GetCtx().Logger, dbm.NewMemDB(), nil, true,
encodingCfg,
Expand Down
1 change: 1 addition & 0 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ var _ types.Iterator = (*iavlIterator)(nil)
// newIAVLIterator will create a new iavlIterator.
// CONTRACT: Caller must release the iavlIterator, as each one creates a new
// goroutine.
//nolint:deadcode,unused
func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator {
iterator, err := tree.Iterator(start, end, ascending)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
math.OneInt(),
)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion testutil/sims/app_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
dbm "github.com/tendermint/tm-db"

"cosmossdk.io/depinject"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -199,7 +200,7 @@ func GenesisStateWithValSet(codec codec.Codec, genesisState map[string]json.RawM
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
MinSelfDelegation: sdk.ZeroInt(),
MinSelfDelegation: math.ZeroInt(),
}
validators = append(validators, validator)
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec()))
Expand Down
Loading

0 comments on commit 5decd22

Please sign in to comment.