Skip to content

Commit

Permalink
fix: few linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anshalshukla committed Sep 2, 2024
1 parent c0c1298 commit 43043ed
Show file tree
Hide file tree
Showing 44 changed files with 113 additions and 129 deletions.
4 changes: 2 additions & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}

Expand Down
16 changes: 8 additions & 8 deletions accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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()

Expand All @@ -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()

Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion accounts/scwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion accounts/usbwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion beacon/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/blsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/era/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/internal/t8ntool/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions core/blockstm/mvhashmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eth/fetcher/block_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/live/supply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion ethclient/ethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/bootnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/chain_sethead.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number>``` 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")
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/debug_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number>``` command will create an archive containing traces of a bor block.",
p.Flags().MarkDown(),
c.Flags().MarkDown(),
}

return strings.Join(items, "\n\n")
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/debug_pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <enode>``` command will create an archive containing bor pprof traces.",
p.Flags().MarkDown(),
d.Flags().MarkDown(),
}

return strings.Join(items, "\n\n")
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/dumpconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your-favourite-flags>``` command will export the user provided flags into a configuration file",
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
18 changes: 9 additions & 9 deletions internal/cli/peers_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit 43043ed

Please sign in to comment.