Skip to content

chore: fix lints and finalize ci to pass #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 26, 2025
Merged
  •  
  •  
  •  
105 changes: 78 additions & 27 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,112 @@
run:
tests: true
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
concurrency: 4
go: '1.23'

issues:
exclude-dirs:
- x/evm/core

linters:
disable-all: true
enable:
- dogsled
- dupl
- errcheck
- copyloopvar
- gci
- goconst
- gocritic
- gofumpt
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- copyloopvar
- nolintlint
- revive
- staticcheck
- stylecheck
- typecheck
- thelper
- unconvert
- unparam
- unused
- nolintlint
- asciicheck
- gofumpt
- gomodguard

issues:
exclude-rules:
- text: 'Use of weak random number generator'
linters:
- gosec
- text: 'comment on exported var'
linters:
- golint
- text: "don't use an underscore in package name"
linters:
- golint
- 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
exclude-dirs:
- x/vm/core

max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
gci:
custom-order: true
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- blank # blank imports
- dot # dot imports
- prefix(github.com/cometbft/cometbft) # comet
- prefix(github.com/cosmos) # cosmos org
- prefix(cosmossdk.io) # new modules
- prefix(github.com/cosmos/cosmos-sdk) # cosmos sdk
- prefix(github.com/CosmWasm/wasmd) # cosmwasm
- prefix(github.com/cosmos/gaia) # Gaia
dogsled:
max-blank-identifiers: 3
golint:
min-confidence: 0
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
misspell:
locale: US
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
gomodguard:
blocked:
versions: # List of blocked module version constraints
- https://github.com/etcd-io/etcd: # Blocked module with version constraint
version: ">= 3.4.10 || ~3.3.23" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional)
- https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint
version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional)
revive:
ignore-generated-header: true
severity: warning
rules:
- name: unused-parameter
disabled: true
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ benchmark:
###############################################################################
### Linting ###
###############################################################################
golangci_lint_cmd=golangci-lint
golangci_version=v1.64.8

lint: lint-go lint-python lint-contracts

lint-go:
gofumpt -l .
golangci-lint run --out-format=tab
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run --timeout=10m

lint-python:
find . -name "*.py" -type f -not -path "*/node_modules/*" | xargs pylint
Expand All @@ -92,7 +95,8 @@ lint-contracts:
solhint contracts/**/*.sol

lint-fix:
golangci-lint run --fix --out-format=tab --issues-exit-code=0
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@$(golangci_lint_cmd) run --timeout=10m --fix

lint-fix-contracts:
solhint --fix contracts/**/*.sol
Expand Down
1 change: 1 addition & 0 deletions ante/cosmos/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/authz"
Expand Down
22 changes: 13 additions & 9 deletions ante/cosmos/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ import (
"testing"
"time"

"cosmossdk.io/math"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"

abci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

cosmosante "github.com/cosmos/evm/ante/cosmos"
"github.com/cosmos/evm/testutil"
"github.com/cosmos/evm/testutil/integration/common/factory"
"github.com/cosmos/evm/testutil/integration/os/network"
utiltx "github.com/cosmos/evm/testutil/tx"
evmtypes "github.com/cosmos/evm/x/vm/types"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"

"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

func TestAuthzLimiterDecorator(t *testing.T) {
Expand Down
17 changes: 10 additions & 7 deletions ante/cosmos/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ package cosmos
import (
"fmt"

ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/ethereum/go-ethereum/signer/core/apitypes"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/crypto/ethsecp256k1"
"github.com/cosmos/evm/ethereum/eip712"
"github.com/cosmos/evm/types"

errorsmod "cosmossdk.io/errors"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -13,13 +23,6 @@ import (
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/crypto/ethsecp256k1"
"github.com/cosmos/evm/ethereum/eip712"
"github.com/cosmos/evm/types"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/ethereum/go-ethereum/signer/core/apitypes"
)

var evmCodec codec.ProtoCodecMarshaler
Expand Down
5 changes: 3 additions & 2 deletions ante/cosmos/min_gas_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"math/big"
"slices"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
evmtypes "github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
evmtypes "github.com/cosmos/evm/x/vm/types"
)

// MinGasPriceDecorator will check if the transaction's fee is at least as large
Expand Down
6 changes: 3 additions & 3 deletions ante/cosmos/min_gas_price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package cosmos_test
import (
"fmt"

cosmosante "github.com/cosmos/evm/ante/cosmos"
"github.com/cosmos/evm/testutil"
"github.com/cosmos/evm/testutil/constants"
testutiltx "github.com/cosmos/evm/testutil/tx"

"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
cosmosante "github.com/cosmos/evm/ante/cosmos"
"github.com/cosmos/evm/testutil"
testutiltx "github.com/cosmos/evm/testutil/tx"
)

var execTypes = []struct {
Expand Down
4 changes: 3 additions & 1 deletion ante/cosmos/reject_msgs.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cosmos

import (
evmtypes "github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
evmtypes "github.com/cosmos/evm/x/vm/types"
)

// RejectMessagesDecorator prevents invalid msg types from being executed.
Expand Down
3 changes: 2 additions & 1 deletion ante/cosmos/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package cosmos_test
import (
"testing"

"github.com/cosmos/evm/ante/testutils"
"github.com/stretchr/testify/suite"

"github.com/cosmos/evm/ante/testutils"
)

type AnteTestSuite struct {
Expand Down
6 changes: 4 additions & 2 deletions ante/cosmos/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import (
"context"
"time"

"github.com/cosmos/evm/ante/testutils"
"github.com/cosmos/evm/crypto/ethsecp256k1"

sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/evm/ante/testutils"
"github.com/cosmos/evm/crypto/ethsecp256k1"
)

func (suite *AnteTestSuite) CreateTestCosmosTxBuilder(gasPrice sdkmath.Int, denom string, msgs ...sdk.Msg) client.TxBuilder {
Expand Down
6 changes: 4 additions & 2 deletions ante/evm/01_setup_ctx.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package evm

import (
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
evmante "github.com/cosmos/evm/x/vm/ante"

errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"

sdktypes "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
evmante "github.com/cosmos/evm/x/vm/ante"
)

var _ sdktypes.AnteDecorator = &EthSetupContextDecorator{}
Expand Down
5 changes: 3 additions & 2 deletions ante/evm/01_setup_ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (

evmante "github.com/cosmos/evm/ante/evm"
"github.com/cosmos/evm/testutil"
testutiltx "github.com/cosmos/evm/testutil/tx"
evmtypes "github.com/cosmos/evm/x/vm/types"

storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"
testutiltx "github.com/cosmos/evm/testutil/tx"
evmtypes "github.com/cosmos/evm/x/vm/types"
)

func (suite *AnteTestSuite) TestEthSetupContextDecorator() {
Expand Down
1 change: 1 addition & 0 deletions ante/evm/02_mempool_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package evm
import (
errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"

errortypes "github.com/cosmos/cosmos-sdk/types/errors"
)

Expand Down
4 changes: 3 additions & 1 deletion ante/evm/02_mempool_fee_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package evm_test

import (
"github.com/cosmos/evm/ante/evm"

sdkmath "cosmossdk.io/math"

errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/evm/ante/evm"
)

func (suite *EvmAnteTestSuite) TestMempoolFee() {
Expand Down
1 change: 1 addition & 0 deletions ante/evm/03_global_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package evm
import (
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

errortypes "github.com/cosmos/cosmos-sdk/types/errors"
)

Expand Down
Loading
Loading