From 3293a2ef97754859d2c4962315824ae79ec305d4 Mon Sep 17 00:00:00 2001 From: Thomas van Dam Date: Wed, 18 Sep 2024 10:34:06 +0200 Subject: [PATCH] chore: update golangci to v1.61.0 Also fix the new issues identified by the update. --- Makefile | 2 +- x/randomness/keeper/abci.go | 16 ++++++++++------ x/tally/keeper/abci.go | 5 +++-- x/tally/types/filters.go | 1 - 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 513bd8c7..4cc3466d 100644 --- a/Makefile +++ b/Makefile @@ -146,7 +146,7 @@ fmt: ### Linting ### ############################################################################### -golangci_version=v1.60.3 +golangci_version=v1.61.0 lint-install: @echo "--> Installing golangci-lint $(golangci_version)" diff --git a/x/randomness/keeper/abci.go b/x/randomness/keeper/abci.go index 66dc954a..5bed5d07 100644 --- a/x/randomness/keeper/abci.go +++ b/x/randomness/keeper/abci.go @@ -50,6 +50,7 @@ func (h *ProposalHandler) PrepareProposalHandler( var maxBlockGas uint64 if b := ctx.ConsensusParams().Block; b != nil { + //nolint:gosec // G115: We should always have a gas limit for blocks. maxBlockGas = uint64(b.MaxGas) } @@ -93,7 +94,9 @@ func (h *ProposalHandler) PrepareProposalHandler( return nil, err } - stop := h.txSelector.SelectTxForProposal(ctx, uint64(req.MaxTxBytes), maxBlockGas, newSeedTx, newSeedTxBz) + //nolint:gosec // G115: We should always have a bytes limit for transactions + maxTxBytes := uint64(req.MaxTxBytes) + stop := h.txSelector.SelectTxForProposal(ctx, maxTxBytes, maxBlockGas, newSeedTx, newSeedTxBz) if stop { return nil, types.ErrNewSeedTxNotIncluded } @@ -111,7 +114,7 @@ func (h *ProposalHandler) PrepareProposalHandler( continue } - stop := h.txSelector.SelectTxForProposal(ctx, uint64(req.MaxTxBytes), maxBlockGas, tx, txBz) + stop := h.txSelector.SelectTxForProposal(ctx, maxTxBytes, maxBlockGas, tx, txBz) if stop { break } @@ -130,9 +133,10 @@ func (h *ProposalHandler) ProcessProposalHandler( ) sdk.ProcessProposalHandler { return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { var totalTxGas uint64 - var maxBlockGas int64 + var maxBlockGas uint64 if b := ctx.ConsensusParams().Block; b != nil { - maxBlockGas = b.MaxGas + //nolint:gosec // G115: We should always have a gas limit for blocks. + maxBlockGas = uint64(b.MaxGas) } // process the NewSeed tx @@ -147,7 +151,7 @@ func (h *ProposalHandler) ProcessProposalHandler( totalTxGas += gasTx.GetGas() } - if totalTxGas > uint64(maxBlockGas) { + if totalTxGas > maxBlockGas { return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, err } } @@ -216,7 +220,7 @@ func (h *ProposalHandler) ProcessProposalHandler( totalTxGas += gasTx.GetGas() } - if totalTxGas > uint64(maxBlockGas) { + if totalTxGas > maxBlockGas { return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, err } } diff --git a/x/tally/keeper/abci.go b/x/tally/keeper/abci.go index 413c5296..02c7a039 100644 --- a/x/tally/keeper/abci.go +++ b/x/tally/keeper/abci.go @@ -77,8 +77,9 @@ func (k Keeper) ProcessTallies(ctx sdk.Context) error { sudoMsg := types.Sudo{ ID: req.ID, Result: types.DataResult{ - Version: req.Version, - ID: req.ID, + Version: req.Version, + ID: req.ID, + //nolint:gosec // G115: We shouldn't get negative block heights anwyay... BlockHeight: uint64(ctx.BlockHeight()), GasUsed: "0", // TODO PaybackAddress: req.PaybackAddress, diff --git a/x/tally/types/filters.go b/x/tally/types/filters.go index db922ee4..d68d04c3 100644 --- a/x/tally/types/filters.go +++ b/x/tally/types/filters.go @@ -3,7 +3,6 @@ package types import ( "bytes" "encoding/binary" - "slices" "golang.org/x/exp/constraints"