diff --git a/accounts/keystore/key.go b/accounts/keystore/key.go index d678976d9..292fe0924 100644 --- a/accounts/keystore/key.go +++ b/accounts/keystore/key.go @@ -29,10 +29,10 @@ import ( "strings" "time" + "github.com/google/uuid" "github.com/ledgerwatch/turbo-geth/accounts" "github.com/ledgerwatch/turbo-geth/common" "github.com/ledgerwatch/turbo-geth/crypto" - "github.com/google/uuid" ) const ( diff --git a/accounts/keystore/passphrase.go b/accounts/keystore/passphrase.go index 1fa5e9616..034e778f1 100644 --- a/accounts/keystore/passphrase.go +++ b/accounts/keystore/passphrase.go @@ -38,11 +38,11 @@ import ( "os" "path/filepath" + "github.com/google/uuid" "github.com/ledgerwatch/turbo-geth/accounts" "github.com/ledgerwatch/turbo-geth/common" "github.com/ledgerwatch/turbo-geth/common/math" "github.com/ledgerwatch/turbo-geth/crypto" - "github.com/google/uuid" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" ) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index a4ba40743..3a33911d5 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -198,7 +198,7 @@ func Main(ctx *cli.Context) error { defer inFile.Close() decoder := json.NewDecoder(inFile) if err := decoder.Decode(&txsWithKeys); err != nil { - return NewError(ErrorJson, fmt.Errorf("Failed unmarshaling txs-file: %v", err)) + return NewError(ErrorJson, fmt.Errorf("failed unmarshaling txs-file: %v", err)) } } else { txsWithKeys = inputData.Txs @@ -207,7 +207,7 @@ func Main(ctx *cli.Context) error { signer := types.MakeSigner(chainConfig, big.NewInt(int64(prestate.Env.Number))) if txs, err = signUnsignedTransactions(txsWithKeys, signer); err != nil { - return NewError(ErrorJson, fmt.Errorf("Failed signing transactions: %v", err)) + return NewError(ErrorJson, fmt.Errorf("failed signing transactions: %v", err)) } // Iterate over all the tests, run them and aggregate the results @@ -244,10 +244,10 @@ func (t *txWithKey) UnmarshalJSON(input []byte) error { } if key.Key != nil { k := key.Key.Hex()[2:] - if ecdsaKey, err := crypto.HexToECDSA(k); err != nil { - return err - } else { + if ecdsaKey, err := crypto.HexToECDSA(k); err == nil { t.key = ecdsaKey + } else { + return err } } // Now, read the transaction itself diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 0408d6bb7..c819b7abe 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -831,6 +831,7 @@ func WriteBadBlock(db ethdb.Database, block *types.Block) { } // DeleteBadBlocks deletes all the bad blocks from the database +//nolint:interfacer func DeleteBadBlocks(db ethdb.Database) { if err := db.Delete(dbutils.InvalidBlock, []byte(dbutils.InvalidBlock), nil); err != nil { log.Crit("Failed to delete bad blocks", "err", err) diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 5432640df..8dff0b29b 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -75,7 +75,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, ibs *state.IntraBlockStat // precacheTransaction attempts to apply a transaction to the given state database // and uses the input parameters for its environment. The goal is not to execute // the transaction successfully, rather to warm up touched data slots. -func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, ibs *state.IntraBlockState, header *types.Header, evm *vm.EVM) error { +func precacheTransaction(msg types.Message, config *params.ChainConfig, gaspool *GasPool, ibs vm.IntraBlockState, header *types.Header, evm *vm.EVM) error { // Update the evm with the new transaction context. evm.Reset(NewEVMTxContext(msg), ibs) // Add addresses to access list if applicable diff --git a/core/tx_pool.go b/core/tx_pool.go index d2995468e..d0f42b038 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1705,7 +1705,7 @@ func (t *txLookup) RemoteToLocals(locals *accountSet) int { if locals.containsTx(tx) { t.locals[hash] = tx delete(t.remotes, hash) - migrated += 1 + migrated++ } } return migrated diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index 46e257536..ce1be2bbd 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -1984,7 +1984,9 @@ func benchmarkFuturePromotion(b *testing.B, size int) { for i := 0; i < size; i++ { tx := transaction(uint64(1+i), 100000, key) - pool.enqueueTx(tx.Hash(), tx, false, true) + if _, err := pool.enqueueTx(tx.Hash(), tx, false, true); err != nil { + b.Fatal(err) + } } // Benchmark the speed of pool validation b.ResetTimer() diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index e0a83e0e4..0f60bf58f 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -19,6 +19,7 @@ package types import ( "bytes" "crypto/ecdsa" + "encoding" "encoding/json" "fmt" "math/big" @@ -459,7 +460,7 @@ func encodeDecodeJSON(tx *Transaction) (*Transaction, error) { return parsedTx, nil } -func encodeDecodeBinary(tx *Transaction) (*Transaction, error) { +func encodeDecodeBinary(tx encoding.BinaryMarshaler) (*Transaction, error) { data, err := tx.MarshalBinary() if err != nil { return nil, fmt.Errorf("rlp encoding failed: %v", err) @@ -481,7 +482,7 @@ func assertEqual(orig *Transaction, cpy *Transaction) error { } if orig.AccessList() != nil { if !reflect.DeepEqual(orig.AccessList(), cpy.AccessList()) { - return fmt.Errorf("access list wrong!") + return fmt.Errorf("access list wrong") } if orig.ChainId().Cmp(cpy.ChainId()) != 0 { return fmt.Errorf("invalid chain id, want %d, got %d", orig.ChainId(), cpy.ChainId()) diff --git a/eth/protocols/eth/discovery.go b/eth/protocols/eth/discovery.go index 35f0777ee..2e7615887 100644 --- a/eth/protocols/eth/discovery.go +++ b/eth/protocols/eth/discovery.go @@ -58,7 +58,7 @@ func StartENRUpdater(chain *core.BlockChain, ln *enode.LocalNode) { } // currentENREntry constructs an `eth` ENR entry based on the current state of the chain. -func currentENREntry(chain *core.BlockChain) *enrEntry { +func currentENREntry(chain forkid.Blockchain) *enrEntry { return &enrEntry{ ForkID: forkid.NewID(chain.Config(), chain.Genesis().Hash(), chain.CurrentHeader().Number.Uint64()), } diff --git a/eth/protocols/eth/protocol_test.go b/eth/protocols/eth/protocol_test.go index 667d91365..d57f609c3 100644 --- a/eth/protocols/eth/protocol_test.go +++ b/eth/protocols/eth/protocol_test.go @@ -178,7 +178,7 @@ func TestEth66Messages(t *testing.T) { // init the receipts { receipts = []*types.Receipt{ - &types.Receipt{ + { Status: types.ReceiptStatusFailed, CumulativeGasUsed: 1, Logs: []*types.Log{ diff --git a/eth/sync_test.go b/eth/sync_test.go index bb56d2dfd..659faf77a 100644 --- a/eth/sync_test.go +++ b/eth/sync_test.go @@ -59,9 +59,11 @@ func testFastSyncDisabling(t *testing.T, protocol uint) { defer emptyPeer.Close() defer fullPeer.Close() + //nolint:errcheck go empty.handler.runEthPeer(emptyPeer, func(peer *eth.Peer) error { return eth.Handle((*ethHandler)(empty.handler), peer) }) + //nolint:errcheck go full.handler.runEthPeer(fullPeer, func(peer *eth.Peer) error { return eth.Handle((*ethHandler)(full.handler), peer) }) diff --git a/event/subscription_test.go b/event/subscription_test.go index ba081705c..2cc21be70 100644 --- a/event/subscription_test.go +++ b/event/subscription_test.go @@ -137,9 +137,8 @@ func TestResubscribeWithErrorHandler(t *testing.T) { sub := NewSubscription(func(unsubscribed <-chan struct{}) error { if i < nfails { return fmt.Errorf("err-%v", i) - } else { - return nil } + return nil }) return sub, nil })