From 178da7c6a94718389e7192d87df5ee42e7223bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 5 Sep 2016 19:07:57 +0300 Subject: mobile: initial wrappers for mobile support --- cmd/abigen/main.go | 23 ++++++++++++++++++----- cmd/utils/bootnodes.go | 30 ++++++++++++++++++++++++------ cmd/utils/flags.go | 4 ++-- 3 files changed, 44 insertions(+), 13 deletions(-) (limited to 'cmd') diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index 9c9ab6d31..dfbd025da 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -31,14 +31,15 @@ import ( var ( abiFlag = flag.String("abi", "", "Path to the Ethereum contract ABI json to bind") binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)") - typFlag = flag.String("type", "", "Go struct name for the binding (default = package name)") + typFlag = flag.String("type", "", "Struct name for the binding (default = package name)") solFlag = flag.String("sol", "", "Path to the Ethereum contract Solidity source to build and bind") solcFlag = flag.String("solc", "solc", "Solidity compiler to use if source builds are requested") excFlag = flag.String("exc", "", "Comma separated types to exclude from binding") - pkgFlag = flag.String("pkg", "", "Go package name to generate the binding into") - outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)") + pkgFlag = flag.String("pkg", "", "Package name to generate the binding into") + outFlag = flag.String("out", "", "Output file for the generated binding (default = stdout)") + langFlag = flag.String("lang", "go", "Destination language for the bindings (go, java, objc)") ) func main() { @@ -53,7 +54,19 @@ func main() { os.Exit(-1) } if *pkgFlag == "" { - fmt.Printf("No destination Go package specified (--pkg)\n") + fmt.Printf("No destination package specified (--pkg)\n") + os.Exit(-1) + } + var lang bind.Lang + switch *langFlag { + case "go": + lang = bind.LangGo + case "java": + lang = bind.LangJava + case "objc": + lang = bind.LangObjC + default: + fmt.Printf("Unsupported destination language \"%s\" (--lang)\n", *langFlag) os.Exit(-1) } // If the entire solidity code was specified, build and bind based on that @@ -108,7 +121,7 @@ func main() { types = append(types, kind) } // Generate the contract binding - code, err := bind.Bind(types, abis, bins, *pkgFlag) + code, err := bind.Bind(types, abis, bins, *pkgFlag, lang) if err != nil { fmt.Printf("Failed to generate ABI binding: %v\n", err) os.Exit(-1) diff --git a/cmd/utils/bootnodes.go b/cmd/utils/bootnodes.go index fbbaa1f22..23ac6c2fa 100644 --- a/cmd/utils/bootnodes.go +++ b/cmd/utils/bootnodes.go @@ -16,11 +16,15 @@ package utils -import "github.com/ethereum/go-ethereum/p2p/discover" +import ( + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/params" +) -// FrontierBootNodes are the enode URLs of the P2P bootstrap nodes running on -// the Frontier network. -var FrontierBootNodes = []*discover.Node{ +// MainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on +// the main Ethereum network. +var MainnetBootnodes = []*discover.Node{ // ETH/DEV Go Bootnodes discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), // IE discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), // BR @@ -30,12 +34,26 @@ var FrontierBootNodes = []*discover.Node{ discover.MustParseNode("enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"), } -// TestNetBootNodes are the enode URLs of the P2P bootstrap nodes running on the +// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the // Morden test network. -var TestNetBootNodes = []*discover.Node{ +var TestnetBootnodes = []*discover.Node{ // ETH/DEV Go Bootnodes discover.MustParseNode("enode://e4533109cc9bd7604e4ff6c095f7a1d807e15b38e9bfeb05d3b7c423ba86af0a9e89abbf40bd9dde4250fef114cd09270fa4e224cbeef8b7bf05a51e8260d6b8@94.242.229.4:40404"), discover.MustParseNode("enode://8c336ee6f03e99613ad21274f269479bf4413fb294d697ef15ab897598afb931f56beb8e97af530aee20ce2bcba5776f4a312bc168545de4d43736992c814592@94.242.229.203:30303"), // ETH/DEV Cpp Bootnodes } + +// MainnetChainConfig is the chain parameters to run a node on the main network. +var MainnetChainConfig = &core.ChainConfig{ + HomesteadBlock: params.MainNetHomesteadBlock, + DAOForkBlock: params.MainNetDAOForkBlock, + DAOForkSupport: true, +} + +// TestnetChainConfig is the chain parameters to run a node on the test network. +var TestnetChainConfig = &core.ChainConfig{ + HomesteadBlock: params.TestNetHomesteadBlock, + DAOForkBlock: params.TestNetDAOForkBlock, + DAOForkSupport: false, +} diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2d6bb4f5b..a0b305d4a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -487,9 +487,9 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node { // Return pre-configured nodes if none were manually requested if !ctx.GlobalIsSet(BootnodesFlag.Name) { if ctx.GlobalBool(TestNetFlag.Name) { - return TestNetBootNodes + return TestnetBootnodes } - return FrontierBootNodes + return MainnetBootnodes } // Otherwise parse and use the CLI bootstrap nodes bootnodes := []*discover.Node{} -- cgit v1.2.3 From de4b39a1a32a61a9683a036b2e27e8df7cd4c9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 9 Nov 2016 16:19:19 +0200 Subject: cmd/utils, mobile: update to reprice HF and light client --- cmd/utils/bootnodes.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'cmd') diff --git a/cmd/utils/bootnodes.go b/cmd/utils/bootnodes.go index 23ac6c2fa..1947030fc 100644 --- a/cmd/utils/bootnodes.go +++ b/cmd/utils/bootnodes.go @@ -46,14 +46,18 @@ var TestnetBootnodes = []*discover.Node{ // MainnetChainConfig is the chain parameters to run a node on the main network. var MainnetChainConfig = &core.ChainConfig{ - HomesteadBlock: params.MainNetHomesteadBlock, - DAOForkBlock: params.MainNetDAOForkBlock, - DAOForkSupport: true, + HomesteadBlock: params.MainNetHomesteadBlock, + DAOForkBlock: params.MainNetDAOForkBlock, + DAOForkSupport: true, + HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock, + HomesteadGasRepriceHash: params.MainNetHomesteadGasRepriceHash, } // TestnetChainConfig is the chain parameters to run a node on the test network. var TestnetChainConfig = &core.ChainConfig{ - HomesteadBlock: params.TestNetHomesteadBlock, - DAOForkBlock: params.TestNetDAOForkBlock, - DAOForkSupport: false, + HomesteadBlock: params.TestNetHomesteadBlock, + DAOForkBlock: params.TestNetDAOForkBlock, + DAOForkSupport: false, + HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock, + HomesteadGasRepriceHash: params.TestNetHomesteadGasRepriceHash, } -- cgit v1.2.3 From b61f48e5aad9cf897f5655a0db002a3349109c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Wed, 9 Nov 2016 16:35:04 +0200 Subject: cmd, mobile, node, p2p: surface the discovery V5 bootnodes --- cmd/utils/bootnodes.go | 9 +++++++++ cmd/utils/flags.go | 29 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/utils/bootnodes.go b/cmd/utils/bootnodes.go index 1947030fc..50b658467 100644 --- a/cmd/utils/bootnodes.go +++ b/cmd/utils/bootnodes.go @@ -19,6 +19,7 @@ package utils import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/p2p/discover" + "github.com/ethereum/go-ethereum/p2p/discv5" "github.com/ethereum/go-ethereum/params" ) @@ -44,6 +45,14 @@ var TestnetBootnodes = []*discover.Node{ // ETH/DEV Cpp Bootnodes } +// DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the +// experimental RLPx v5 topic-discovery network. +var DiscoveryV5Bootnodes = []*discv5.Node{ + discv5.MustParseNode("enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30305"), + discv5.MustParseNode("enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30308"), + discv5.MustParseNode("enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30309"), +} + // MainnetChainConfig is the chain parameters to run a node on the main network. var MainnetChainConfig = &core.ChainConfig{ HomesteadBlock: params.MainNetHomesteadBlock, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a0b305d4a..0b18d9f79 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -46,6 +46,7 @@ import ( "github.com/ethereum/go-ethereum/metrics" "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/p2p/nat" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" @@ -505,13 +506,36 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node { return bootnodes } +// MakeBootstrapNodesV5 creates a list of bootstrap nodes from the command line +// flags, reverting to pre-configured ones if none have been specified. +func MakeBootstrapNodesV5(ctx *cli.Context) []*discv5.Node { + // Return pre-configured nodes if none were manually requested + if !ctx.GlobalIsSet(BootnodesFlag.Name) { + return DiscoveryV5Bootnodes + } + // Otherwise parse and use the CLI bootstrap nodes + bootnodes := []*discv5.Node{} + + for _, url := range strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",") { + node, err := discv5.ParseNode(url) + if err != nil { + glog.V(logger.Error).Infof("Bootstrap URL %s: %v\n", url, err) + continue + } + bootnodes = append(bootnodes, node) + } + return bootnodes +} + // MakeListenAddress creates a TCP listening address string from set command // line flags. func MakeListenAddress(ctx *cli.Context) string { return fmt.Sprintf(":%d", ctx.GlobalInt(ListenPortFlag.Name)) } -func MakeListenAddressV5(ctx *cli.Context) string { +// MakeDiscoveryV5Address creates a UDP listening address string from set command +// line flags for the V5 discovery protocol. +func MakeDiscoveryV5Address(ctx *cli.Context) string { return fmt.Sprintf(":%d", ctx.GlobalInt(ListenPortFlag.Name)+1) } @@ -647,9 +671,10 @@ func MakeNode(ctx *cli.Context, name, gitCommit string) *node.Node { UserIdent: makeNodeUserIdent(ctx), NoDiscovery: ctx.GlobalBool(NoDiscoverFlag.Name) || ctx.GlobalBool(LightModeFlag.Name), DiscoveryV5: ctx.GlobalBool(DiscoveryV5Flag.Name) || ctx.GlobalBool(LightModeFlag.Name) || ctx.GlobalInt(LightServFlag.Name) > 0, + DiscoveryV5Addr: MakeDiscoveryV5Address(ctx), BootstrapNodes: MakeBootstrapNodes(ctx), + BootstrapNodesV5: MakeBootstrapNodesV5(ctx), ListenAddr: MakeListenAddress(ctx), - ListenAddrV5: MakeListenAddressV5(ctx), NAT: MakeNAT(ctx), MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name), MaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name), -- cgit v1.2.3 From 4a439c2359991bdc49463ae66da11da895cc6eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 14 Nov 2016 13:03:29 +0200 Subject: mobile: port wrappers to EIP155 and EIP158 fork --- cmd/utils/bootnodes.go | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'cmd') diff --git a/cmd/utils/bootnodes.go b/cmd/utils/bootnodes.go index 50b658467..07e64b25f 100644 --- a/cmd/utils/bootnodes.go +++ b/cmd/utils/bootnodes.go @@ -17,10 +17,8 @@ package utils import ( - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/p2p/discv5" - "github.com/ethereum/go-ethereum/params" ) // MainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on @@ -52,21 +50,3 @@ var DiscoveryV5Bootnodes = []*discv5.Node{ discv5.MustParseNode("enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30308"), discv5.MustParseNode("enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30309"), } - -// MainnetChainConfig is the chain parameters to run a node on the main network. -var MainnetChainConfig = &core.ChainConfig{ - HomesteadBlock: params.MainNetHomesteadBlock, - DAOForkBlock: params.MainNetDAOForkBlock, - DAOForkSupport: true, - HomesteadGasRepriceBlock: params.MainNetHomesteadGasRepriceBlock, - HomesteadGasRepriceHash: params.MainNetHomesteadGasRepriceHash, -} - -// TestnetChainConfig is the chain parameters to run a node on the test network. -var TestnetChainConfig = &core.ChainConfig{ - HomesteadBlock: params.TestNetHomesteadBlock, - DAOForkBlock: params.TestNetDAOForkBlock, - DAOForkSupport: false, - HomesteadGasRepriceBlock: params.TestNetHomesteadGasRepriceBlock, - HomesteadGasRepriceHash: params.TestNetHomesteadGasRepriceHash, -} -- cgit v1.2.3 From dfe79cc7845d94d14c2bc091c7eeac082f6b1e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 14 Nov 2016 13:44:35 +0200 Subject: cmd/utils, mobile: place bootnodes in LGPL packages --- cmd/utils/bootnodes.go | 52 -------------------------------------------------- cmd/utils/flags.go | 6 +++--- 2 files changed, 3 insertions(+), 55 deletions(-) delete mode 100644 cmd/utils/bootnodes.go (limited to 'cmd') diff --git a/cmd/utils/bootnodes.go b/cmd/utils/bootnodes.go deleted file mode 100644 index 07e64b25f..000000000 --- a/cmd/utils/bootnodes.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 The go-ethereum Authors -// This file is part of go-ethereum. -// -// go-ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// go-ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with go-ethereum. If not, see . - -package utils - -import ( - "github.com/ethereum/go-ethereum/p2p/discover" - "github.com/ethereum/go-ethereum/p2p/discv5" -) - -// MainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on -// the main Ethereum network. -var MainnetBootnodes = []*discover.Node{ - // ETH/DEV Go Bootnodes - discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"), // IE - discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"), // BR - discover.MustParseNode("enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303"), // SG - - // ETH/DEV Cpp Bootnodes - discover.MustParseNode("enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"), -} - -// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the -// Morden test network. -var TestnetBootnodes = []*discover.Node{ - // ETH/DEV Go Bootnodes - discover.MustParseNode("enode://e4533109cc9bd7604e4ff6c095f7a1d807e15b38e9bfeb05d3b7c423ba86af0a9e89abbf40bd9dde4250fef114cd09270fa4e224cbeef8b7bf05a51e8260d6b8@94.242.229.4:40404"), - discover.MustParseNode("enode://8c336ee6f03e99613ad21274f269479bf4413fb294d697ef15ab897598afb931f56beb8e97af530aee20ce2bcba5776f4a312bc168545de4d43736992c814592@94.242.229.203:30303"), - - // ETH/DEV Cpp Bootnodes -} - -// DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the -// experimental RLPx v5 topic-discovery network. -var DiscoveryV5Bootnodes = []*discv5.Node{ - discv5.MustParseNode("enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30305"), - discv5.MustParseNode("enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30308"), - discv5.MustParseNode("enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30309"), -} diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 0b18d9f79..1ba905657 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -488,9 +488,9 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node { // Return pre-configured nodes if none were manually requested if !ctx.GlobalIsSet(BootnodesFlag.Name) { if ctx.GlobalBool(TestNetFlag.Name) { - return TestnetBootnodes + return params.TestnetBootnodes } - return MainnetBootnodes + return params.MainnetBootnodes } // Otherwise parse and use the CLI bootstrap nodes bootnodes := []*discover.Node{} @@ -511,7 +511,7 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node { func MakeBootstrapNodesV5(ctx *cli.Context) []*discv5.Node { // Return pre-configured nodes if none were manually requested if !ctx.GlobalIsSet(BootnodesFlag.Name) { - return DiscoveryV5Bootnodes + return params.DiscoveryV5Bootnodes } // Otherwise parse and use the CLI bootstrap nodes bootnodes := []*discv5.Node{} -- cgit v1.2.3