Skip to content

Commit

Permalink
chore(*): bump golangci-lint (#1799)
Browse files Browse the repository at this point in the history
Bump golangci-lint from v1.50.1 to v1.60.3

Add `ToInt*` int conversion functions to `umath` package.

issue: none

---------

Co-authored-by: Aayush Rajasekaran <arajasek94@gmail.com>
  • Loading branch information
corverroos and arajasek authored Sep 3, 2024
1 parent 369b6f1 commit d2bb0bf
Show file tree
Hide file tree
Showing 37 changed files with 297 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.59.1
version: v1.60.3
# Verbose with color. Just fail, don't fix issues. Use both annotations and normal output.
args: -v --color=always --fix=false --out-format=colored-line-number,github-actions
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ linters:
- ireturn # Too many false positives
- mnd # Too many false positives
- prealloc # Too many false positives
- predeclared # Too strict
- tagliatelle # Too strict
- varnamelen # False positives
- wsl # Way to strict and opinionated
- lll # Disable rigid line length limit

# Disable deprecated/archived linters (alphabetical order)
- execinquery
- exportloopref
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
# Then run code validators (on the formatted code)

- repo: https://github.com/golangci/golangci-lint # See .golangci.yml for config
rev: v1.59.1
rev: v1.60.3
hooks:
- id: golangci-lint
require_serial: true # Don't run this in parallel
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/omni-network/omni/lib/evmchain"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/netconf"
"github.com/omni-network/omni/lib/umath"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -169,7 +170,7 @@ func createValidator(ctx context.Context, cfg createValConfig) error {
if err != nil {
return err
}
txOpts.Value = new(big.Int).Mul(big.NewInt(int64(cfg.SelfDelegation)), big.NewInt(params.Ether)) // Send self-delegation
txOpts.Value = new(big.Int).Mul(umath.NewBigInt(cfg.SelfDelegation), big.NewInt(params.Ether)) // Send self-delegation

consPubkey, err := cfg.ConsensusPubKey()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion e2e/app/erc20faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/netconf"
"github.com/omni-network/omni/lib/umath"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -41,7 +42,7 @@ func RunERC20Faucet(ctx context.Context, def Definition, cfg RunERC20FaucetConfi
network := networkFromDef(def)
addr := common.HexToAddress(cfg.AddrToFund)
tokenAddr := contracts.Token(networkID)
amt := new(big.Int).Mul(big.NewInt(int64(cfg.Amount)), big.NewInt(params.Ether))
amt := new(big.Int).Mul(umath.NewBigInt(cfg.Amount), big.NewInt(params.Ether))

funder, err := omnitoken.InitialSupplyRecipient(networkID)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions e2e/docker/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
const (
ipPrefix = "10.186.73." // See github.com/cometbft/cometbft/test/e2e/pkg for reference
startIPSuffix = 100
startPort = 8000
startPort = uint32(8000)
)

var localhost = net.ParseIP("127.0.0.1") //nolint:gochecknoglobals // Static IP
Expand All @@ -37,7 +37,7 @@ func NewInfraData(manifest types.Manifest) (types.InfrastructureData, error) {
port := startPort
nextPort := func() uint32 {
defer func() { port++ }()
return uint32(port)
return port
}

for name := range manifest.OmniEVMs() {
Expand Down
4 changes: 2 additions & 2 deletions e2e/fbproxy/app/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package app
import (
"context"
"encoding/json"
"math/big"

"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/umath"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand All @@ -24,7 +24,7 @@ type txSigner interface {
func NewSendTxMiddleware(txsigner txSigner, chainID uint64) Middleware {
// sigHelper used to create signature hash and recover tx sender,
// not for actual signing which is left to txsigner
sigHelper := types.LatestSignerForChainID(big.NewInt(int64(chainID)))
sigHelper := types.LatestSignerForChainID(umath.NewBigInt(chainID))

return func(ctx context.Context, req JSONRPCMessage) (JSONRPCMessage, error) {
if req.Method != "eth_sendTransaction" {
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/attestations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestApprovedAttestations(t *testing.T) {
for _, chainVer := range consChain.ChainVersions() {
atts, err := fetchAllAtts(ctx, cprov, chainVer, node.StartAt > 0)
require.NoError(t, err)
require.NotEmpty(t, len(atts))
require.NotEmpty(t, atts)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/portals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestPortalOffsets(t *testing.T) {
require.NoError(t, err)

// require at least some xmsgs were sent
require.Greater(t, sourceOffset, uint64(0),
require.Positive(t, sourceOffset,
"no xmsgs sent from source chain %v to dest chain %v",
source.Chain.ID, dest.Chain.ID)

Expand Down
6 changes: 3 additions & 3 deletions e2e/vmcompose/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
var omniEvmRegx = regexp.MustCompile(".*_evm")

const (
evmPort = 8545
haloPort = 26657
evmPort = uint32(8545)
haloPort = uint32(26657)
relayer = "relayer"
)

Expand Down Expand Up @@ -76,7 +76,7 @@ func LoadData(path string) (types.InfrastructureData, error) {
instances[serviceName] = e2e.InstanceData{
IPAddress: vm.IPAddress,
ExtIPAddress: vm.ExtIPAddress,
Port: uint32(port),
Port: port,
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion halo/app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func makeBaseAppOpts(cfg Config) ([]func(*baseapp.BaseApp), error) {
return nil, err
}

snapshotOptions := snapshottypes.NewSnapshotOptions(cfg.SnapshotInterval, uint32(cfg.SnapshotKeepRecent))
snapshotOptions := snapshottypes.NewSnapshotOptions(cfg.SnapshotInterval, cfg.SnapshotKeepRecent)

pruneOpts := pruningtypes.NewPruningOptionsFromString(cfg.PruningOption)
if cfg.PruningOption == pruningtypes.PruningOptionDefault {
Expand Down
16 changes: 16 additions & 0 deletions halo/attest/keeper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/omni-network/omni/halo/attest/types"
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/umath"
"github.com/omni-network/omni/lib/xchain"
)

Expand All @@ -19,6 +20,21 @@ func (a *Attestation) IsFuzzy() bool {
return xchain.ConfLevel(a.GetConfLevel()).IsFuzzy()
}

func statusToDB(status uint32) (Status, error) {
statusInt32, err := umath.ToInt32(status)
if err != nil {
return Status_Unknown, err
}

resp := Status(statusInt32)

if resp <= Status_Unknown || resp > Status_Approved {
return 0, errors.New("invalid status")
}

return resp, nil
}

func AttestationFromDB(att *Attestation, consensusChainID uint64, sigs []*Signature) *types.Attestation {
return &types.Attestation{
AttestHeader: &types.AttestHeader{
Expand Down
4 changes: 2 additions & 2 deletions halo/attest/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ func (k *Keeper) ExtendVote(ctx sdk.Context, _ *abci.RequestExtendVote) (*abci.R
countsByChainVer[vote.AttestHeader.XChainVersion()]++
filtered = append(filtered, vote)

if len(filtered) >= int(k.voteExtLimit) {
if umath.Len(filtered) >= k.voteExtLimit {
break
}
}
Expand Down Expand Up @@ -749,7 +749,7 @@ func (k *Keeper) VerifyVoteExtension(ctx sdk.Context, req *abci.RequestVerifyVot
return respReject, nil
} else if !ok {
return respAccept, nil
} else if len(votes.Votes) > int(k.voteExtLimit) {
} else if umath.Len(votes.Votes) > k.voteExtLimit {
log.Warn(ctx, "Rejecting vote extension exceeding limit", nil, "count", len(votes.Votes), "limit", k.voteExtLimit)
return respReject, nil
}
Expand Down
15 changes: 13 additions & 2 deletions halo/attest/keeper/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/omni-network/omni/halo/attest/types"
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/netconf"
"github.com/omni-network/omni/lib/umath"
"github.com/omni-network/omni/lib/xchain"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -93,9 +94,14 @@ func (k *Keeper) ListAllAttestations(ctx context.Context, req *types.ListAllAtte
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

s, err := statusToDB(req.Status)
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}

chainVer := xchain.ChainVersion{ID: req.ChainId, ConfLevel: xchain.ConfLevel(req.ConfLevel)}

atts, err := k.listAllAttestations(ctx, chainVer, Status(req.Status), req.FromOffset)
atts, err := k.listAllAttestations(ctx, chainVer, s, req.FromOffset)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand All @@ -113,7 +119,12 @@ func (k *Keeper) WindowCompare(ctx context.Context, req *types.WindowCompareRequ
return nil, status.Error(codes.Internal, err.Error())
}

return &types.WindowCompareResponse{Cmp: int32(cmp)}, nil
cmpInt32, err := umath.ToInt32(cmp)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

return &types.WindowCompareResponse{Cmp: cmpInt32}, nil
}

func getConsensusChainID(ctx context.Context) (uint64, error) {
Expand Down
2 changes: 1 addition & 1 deletion halo/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func bindRunFlags(cmd *cobra.Command, cfg *halocfg.Config) {
flags.StringVar(&cfg.EngineEndpoint, "engine-endpoint", cfg.EngineEndpoint, "An EVM execution client Engine API http endpoint")
flags.StringVar(&cfg.EngineJWTFile, "engine-jwt-file", cfg.EngineJWTFile, "The path to the Engine API JWT file")
flags.Uint64Var(&cfg.SnapshotInterval, "snapshot-interval", cfg.SnapshotInterval, "State sync snapshot interval")
flags.Uint64Var(&cfg.SnapshotKeepRecent, "snapshot-keep-recent", cfg.SnapshotKeepRecent, "State sync snapshot to keep")
flags.Uint32Var(&cfg.SnapshotKeepRecent, "snapshot-keep-recent", cfg.SnapshotKeepRecent, "State sync snapshot to keep")
flags.Uint64Var(&cfg.MinRetainBlocks, "min-retain-blocks", cfg.MinRetainBlocks, "Minimum block height offset during ABCI commit to prune CometBFT blocks")
flags.StringVar(&cfg.BackendType, "app-db-backend", cfg.BackendType, "The type of database for application and snapshots databases")
flags.StringVar(&cfg.PruningOption, "pruning", cfg.PruningOption, "Pruning strategy (default|nothing|everything)")
Expand Down
2 changes: 1 addition & 1 deletion halo/cmd/testdata/TestCLIReference_rollback.golden
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Flags:
--network string Omni network to participate in: mainnet, omega, devnet
--pruning string Pruning strategy (default|nothing|everything) (default "default")
--snapshot-interval uint State sync snapshot interval (default 1000)
--snapshot-keep-recent uint State sync snapshot to keep (default 2)
--snapshot-keep-recent uint32 State sync snapshot to keep (default 2)
--tracing-endpoint string Tracing OTLP endpoint
--tracing-headers string Tracing OTLP headers
--unsafe-skip-upgrades ints Skip a set of upgrade heights to continue the old binary
Expand Down
2 changes: 1 addition & 1 deletion halo/cmd/testdata/TestCLIReference_run.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Flags:
--network string Omni network to participate in: mainnet, omega, devnet
--pruning string Pruning strategy (default|nothing|everything) (default "default")
--snapshot-interval uint State sync snapshot interval (default 1000)
--snapshot-keep-recent uint State sync snapshot to keep (default 2)
--snapshot-keep-recent uint32 State sync snapshot to keep (default 2)
--tracing-endpoint string Tracing OTLP endpoint
--tracing-headers string Tracing OTLP headers
--unsafe-skip-upgrades ints Skip a set of upgrade heights to continue the old binary
Expand Down
2 changes: 1 addition & 1 deletion halo/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Config struct {
EngineEndpoint string
RPCEndpoints xchain.RPCEndpoints
SnapshotInterval uint64 // See cosmossdk.io/store/snapshots/types/options.go
SnapshotKeepRecent uint64 // See cosmossdk.io/store/snapshots/types/options.go
SnapshotKeepRecent uint32 // See cosmossdk.io/store/snapshots/types/options.go
BackendType string // See cosmos-db/db.go
MinRetainBlocks uint64
PruningOption string // See cosmossdk.io/store/pruning/types/options.go
Expand Down
11 changes: 6 additions & 5 deletions halo/evmupgrade/evmupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/ethclient"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/umath"
evmenginetypes "github.com/omni-network/omni/octane/evmengine/types"

"github.com/ethereum/go-ethereum"
Expand Down Expand Up @@ -137,21 +138,21 @@ func (p EventProcessor) deliverCancelUpgrade(ctx context.Context, _ *bindings.Up
func (p EventProcessor) deliverPlanUpgrade(ctx context.Context, plan *bindings.UpgradePlanUpgrade) error {
log.Info(ctx, "EVM plan upgrade detected", "name", plan.Name, "height", plan.Height)

height := int64(plan.Height)
if height < 0 {
return errors.New("invalid height")
heightInt64, err := umath.ToInt64(plan.Height)
if err != nil {
return err
}

msg := utypes.MsgSoftwareUpgrade{
Authority: authtypes.NewModuleAddress(ModuleName).String(),
Plan: utypes.Plan{
Name: plan.Name,
Height: height,
Height: heightInt64,
Info: plan.Info,
},
}

_, err := ukeeper.NewMsgServerImpl(p.uKeeper).SoftwareUpgrade(ctx, &msg)
_, err = ukeeper.NewMsgServerImpl(p.uKeeper).SoftwareUpgrade(ctx, &msg)
if err != nil {
return errors.Wrap(err, "plan software upgrade")
}
Expand Down
3 changes: 2 additions & 1 deletion halo/genutil/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/omni-network/omni/lib/anvil"
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/netconf"
"github.com/omni-network/omni/lib/umath"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
Expand Down Expand Up @@ -49,7 +50,7 @@ func MakeGenesis(network netconf.ID) (core.Genesis, error) {
// See geth reference: https://github.com/ethereum/go-ethereum/blob/master/params/config.go#L65
func defaultChainConfig(network netconf.ID) *params.ChainConfig {
return &params.ChainConfig{
ChainID: big.NewInt(int64(network.Static().OmniExecutionChainID)),
ChainID: umath.NewBigInt(network.Static().OmniExecutionChainID),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
Expand Down
2 changes: 1 addition & 1 deletion lib/buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewVersionCmd() *cobra.Command {
_, _ = sb.WriteString("Git Timestamp " + timestamp)
_, _ = sb.WriteString("\n")

cmd.Printf(sb.String())
cmd.Printf(sb.String()) //nolint:govet // Not a problem
},
}
}
Expand Down
7 changes: 6 additions & 1 deletion lib/cchain/provider/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ func (a rpcAdaptor) Invoke(ctx context.Context, method string, req, resp any, _
queryHeight = v
}

r, err := a.abci.ABCIQueryWithOptions(ctx, method, bz, rpcclient.ABCIQueryOptions{Height: int64(queryHeight)})
queryHeightInt64, err := umath.ToInt64(queryHeight)
if err != nil {
return err
}

r, err := a.abci.ABCIQueryWithOptions(ctx, method, bz, rpcclient.ABCIQueryOptions{Height: queryHeightInt64})
if err != nil {
return errors.Wrap(err, "abci query")
} else if !r.Response.IsOK() {
Expand Down
Loading

0 comments on commit d2bb0bf

Please sign in to comment.