Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Aug 22, 2024
1 parent e41abcb commit 96bd7d2
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ linters:
disable-all: true
enable:
- dogsled
- exportloopref
- copyloopvar
- goconst
- gocritic
- gofumpt
Expand Down
2 changes: 1 addition & 1 deletion testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func RandomAccounts(r *rand.Rand, n int) []Account {

func CreateRandomTx(txCfg client.TxConfig, account Account, nonce, numberMsgs, timeout uint64, gasLimit uint64, fees ...sdk.Coin) (authsigning.Tx, error) {
msgs := make([]sdk.Msg, numberMsgs)
for i := 0; i < int(numberMsgs); i++ {
for i := 0; i < int(numberMsgs); i++ { //nolint:gosec
msgs[i] = &banktypes.MsgSend{
FromAddress: account.Address.String(),
ToAddress: account.Address.String(),
Expand Down
6 changes: 3 additions & 3 deletions x/feemarket/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (dfd feeMarketCheckDecorator) anteHandle(ctx sdk.Context, tx sdk.Tx, simula
payCoin = feeCoins[0]
}

feeGas := int64(feeTx.GetGas())
feeGas := int64(feeTx.GetGas()) //nolint:gosec

minGasPrice, err := dfd.feemarketKeeper.GetMinGasPrice(ctx, payCoin.GetDenom())
if err != nil {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (dfd feeMarketCheckDecorator) anteHandle(ctx sdk.Context, tx sdk.Tx, simula
return ctx, err
}

ctx = ctx.WithPriority(GetTxPriority(priorityFee, int64(gas), baseGasPrice))
ctx = ctx.WithPriority(GetTxPriority(priorityFee, int64(gas), baseGasPrice)) //nolint:gosec

return next(ctx, tx, simulate)
}
Expand Down Expand Up @@ -237,7 +237,7 @@ func CheckTxFee(ctx sdk.Context, gasPrice sdk.DecCoin, feeCoin sdk.Coin, feeGas

// Determine the required fees by multiplying each required minimum gas
// price by the gas, where fee = ceil(minGasPrice * gas).
gasConsumed := int64(ctx.GasMeter().GasConsumed())
gasConsumed := int64(ctx.GasMeter().GasConsumed()) //nolint:gosec
gcDec := sdkmath.LegacyNewDec(gasConsumed)
glDec := sdkmath.LegacyNewDec(feeGas)

Expand Down
4 changes: 2 additions & 2 deletions x/feemarket/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestAnteHandleMock(t *testing.T) {
// Same data for every test case
gasLimit := antesuite.NewTestGasLimit()

validFeeAmount := types.DefaultMinBaseGasPrice.MulInt64(int64(gasLimit))
validFeeAmount := types.DefaultMinBaseGasPrice.MulInt64(int64(gasLimit)) //nolint:gosec
validFee := sdk.NewCoins(sdk.NewCoin("stake", validFeeAmount.TruncateInt()))
validFeeDifferentDenom := sdk.NewCoins(sdk.NewCoin("atom", math.Int(validFeeAmount)))

Expand Down Expand Up @@ -210,7 +210,7 @@ func TestAnteHandle(t *testing.T) {
// Same data for every test case
gasLimit := antesuite.NewTestGasLimit()

validFeeAmount := types.DefaultMinBaseGasPrice.MulInt64(int64(gasLimit))
validFeeAmount := types.DefaultMinBaseGasPrice.MulInt64(int64(gasLimit)) //nolint:gosec
validFee := sdk.NewCoins(sdk.NewCoin("stake", validFeeAmount.TruncateInt()))
validFeeDifferentDenom := sdk.NewCoins(sdk.NewCoin("atom", math.Int(validFeeAmount)))

Expand Down
3 changes: 2 additions & 1 deletion x/feemarket/ante/suite/suite.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package suite

import (
storetypes "cosmossdk.io/store/types"
"testing"

storetypes "cosmossdk.io/store/types"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

txsigning "cosmossdk.io/x/tx/signing"
Expand Down
8 changes: 4 additions & 4 deletions x/feemarket/fuzz/aimd_eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ func TestAIMDGasPrice(t *testing.T) {
// EIP-1559 fee market implementation.
func CreateRandomAIMDParams(t *rapid.T) types.Params {
a := rapid.Uint64Range(1, 1000).Draw(t, "alpha")
alpha := math.LegacyNewDec(int64(a)).Quo(math.LegacyNewDec(1000))
alpha := math.LegacyNewDec(int64(a)).Quo(math.LegacyNewDec(1000)) //nolint:gosec

b := rapid.Uint64Range(50, 99).Draw(t, "beta")
beta := math.LegacyNewDec(int64(b)).Quo(math.LegacyNewDec(100))
beta := math.LegacyNewDec(int64(b)).Quo(math.LegacyNewDec(100)) //nolint:gosec

g := rapid.Uint64Range(10, 50).Draw(t, "gamma")
gamma := math.LegacyNewDec(int64(g)).Quo(math.LegacyNewDec(100))
gamma := math.LegacyNewDec(int64(g)).Quo(math.LegacyNewDec(100)) //nolint:gosec

d := rapid.Uint64Range(1, 1000).Draw(t, "delta")
delta := math.LegacyNewDec(int64(d)).Quo(math.LegacyNewDec(1000))
delta := math.LegacyNewDec(int64(d)).Quo(math.LegacyNewDec(1000)) //nolint:gosec

targetBlockUtilization := rapid.Uint64Range(1, 30_000_000).Draw(t, "target_block_utilization")
maxBlockUtilization := rapid.Uint64Range(targetBlockUtilization, targetBlockUtilization*5).Draw(t, "max_block_utilization")
Expand Down
6 changes: 3 additions & 3 deletions x/feemarket/fuzz/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func TestGasPrice(t *testing.T) {
// EIP-1559 fee market implementation.
func CreateRandomParams(t *rapid.T) types.Params {
a := rapid.Uint64Range(1, 1000).Draw(t, "alpha")
alpha := math.LegacyNewDec(int64(a)).Quo(math.LegacyNewDec(1000))
alpha := math.LegacyNewDec(int64(a)).Quo(math.LegacyNewDec(1000)) //nolint:gosec

b := rapid.Uint64Range(50, 99).Draw(t, "beta")
beta := math.LegacyNewDec(int64(b)).Quo(math.LegacyNewDec(100))
beta := math.LegacyNewDec(int64(b)).Quo(math.LegacyNewDec(100)) //nolint:gosec

g := rapid.Uint64Range(10, 50).Draw(t, "gamma")
gamma := math.LegacyNewDec(int64(g)).Quo(math.LegacyNewDec(100))
gamma := math.LegacyNewDec(int64(g)).Quo(math.LegacyNewDec(100)) //nolint:gosec

maxBlockUtilization := rapid.Uint64Range(2, 30_000_000).Draw(t, "max_block_utilization")

Expand Down
2 changes: 1 addition & 1 deletion x/feemarket/post/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (dfd FeeMarketDeductDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simul
payCoin = feeCoins[0]
}

feeGas := int64(feeTx.GetGas())
feeGas := int64(feeTx.GetGas()) //nolint:gosec

minGasPrice, err := dfd.feemarketKeeper.GetMinGasPrice(ctx, payCoin.GetDenom())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/feemarket/types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (s *State) GetAverageUtilization(params Params) math.LegacyDec {

// ValidateBasic performs basic validation on the state.
func (s *State) ValidateBasic() error {
if s.Window == nil || len(s.Window) == 0 {
if s.Window == nil {
return fmt.Errorf("block utilization window cannot be nil or empty")
}

Expand Down
4 changes: 2 additions & 2 deletions x/feemarket/types/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestState_UpdateBaseGasPrice(t *testing.T) {
expectedLR := prevLR.Add(params.Alpha)
expectedLRAdjustment := (expectedLR.Mul(expectedUtilization)).Add(math.LegacyOneDec())

expectedNetUtilization := math.LegacyNewDec(-1 * int64(params.TargetBlockUtilization()) / 2)
expectedNetUtilization := math.LegacyNewDec(-1 * int64(params.TargetBlockUtilization()) / 2) //nolint:gosec
deltaDiff := expectedNetUtilization.Mul(params.Delta)
expectedGasPrice := prevBF.Mul(expectedLRAdjustment).Add(deltaDiff)

Expand Down Expand Up @@ -381,7 +381,7 @@ func TestState_UpdateBaseGasPrice(t *testing.T) {
expectedLR := prevLR.Add(params.Alpha)
expectedLRAdjustment := (expectedLR.Mul(expectedUtilization)).Add(math.LegacyOneDec())

expectedNetUtilization := math.LegacyNewDec(int64(params.MaxBlockUtilization) / 4)
expectedNetUtilization := math.LegacyNewDec(int64(params.MaxBlockUtilization) / 4) //nolint:gosec
deltaDiff := expectedNetUtilization.Mul(params.Delta)
expectedGasPrice := prevBGS.Mul(expectedLRAdjustment).Add(deltaDiff)
require.Equal(t, expectedLR, lr)
Expand Down

0 comments on commit 96bd7d2

Please sign in to comment.