diff --git a/cmd/status/utils.go b/cmd/status/utils.go index 40f2d7e29..67efdd5a5 100644 --- a/cmd/status/utils.go +++ b/cmd/status/utils.go @@ -12,9 +12,9 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/les/status" - "github.com/ethereum/go-ethereum/rpc" "github.com/status-im/status-go/geth" ) @@ -576,7 +576,7 @@ func testCompleteTransaction(t *testing.T) bool { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != nil { t.Errorf("Test failed: cannot send transaction: %v", err) @@ -647,7 +647,7 @@ func testCompleteMultipleQueuedTransactions(t *testing.T) bool { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != nil { t.Errorf("unexpected error thrown: %v", err) @@ -832,7 +832,7 @@ func testDiscardTransaction(t *testing.T) bool { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != status.ErrQueuedTxDiscarded { t.Errorf("expected error not thrown: %v", err) @@ -931,7 +931,7 @@ func testDiscardMultipleQueuedTransactions(t *testing.T) bool { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != status.ErrQueuedTxDiscarded { t.Errorf("expected error not thrown: %v", err) diff --git a/geth/node.go b/geth/node.go index f0389609c..664222011 100644 --- a/geth/node.go +++ b/geth/node.go @@ -19,6 +19,8 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/discv5" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" whisper "github.com/ethereum/go-ethereum/whisper/whisperv2" @@ -92,10 +94,8 @@ func MakeNode(dataDir string, rpcPort int) *Node { glog.CopyStandardLogTo("INFO") glog.SetToStderr(true) - bootstrapNodes := params.MainnetBootnodes if UseTestnet { dataDir = filepath.Join(dataDir, "testnet") - bootstrapNodes = params.TestnetBootnodes } // configure required node (should you need to update node's config, e.g. add bootstrap nodes, see node.Config) @@ -107,8 +107,8 @@ func MakeNode(dataDir string, rpcPort int) *Node { NoDiscovery: true, DiscoveryV5: true, DiscoveryV5Addr: fmt.Sprintf(":%d", NetworkPort+1), - BootstrapNodes: bootstrapNodes, - BootstrapNodesV5: params.DiscoveryV5Bootnodes, + BootstrapNodes: makeBootstrapNodes(), + BootstrapNodesV5: makeBootstrapNodesV5(), ListenAddr: fmt.Sprintf(":%d", NetworkPort), MaxPeers: MaxPeers, MaxPendingPeers: MaxPendingPeers, @@ -269,6 +269,33 @@ func makeDefaultExtra() []byte { return extra } +// makeBootstrapNodes returns default (hence bootstrap) list of peers +func makeBootstrapNodes() []*discover.Node { + enodes := params.MainnetBootnodes + if UseTestnet { + enodes = params.TestnetBootnodes + } + + var bootstapNodes []*discover.Node + for _, enode := range enodes { + bootstapNodes = append(bootstapNodes, discover.MustParseNode(enode)) + } + + return bootstapNodes +} + +// makeBootstrapNodesV5 returns default (hence bootstrap) list of peers +func makeBootstrapNodesV5() []*discv5.Node { + enodes := params.DiscoveryV5Bootnodes + + var bootstapNodes []*discv5.Node + for _, enode := range enodes { + bootstapNodes = append(bootstapNodes, discv5.MustParseNode(enode)) + } + + return bootstapNodes +} + func Fatalf(reason interface{}, args ...interface{}) { // decide on output stream w := io.MultiWriter(os.Stdout, os.Stderr) diff --git a/geth/node_manager.go b/geth/node_manager.go index 02bc779ea..96388b345 100644 --- a/geth/node_manager.go +++ b/geth/node_manager.go @@ -184,7 +184,7 @@ func (m *NodeManager) StartNodeRPCServer() (bool, error) { config := m.node.config modules := strings.Join(config.HTTPModules, ",") - return m.api.StartRPC(&config.HTTPHost, rpc.NewHexNumber(config.HTTPPort), &config.HTTPCors, &modules) + return m.api.StartRPC(&config.HTTPHost, &config.HTTPPort, &config.HTTPCors, &modules) } // StopNodeRPCServer stops HTTP RPC service attached to node diff --git a/geth/txqueue.go b/geth/txqueue.go index 4c00d4c6d..d9b17ccbc 100644 --- a/geth/txqueue.go +++ b/geth/txqueue.go @@ -8,8 +8,8 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/les/status" - "github.com/ethereum/go-ethereum/rpc" "github.com/robertkrimen/otto" ) @@ -264,8 +264,8 @@ func sendTxArgsFromRPCCall(req RPCCall) status.SendTxArgs { return status.SendTxArgs{ From: common.HexToAddress(from), To: &toAddress, - Value: rpc.NewHexNumber(big.NewInt(value)), - Data: data, + Value: (*hexutil.Big)(big.NewInt(value)), + Data: hexutil.Bytes(data), } } diff --git a/geth/txqueue_test.go b/geth/txqueue_test.go index 3c1573b50..46bbd267a 100644 --- a/geth/txqueue_test.go +++ b/geth/txqueue_test.go @@ -9,8 +9,8 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/les/status" - "github.com/ethereum/go-ethereum/rpc" "github.com/status-im/status-go/geth" ) @@ -88,7 +88,7 @@ func TestQueuedTransactions(t *testing.T) { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != nil { t.Errorf("Test failed: cannot send transaction: %v", err) @@ -208,7 +208,7 @@ func TestDoubleCompleteQueuedTransactions(t *testing.T) { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != nil { t.Errorf("cannot send transaction: %v", err) @@ -334,7 +334,7 @@ func TestDiscardQueuedTransactions(t *testing.T) { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != status.ErrQueuedTxDiscarded { t.Errorf("expected error not thrown: %v", err) @@ -411,7 +411,7 @@ func TestCompleteMultipleQueuedTransactions(t *testing.T) { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != nil { t.Errorf("unexpected error thrown: %v", err) @@ -571,7 +571,7 @@ func TestDiscardMultipleQueuedTransactions(t *testing.T) { txHashCheck, err := backend.SendTransaction(nil, status.SendTxArgs{ From: geth.FromAddress(testAddress), To: geth.ToAddress(testAddress1), - Value: rpc.NewHexNumber(big.NewInt(1000000000000)), + Value: (*hexutil.Big)(big.NewInt(1000000000000)), }) if err != status.ErrQueuedTxDiscarded { t.Errorf("expected error not thrown: %v", err)