Skip to content

Commit

Permalink
chore: linting/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iquidus committed Aug 16, 2021
1 parent cd9e55a commit 70cebe9
Show file tree
Hide file tree
Showing 33 changed files with 73 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ linters:
enable:
- deadcode
- goconst
- goimports
# - goimports
- gosimple
- govet
- ineffassign
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/unpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"strings"
"testing"

"github.com/ubiq/go-ubiq/v5/common"
"github.com/stretchr/testify/require"
"github.com/ubiq/go-ubiq/v5/common"
)

// TestUnpack tests the general pack/unpack tests in packing_test.go
Expand Down
2 changes: 1 addition & 1 deletion accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"math/big"

"github.com/ubiq/go-ubiq/v5"
ethereum "github.com/ubiq/go-ubiq/v5"
"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/core/types"
"github.com/ubiq/go-ubiq/v5/event"
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package keystore
import (
"math/big"

"github.com/ubiq/go-ubiq/v5"
ethereum "github.com/ubiq/go-ubiq/v5"
"github.com/ubiq/go-ubiq/v5/accounts"
"github.com/ubiq/go-ubiq/v5/core/types"
"github.com/ubiq/go-ubiq/v5/crypto"
Expand Down
2 changes: 1 addition & 1 deletion accounts/keystore/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ package keystore
import (
"time"

"github.com/ubiq/go-ubiq/v5/log"
"github.com/rjeczalik/notify"
"github.com/ubiq/go-ubiq/v5/log"
)

type watcher struct {
Expand Down
2 changes: 1 addition & 1 deletion accounts/scwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

pcsc "github.com/gballet/go-libpcsclite"
"github.com/status-im/keycard-go/derivationpath"
"github.com/ubiq/go-ubiq/v5"
ethereum "github.com/ubiq/go-ubiq/v5"
"github.com/ubiq/go-ubiq/v5/accounts"
"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/core/types"
Expand Down
6 changes: 3 additions & 3 deletions cmd/puppeth/module_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func deployNode(client *sshClient, network string, bootnodes []string, config *n
template.Must(template.New("").Parse(nodeComposefile)).Execute(composefile, map[string]interface{}{
"Type": kind,
"Datadir": config.datadir,
"Ubqhashdir": config.ubqhashdir,
"Ubqhashdir": config.ubqhashdir,
"Network": network,
"Port": config.port,
"TotalPeers": config.peersTotal,
Expand Down Expand Up @@ -155,7 +155,7 @@ type nodeInfos struct {
genesis []byte
network int64
datadir string
ubqhashdir string
ubqhashdir string
ethstats string
port int
enode string
Expand Down Expand Up @@ -255,7 +255,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
stats := &nodeInfos{
genesis: genesis,
datadir: infos.volumes["/root/.ubiq"],
ubqhashdir: infos.volumes["/root/.ubqhash"],
ubqhashdir: infos.volumes["/root/.ubqhash"],
port: port,
peersTotal: totalPeers,
peersLight: lightPeers,
Expand Down
12 changes: 0 additions & 12 deletions cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,3 @@ func (w *wizard) manageGenesis() {
return
}
}

// saveGenesis JSON encodes an arbitrary genesis spec into a pre-defined file.
func saveGenesis(folder, network, client string, spec interface{}) {
path := filepath.Join(folder, fmt.Sprintf("%s-%s.json", network, client))

out, _ := json.MarshalIndent(spec, "", " ")
if err := ioutil.WriteFile(path, out, 0644); err != nil {
log.Error("Failed to save genesis file", "client", client, "err", err)
return
}
log.Info("Saved genesis chain spec", "client", client, "path", path)
}
2 changes: 1 addition & 1 deletion cmd/puppeth/wizard_netstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"strings"
"sync"

"github.com/olekukonko/tablewriter"
"github.com/ubiq/go-ubiq/v5/core"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/olekukonko/tablewriter"
)

// networkStats verifies the status of network components and generates a protip
Expand Down
6 changes: 4 additions & 2 deletions core/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3218,11 +3218,13 @@ func TestEIP1559Transition(t *testing.T) {

state, _ := chain.State()

reward, _ := ubqhash.CalcBaseBlockReward(chain.Config().Ubqhash, block.Number())

// 3: Ensure that miner received only the tx's tip.
actual := state.GetBalance(block.Coinbase())
expected := new(big.Int).Add(
new(big.Int).SetUint64(block.GasUsed()*block.Transactions()[0].GasTipCap().Uint64()),
ubqhash.ConstantinopleBlockReward,
reward,
)
if actual.Cmp(expected) != 0 {
t.Fatalf("miner balance incorrect: expected %d, got %d", expected, actual)
Expand Down Expand Up @@ -3262,7 +3264,7 @@ func TestEIP1559Transition(t *testing.T) {
actual = state.GetBalance(block.Coinbase())
expected = new(big.Int).Add(
new(big.Int).SetUint64(block.GasUsed()*effectiveTip),
ubqhash.ConstantinopleBlockReward,
reward,
)
if actual.Cmp(expected) != 0 {
t.Fatalf("miner balance incorrect: expected %d, got %d", expected, actual)
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"sync/atomic"
"time"

"github.com/olekukonko/tablewriter"
"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/ethdb"
"github.com/ubiq/go-ubiq/v5/ethdb/leveldb"
"github.com/ubiq/go-ubiq/v5/ethdb/memorydb"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/olekukonko/tablewriter"
)

// freezerdb is a database wrapper that enabled freezer data retrievals.
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/freezer_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"sync"
"sync/atomic"

"github.com/golang/snappy"
"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/metrics"
"github.com/golang/snappy"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestStateProcessorErrors(t *testing.T) {
},
}
genesis = gspec.MustCommit(db)
blockchain, _ = NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
blockchain, _ = NewBlockChain(db, nil, gspec.Config, ubqhash.NewFaker(), vm.Config{}, nil, nil)
)
defer blockchain.Stop()
for i, tt := range []struct {
Expand All @@ -272,7 +272,7 @@ func TestStateProcessorErrors(t *testing.T) {
want: "could not apply tx 0 [0x88626ac0d53cb65308f2416103c62bb1f18b805573d4f96a3640bbbfff13c14f]: sender not an eoa: address 0x71562b71999873DB5b286dF957af199Ec94617F7, codehash: 0x9280914443471259d4570a8661015ae4a5b80186dbc619658fb494bebc3da3d1",
},
} {
block := GenerateBadBlock(genesis, ethash.NewFaker(), tt.txs, gspec.Config)
block := GenerateBadBlock(genesis, ubqhash.NewFaker(), tt.txs, gspec.Config)
_, err := blockchain.InsertChain(types.Blocks{block})
if err == nil {
t.Fatal("block imported without errors")
Expand Down
2 changes: 1 addition & 1 deletion eth/downloader/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"
"sync"

"github.com/ubiq/go-ubiq/v5"
ethereum "github.com/ubiq/go-ubiq/v5"
"github.com/ubiq/go-ubiq/v5/event"
"github.com/ubiq/go-ubiq/v5/rpc"
)
Expand Down
9 changes: 4 additions & 5 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ var (
MaxReceiptFetch = 256 // Amount of transaction receipts to allow fetching per request
MaxStateFetch = 384 // Amount of node state values to allow fetching per request

maxQueuedHeaders = 32 * 1024 // [eth/62] Maximum number of headers to queue for import (DOS protection)
maxHeadersProcess = 2048 // Number of header download results to import at once into the chain
maxResultsProcess = 2048 // Number of content download results to import at once into the chain
fullMaxForkAncestry uint64 = params.FullImmutabilityThreshold // Maximum chain reorganisation (locally redeclared so tests can reduce it)
lightMaxForkAncestry uint64 = params.LightImmutabilityThreshold // Maximum chain reorganisation (locally redeclared so tests can reduce it)
maxQueuedHeaders = 32 * 1024 // [eth/62] Maximum number of headers to queue for import (DOS protection)
maxHeadersProcess = 2048 // Number of header download results to import at once into the chain
maxResultsProcess = 2048 // Number of content download results to import at once into the chain
fullMaxForkAncestry uint64 = params.FullImmutabilityThreshold // Maximum chain reorganisation (locally redeclared so tests can reduce it)

reorgProtThreshold = 48 // Threshold number of recent blocks to disable mini reorg protection
reorgProtHeaderDelay = 2 // Number of headers to delay delivering to cover mini reorgs
Expand Down
7 changes: 2 additions & 5 deletions eth/downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,8 @@ func testMultiProtoSync(t *testing.T, protocol uint, mode SyncMode) {
func TestEmptyShortCircuit65Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, FullSync) }
func TestEmptyShortCircuit65Fast(t *testing.T) { testEmptyShortCircuit(t, eth.ETH65, FastSync) }

func TestEmptyShortCircuit65Full(t *testing.T) { testEmptyShortCircuit(t, 65, FullSync) }
func TestEmptyShortCircuit65Fast(t *testing.T) { testEmptyShortCircuit(t, 65, FastSync) }

func TestEmptyShortCircuit66Full(t *testing.T) { testEmptyShortCircuit(t, 66, FullSync) }
func TestEmptyShortCircuit66Fast(t *testing.T) { testEmptyShortCircuit(t, 66, FastSync) }
func TestEmptyShortCircuit66Full(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, FullSync) }
func TestEmptyShortCircuit66Fast(t *testing.T) { testEmptyShortCircuit(t, eth.ETH66, FastSync) }

func testEmptyShortCircuit(t *testing.T, protocol uint, mode SyncMode) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestNoStepExec(t *testing.T) {
}

func TestIsPrecompile(t *testing.T) {
chaincfg := &params.ChainConfig{ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(200), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(300), LondonBlock: big.NewInt(0), CatalystBlock: nil, Ethash: new(params.EthashConfig), Clique: nil}
chaincfg := &params.ChainConfig{ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), EIP150Block: big.NewInt(0), EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(200), BerlinBlock: big.NewInt(300), LondonBlock: big.NewInt(0), Ubqhash: new(params.UbqhashConfig), Clique: nil}
chaincfg.ByzantiumBlock = big.NewInt(100)
chaincfg.IstanbulBlock = big.NewInt(200)
chaincfg.BerlinBlock = big.NewInt(300)
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/tracers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func BenchmarkTransactionTrace(b *testing.B) {
//DisableMemory: true,
//DisableReturnData: true,
})
evm := vm.NewEVM(context, txContext, statedb, params.AllEthashProtocolChanges, vm.Config{Debug: true, Tracer: tracer})
evm := vm.NewEVM(context, txContext, statedb, params.AllUbqhashProtocolChanges, vm.Config{Debug: true, Tracer: tracer})
msg, err := tx.AsMessage(signer, nil)
if err != nil {
b.Fatalf("failed to prepare transaction for tracing: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions ethdb/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import (
"sync"
"time"

"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/ethdb"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/metrics"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/filter"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/util"
"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/ethdb"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/metrics"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions internal/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"os"
"runtime"

"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/metrics"
"github.com/ubiq/go-ubiq/v5/metrics/exp"
"github.com/fjl/memsize/memsizeui"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/metrics"
"github.com/ubiq/go-ubiq/v5/metrics/exp"
"gopkg.in/urfave/cli.v1"
)

Expand Down
2 changes: 1 addition & 1 deletion metrics/cpu_enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package metrics

import (
"github.com/ubiq/go-ubiq/v5/log"
"github.com/shirou/gopsutil/cpu"
"github.com/ubiq/go-ubiq/v5/log"
)

// ReadCPUStats retrieves the current CPU stats.
Expand Down
2 changes: 1 addition & 1 deletion metrics/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
uurl "net/url"
"time"

"github.com/influxdata/influxdb/client"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/metrics"
"github.com/influxdata/influxdb/client"
)

type reporter struct {
Expand Down
10 changes: 5 additions & 5 deletions miner/stress/1559/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/ubiq/go-ubiq/v5/accounts/keystore"
"github.com/ubiq/go-ubiq/v5/common"
"github.com/ubiq/go-ubiq/v5/common/fdlimit"
"github.com/ubiq/go-ubiq/v5/consensus/ethash"
"github.com/ubiq/go-ubiq/v5/consensus/ubqhash"
"github.com/ubiq/go-ubiq/v5/core"
"github.com/ubiq/go-ubiq/v5/core/types"
"github.com/ubiq/go-ubiq/v5/crypto"
Expand Down Expand Up @@ -58,7 +58,7 @@ func main() {
faucets[i], _ = crypto.GenerateKey()
}
// Pre-generate the ethash mining DAG so we don't race
ethash.MakeDataset(1, filepath.Join(os.Getenv("HOME"), ".ethash"))
ubqhash.MakeDataset(1, filepath.Join(os.Getenv("HOME"), ".ubqhash"))

// Create an Ethash network based off of the Ropsten config
genesis := makeGenesis(faucets)
Expand Down Expand Up @@ -186,9 +186,9 @@ func makeTransaction(nonce uint64, privKey *ecdsa.PrivateKey, signer types.Signe
// makeGenesis creates a custom Ethash genesis block based on some pre-defined
// faucet accounts.
func makeGenesis(faucets []*ecdsa.PrivateKey) *core.Genesis {
genesis := core.DefaultRopstenGenesisBlock()
genesis := core.DefaultRinkebyGenesisBlock()

genesis.Config = params.AllEthashProtocolChanges
genesis.Config = params.AllUbqhashProtocolChanges
genesis.Config.LondonBlock = londonBlock
genesis.Difficulty = params.MinimumDifficulty

Expand Down Expand Up @@ -240,7 +240,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
DatabaseHandles: 256,
TxPool: core.DefaultTxPoolConfig,
GPO: ethconfig.Defaults.GPO,
Ethash: ethconfig.Defaults.Ethash,
Ubqhash: ethconfig.Defaults.Ubqhash,
Miner: miner.Config{
GasCeil: genesis.GasLimit * 11 / 10,
GasPrice: big.NewInt(1),
Expand Down
4 changes: 2 additions & 2 deletions miner/stress/ethash/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func main() {
// makeGenesis creates a custom Ubqhash genesis block based on some pre-defined
// faucet accounts.
func makeGenesis(faucets []*ecdsa.PrivateKey) *core.Genesis {
genesis := core.DefaultTestnetGenesisBlock()
genesis := core.DefaultRinkebyGenesisBlock()
genesis.Difficulty = params.MinimumDifficulty
genesis.GasLimit = 25000000

Expand Down Expand Up @@ -169,7 +169,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
DatabaseHandles: 256,
TxPool: core.DefaultTxPoolConfig,
GPO: ethconfig.Defaults.GPO,
Ethash: ethconfig.Defaults.Ethash,
Ubqhash: ethconfig.Defaults.Ubqhash,
Miner: miner.Config{
GasCeil: genesis.GasLimit * 11 / 10,
GasPrice: big.NewInt(1),
Expand Down
2 changes: 1 addition & 1 deletion p2p/dnsdisc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"sync"
"time"

lru "github.com/hashicorp/golang-lru"
"github.com/ubiq/go-ubiq/v5/common/mclock"
"github.com/ubiq/go-ubiq/v5/crypto"
"github.com/ubiq/go-ubiq/v5/log"
"github.com/ubiq/go-ubiq/v5/p2p/enode"
"github.com/ubiq/go-ubiq/v5/p2p/enr"
lru "github.com/hashicorp/golang-lru"
"golang.org/x/sync/singleflight"
"golang.org/x/time/rate"
)
Expand Down
4 changes: 2 additions & 2 deletions p2p/enode/idscheme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
"math/big"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/ubiq/go-ubiq/v5/crypto"
"github.com/ubiq/go-ubiq/v5/p2p/enr"
"github.com/ubiq/go-ubiq/v5/rlp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion p2p/enode/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"testing"
"testing/quick"

"github.com/stretchr/testify/assert"
"github.com/ubiq/go-ubiq/v5/p2p/enr"
"github.com/ubiq/go-ubiq/v5/rlp"
"github.com/stretchr/testify/assert"
)

var pyRecord, _ = hex.DecodeString("f884b8407098ad865b00a582051940cb9cf36836572411a47278783077011599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11df72ecf1145ccb9c01826964827634826970847f00000189736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31388375647082765f")
Expand Down
2 changes: 1 addition & 1 deletion p2p/enr/enr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
"testing"
"time"

"github.com/ubiq/go-ubiq/v5/rlp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/ubiq/go-ubiq/v5/rlp"
)

var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
Expand Down
Loading

0 comments on commit 70cebe9

Please sign in to comment.