From 43043ed7ec84c2f8a28a8ea2d76145476c7b96ec Mon Sep 17 00:00:00 2001 From: anshalshukla Date: Mon, 2 Sep 2024 11:00:33 +0530 Subject: [PATCH] fix: few linting errors --- accounts/abi/bind/backends/simulated.go | 4 ++-- accounts/abi/bind/backends/simulated_test.go | 16 ++++++++-------- accounts/external/backend.go | 2 +- accounts/scwallet/wallet.go | 2 +- accounts/usbwallet/wallet.go | 2 +- beacon/types/config.go | 2 +- cmd/blsync/main.go | 2 +- cmd/clef/main.go | 4 ++-- cmd/era/main.go | 2 +- cmd/evm/internal/t8ntool/block.go | 2 +- consensus/bor/bor.go | 4 ++-- core/blockchain.go | 1 + core/blockstm/mvhashmap.go | 6 +++--- core/state/statedb.go | 15 --------------- eth/fetcher/block_fetcher_test.go | 2 +- eth/tracers/api_test.go | 2 +- eth/tracers/live/supply.go | 2 +- ethclient/ethclient_test.go | 2 +- internal/cli/bootnode.go | 4 ++-- internal/cli/chain_sethead.go | 4 ++-- internal/cli/debug.go | 2 +- internal/cli/debug_block.go | 4 ++-- internal/cli/debug_pprof.go | 4 ++-- internal/cli/dumpconfig.go | 2 +- internal/cli/peers.go | 2 +- internal/cli/peers_add.go | 18 +++++++++--------- internal/cli/peers_list.go | 16 ++++++++-------- internal/cli/peers_remove.go | 18 +++++++++--------- internal/cli/peers_status.go | 18 +++++++++--------- internal/cli/server/chains/utils.go | 6 +++--- internal/cli/snapshot.go | 2 +- internal/cli/snapshot_test.go | 2 +- internal/cli/status.go | 4 ++-- internal/cli/version.go | 2 +- internal/debug/api.go | 2 +- internal/debug/flags.go | 8 ++++---- internal/ethapi/api.go | 12 ++++++------ internal/ethapi/api_test.go | 2 +- miner/worker_test.go | 2 +- node/node.go | 11 +++++------ node/rpcstack.go | 12 +++++------- params/config.go | 3 ++- scripts/getconfig.go | 2 +- tests/bor/bor_test.go | 8 ++++---- 44 files changed, 113 insertions(+), 129 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 80a0d76213..9763f154e0 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -83,7 +83,7 @@ type SimulatedBackend struct { // NewSimulatedBackendWithDatabase creates a new binding backend based on the given database // and uses a simulated blockchain for testing purposes. // A simulated backend always uses chainID 1337. -func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend { +func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc types.GenesisAlloc, gasLimit uint64) *SimulatedBackend { genesis := core.Genesis{ Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, @@ -111,7 +111,7 @@ func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.Genesis // NewSimulatedBackend creates a new binding backend using a simulated blockchain // for testing purposes. // A simulated backend always uses chainID 1337. -func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend { +func NewSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64) *SimulatedBackend { return NewSimulatedBackendWithDatabase(rawdb.NewMemoryDatabase(), alloc, gasLimit) } diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index 227e971d5f..860d4e59af 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -46,7 +46,7 @@ func TestSimulatedBackend(t *testing.T) { key, _ := crypto.GenerateKey() // nolint: gosec auth, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - genAlloc := make(core.GenesisAlloc) + genAlloc := make(types.GenesisAlloc) genAlloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(9223372036854775807)} sim := NewSimulatedBackend(genAlloc, gasLimit) @@ -125,7 +125,7 @@ var expectedReturn = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 func simTestBackend(testAddr common.Address) *SimulatedBackend { return NewSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ testAddr: {Balance: big.NewInt(10000000000000000)}, }, 10000000, ) @@ -250,7 +250,7 @@ func TestBalanceAt(t *testing.T) { func TestBlockByHash(t *testing.T) { t.Parallel() sim := NewSimulatedBackend( - core.GenesisAlloc{}, 10000000, + types.GenesisAlloc{}, 10000000, ) defer sim.Close() @@ -274,7 +274,7 @@ func TestBlockByHash(t *testing.T) { func TestBlockByNumber(t *testing.T) { t.Parallel() sim := NewSimulatedBackend( - core.GenesisAlloc{}, 10000000, + types.GenesisAlloc{}, 10000000, ) defer sim.Close() @@ -412,7 +412,7 @@ func TestTransactionByHash(t *testing.T) { testAddr := crypto.PubkeyToAddress(testKey.PublicKey) sim := NewSimulatedBackend( - core.GenesisAlloc{ + types.GenesisAlloc{ testAddr: {Balance: big.NewInt(10000000000000000)}, }, 10000000, ) @@ -488,7 +488,7 @@ func TestEstimateGas(t *testing.T) { addr := crypto.PubkeyToAddress(key.PublicKey) opts, _ := bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337)) - sim := NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, 10000000) + sim := NewSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether)}}, 10000000) defer sim.Close() parsed, _ := abi.JSON(strings.NewReader(contractAbi)) @@ -599,7 +599,7 @@ func TestEstimateGasWithPrice(t *testing.T) { key, _ := crypto.GenerateKey() addr := crypto.PubkeyToAddress(key.PublicKey) - sim := NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether*2 + 2e17)}}, 10000000) + sim := NewSimulatedBackend(types.GenesisAlloc{addr: {Balance: big.NewInt(params.Ether*2 + 2e17)}}, 10000000) defer sim.Close() recipient := common.HexToAddress("deadbeef") @@ -1002,7 +1002,7 @@ func TestTransactionReceipt(t *testing.T) { func TestSuggestGasPrice(t *testing.T) { t.Parallel() sim := NewSimulatedBackend( - core.GenesisAlloc{}, + types.GenesisAlloc{}, 10000000, ) defer sim.Close() diff --git a/accounts/external/backend.go b/accounts/external/backend.go index 4d8b412586..14fbab9c96 100644 --- a/accounts/external/backend.go +++ b/accounts/external/backend.go @@ -22,7 +22,7 @@ import ( "math/big" "sync" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/accounts/scwallet/wallet.go b/accounts/scwallet/wallet.go index 78c5b7ff75..047a41e04d 100644 --- a/accounts/scwallet/wallet.go +++ b/accounts/scwallet/wallet.go @@ -33,7 +33,7 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" diff --git a/accounts/usbwallet/wallet.go b/accounts/usbwallet/wallet.go index e6aad893ae..f5bfba474b 100644 --- a/accounts/usbwallet/wallet.go +++ b/accounts/usbwallet/wallet.go @@ -25,7 +25,7 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" diff --git a/beacon/types/config.go b/beacon/types/config.go index 7706e85f6c..f625ca8b3a 100644 --- a/beacon/types/config.go +++ b/beacon/types/config.go @@ -30,7 +30,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" - "gopkg.in/yaml.v3" + yaml "gopkg.in/yaml.v3" ) // syncCommitteeDomain specifies the signatures specific use to avoid clashes diff --git a/cmd/blsync/main.go b/cmd/blsync/main.go index 854c99703c..004223530f 100644 --- a/cmd/blsync/main.go +++ b/cmd/blsync/main.go @@ -28,7 +28,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" - "github.com/urfave/cli/v2" + cli "github.com/urfave/cli/v2" ) func main() { diff --git a/cmd/clef/main.go b/cmd/clef/main.go index ce9f14e3a8..e787b2a512 100644 --- a/cmd/clef/main.go +++ b/cmd/clef/main.go @@ -54,8 +54,8 @@ import ( "github.com/ethereum/go-ethereum/signer/fourbyte" "github.com/ethereum/go-ethereum/signer/rules" "github.com/ethereum/go-ethereum/signer/storage" - "github.com/mattn/go-colorable" - "github.com/mattn/go-isatty" + colorable "github.com/mattn/go-colorable" + isatty "github.com/mattn/go-isatty" "github.com/urfave/cli/v2" ) diff --git a/cmd/era/main.go b/cmd/era/main.go index 36ecefafad..47549ddc1f 100644 --- a/cmd/era/main.go +++ b/cmd/era/main.go @@ -34,7 +34,7 @@ import ( "github.com/ethereum/go-ethereum/internal/flags" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" - "github.com/urfave/cli/v2" + cli "github.com/urfave/cli/v2" ) var app = flags.NewApp("go-ethereum era tool") diff --git a/cmd/evm/internal/t8ntool/block.go b/cmd/evm/internal/t8ntool/block.go index 7ab96ea372..15a4432aa4 100644 --- a/cmd/evm/internal/t8ntool/block.go +++ b/cmd/evm/internal/t8ntool/block.go @@ -24,7 +24,7 @@ import ( "math/big" "os" - "github.com/urfave/cli/v2" + cli "github.com/urfave/cli/v2" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index e7d5c6e90d..60c20528b5 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -860,8 +860,8 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, bc.SetStateSync(stateSyncData) } -func decodeGenesisAlloc(i interface{}) (core.GenesisAlloc, error) { - var alloc core.GenesisAlloc +func decodeGenesisAlloc(i interface{}) (types.GenesisAlloc, error) { + var alloc types.GenesisAlloc b, err := json.Marshal(i) if err != nil { diff --git a/core/blockchain.go b/core/blockchain.go index c4790534be..3b78e9a15d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2519,6 +2519,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) // blockProcessingResult is a summary of block processing // used for updating the stats. +// nolint type blockProcessingResult struct { usedGas uint64 procTime time.Duration diff --git a/core/blockstm/mvhashmap.go b/core/blockstm/mvhashmap.go index 003de91e70..57f9867031 100644 --- a/core/blockstm/mvhashmap.go +++ b/core/blockstm/mvhashmap.go @@ -198,9 +198,9 @@ func (res *MVReadResult) Value() interface{} { return res.value } -func (mvr MVReadResult) Status() int { - if mvr.depIdx != -1 { - if mvr.incarnation == -1 { +func (res MVReadResult) Status() int { + if res.depIdx != -1 { + if res.incarnation == -1 { return MVReadResultDependency } else { return MVReadResultDone diff --git a/core/state/statedb.go b/core/state/statedb.go index 85c198055e..35c90bd8b3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1935,21 +1935,6 @@ func (s *StateDB) ValidateKnownAccounts(knownAccounts types.KnownAccounts) error return nil } -// convertAccountSet converts a provided account set from address keyed to hash keyed. -func (s *StateDB) convertAccountSet(set map[common.Address]*types.StateAccount) map[common.Hash]struct{} { - ret := make(map[common.Hash]struct{}, len(set)) - for addr := range set { - obj, exist := s.stateObjects[addr] - if !exist { - ret[crypto.Keccak256Hash(addr[:])] = struct{}{} - } else { - ret[obj.addrHash] = struct{}{} - } - } - - return ret -} - // markDelete is invoked when an account is deleted but the deletion is // not yet committed. The pending mutation is cached and will be applied // all together diff --git a/eth/fetcher/block_fetcher_test.go b/eth/fetcher/block_fetcher_test.go index 1985d56e79..121aa1f67a 100644 --- a/eth/fetcher/block_fetcher_test.go +++ b/eth/fetcher/block_fetcher_test.go @@ -42,7 +42,7 @@ var ( testAddress = crypto.PubkeyToAddress(testKey.PublicKey) gspec = &core.Genesis{ Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{testAddress: {Balance: big.NewInt(1000000000000000)}}, + Alloc: types.GenesisAlloc{testAddress: {Balance: big.NewInt(1000000000000000)}}, BaseFee: big.NewInt(params.InitialBaseFee), } genesis = gspec.MustCommit(testdb, triedb.NewDatabase(testdb, triedb.HashDefaults)) diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index fd20e8b8f2..4a3d23a4fa 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -604,7 +604,7 @@ func TestIOdump(t *testing.T) { // Initialize test accounts accounts := newAccounts(5) - genesis := &core.Genesis{Alloc: core.GenesisAlloc{ + genesis := &core.Genesis{Alloc: types.GenesisAlloc{ accounts[0].addr: {Balance: big.NewInt(params.Ether)}, accounts[1].addr: {Balance: big.NewInt(params.Ether)}, accounts[2].addr: {Balance: big.NewInt(params.Ether)}, diff --git a/eth/tracers/live/supply.go b/eth/tracers/live/supply.go index 96f7059454..1adcacbb27 100644 --- a/eth/tracers/live/supply.go +++ b/eth/tracers/live/supply.go @@ -15,7 +15,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/log" - "gopkg.in/natefinch/lumberjack.v2" + lumberjack "gopkg.in/natefinch/lumberjack.v2" ) func init() { diff --git a/ethclient/ethclient_test.go b/ethclient/ethclient_test.go index 22b3b244b0..637caf7ab8 100644 --- a/ethclient/ethclient_test.go +++ b/ethclient/ethclient_test.go @@ -176,7 +176,7 @@ func TestToFilterArg(t *testing.T) { // var genesis = &core.Genesis{ // Config: params.AllEthashProtocolChanges, -// Alloc: core.GenesisAlloc{testAddr: {Balance: testBalance}}, +// Alloc: types.GenesisAlloc{testAddr: {Balance: testBalance}}, // ExtraData: []byte("test genesis"), // Timestamp: 9000, // BaseFee: big.NewInt(params.InitialBaseFee), diff --git a/internal/cli/bootnode.go b/internal/cli/bootnode.go index 2dd99cc8c0..c0f8d2476d 100644 --- a/internal/cli/bootnode.go +++ b/internal/cli/bootnode.go @@ -48,10 +48,10 @@ func (b *BootnodeCommand) Help() string { } // MarkDown implements cli.MarkDown interface -func (c *BootnodeCommand) MarkDown() string { +func (b *BootnodeCommand) MarkDown() string { items := []string{ "# Bootnode", - c.Flags().MarkDown(), + b.Flags().MarkDown(), } return strings.Join(items, "\n\n") diff --git a/internal/cli/chain_sethead.go b/internal/cli/chain_sethead.go index 718ada4648..353470cf20 100644 --- a/internal/cli/chain_sethead.go +++ b/internal/cli/chain_sethead.go @@ -18,13 +18,13 @@ type ChainSetHeadCommand struct { } // MarkDown implements cli.MarkDown interface -func (a *ChainSetHeadCommand) MarkDown() string { +func (c *ChainSetHeadCommand) MarkDown() string { items := []string{ "# Chain sethead", "The ```chain sethead ``` command sets the current chain to a certain block.", "## Arguments", "- ```number```: The block number to roll back.", - a.Flags().MarkDown(), + c.Flags().MarkDown(), } return strings.Join(items, "\n\n") diff --git a/internal/cli/debug.go b/internal/cli/debug.go index baa29c8721..12ad94a50c 100644 --- a/internal/cli/debug.go +++ b/internal/cli/debug.go @@ -28,7 +28,7 @@ type DebugCommand struct { } // MarkDown implements cli.MarkDown interface -func (d *DebugCommand) MarkDown() string { +func (c *DebugCommand) MarkDown() string { examples := []string{ "## Examples", "By default it creates a tar.gz file with the output:", diff --git a/internal/cli/debug_block.go b/internal/cli/debug_block.go index 5a282cc550..011349083c 100644 --- a/internal/cli/debug_block.go +++ b/internal/cli/debug_block.go @@ -17,11 +17,11 @@ type DebugBlockCommand struct { output string } -func (p *DebugBlockCommand) MarkDown() string { +func (c *DebugBlockCommand) MarkDown() string { items := []string{ "# Debug trace", "The ```bor debug block ``` command will create an archive containing traces of a bor block.", - p.Flags().MarkDown(), + c.Flags().MarkDown(), } return strings.Join(items, "\n\n") diff --git a/internal/cli/debug_pprof.go b/internal/cli/debug_pprof.go index ddb4520e9c..3910dc7e9c 100644 --- a/internal/cli/debug_pprof.go +++ b/internal/cli/debug_pprof.go @@ -21,11 +21,11 @@ type DebugPprofCommand struct { skiptrace bool } -func (p *DebugPprofCommand) MarkDown() string { +func (d *DebugPprofCommand) MarkDown() string { items := []string{ "# Debug Pprof", "The ```debug pprof ``` command will create an archive containing bor pprof traces.", - p.Flags().MarkDown(), + d.Flags().MarkDown(), } return strings.Join(items, "\n\n") diff --git a/internal/cli/dumpconfig.go b/internal/cli/dumpconfig.go index 13ef57c087..0597bfdec4 100644 --- a/internal/cli/dumpconfig.go +++ b/internal/cli/dumpconfig.go @@ -15,7 +15,7 @@ type DumpconfigCommand struct { } // MarkDown implements cli.MarkDown interface -func (p *DumpconfigCommand) MarkDown() string { +func (c *DumpconfigCommand) MarkDown() string { items := []string{ "# Dumpconfig", "The ```bor dumpconfig ``` command will export the user provided flags into a configuration file", diff --git a/internal/cli/peers.go b/internal/cli/peers.go index fbbca24fad..5d87178f12 100644 --- a/internal/cli/peers.go +++ b/internal/cli/peers.go @@ -12,7 +12,7 @@ type PeersCommand struct { } // MarkDown implements cli.MarkDown interface -func (a *PeersCommand) MarkDown() string { +func (c *PeersCommand) MarkDown() string { items := []string{ "# Peers", "The ```peers``` command groups actions to interact with peers:", diff --git a/internal/cli/peers_add.go b/internal/cli/peers_add.go index 3df1a6b6cb..10bbc1fcb8 100644 --- a/internal/cli/peers_add.go +++ b/internal/cli/peers_add.go @@ -48,36 +48,36 @@ func (p *PeersAddCommand) Flags() *flagset.Flagset { } // Synopsis implements the cli.Command interface -func (c *PeersAddCommand) Synopsis() string { +func (p *PeersAddCommand) Synopsis() string { return "Join the client to a remote peer" } // Run implements the cli.Command interface -func (c *PeersAddCommand) Run(args []string) int { - flags := c.Flags() +func (p *PeersAddCommand) Run(args []string) int { + flags := p.Flags() if err := flags.Parse(args); err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } args = flags.Args() if len(args) != 1 { - c.UI.Error("No enode address provided") + p.UI.Error("No enode address provided") return 1 } - borClt, err := c.BorConn() + borClt, err := p.BorConn() if err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } req := &proto.PeersAddRequest{ Enode: args[0], - Trusted: c.trusted, + Trusted: p.trusted, } if _, err := borClt.PeersAdd(context.Background(), req); err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } diff --git a/internal/cli/peers_list.go b/internal/cli/peers_list.go index 4a572447c1..a0e8fadc34 100644 --- a/internal/cli/peers_list.go +++ b/internal/cli/peers_list.go @@ -41,21 +41,21 @@ func (p *PeersListCommand) Flags() *flagset.Flagset { } // Synopsis implements the cli.Command interface -func (c *PeersListCommand) Synopsis() string { +func (p *PeersListCommand) Synopsis() string { return "" } // Run implements the cli.Command interface -func (c *PeersListCommand) Run(args []string) int { - flags := c.Flags() +func (p *PeersListCommand) Run(args []string) int { + flags := p.Flags() if err := flags.Parse(args); err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } - borClt, err := c.BorConn() + borClt, err := p.BorConn() if err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } @@ -63,11 +63,11 @@ func (c *PeersListCommand) Run(args []string) int { resp, err := borClt.PeersList(context.Background(), req) if err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } - c.UI.Output(formatPeers(resp.Peers)) + p.UI.Output(formatPeers(resp.Peers)) return 0 } diff --git a/internal/cli/peers_remove.go b/internal/cli/peers_remove.go index f53284c40c..e3d30dfa53 100644 --- a/internal/cli/peers_remove.go +++ b/internal/cli/peers_remove.go @@ -48,36 +48,36 @@ func (p *PeersRemoveCommand) Flags() *flagset.Flagset { } // Synopsis implements the cli.Command interface -func (c *PeersRemoveCommand) Synopsis() string { +func (p *PeersRemoveCommand) Synopsis() string { return "Disconnects a peer from the client" } // Run implements the cli.Command interface -func (c *PeersRemoveCommand) Run(args []string) int { - flags := c.Flags() +func (p *PeersRemoveCommand) Run(args []string) int { + flags := p.Flags() if err := flags.Parse(args); err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } args = flags.Args() if len(args) != 1 { - c.UI.Error("No enode address provided") + p.UI.Error("No enode address provided") return 1 } - borClt, err := c.BorConn() + borClt, err := p.BorConn() if err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } req := &proto.PeersRemoveRequest{ Enode: args[0], - Trusted: c.trusted, + Trusted: p.trusted, } if _, err := borClt.PeersRemove(context.Background(), req); err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } diff --git a/internal/cli/peers_status.go b/internal/cli/peers_status.go index f5d700a273..ad02e22dc8 100644 --- a/internal/cli/peers_status.go +++ b/internal/cli/peers_status.go @@ -41,27 +41,27 @@ func (p *PeersStatusCommand) Flags() *flagset.Flagset { } // Synopsis implements the cli.Command interface -func (c *PeersStatusCommand) Synopsis() string { +func (p *PeersStatusCommand) Synopsis() string { return "Display the status of a peer" } // Run implements the cli.Command interface -func (c *PeersStatusCommand) Run(args []string) int { - flags := c.Flags() +func (p *PeersStatusCommand) Run(args []string) int { + flags := p.Flags() if err := flags.Parse(args); err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } args = flags.Args() if len(args) != 1 { - c.UI.Error("No enode address provided") + p.UI.Error("No enode address provided") return 1 } - borClt, err := c.BorConn() + borClt, err := p.BorConn() if err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } @@ -71,11 +71,11 @@ func (c *PeersStatusCommand) Run(args []string) int { resp, err := borClt.PeersStatus(context.Background(), req) if err != nil { - c.UI.Error(err.Error()) + p.UI.Error(err.Error()) return 1 } - c.UI.Output(formatPeer(resp.Peer)) + p.UI.Output(formatPeer(resp.Peer)) return 0 } diff --git a/internal/cli/server/chains/utils.go b/internal/cli/server/chains/utils.go index 860ff5b6ee..33d7a9c0ed 100644 --- a/internal/cli/server/chains/utils.go +++ b/internal/cli/server/chains/utils.go @@ -5,13 +5,13 @@ import ( "encoding/json" "fmt" - "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/types" ) //go:embed allocs var allocs embed.FS -func readPrealloc(filename string) core.GenesisAlloc { +func readPrealloc(filename string) types.GenesisAlloc { f, err := allocs.Open(filename) if err != nil { panic(fmt.Sprintf("Could not open genesis preallocation for %s: %v", filename, err)) @@ -19,7 +19,7 @@ func readPrealloc(filename string) core.GenesisAlloc { defer f.Close() decoder := json.NewDecoder(f) - ga := make(core.GenesisAlloc) + ga := make(types.GenesisAlloc) err = decoder.Decode(&ga) if err != nil { diff --git a/internal/cli/snapshot.go b/internal/cli/snapshot.go index ffe49d1543..b610f6b71f 100644 --- a/internal/cli/snapshot.go +++ b/internal/cli/snapshot.go @@ -32,7 +32,7 @@ type SnapshotCommand struct { } // MarkDown implements cli.MarkDown interface -func (a *SnapshotCommand) MarkDown() string { +func (c *SnapshotCommand) MarkDown() string { items := []string{ "# snapshot", "The ```snapshot``` command groups snapshot related actions:", diff --git a/internal/cli/snapshot_test.go b/internal/cli/snapshot_test.go index 6347608330..115f0b0599 100644 --- a/internal/cli/snapshot_test.go +++ b/internal/cli/snapshot_test.go @@ -33,7 +33,7 @@ var ( key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") address = crypto.PubkeyToAddress(key.PublicKey) balance = big.NewInt(1_000000000000000000) - gspec = &core.Genesis{Config: params.TestChainConfig, Alloc: core.GenesisAlloc{address: {Balance: balance}}} + gspec = &core.Genesis{Config: params.TestChainConfig, Alloc: types.GenesisAlloc{address: {Balance: balance}}} signer = types.LatestSigner(gspec.Config) config = &core.CacheConfig{ TrieCleanLimit: 256, diff --git a/internal/cli/status.go b/internal/cli/status.go index 63386d9680..1939a84fdb 100644 --- a/internal/cli/status.go +++ b/internal/cli/status.go @@ -30,7 +30,7 @@ func (c *StatusCommand) Flags() *flagset.Flagset { } // MarkDown implements cli.MarkDown interface -func (p *StatusCommand) MarkDown() string { +func (c *StatusCommand) MarkDown() string { items := []string{ "# Status", "The ```status``` command outputs the status of the client.", @@ -40,7 +40,7 @@ func (p *StatusCommand) MarkDown() string { } // Help implements the cli.Command interface -func (p *StatusCommand) Help() string { +func (c *StatusCommand) Help() string { return `Usage: bor status Output the status of the client` diff --git a/internal/cli/version.go b/internal/cli/version.go index 949599904e..b603da141e 100644 --- a/internal/cli/version.go +++ b/internal/cli/version.go @@ -14,7 +14,7 @@ type VersionCommand struct { } // MarkDown implements cli.MarkDown interface -func (d *VersionCommand) MarkDown() string { +func (c *VersionCommand) MarkDown() string { examples := []string{ "## Usage", CodeBlock([]string{ diff --git a/internal/debug/api.go b/internal/debug/api.go index 91a8df311f..b4141c3487 100644 --- a/internal/debug/api.go +++ b/internal/debug/api.go @@ -36,7 +36,7 @@ import ( "time" "github.com/ethereum/go-ethereum/log" - "github.com/hashicorp/go-bexpr" + bexpr "github.com/hashicorp/go-bexpr" ) // Handler is the global debugging handler. diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 19222c8325..4b3748700d 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -32,10 +32,10 @@ import ( "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/exp" "github.com/fjl/memsize/memsizeui" - "github.com/mattn/go-colorable" - "github.com/mattn/go-isatty" - "github.com/urfave/cli/v2" - "gopkg.in/natefinch/lumberjack.v2" + colorable "github.com/mattn/go-colorable" + isatty "github.com/mattn/go-isatty" + cli "github.com/urfave/cli/v2" + lumberjack "gopkg.in/natefinch/lumberjack.v2" ) var Memsize memsizeui.Handler diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 0b2b2d29ae..0ac6ddd5fb 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -685,8 +685,8 @@ func NewBlockChainAPI(b Backend) *BlockChainAPI { } // GetTransactionReceiptsByBlock returns the transaction receipts for the given block number or hash. -func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error) { - block, err := s.b.BlockByNumberOrHash(ctx, blockNrOrHash) +func (api *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error) { + block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash) if err != nil { return nil, err } @@ -695,7 +695,7 @@ func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, block return nil, errors.New("block not found") } - receipts, err := s.b.GetReceipts(ctx, block.Hash()) + receipts, err := api.b.GetReceipts(ctx, block.Hash()) if err != nil { return nil, err } @@ -704,13 +704,13 @@ func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, block var txHash common.Hash - borReceipt := rawdb.ReadBorReceipt(s.b.ChainDb(), block.Hash(), block.NumberU64(), s.b.ChainConfig()) + borReceipt := rawdb.ReadBorReceipt(api.b.ChainDb(), block.Hash(), block.NumberU64(), api.b.ChainConfig()) if borReceipt != nil { receipts = append(receipts, borReceipt) txHash = types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash())) if txHash != (common.Hash{}) { - borTx, _, _, _, _ := s.b.GetBorBlockTransactionWithBlockHash(ctx, txHash, block.Hash()) + borTx, _, _, _, _ := api.b.GetBorBlockTransactionWithBlockHash(ctx, txHash, block.Hash()) txs = append(txs, borTx) } } @@ -724,7 +724,7 @@ func (s *BlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, block for idx, receipt := range receipts { tx := txs[idx] - signer := types.MakeSigner(s.b.ChainConfig(), block.Number(), block.Time()) + signer := types.MakeSigner(api.b.ChainConfig(), block.Number(), block.Time()) from, _ := types.Sender(signer, tx) fields := map[string]interface{}{ diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 75b705798a..ac825fa402 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -2057,7 +2057,7 @@ func TestRPCGetTransactionReceiptsByBlock(t *testing.T) { contract = common.HexToAddress("0000000000000000000000000000000000031ec7") genesis = &core.Genesis{ Config: params.TestChainConfig, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ acc1Addr: {Balance: big.NewInt(params.Ether)}, acc2Addr: {Balance: big.NewInt(params.Ether)}, contract: {Balance: big.NewInt(params.Ether), Code: common.FromHex("0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a9059cbb14610030575b600080fd5b61004a6004803603810190610045919061016a565b610060565b60405161005791906101c5565b60405180910390f35b60008273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516100bf91906101ef565b60405180910390a36001905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610101826100d6565b9050919050565b610111816100f6565b811461011c57600080fd5b50565b60008135905061012e81610108565b92915050565b6000819050919050565b61014781610134565b811461015257600080fd5b50565b6000813590506101648161013e565b92915050565b60008060408385031215610181576101806100d1565b5b600061018f8582860161011f565b92505060206101a085828601610155565b9150509250929050565b60008115159050919050565b6101bf816101aa565b82525050565b60006020820190506101da60008301846101b6565b92915050565b6101e981610134565b82525050565b600060208201905061020460008301846101e0565b9291505056fea2646970667358221220b469033f4b77b9565ee84e0a2f04d496b18160d26034d54f9487e57788fd36d564736f6c63430008120033")}, diff --git a/miner/worker_test.go b/miner/worker_test.go index 16f98439a3..1f90c79ec1 100644 --- a/miner/worker_test.go +++ b/miner/worker_test.go @@ -227,7 +227,7 @@ type testWorkerBackend struct { func newTestWorkerBackend(t TensingObject, chainConfig *params.ChainConfig, engine consensus.Engine, db ethdb.Database) *testWorkerBackend { var gspec = &core.Genesis{ Config: chainConfig, - Alloc: core.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, + Alloc: types.GenesisAlloc{testBankAddress: {Balance: testBankFunds}}, } switch e := engine.(type) { case *bor.Bor: diff --git a/node/node.go b/node/node.go index 40b67851bd..643f7615e9 100644 --- a/node/node.go +++ b/node/node.go @@ -466,12 +466,11 @@ func (n *Node) startRPC() error { } if err := server.enableWS(openAPIs, wsConfig{ - executionPoolSize: n.config.WSJsonRPCExecutionPoolSize, - executionPoolRequestTimeout: n.config.WSJsonRPCExecutionPoolRequestTimeout, - Modules: n.config.WSModules, - Origins: n.config.WSOrigins, - prefix: n.config.WSPathPrefix, - rpcEndpointConfig: rpcConfig, + executionPoolSize: n.config.WSJsonRPCExecutionPoolSize, + Modules: n.config.WSModules, + Origins: n.config.WSOrigins, + prefix: n.config.WSPathPrefix, + rpcEndpointConfig: rpcConfig, }); err != nil { return err } diff --git a/node/rpcstack.go b/node/rpcstack.go index 9dd3ebd769..7b4d723eeb 100644 --- a/node/rpcstack.go +++ b/node/rpcstack.go @@ -45,19 +45,17 @@ type httpConfig struct { prefix string // path prefix on which to mount http handler // Execution pool config - executionPoolSize uint64 - executionPoolRequestTimeout time.Duration + executionPoolSize uint64 rpcEndpointConfig } // wsConfig is the JSON-RPC/Websocket configuration type wsConfig struct { // Execution pool config - executionPoolSize uint64 - executionPoolRequestTimeout time.Duration - Origins []string - Modules []string - prefix string // path prefix on which to mount ws handler + executionPoolSize uint64 + Origins []string + Modules []string + prefix string // path prefix on which to mount ws handler rpcEndpointConfig } diff --git a/params/config.go b/params/config.go index bee3a14c55..53a144f36b 100644 --- a/params/config.go +++ b/params/config.go @@ -678,7 +678,7 @@ type BorConfig struct { } // String implements the stringer interface, returning the consensus engine details. -func (b *BorConfig) String() string { +func (c *BorConfig) String() string { return "bor" } @@ -1258,6 +1258,7 @@ func newBlockCompatError(what string, storedblock, newblock *big.Int) *ConfigCom return err } +// nolint func newTimestampCompatError(what string, storedtime, newtime *uint64) *ConfigCompatError { var rew *uint64 switch { diff --git a/scripts/getconfig.go b/scripts/getconfig.go index 1dfe5b9e80..44ea9b51f3 100644 --- a/scripts/getconfig.go +++ b/scripts/getconfig.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/pelletier/go-toml" + toml "github.com/pelletier/go-toml" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/internal/cli/server" diff --git a/tests/bor/bor_test.go b/tests/bor/bor_test.go index b9efc9ff80..47136f7931 100644 --- a/tests/bor/bor_test.go +++ b/tests/bor/bor_test.go @@ -772,7 +772,7 @@ func TestEIP1559Transition(t *testing.T) { funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)) gspec = &core.Genesis{ Config: params.BorUnittestChainConfig, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr1: {Balance: funds}, addr2: {Balance: funds}, addr3: {Balance: funds}, @@ -989,7 +989,7 @@ func TestBurnContract(t *testing.T) { funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)) gspec = &core.Genesis{ Config: params.BorUnittestChainConfig, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr1: {Balance: funds}, addr2: {Balance: funds}, addr3: {Balance: funds}, @@ -1274,7 +1274,7 @@ func TestEIP1559TransitionWithEIP155(t *testing.T) { funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)) gspec = &core.Genesis{ Config: params.BorUnittestChainConfig, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr1: {Balance: funds}, addr2: {Balance: funds}, addr3: {Balance: funds}, @@ -1347,7 +1347,7 @@ func TestTransitionWithoutEIP155(t *testing.T) { funds = new(big.Int).Mul(common.Big1, big.NewInt(params.Ether)) gspec = &core.Genesis{ Config: params.BorUnittestChainConfig, - Alloc: core.GenesisAlloc{ + Alloc: types.GenesisAlloc{ addr1: {Balance: funds}, addr2: {Balance: funds}, addr3: {Balance: funds},