Skip to content

Commit 810f9e0

Browse files
authored
all: remove redundant conversions and import names (ethereum#21903)
1 parent f59ed35 commit 810f9e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+66
-67
lines changed

accounts/abi/reflect_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ func TestConvertType(t *testing.T) {
202202
fields = append(fields, reflect.StructField{
203203
Name: "X",
204204
Type: reflect.TypeOf(new(big.Int)),
205-
Tag: reflect.StructTag("json:\"" + "x" + "\""),
205+
Tag: "json:\"" + "x" + "\"",
206206
})
207207
fields = append(fields, reflect.StructField{
208208
Name: "Y",
209209
Type: reflect.TypeOf(new(big.Int)),
210-
Tag: reflect.StructTag("json:\"" + "y" + "\""),
210+
Tag: "json:\"" + "y" + "\"",
211211
})
212212
val := reflect.New(reflect.StructOf(fields))
213213
val.Elem().Field(0).Set(reflect.ValueOf(big.NewInt(1)))

accounts/abi/type_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func TestTypeCheck(t *testing.T) {
255255
{"bytes", nil, [2]byte{0, 1}, "abi: cannot use array as type slice as argument"},
256256
{"bytes", nil, common.Hash{1}, "abi: cannot use array as type slice as argument"},
257257
{"string", nil, "hello world", ""},
258-
{"string", nil, string(""), ""},
258+
{"string", nil, "", ""},
259259
{"string", nil, []byte{}, "abi: cannot use slice as type string as argument"},
260260
{"bytes32[]", nil, [][32]byte{{}}, ""},
261261
{"function", nil, [24]byte{}, ""},

accounts/accounts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"math/big"
2323

24-
ethereum "github.com/ethereum/go-ethereum"
24+
"github.com/ethereum/go-ethereum"
2525
"github.com/ethereum/go-ethereum/common"
2626
"github.com/ethereum/go-ethereum/core/types"
2727
"github.com/ethereum/go-ethereum/event"

accounts/keystore/passphrase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
230230
key := crypto.ToECDSAUnsafe(keyBytes)
231231

232232
return &Key{
233-
Id: uuid.UUID(keyId),
233+
Id: keyId,
234234
Address: crypto.PubkeyToAddress(key.PublicKey),
235235
PrivateKey: key,
236236
}, nil

accounts/keystore/wallet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package keystore
1919
import (
2020
"math/big"
2121

22-
ethereum "github.com/ethereum/go-ethereum"
22+
"github.com/ethereum/go-ethereum"
2323
"github.com/ethereum/go-ethereum/accounts"
2424
"github.com/ethereum/go-ethereum/core/types"
2525
"github.com/ethereum/go-ethereum/crypto"

accounts/scwallet/wallet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"sync"
3434
"time"
3535

36-
ethereum "github.com/ethereum/go-ethereum"
36+
"github.com/ethereum/go-ethereum"
3737
"github.com/ethereum/go-ethereum/accounts"
3838
"github.com/ethereum/go-ethereum/common"
3939
"github.com/ethereum/go-ethereum/core/types"

accounts/usbwallet/wallet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"sync"
2626
"time"
2727

28-
ethereum "github.com/ethereum/go-ethereum"
28+
"github.com/ethereum/go-ethereum"
2929
"github.com/ethereum/go-ethereum/accounts"
3030
"github.com/ethereum/go-ethereum/common"
3131
"github.com/ethereum/go-ethereum/core/types"

cmd/clef/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import (
5454
"github.com/ethereum/go-ethereum/signer/rules"
5555
"github.com/ethereum/go-ethereum/signer/storage"
5656

57-
colorable "github.com/mattn/go-colorable"
57+
"github.com/mattn/go-colorable"
5858
"github.com/mattn/go-isatty"
5959
"gopkg.in/urfave/cli.v1"
6060
)

cmd/devp2p/dnscmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/ethereum/go-ethereum/console/prompt"
3131
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
3232
"github.com/ethereum/go-ethereum/p2p/enode"
33-
cli "gopkg.in/urfave/cli.v1"
33+
"gopkg.in/urfave/cli.v1"
3434
)
3535

3636
var (

cmd/evm/compiler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
"github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
2525

26-
cli "gopkg.in/urfave/cli.v1"
26+
"gopkg.in/urfave/cli.v1"
2727
)
2828

2929
var compileCommand = cli.Command{

cmd/evm/disasm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"strings"
2424

2525
"github.com/ethereum/go-ethereum/core/asm"
26-
cli "gopkg.in/urfave/cli.v1"
26+
"gopkg.in/urfave/cli.v1"
2727
)
2828

2929
var disasmCommand = cli.Command{

cmd/evm/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"github.com/ethereum/go-ethereum/core/vm/runtime"
3939
"github.com/ethereum/go-ethereum/log"
4040
"github.com/ethereum/go-ethereum/params"
41-
cli "gopkg.in/urfave/cli.v1"
41+
"gopkg.in/urfave/cli.v1"
4242
)
4343

4444
var runCommand = cli.Command{

cmd/evm/staterunner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/ethereum/go-ethereum/log"
2929
"github.com/ethereum/go-ethereum/tests"
3030

31-
cli "gopkg.in/urfave/cli.v1"
31+
"gopkg.in/urfave/cli.v1"
3232
)
3333

3434
var stateTestCommand = cli.Command{

cmd/geth/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"reflect"
2525
"unicode"
2626

27-
cli "gopkg.in/urfave/cli.v1"
27+
"gopkg.in/urfave/cli.v1"
2828

2929
"github.com/ethereum/go-ethereum/cmd/utils"
3030
"github.com/ethereum/go-ethereum/eth"

cmd/geth/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"github.com/ethereum/go-ethereum/metrics"
4343
"github.com/ethereum/go-ethereum/node"
4444
gopsutil "github.com/shirou/gopsutil/mem"
45-
cli "gopkg.in/urfave/cli.v1"
45+
"gopkg.in/urfave/cli.v1"
4646
)
4747

4848
const (

cmd/geth/usage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/ethereum/go-ethereum/cmd/utils"
2626
"github.com/ethereum/go-ethereum/internal/debug"
2727
"github.com/ethereum/go-ethereum/internal/flags"
28-
cli "gopkg.in/urfave/cli.v1"
28+
"gopkg.in/urfave/cli.v1"
2929
)
3030

3131
// AppHelpFlagGroups is the application flags, grouped by functionality.

cmd/puppeth/genesis.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func newAlethGenesisSpec(network string, genesis *core.Genesis) (*alethGenesisSp
152152
spec.Genesis.Author = genesis.Coinbase
153153
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)
154154
spec.Genesis.ParentHash = genesis.ParentHash
155-
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData)
155+
spec.Genesis.ExtraData = genesis.ExtraData
156156
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
157157

158158
for address, account := range genesis.Alloc {
@@ -430,7 +430,7 @@ func newParityChainSpec(network string, genesis *core.Genesis, bootnodes []strin
430430
spec.Genesis.Author = genesis.Coinbase
431431
spec.Genesis.Timestamp = (hexutil.Uint64)(genesis.Timestamp)
432432
spec.Genesis.ParentHash = genesis.ParentHash
433-
spec.Genesis.ExtraData = (hexutil.Bytes)(genesis.ExtraData)
433+
spec.Genesis.ExtraData = genesis.ExtraData
434434
spec.Genesis.GasLimit = (hexutil.Uint64)(genesis.GasLimit)
435435

436436
spec.Accounts = make(map[common.UnprefixedAddress]*parityChainSpecAccount)

cmd/utils/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import (
6464
"github.com/ethereum/go-ethereum/p2p/netutil"
6565
"github.com/ethereum/go-ethereum/params"
6666
pcsclite "github.com/gballet/go-libpcsclite"
67-
cli "gopkg.in/urfave/cli.v1"
67+
"gopkg.in/urfave/cli.v1"
6868
)
6969

7070
func init() {

common/hexutil/json_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestUnmarshalBytes(t *testing.T) {
8888
if !checkError(t, test.input, err, test.wantErr) {
8989
continue
9090
}
91-
if !bytes.Equal(test.want.([]byte), []byte(v)) {
91+
if !bytes.Equal(test.want.([]byte), v) {
9292
t.Errorf("input %s: value mismatch: got %x, want %x", test.input, &v, test.want)
9393
continue
9494
}

consensus/ethash/ethash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"time"
3434
"unsafe"
3535

36-
mmap "github.com/edsrzf/mmap-go"
36+
"github.com/edsrzf/mmap-go"
3737
"github.com/ethereum/go-ethereum/consensus"
3838
"github.com/ethereum/go-ethereum/log"
3939
"github.com/ethereum/go-ethereum/metrics"

contracts/checkpointoracle/oracle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (oracle *CheckpointOracle) LookupCheckpointEvents(blockLogs [][]*types.Log,
6565
if err != nil {
6666
continue
6767
}
68-
if event.Index == section && common.Hash(event.CheckpointHash) == hash {
68+
if event.Index == section && event.CheckpointHash == hash {
6969
votes = append(votes, event)
7070
}
7171
}

core/state/statedb.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
318318
func (s *StateDB) GetProof(a common.Address) ([][]byte, error) {
319319
var proof proofList
320320
err := s.trie.Prove(crypto.Keccak256(a.Bytes()), 0, &proof)
321-
return [][]byte(proof), err
321+
return proof, err
322322
}
323323

324324
// GetStorageProof returns the StorageProof for given key
@@ -329,7 +329,7 @@ func (s *StateDB) GetStorageProof(a common.Address, key common.Hash) ([][]byte,
329329
return proof, errors.New("storage trie for requested address does not exist")
330330
}
331331
err := trie.Prove(crypto.Keccak256(key.Bytes()), 0, &proof)
332-
return [][]byte(proof), err
332+
return proof, err
333333
}
334334

335335
// GetCommittedState retrieves a value from the given account's committed storage trie.

core/tx_pool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ func TestTransactionAllowedTxSize(t *testing.T) {
11391139
t.Fatalf("expected rejection on slightly oversize transaction")
11401140
}
11411141
// Try adding a transaction of random not allowed size
1142-
if err := pool.addRemoteSync(pricedDataTransaction(2, pool.currentMaxGas, big.NewInt(1), key, dataSize+1+uint64(rand.Intn(int(10*txMaxSize))))); err == nil {
1142+
if err := pool.addRemoteSync(pricedDataTransaction(2, pool.currentMaxGas, big.NewInt(1), key, dataSize+1+uint64(rand.Intn(10*txMaxSize)))); err == nil {
11431143
t.Fatalf("expected rejection on oversize transaction")
11441144
}
11451145
// Run some sanity checks on the pool internals

core/vm/evm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I
525525
// instead of the usual sender-and-nonce-hash as the address where the contract is initialized at.
526526
func (evm *EVM) Create2(caller ContractRef, code []byte, gas uint64, endowment *big.Int, salt *uint256.Int) (ret []byte, contractAddr common.Address, leftOverGas uint64, err error) {
527527
codeAndHash := &codeAndHash{code: code}
528-
contractAddr = crypto.CreateAddress2(caller.Address(), common.Hash(salt.Bytes32()), codeAndHash.Hash().Bytes())
528+
contractAddr = crypto.CreateAddress2(caller.Address(), salt.Bytes32(), codeAndHash.Hash().Bytes())
529529
return evm.create(caller, codeAndHash, gas, endowment, contractAddr)
530530
}
531531

core/vm/gas_table.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var (
9696
func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
9797
var (
9898
y, x = stack.Back(1), stack.Back(0)
99-
current = evm.StateDB.GetState(contract.Address(), common.Hash(x.Bytes32()))
99+
current = evm.StateDB.GetState(contract.Address(), x.Bytes32())
100100
)
101101
// The legacy gas metering only takes into consideration the current state
102102
// Legacy rules should be applied if we are in Petersburg (removal of EIP-1283)
@@ -135,7 +135,7 @@ func gasSStore(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySi
135135
if current == value { // noop (1)
136136
return params.NetSstoreNoopGas, nil
137137
}
138-
original := evm.StateDB.GetCommittedState(contract.Address(), common.Hash(x.Bytes32()))
138+
original := evm.StateDB.GetCommittedState(contract.Address(), x.Bytes32())
139139
if original == current {
140140
if original == (common.Hash{}) { // create slot (2.1.1)
141141
return params.NetSstoreInitGas, nil
@@ -183,14 +183,14 @@ func gasSStoreEIP2200(evm *EVM, contract *Contract, stack *Stack, mem *Memory, m
183183
// Gas sentry honoured, do the actual gas calculation based on the stored value
184184
var (
185185
y, x = stack.Back(1), stack.Back(0)
186-
current = evm.StateDB.GetState(contract.Address(), common.Hash(x.Bytes32()))
186+
current = evm.StateDB.GetState(contract.Address(), x.Bytes32())
187187
)
188188
value := common.Hash(y.Bytes32())
189189

190190
if current == value { // noop (1)
191191
return params.SloadGasEIP2200, nil
192192
}
193-
original := evm.StateDB.GetCommittedState(contract.Address(), common.Hash(x.Bytes32()))
193+
original := evm.StateDB.GetCommittedState(contract.Address(), x.Bytes32())
194194
if original == current {
195195
if original == (common.Hash{}) { // create slot (2.1.1)
196196
return params.SstoreSetGasEIP2200, nil

core/vm/instructions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func opReturnDataCopy(pc *uint64, interpreter *EVMInterpreter, callContext *call
341341

342342
func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
343343
slot := callContext.stack.peek()
344-
slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(common.Address(slot.Bytes20()))))
344+
slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(slot.Bytes20())))
345345
return nil, nil
346346
}
347347

@@ -517,7 +517,7 @@ func opSstore(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]
517517
loc := callContext.stack.pop()
518518
val := callContext.stack.pop()
519519
interpreter.evm.StateDB.SetState(callContext.contract.Address(),
520-
common.Hash(loc.Bytes32()), common.Hash(val.Bytes32()))
520+
loc.Bytes32(), val.Bytes32())
521521
return nil, nil
522522
}
523523

@@ -817,7 +817,7 @@ func opStop(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]by
817817
func opSuicide(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
818818
beneficiary := callContext.stack.pop()
819819
balance := interpreter.evm.StateDB.GetBalance(callContext.contract.Address())
820-
interpreter.evm.StateDB.AddBalance(common.Address(beneficiary.Bytes20()), balance)
820+
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance)
821821
interpreter.evm.StateDB.Suicide(callContext.contract.Address())
822822
return nil, nil
823823
}
@@ -832,7 +832,7 @@ func makeLog(size int) executionFunc {
832832
mStart, mSize := stack.pop(), stack.pop()
833833
for i := 0; i < size; i++ {
834834
addr := stack.pop()
835-
topics[i] = common.Hash(addr.Bytes32())
835+
topics[i] = addr.Bytes32()
836836
}
837837

838838
d := callContext.memory.GetCopy(int64(mStart.Uint64()), int64(mSize.Uint64()))

core/vm/operations_acl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func gasSStoreEIP2929(evm *EVM, contract *Contract, stack *Stack, mem *Memory, m
7373
// return params.SloadGasEIP2200, nil
7474
return cost + WarmStorageReadCostEIP2929, nil // SLOAD_GAS
7575
}
76-
original := evm.StateDB.GetCommittedState(contract.Address(), common.Hash(x.Bytes32()))
76+
original := evm.StateDB.GetCommittedState(contract.Address(), x.Bytes32())
7777
if original == current {
7878
if original == (common.Hash{}) { // create slot (2.1.1)
7979
return cost + params.SstoreSetGasEIP2200, nil

eth/downloader/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121
"sync"
2222

23-
ethereum "github.com/ethereum/go-ethereum"
23+
"github.com/ethereum/go-ethereum"
2424
"github.com/ethereum/go-ethereum/event"
2525
"github.com/ethereum/go-ethereum/rpc"
2626
)

eth/filters/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"sync"
2626
"time"
2727

28-
ethereum "github.com/ethereum/go-ethereum"
28+
"github.com/ethereum/go-ethereum"
2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/common/hexutil"
3131
"github.com/ethereum/go-ethereum/core/types"
@@ -292,7 +292,7 @@ func (api *PublicFilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) {
292292
logs := make(chan []*types.Log)
293293
logsSub, err := api.events.SubscribeLogs(ethereum.FilterQuery(crit), logs)
294294
if err != nil {
295-
return rpc.ID(""), err
295+
return "", err
296296
}
297297

298298
api.filtersMu.Lock()

eth/filters/filter_system.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"sync"
2525
"time"
2626

27-
ethereum "github.com/ethereum/go-ethereum"
27+
"github.com/ethereum/go-ethereum"
2828
"github.com/ethereum/go-ethereum/common"
2929
"github.com/ethereum/go-ethereum/core"
3030
"github.com/ethereum/go-ethereum/core/rawdb"

eth/filters/filter_system_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"testing"
2626
"time"
2727

28-
ethereum "github.com/ethereum/go-ethereum"
28+
"github.com/ethereum/go-ethereum"
2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/consensus/ethash"
3131
"github.com/ethereum/go-ethereum/core"

eth/tracers/tracer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/ethereum/go-ethereum/core/vm"
3131
"github.com/ethereum/go-ethereum/crypto"
3232
"github.com/ethereum/go-ethereum/log"
33-
duktape "gopkg.in/olebedev/go-duktape.v3"
33+
"gopkg.in/olebedev/go-duktape.v3"
3434
)
3535

3636
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.

event/event_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestSubCloseUnsub(t *testing.T) {
2929
// the point of this test is **not** to panic
3030
var mux TypeMux
3131
mux.Stop()
32-
sub := mux.Subscribe(int(0))
32+
sub := mux.Subscribe(0)
3333
sub.Unsubscribe()
3434
}
3535

0 commit comments

Comments
 (0)