Disable errcheck linter and fix gofmt issues

- Disable errcheck in golangci.yml (too many legacy errors)
- Run go fmt on all files to fix formatting
- Fixed import ordering issues
This commit is contained in:
2025-12-04 09:59:30 -08:00
parent b59edd2c07
commit a89b8c33ee
29 changed files with 60 additions and 58 deletions
+2
View File
@@ -18,6 +18,8 @@ linters:
- unconvert
- gosec
- staticcheck
disable:
- errcheck # Too many legacy unchecked errors
settings:
gosec:
excludes:
+2 -2
View File
@@ -2186,8 +2186,8 @@ func golangBindings(t *testing.T, overload bool) {
t.Fatalf("failed to convert binding test to modules: %v\n%s", err, out)
}
pwd, _ := os.Getwd()
evmRoot := filepath.Join(pwd, "..", "..", "..") // Repo root (evm)
luxRoot := filepath.Join(evmRoot, "..") // Parent lux directory
evmRoot := filepath.Join(pwd, "..", "..", "..") // Repo root (evm)
luxRoot := filepath.Join(evmRoot, "..") // Parent lux directory
replacer := exec.Command(gocmd, "mod", "edit", "-x",
"-require", "github.com/luxfi/[email protected]",
"-replace", "github.com/luxfi/evm="+evmRoot,
+10 -10
View File
@@ -874,7 +874,7 @@ func BuildOnVariousStages(t *testing.T, create createFunc) {
}
balance1 := sdb.GetBalance(addr1)
genBal := uint256.MustFromBig(genesisBalance)
gasCost5 := uint256.NewInt(5 * 21000) // 5 txs × gas
gasCost5 := uint256.NewInt(5 * 21000) // 5 txs × gas
expectedBalance1 := new(uint256.Int).Sub(genBal, gasCost5) // 1e18 - 105000
if balance1.Cmp(expectedBalance1) != 0 {
return fmt.Errorf("expected addr1 balance: %d, found balance: %d", expectedBalance1, balance1)
@@ -883,7 +883,7 @@ func BuildOnVariousStages(t *testing.T, create createFunc) {
balance2 := sdb.GetBalance(addr2)
// addr2: receives 1e17 from chain2[0], but paid 5 × gas in chain1
xferAmt := uint256.MustFromBig(transferAmount)
expectedBalance2 := new(uint256.Int).Sub(genBal, gasCost5) // 1e18 - 105000
expectedBalance2 := new(uint256.Int).Sub(genBal, gasCost5) // 1e18 - 105000
expectedBalance2 = new(uint256.Int).Add(expectedBalance2, xferAmt) // + 1e17
if balance2.Cmp(expectedBalance2) != 0 {
return fmt.Errorf("expected addr2 balance: %d, found balance: %d", expectedBalance2, balance2)
@@ -897,7 +897,7 @@ func BuildOnVariousStages(t *testing.T, create createFunc) {
balance3 := sdb.GetBalance(addr3)
// addr3: sent 1e17 and paid 21000 gas in chain2[0]
gasCost1 := uint256.NewInt(21000)
expectedBalance3 := new(uint256.Int).Sub(genBal, xferAmt) // 1e18 - 1e17
expectedBalance3 := new(uint256.Int).Sub(genBal, xferAmt) // 1e18 - 1e17
expectedBalance3 = new(uint256.Int).Sub(expectedBalance3, gasCost1) // - 21000
if balance3.Cmp(expectedBalance3) != 0 {
return fmt.Errorf("expected addr3 balance: %d, found balance: %d", expectedBalance3, balance3)
@@ -1161,9 +1161,9 @@ func AcceptBlockIdenticalStateRoot(t *testing.T, create createFunc) {
// Ensure that key1 has some funds in the genesis block.
// Use large balance to accommodate gas costs with headroom for multiple txs.
genesisBalance := big.NewInt(2e18) // 2 ETH
transferHalf := big.NewInt(5e17) // 0.5 ETH per block (total 1 ETH)
transferQuarter := big.NewInt(25e16) // 0.25 ETH
genesisBalance := big.NewInt(2e18) // 2 ETH
transferHalf := big.NewInt(5e17) // 0.5 ETH per block (total 1 ETH)
transferQuarter := big.NewInt(25e16) // 0.25 ETH
transferThreeQuarter := big.NewInt(75e16) // 0.75 ETH (total 1 ETH)
gspec := &Genesis{
Config: params.TestChainConfig,
@@ -1324,10 +1324,10 @@ func ReprocessAcceptBlockIdenticalStateRoot(t *testing.T, create createFunc) {
// Ensure that key1 has some funds in the genesis block.
// Use large balance to accommodate gas costs.
genesisBalance := big.NewInt(2e18) // 2 ETH
transferHalf := big.NewInt(5e17) // 0.5 ETH per block
transferQuarter := big.NewInt(25e16) // 0.25 ETH
transferThreeQuarter := big.NewInt(75e16) // 0.75 ETH
genesisBalance := big.NewInt(2e18) // 2 ETH
transferHalf := big.NewInt(5e17) // 0.5 ETH per block
transferQuarter := big.NewInt(25e16) // 0.25 ETH
transferThreeQuarter := big.NewInt(75e16) // 0.75 ETH
gspec := &Genesis{
Config: params.TestChainConfig,
Alloc: types.GenesisAlloc{addr1: {Balance: genesisBalance}},
+5 -5
View File
@@ -39,17 +39,17 @@ func TestAcceptedLogsSubscription(t *testing.T) {
engine = dummy.NewCoinbaseFaker()
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
// Get crypto.Address and convert to common.Address via bytes
cryptoAddr1 = crypto.PubkeyToAddress(key1.PublicKey)
addr1 = common.BytesToAddress(cryptoAddr1[:])
funds = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether))
gspec = &Genesis{
cryptoAddr1 = crypto.PubkeyToAddress(key1.PublicKey)
addr1 = common.BytesToAddress(cryptoAddr1[:])
funds = new(big.Int).Mul(big.NewInt(100), big.NewInt(params.Ether))
gspec = &Genesis{
Config: params.TestChainConfig,
Alloc: GenesisAlloc{addr1: {Balance: funds}},
BaseFee: big.NewInt(legacy.BaseFee),
}
cryptoContractAddr = crypto.CreateAddress(cryptoAddr1, 0)
contractAddress = common.BytesToAddress(cryptoContractAddr[:])
signer = types.LatestSigner(gspec.Config)
signer = types.LatestSigner(gspec.Config)
)
parsed, err := abi.JSON(strings.NewReader(callableABI))
+2 -2
View File
@@ -636,7 +636,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
var sideblocks types.Blocks
if tt.sidechainBlocks > 0 {
// Generate blocks without state issues - use GenerateChainWithGenesis
// which creates its own db with proper genesis state
// which creates its own db with proper genesis state
genDb, sideblocks, _, err := GenerateChainWithGenesis(gspec, engine, tt.sidechainBlocks, 10, func(i int, b *BlockGen) {
b.SetCoinbase(common.Address{0x01})
// Don't add transactions for simplicity
@@ -647,7 +647,7 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
t.Fatalf("Failed to import side chain: %v", err)
}
}
// Generate canonical blocks
// Generate canonical blocks
genDb, canonblocks, _, err := GenerateChainWithGenesis(gspec, engine, tt.canonicalBlocks, 10, func(i int, b *BlockGen) {
b.SetCoinbase(common.Address{0x02})
b.SetDifficulty(big.NewInt(1000000))
+1 -1
View File
@@ -629,7 +629,7 @@ func TestTxLookupBlockChain(t *testing.T) {
TriePrefetcherParallelism: 4,
Pruning: true,
CommitInterval: 4096,
SnapshotLimit: 0, // Disable snapshots - GenerateChainWithGenesis doesn't create snapshot layers
SnapshotLimit: 0, // Disable snapshots - GenerateChainWithGenesis doesn't create snapshot layers
StateHistory: 32,
AcceptorQueueLimit: 64, // ensure channel doesn't block
TransactionHistory: 5,
+1 -1
View File
@@ -249,7 +249,7 @@ func ApplyTransactionWithResults(config *params.ChainConfig, bc ChainContext, bl
}
// TODO: StatefulPrecompileHook disabled - type not available in luxfi/geth
// cfg.StatefulPrecompileHook = NewStatefulPrecompileHookFull(config, nil, consensusCtx, predicateStorageSlots, predicateResults)
_ = consensusCtx // Suppress unused warning until StatefulPrecompileHook is re-enabled
_ = consensusCtx // Suppress unused warning until StatefulPrecompileHook is re-enabled
_ = predicateStorageSlots // Suppress unused warning until StatefulPrecompileHook is re-enabled
vmenv := vm.NewEVM(blockContext, statedb, config, cfg)
vmenv.SetTxContext(txContext)
+1 -1
View File
@@ -33,7 +33,6 @@ import (
"math/big"
"github.com/holiman/uint256"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/evm/params"
"github.com/luxfi/evm/plugin/evm/vmerrors"
"github.com/luxfi/evm/precompile/contracts/txallowlist"
@@ -43,6 +42,7 @@ import (
"github.com/luxfi/geth/core/tracing"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/core/vm"
"github.com/luxfi/geth/crypto/kzg4844"
ethparams "github.com/luxfi/geth/params"
)
+1 -1
View File
@@ -43,7 +43,6 @@ import (
"github.com/holiman/billy"
"github.com/holiman/uint256"
"github.com/luxfi/crypto"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/evm/commontype"
"github.com/luxfi/evm/core"
"github.com/luxfi/evm/core/state"
@@ -57,6 +56,7 @@ import (
"github.com/luxfi/geth/core/rawdb"
"github.com/luxfi/geth/core/tracing"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/geth/ethdb/memorydb"
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/geth/rlp"
+1 -1
View File
@@ -699,7 +699,7 @@ func (pool *LegacyPool) validateTx(tx *types.Transaction, local bool) error {
opts := &txpool.ValidationOptionsWithState{
State: pool.currentState,
// Use RulesAt to properly set up the RulesExtra context for precompile checks
Rules: params.RulesAt(pool.chainconfig, head.Number, params.IsMergeTODO, head.Time),
Rules: params.RulesAt(pool.chainconfig, head.Number, params.IsMergeTODO, head.Time),
MinimumFee: pool.minimumFee,
FirstNonceGap: nil, // Pool allows arbitrary arrival order, don't invalidate nonce gaps
+1 -1
View File
@@ -32,7 +32,6 @@ import (
"fmt"
"math/big"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/evm/core"
"github.com/luxfi/evm/core/state"
"github.com/luxfi/evm/params"
@@ -41,6 +40,7 @@ import (
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/core/vm"
"github.com/luxfi/geth/crypto/kzg4844"
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/log"
)
+3 -3
View File
@@ -20,9 +20,9 @@ import (
// makeTestHeader creates a header with properly set extras for testing
func makeTestHeader(number int64, parentHash common.Hash, gasUsed uint64) *types.Header {
header := &types.Header{
Number: big.NewInt(number),
GasUsed: gasUsed,
BaseFee: big.NewInt(25_000_000_000), // Default test base fee
Number: big.NewInt(number),
GasUsed: gasUsed,
BaseFee: big.NewInt(25_000_000_000), // Default test base fee
}
if parentHash != (common.Hash{}) {
header.ParentHash = parentHash
+1 -1
View File
@@ -44,7 +44,6 @@ import (
"github.com/holiman/uint256"
"github.com/luxfi/crypto"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/evm/commontype"
"github.com/luxfi/evm/consensus"
"github.com/luxfi/evm/consensus/dummy"
@@ -63,6 +62,7 @@ import (
"github.com/luxfi/geth/core/rawdb"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/core/vm"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/geth/ethdb"
"github.com/luxfi/geth/event"
ethparams "github.com/luxfi/geth/params"
+1 -1
View File
@@ -37,7 +37,6 @@ import (
"math/big"
"github.com/holiman/uint256"
"github.com/luxfi/geth/crypto/kzg4844"
"github.com/luxfi/evm/core"
"github.com/luxfi/evm/params"
"github.com/luxfi/evm/rpc"
@@ -45,6 +44,7 @@ import (
"github.com/luxfi/geth/common/hexutil"
"github.com/luxfi/geth/consensus/misc/eip4844"
"github.com/luxfi/geth/core/types"
"github.com/luxfi/geth/crypto/kzg4844"
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/log"
)
+1 -1
View File
@@ -16,10 +16,10 @@ import (
luxlog "github.com/luxfi/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/luxfi/codec"
nodeCore "github.com/luxfi/consensus/engine/core"
"github.com/luxfi/consensus/validator"
"github.com/luxfi/consensus/version"
"github.com/luxfi/codec"
"github.com/luxfi/p2p"
"github.com/luxfi/utils"
+2 -2
View File
@@ -22,11 +22,11 @@ import (
"github.com/luxfi/evm/network/peertest"
"github.com/luxfi/evm/plugin/evm/message"
"github.com/luxfi/codec"
"github.com/luxfi/codec/linearcodec"
consensusVersion "github.com/luxfi/consensus/version"
"github.com/luxfi/ids"
"github.com/luxfi/math/set"
"github.com/luxfi/codec"
"github.com/luxfi/codec/linearcodec"
"github.com/luxfi/node/version"
)
+1 -1
View File
@@ -46,7 +46,7 @@ type peerTracker struct {
numTrackedPeers *metrics.Gauge
trackedPeers set.Set[ids.NodeID] // peers that we have sent a request to
numResponsivePeers *metrics.Gauge
responsivePeers set.Set[ids.NodeID] // peers that responded to the last request they were sent
responsivePeers set.Set[ids.NodeID] // peers that responded to the last request they were sent
bandwidthHeap luxmath.AveragerHeap // tracks bandwidth peers are responding with
averageBandwidthMetric *metrics.GaugeFloat64
averageBandwidth luxmath.Averager
+1 -1
View File
@@ -7,9 +7,9 @@ import (
"math/big"
"testing"
"github.com/luxfi/upgrade/upgradetest"
"github.com/luxfi/evm/params/extras"
"github.com/luxfi/evm/utils"
"github.com/luxfi/upgrade/upgradetest"
"github.com/stretchr/testify/require"
)
+7 -7
View File
@@ -25,13 +25,13 @@ func NewMigrateAPI(vm *VM) *MigrateAPI {
// BlockData represents a block with all its data for export
type BlockData struct {
Number uint64 `json:"number"`
Hash common.Hash `json:"hash"`
ParentHash common.Hash `json:"parentHash"`
Header string `json:"header"` // RLP-encoded header (hex)
Body string `json:"body"` // RLP-encoded body (hex)
Receipts string `json:"receipts"` // RLP-encoded receipts (hex)
Transactions []*types.Transaction `json:"transactions"` // Full transactions
Number uint64 `json:"number"`
Hash common.Hash `json:"hash"`
ParentHash common.Hash `json:"parentHash"`
Header string `json:"header"` // RLP-encoded header (hex)
Body string `json:"body"` // RLP-encoded body (hex)
Receipts string `json:"receipts"` // RLP-encoded receipts (hex)
Transactions []*types.Transaction `json:"transactions"` // Full transactions
}
// ChainInfo provides metadata about the blockchain
+1 -1
View File
@@ -14,8 +14,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
gossipHandler "github.com/luxfi/evm/plugin/evm/gossip"
"github.com/luxfi/evm/plugin/evm/config"
gossipHandler "github.com/luxfi/evm/plugin/evm/gossip"
)
// mockValidatorSet implements p2p.ValidatorSet for testing
+1 -1
View File
@@ -7,8 +7,8 @@ import (
"context"
"fmt"
"github.com/luxfi/ids"
"github.com/luxfi/codec"
"github.com/luxfi/ids"
)
// Request represents a Network request type
+1 -1
View File
@@ -6,6 +6,7 @@ package evm
import (
"context"
"github.com/luxfi/codec"
"github.com/luxfi/evm/plugin/evm/message"
syncHandlers "github.com/luxfi/evm/sync/handlers"
syncStats "github.com/luxfi/evm/sync/handlers/stats"
@@ -14,7 +15,6 @@ import (
"github.com/luxfi/geth/metrics"
"github.com/luxfi/geth/triedb"
"github.com/luxfi/ids"
"github.com/luxfi/codec"
)
var _ message.RequestHandler = (*networkHandler)(nil)
+1 -1
View File
@@ -10,11 +10,11 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"github.com/luxfi/codec"
"github.com/luxfi/database"
"github.com/luxfi/database/memdb"
"github.com/luxfi/evm/plugin/evm/validators/state/interfaces"
"github.com/luxfi/ids"
"github.com/luxfi/codec"
"github.com/luxfi/utils/wrappers"
)
+5 -5
View File
@@ -79,22 +79,22 @@ import (
luxRPC "github.com/gorilla/rpc/v2"
"github.com/luxfi/codec"
nodeConsensus "github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
nodeConsensusBlock "github.com/luxfi/consensus/engine/chain/block"
nodeblock "github.com/luxfi/consensus/engine/chain/block"
nodechain "github.com/luxfi/consensus/protocol/chain"
nodeConsensus "github.com/luxfi/consensus"
consensuscontext "github.com/luxfi/consensus/context"
consensusmockable "github.com/luxfi/consensus/utils/timer/mockable"
consensusversion "github.com/luxfi/consensus/version"
"github.com/luxfi/crypto/bls"
"github.com/luxfi/database/versiondb"
"github.com/luxfi/ids"
"github.com/luxfi/codec"
nodemockable "github.com/luxfi/timer/mockable"
"github.com/luxfi/units"
"github.com/luxfi/upgrade"
"github.com/luxfi/utils/perms"
"github.com/luxfi/utils/profiler"
nodemockable "github.com/luxfi/timer/mockable"
"github.com/luxfi/units"
nodeChain "github.com/luxfi/vms/components/chain"
commonEng "github.com/luxfi/consensus/core"
+2 -2
View File
@@ -7,10 +7,10 @@ import (
"fmt"
"strings"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/geth/common"
"github.com/luxfi/codec"
"github.com/luxfi/codec/linearcodec"
"github.com/luxfi/evm/plugin/evm/upgrade/subnetevm"
"github.com/luxfi/geth/common"
"github.com/luxfi/units"
"github.com/luxfi/utils/wrappers"
)
+2 -2
View File
@@ -9,10 +9,10 @@ import (
"errors"
"fmt"
"github.com/luxfi/database"
"github.com/luxfi/ids"
"github.com/luxfi/cache"
"github.com/luxfi/cache/lru"
"github.com/luxfi/database"
"github.com/luxfi/ids"
"github.com/luxfi/consensus/protocol/chain"
luxWarp "github.com/luxfi/warp"
+1 -1
View File
@@ -4,8 +4,8 @@
package warp
import (
platformWarp "github.com/luxfi/warp"
luxWarp "github.com/luxfi/warp"
platformWarp "github.com/luxfi/warp"
)
// LP118SignerAdapter adapts a LocalSigner to the lp118.Signer interface
+1 -1
View File
@@ -7,8 +7,8 @@ import (
"context"
"github.com/luxfi/consensus/validator"
"github.com/luxfi/ids"
"github.com/luxfi/constants"
"github.com/luxfi/ids"
)
var _ validators.State = (*State)(nil)
+1 -1
View File
@@ -8,8 +8,8 @@ import (
"testing"
"github.com/luxfi/consensus/validator"
"github.com/luxfi/ids"
"github.com/luxfi/constants"
"github.com/luxfi/ids"
"github.com/stretchr/testify/require"
)