From 564641a1ade14521a287ee20cfa145d3b519ce93 Mon Sep 17 00:00:00 2001 From: Nguyen Ba Tam Date: Wed, 11 Jul 2018 16:58:08 +0700 Subject: [PATCH 1/5] change config from flag to toml file; fix tag listenaddr --- cmd/tomo/chaincmd.go | 14 ++++++------- cmd/tomo/config.go | 42 +++++++++++++++++++++++++++---------- cmd/tomo/consolecmd.go | 9 ++++---- cmd/tomo/main.go | 21 ++++++++++--------- cmd/tomo/testdata/tomo.toml | 29 +++++++++++++++++++++++++ consensus/ethash/ethash.go | 12 +++++------ dashboard/config.go | 6 +++--- eth/config.go | 6 +++--- node/config.go | 16 +++++++------- p2p/discover/node.go | 1 + p2p/server.go | 6 +++--- 11 files changed, 107 insertions(+), 55 deletions(-) create mode 100644 cmd/tomo/testdata/tomo.toml diff --git a/cmd/tomo/chaincmd.go b/cmd/tomo/chaincmd.go index d3086921b9..8439f26c26 100644 --- a/cmd/tomo/chaincmd.go +++ b/cmd/tomo/chaincmd.go @@ -190,7 +190,7 @@ func initGenesis(ctx *cli.Context) error { utils.Fatalf("invalid genesis file: %v", err) } // Open an initialise both full and light databases - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) for _, name := range []string{"chaindata", "lightchaindata"} { chaindb, err := stack.OpenDatabase(name, 0, 0) if err != nil { @@ -209,7 +209,7 @@ func importChain(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) defer chainDb.Close() @@ -303,7 +303,7 @@ func exportChain(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) chain, _ := utils.MakeChain(ctx, stack) start := time.Now() @@ -336,7 +336,7 @@ func importPreimages(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) diskdb := utils.MakeChainDatabase(ctx, stack).(*ethdb.LDBDatabase) start := time.Now() @@ -352,7 +352,7 @@ func exportPreimages(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) diskdb := utils.MakeChainDatabase(ctx, stack).(*ethdb.LDBDatabase) start := time.Now() @@ -369,7 +369,7 @@ func copyDb(ctx *cli.Context) error { utils.Fatalf("Source chaindata directory path argument missing") } // Initialize a new chain for the running node to sync into - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode) @@ -441,7 +441,7 @@ func removeDB(ctx *cli.Context) error { } func dump(ctx *cli.Context) error { - stack := makeFullNode(ctx) + stack,_ := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) for _, arg := range ctx.Args() { var block *types.Block diff --git a/cmd/tomo/config.go b/cmd/tomo/config.go index 8856071901..33cb2e060f 100644 --- a/cmd/tomo/config.go +++ b/cmd/tomo/config.go @@ -25,7 +25,7 @@ import ( "reflect" "unicode" - cli "gopkg.in/urfave/cli.v1" + "gopkg.in/urfave/cli.v1" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/dashboard" @@ -34,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "github.com/naoina/toml" + "strings" ) var ( @@ -71,15 +72,21 @@ var tomlSettings = toml.Config{ } type ethstatsConfig struct { - URL string `toml:",omitempty"` + URL string `toml:"url"` } +type account struct { + Unlocks []string `toml:"unlocks"` + Passwords []string `toml:"passwords"` +} type tomoConfig struct { - Eth eth.Config - Shh whisper.Config - Node node.Config - Ethstats ethstatsConfig - Dashboard dashboard.Config + Eth eth.Config `toml:"eth"` + Shh whisper.Config `toml:"ssh"` + Node node.Config `toml:"node"` + Ethstats ethstatsConfig `toml:"ethstats"` + Dashboard dashboard.Config `toml:"dashboard"` + Account account `toml:"account"` + MineEnable bool `toml:"mine"` } func loadConfig(file string, cfg *tomoConfig) error { @@ -88,7 +95,6 @@ func loadConfig(file string, cfg *tomoConfig) error { return err } defer f.Close() - err = tomlSettings.NewDecoder(bufio.NewReader(f)).Decode(cfg) // Add file name to errors that have a line number. if _, ok := err.(*toml.LineError); ok { @@ -115,7 +121,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { Node: defaultNodeConfig(), Dashboard: dashboard.DefaultConfig, } - // Load config file. if file := ctx.GlobalString(configFileFlag.Name); file != "" { if err := loadConfig(file, &cfg); err != nil { @@ -123,6 +128,21 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { } } + // read passwords from enviroment + passwords := []string{} + for _, env := range cfg.Account.Passwords { + if trimmed := strings.TrimSpace(env); trimmed != "" { + value := os.Getenv(trimmed) + for _, info := range strings.Split(value, ",") { + trimmed2 := strings.TrimSpace(info) + if (trimmed2 != "") { + passwords = append(passwords, trimmed2) + } + } + } + } + cfg.Account.Passwords = passwords + // Apply flags. utils.SetNodeConfig(ctx, &cfg.Node) stack, err := node.New(&cfg.Node) @@ -150,7 +170,7 @@ func enableWhisper(ctx *cli.Context) bool { return false } -func makeFullNode(ctx *cli.Context) *node.Node { +func makeFullNode(ctx *cli.Context) (*node.Node, tomoConfig) { stack, cfg := makeConfigNode(ctx) utils.RegisterEthService(stack, &cfg.Eth) @@ -175,7 +195,7 @@ func makeFullNode(ctx *cli.Context) *node.Node { if cfg.Ethstats.URL != "" { utils.RegisterEthStatsService(stack, cfg.Ethstats.URL) } - return stack + return stack, cfg } // dumpConfig is the dumpconfig command. diff --git a/cmd/tomo/consolecmd.go b/cmd/tomo/consolecmd.go index 296e63e66f..6f1c7bc80f 100644 --- a/cmd/tomo/consolecmd.go +++ b/cmd/tomo/consolecmd.go @@ -77,8 +77,8 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Cons // same time. func localConsole(ctx *cli.Context) error { // Create and start the node based on the CLI flags - node := makeFullNode(ctx) - startNode(ctx, node) + node,cfg := makeFullNode(ctx) + startNode(ctx, node,cfg) defer node.Stop() // Attach to the newly started node and start the JavaScript console @@ -130,6 +130,7 @@ func remoteConsole(ctx *cli.Context) error { } endpoint = fmt.Sprintf("%s/tomo.ipc", path) } + client, err := dialRPC(endpoint) if err != nil { utils.Fatalf("Unable to attach to remote tomo: %v", err) @@ -178,8 +179,8 @@ func dialRPC(endpoint string) (*rpc.Client, error) { // everything down. func ephemeralConsole(ctx *cli.Context) error { // Create and start the node based on the CLI flags - node := makeFullNode(ctx) - startNode(ctx, node) + node,cfg := makeFullNode(ctx) + startNode(ctx, node,cfg) defer node.Stop() // Attach to the newly started node and start the JavaScript console diff --git a/cmd/tomo/main.go b/cmd/tomo/main.go index 0cae7de10e..bccc9a30f6 100644 --- a/cmd/tomo/main.go +++ b/cmd/tomo/main.go @@ -213,8 +213,8 @@ func main() { // It creates a default node based on the command line arguments and runs it in // blocking mode, waiting for it to be shut down. func tomo(ctx *cli.Context) error { - node := makeFullNode(ctx) - startNode(ctx, node) + node,cfg := makeFullNode(ctx) + startNode(ctx, node,cfg) node.Wait() return nil } @@ -222,18 +222,18 @@ func tomo(ctx *cli.Context) error { // startNode boots up the system node and all registered protocols, after which // it unlocks any requested accounts, and starts the RPC/IPC interfaces and the // miner. -func startNode(ctx *cli.Context, stack *node.Node) { +func startNode(ctx *cli.Context, stack *node.Node,cfg tomoConfig) { // Start up the node itself utils.StartNode(stack) // Unlock any account specifically requested ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - passwords := utils.MakePasswordList(ctx) - unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") - for i, account := range unlocks { + //passwords := utils.MakePasswordList(ctx) + //unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") + for i, account := range cfg.Account.Unlocks { if trimmed := strings.TrimSpace(account); trimmed != "" { - unlockAccount(ctx, ks, trimmed, i, passwords) + unlockAccount(ctx, ks, trimmed, i, cfg.Account.Passwords) } } // Register wallet event handlers to open and auto-derive wallets @@ -278,7 +278,8 @@ func startNode(ctx *cli.Context, stack *node.Node) { } }() // Start auxiliary services if enabled - if ctx.GlobalBool(utils.StakingEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) { + //if ctx.GlobalBool(utils.StakingEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) { + if cfg.MineEnable || ctx.GlobalBool(utils.DeveloperFlag.Name) { // Mining only makes sense if a full Ethereum node is running if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { utils.Fatalf("Light clients do not support staking") @@ -305,7 +306,7 @@ func startNode(ctx *cli.Context, stack *node.Node) { } } // Set the gas price to the limits from the CLI and start mining - ethereum.TxPool().SetGasPrice(utils.GlobalBig(ctx, utils.GasPriceFlag.Name)) + ethereum.TxPool().SetGasPrice(cfg.Eth.GasPrice) if err := ethereum.StartStaking(true); err != nil { utils.Fatalf("Failed to start staking: %v", err) } @@ -341,7 +342,7 @@ func startNode(ctx *cli.Context, stack *node.Node) { } } // Set the gas price to the limits from the CLI and start mining - ethereum.TxPool().SetGasPrice(utils.GlobalBig(ctx, utils.GasPriceFlag.Name)) + ethereum.TxPool().SetGasPrice(cfg.Eth.GasPrice) if err := ethereum.StartStaking(true); err != nil { utils.Fatalf("Failed to start staking: %v", err) } diff --git a/cmd/tomo/testdata/tomo.toml b/cmd/tomo/testdata/tomo.toml new file mode 100644 index 0000000000..912aa56e9f --- /dev/null +++ b/cmd/tomo/testdata/tomo.toml @@ -0,0 +1,29 @@ +mine = true # flag --mine ( true : enable miner , false : disable ) +[eth] +NetworkId = 1515 # flag --networkid +SyncMode = "full" # flag --syncmode +GasPrice = 1 # flag --gasprice + +[ssh] + +[node] +datadir = "node1/" # flag --datadir +http_host = "localhost" # flag --rpcaddr +http_port = 8501 # flag --rpcport +http_modules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi +[node.p2p] +listenaddr = ":30311" # flag --port +bootnodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] +# flag --bootnodes + +[ethstats] +[dashboard] +[account] +unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt in flag --unlock +passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789 + + + + + + diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index 1b3dcee302..ad505e6726 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -380,12 +380,12 @@ const ( // Config are the configuration parameters of the ethash. type Config struct { - CacheDir string - CachesInMem int - CachesOnDisk int - DatasetDir string - DatasetsInMem int - DatasetsOnDisk int + CacheDir string `toml:"cachedir"` + CachesInMem int `toml:"cachesinmem"` + CachesOnDisk int `toml:"cachesinmem"` + DatasetDir string `toml:"cachesinmem"` + DatasetsInMem int `toml:"cachesinmem"` + DatasetsOnDisk int `toml:"cachesinmem"` PowMode Mode } diff --git a/dashboard/config.go b/dashboard/config.go index c260ed4f0e..c3477fcfab 100644 --- a/dashboard/config.go +++ b/dashboard/config.go @@ -29,13 +29,13 @@ var DefaultConfig = Config{ type Config struct { // Host is the host interface on which to start the dashboard server. If this // field is empty, no dashboard will be started. - Host string `toml:",omitempty"` + Host string `toml:"host,default=localhost"` // Port is the TCP port number on which to start the dashboard server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). - Port int `toml:",omitempty"` + Port int `toml:"port,default=8080"` // Refresh is the refresh rate of the data updates, the chartEntry will be collected this often. - Refresh time.Duration `toml:",omitempty"` + Refresh time.Duration } diff --git a/eth/config.go b/eth/config.go index dd7f42c7d9..8969bb55f3 100644 --- a/eth/config.go +++ b/eth/config.go @@ -79,8 +79,8 @@ type Config struct { Genesis *core.Genesis `toml:",omitempty"` // Protocol options - NetworkId uint64 // Network ID to use for selecting peers to connect to - SyncMode downloader.SyncMode + NetworkId uint64 `toml:"NetworkId,default=1"` // Network ID to use for selecting peers to connect to ,default=1 + SyncMode downloader.SyncMode `toml:"SyncMode,default=FastSync"` NoPruning bool // Light client options @@ -98,7 +98,7 @@ type Config struct { Etherbase common.Address `toml:",omitempty"` MinerThreads int `toml:",omitempty"` ExtraData []byte `toml:",omitempty"` - GasPrice *big.Int + GasPrice *big.Int `toml:"GasPrice"` // Ethash options Ethash ethash.Config diff --git a/node/config.go b/node/config.go index dda24583ee..fc91ecefac 100644 --- a/node/config.go +++ b/node/config.go @@ -53,7 +53,7 @@ type Config struct { Name string `toml:"-"` // UserIdent, if set, is used as an additional component in the devp2p node identifier. - UserIdent string `toml:",omitempty"` + UserIdent string `toml:"identity"` // Version should be set to the version number of the program. It is used // in the devp2p node identifier. @@ -64,10 +64,10 @@ type Config struct { // registered services, instead those can use utility methods to create/access // databases or flat files. This enables ephemeral nodes which can fully reside // in memory. - DataDir string + DataDir string `toml:"datadir"` // Configuration of peer-to-peer networking. - P2P p2p.Config + P2P p2p.Config `toml:"p2p"` // KeyStoreDir is the file system folder that contains private keys. The directory can // be specified as a relative path, in which case it is resolved relative to the @@ -76,11 +76,11 @@ type Config struct { // If KeyStoreDir is empty, the default location is the "keystore" subdirectory of // DataDir. If DataDir is unspecified and KeyStoreDir is empty, an ephemeral directory // is created by New and destroyed when the node is stopped. - KeyStoreDir string `toml:",omitempty"` + KeyStoreDir string `toml:"keystore"` // UseLightweightKDF lowers the memory and CPU requirements of the key store // scrypt KDF at the expense of security. - UseLightweightKDF bool `toml:",omitempty"` + UseLightweightKDF bool `toml:"lightkdf"` // NoUSB disables hardware wallet monitoring and connectivity. NoUSB bool `toml:",omitempty"` @@ -93,12 +93,12 @@ type Config struct { // HTTPHost is the host interface on which to start the HTTP RPC server. If this // field is empty, no HTTP API endpoint will be started. - HTTPHost string `toml:",omitempty"` + HTTPHost string `toml:"http_host"` // HTTPPort is the TCP port number on which to start the HTTP RPC server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). - HTTPPort int `toml:",omitempty"` + HTTPPort int `toml:"http_port"` // HTTPCors is the Cross-Origin Resource Sharing header to send to requesting // clients. Please be aware that CORS is a browser enforced security, it's fully @@ -117,7 +117,7 @@ type Config struct { // HTTPModules is a list of API modules to expose via the HTTP RPC interface. // If the module list is empty, all RPC API endpoints designated public will be // exposed. - HTTPModules []string `toml:",omitempty"` + HTTPModules []string `toml:"http_modules"` // WSHost is the host interface on which to start the websocket RPC server. If // this field is empty, no websocket API endpoint will be started. diff --git a/p2p/discover/node.go b/p2p/discover/node.go index 3b0c84115c..86275a8955 100644 --- a/p2p/discover/node.go +++ b/p2p/discover/node.go @@ -56,6 +56,7 @@ type Node struct { addedAt time.Time } + // NewNode creates a new node. It is mostly meant to be used for // testing purposes. func NewNode(id NodeID, ip net.IP, udpPort, tcpPort uint16) *Node { diff --git a/p2p/server.go b/p2p/server.go index c41d1dc156..a273f124ac 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -86,12 +86,12 @@ type Config struct { // BootstrapNodes are used to establish connectivity // with the rest of the network. - BootstrapNodes []*discover.Node + BootstrapNodes []*discover.Node `toml:"bootnodes"` // BootstrapNodesV5 are used to establish connectivity // with the rest of the network using the V5 discovery // protocol. - BootstrapNodesV5 []*discv5.Node `toml:",omitempty"` + BootstrapNodesV5 []*discv5.Node `toml:"bootnodes_v5"` // Static nodes are used as pre-configured connections which are always // maintained and re-connected on disconnects. @@ -121,7 +121,7 @@ type Config struct { // If the port is zero, the operating system will pick a port. The // ListenAddr field will be updated with the actual address when // the server is started. - ListenAddr string + ListenAddr string `toml:"listenaddr,default=30303"` // If set to a non-nil value, the given NAT port mapper // is used to make the listening port available to the From a3773b4b424f09448ef1e927f1004858d49277f7 Mon Sep 17 00:00:00 2001 From: Nguyen Ba Tam Date: Wed, 11 Jul 2018 17:59:36 +0700 Subject: [PATCH 2/5] add option set account , password with flag --- cmd/tomo/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/tomo/main.go b/cmd/tomo/main.go index bccc9a30f6..1f99ae3656 100644 --- a/cmd/tomo/main.go +++ b/cmd/tomo/main.go @@ -231,6 +231,14 @@ func startNode(ctx *cli.Context, stack *node.Node,cfg tomoConfig) { //passwords := utils.MakePasswordList(ctx) //unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") + if(ctx.GlobalIsSet(utils.UnlockedAccountFlag.Name)) { + cfg.Account.Unlocks=strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") + } + + if(ctx.GlobalIsSet(utils.PasswordFileFlag.Name)) { + cfg.Account.Passwords=utils.MakePasswordList(ctx) + } + for i, account := range cfg.Account.Unlocks { if trimmed := strings.TrimSpace(account); trimmed != "" { unlockAccount(ctx, ks, trimmed, i, cfg.Account.Passwords) From 0409936d85384e6948309ecaa4b10b845da051ff Mon Sep 17 00:00:00 2001 From: Nguyen Ba Tam Date: Thu, 26 Jul 2018 14:34:38 +0700 Subject: [PATCH 3/5] move config bootnode to toml file --- cmd/tomo/config.go | 44 +++++++++++++++++++++++++++++-------- cmd/tomo/main.go | 5 +---- cmd/tomo/testdata/tomo.toml | 24 +++++++++++++++++++- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/cmd/tomo/config.go b/cmd/tomo/config.go index 33cb2e060f..9d17952f70 100644 --- a/cmd/tomo/config.go +++ b/cmd/tomo/config.go @@ -79,14 +79,23 @@ type account struct { Unlocks []string `toml:"unlocks"` Passwords []string `toml:"passwords"` } + +type Bootnodes struct { + Mainnet []string `toml:"main"` + Testnet []string `toml:"test"` + Rinkeby []string `toml:"rinkeby"` + DiscoveryV5 []string `toml:"discoveryv5"` +} + type tomoConfig struct { - Eth eth.Config `toml:"eth"` - Shh whisper.Config `toml:"ssh"` - Node node.Config `toml:"node"` - Ethstats ethstatsConfig `toml:"ethstats"` - Dashboard dashboard.Config `toml:"dashboard"` - Account account `toml:"account"` - MineEnable bool `toml:"mine"` + Eth eth.Config `toml:"eth"` + Shh whisper.Config `toml:"ssh"` + Node node.Config `toml:"node"` + Ethstats ethstatsConfig `toml:"ethstats"` + Dashboard dashboard.Config `toml:"dashboard"` + Account account `toml:"account"` + StakeEnable bool `toml:"stake"` + Bootnodes Bootnodes `toml:"bootnodes"` } func loadConfig(file string, cfg *tomoConfig) error { @@ -134,14 +143,18 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { if trimmed := strings.TrimSpace(env); trimmed != "" { value := os.Getenv(trimmed) for _, info := range strings.Split(value, ",") { - trimmed2 := strings.TrimSpace(info) - if (trimmed2 != "") { + if trimmed2 := strings.TrimSpace(info); trimmed2 != "" { passwords = append(passwords, trimmed2) } } } } cfg.Account.Passwords = passwords + //Apply Bootnodes + applyValues(cfg.Bootnodes.Mainnet, ¶ms.MainnetBootnodes) + applyValues(cfg.Bootnodes.Testnet, ¶ms.TestnetBootnodes) + applyValues(cfg.Bootnodes.Rinkeby, ¶ms.RinkebyBootnodes) + applyValues(cfg.Bootnodes.DiscoveryV5, ¶ms.DiscoveryV5Bootnodes) // Apply flags. utils.SetNodeConfig(ctx, &cfg.Node) @@ -160,6 +173,19 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { return stack, cfg } +func applyValues(values []string, params *[]string) { + data := []string{} + for _, value := range values { + if trimmed := strings.TrimSpace(value); trimmed != "" { + data = append(data, trimmed) + } + } + if len(data) > 0 { + *params = data + } + +} + // enableWhisper returns true in case one of the whisper flags is set. func enableWhisper(ctx *cli.Context) bool { for _, flag := range whisperFlags { diff --git a/cmd/tomo/main.go b/cmd/tomo/main.go index 1f99ae3656..c331b2a801 100644 --- a/cmd/tomo/main.go +++ b/cmd/tomo/main.go @@ -229,8 +229,6 @@ func startNode(ctx *cli.Context, stack *node.Node,cfg tomoConfig) { // Unlock any account specifically requested ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - //passwords := utils.MakePasswordList(ctx) - //unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") if(ctx.GlobalIsSet(utils.UnlockedAccountFlag.Name)) { cfg.Account.Unlocks=strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") } @@ -286,8 +284,7 @@ func startNode(ctx *cli.Context, stack *node.Node,cfg tomoConfig) { } }() // Start auxiliary services if enabled - //if ctx.GlobalBool(utils.StakingEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) { - if cfg.MineEnable || ctx.GlobalBool(utils.DeveloperFlag.Name) { + if cfg.StakeEnable || ctx.GlobalBool(utils.DeveloperFlag.Name) { // Mining only makes sense if a full Ethereum node is running if ctx.GlobalBool(utils.LightModeFlag.Name) || ctx.GlobalString(utils.SyncModeFlag.Name) == "light" { utils.Fatalf("Light clients do not support staking") diff --git a/cmd/tomo/testdata/tomo.toml b/cmd/tomo/testdata/tomo.toml index 912aa56e9f..7ea88998a8 100644 --- a/cmd/tomo/testdata/tomo.toml +++ b/cmd/tomo/testdata/tomo.toml @@ -1,4 +1,4 @@ -mine = true # flag --mine ( true : enable miner , false : disable ) +stake = true # flag --stake ( true : enable staker , false : disable ) [eth] NetworkId = 1515 # flag --networkid SyncMode = "full" # flag --syncmode @@ -23,6 +23,28 @@ unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789 +[bootnodes] +main =["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303", + "enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303", + "enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303", + "enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303", + "enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303", + "enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"] +test =["enode://30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606@52.176.7.10:30303", + "enode://865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c@52.176.100.77:30303", + "enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303", + "enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303" ] +rinkeby =["enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303", + "enode://343149e4feefa15d882d9fe4ac7d88f885bd05ebb735e547f12e12080a9fa07c8014ca6fd7f373123488102fe5e34111f8509cf0b7de3f5b44339c9f25e87cb8@52.3.158.184:30303", + "enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303"] +discoveryv5 =["enode://06051a5573c81934c9554ef2898eb13b33a34b94cf36b202b69fde139ca17a85051979867720d4bdae4323d4943ddf9aeeb6643633aa656e0be843659795007a@35.177.226.168:30303", + "enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30304", + "enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30306", + "enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30307"] + + + + From acba0ae1fdb4a48422a09696df8067c94111831d Mon Sep 17 00:00:00 2001 From: Nguyen Ba Tam Date: Fri, 27 Jul 2018 11:42:20 +0700 Subject: [PATCH 4/5] remove rinkby and discovery in bootnode --- cmd/tomo/chaincmd.go | 14 +++++++------- cmd/tomo/config.go | 8 ++------ cmd/tomo/consolecmd.go | 8 ++++---- cmd/tomo/main.go | 14 +++++++------- cmd/tomo/testdata/tomo.toml | 20 ++------------------ consensus/ethash/ethash.go | 12 ++++++------ eth/config.go | 4 ++-- p2p/discover/node.go | 1 - p2p/server.go | 2 +- 9 files changed, 31 insertions(+), 52 deletions(-) diff --git a/cmd/tomo/chaincmd.go b/cmd/tomo/chaincmd.go index 8439f26c26..fc3be707f0 100644 --- a/cmd/tomo/chaincmd.go +++ b/cmd/tomo/chaincmd.go @@ -190,7 +190,7 @@ func initGenesis(ctx *cli.Context) error { utils.Fatalf("invalid genesis file: %v", err) } // Open an initialise both full and light databases - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) for _, name := range []string{"chaindata", "lightchaindata"} { chaindb, err := stack.OpenDatabase(name, 0, 0) if err != nil { @@ -209,7 +209,7 @@ func importChain(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) defer chainDb.Close() @@ -303,7 +303,7 @@ func exportChain(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) chain, _ := utils.MakeChain(ctx, stack) start := time.Now() @@ -336,7 +336,7 @@ func importPreimages(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) diskdb := utils.MakeChainDatabase(ctx, stack).(*ethdb.LDBDatabase) start := time.Now() @@ -352,7 +352,7 @@ func exportPreimages(ctx *cli.Context) error { if len(ctx.Args()) < 1 { utils.Fatalf("This command requires an argument.") } - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) diskdb := utils.MakeChainDatabase(ctx, stack).(*ethdb.LDBDatabase) start := time.Now() @@ -369,7 +369,7 @@ func copyDb(ctx *cli.Context) error { utils.Fatalf("Source chaindata directory path argument missing") } // Initialize a new chain for the running node to sync into - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode) @@ -441,7 +441,7 @@ func removeDB(ctx *cli.Context) error { } func dump(ctx *cli.Context) error { - stack,_ := makeFullNode(ctx) + stack, _ := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) for _, arg := range ctx.Args() { var block *types.Block diff --git a/cmd/tomo/config.go b/cmd/tomo/config.go index 9d17952f70..7733d5caa9 100644 --- a/cmd/tomo/config.go +++ b/cmd/tomo/config.go @@ -81,10 +81,8 @@ type account struct { } type Bootnodes struct { - Mainnet []string `toml:"main"` - Testnet []string `toml:"test"` - Rinkeby []string `toml:"rinkeby"` - DiscoveryV5 []string `toml:"discoveryv5"` + Mainnet []string `toml:"main"` + Testnet []string `toml:"test"` } type tomoConfig struct { @@ -153,8 +151,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, tomoConfig) { //Apply Bootnodes applyValues(cfg.Bootnodes.Mainnet, ¶ms.MainnetBootnodes) applyValues(cfg.Bootnodes.Testnet, ¶ms.TestnetBootnodes) - applyValues(cfg.Bootnodes.Rinkeby, ¶ms.RinkebyBootnodes) - applyValues(cfg.Bootnodes.DiscoveryV5, ¶ms.DiscoveryV5Bootnodes) // Apply flags. utils.SetNodeConfig(ctx, &cfg.Node) diff --git a/cmd/tomo/consolecmd.go b/cmd/tomo/consolecmd.go index 6f1c7bc80f..5029602e39 100644 --- a/cmd/tomo/consolecmd.go +++ b/cmd/tomo/consolecmd.go @@ -77,8 +77,8 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/JavaScript-Cons // same time. func localConsole(ctx *cli.Context) error { // Create and start the node based on the CLI flags - node,cfg := makeFullNode(ctx) - startNode(ctx, node,cfg) + node, cfg := makeFullNode(ctx) + startNode(ctx, node, cfg) defer node.Stop() // Attach to the newly started node and start the JavaScript console @@ -179,8 +179,8 @@ func dialRPC(endpoint string) (*rpc.Client, error) { // everything down. func ephemeralConsole(ctx *cli.Context) error { // Create and start the node based on the CLI flags - node,cfg := makeFullNode(ctx) - startNode(ctx, node,cfg) + node, cfg := makeFullNode(ctx) + startNode(ctx, node, cfg) defer node.Stop() // Attach to the newly started node and start the JavaScript console diff --git a/cmd/tomo/main.go b/cmd/tomo/main.go index c331b2a801..3afa5d36bd 100644 --- a/cmd/tomo/main.go +++ b/cmd/tomo/main.go @@ -213,8 +213,8 @@ func main() { // It creates a default node based on the command line arguments and runs it in // blocking mode, waiting for it to be shut down. func tomo(ctx *cli.Context) error { - node,cfg := makeFullNode(ctx) - startNode(ctx, node,cfg) + node, cfg := makeFullNode(ctx) + startNode(ctx, node, cfg) node.Wait() return nil } @@ -222,19 +222,19 @@ func tomo(ctx *cli.Context) error { // startNode boots up the system node and all registered protocols, after which // it unlocks any requested accounts, and starts the RPC/IPC interfaces and the // miner. -func startNode(ctx *cli.Context, stack *node.Node,cfg tomoConfig) { +func startNode(ctx *cli.Context, stack *node.Node, cfg tomoConfig) { // Start up the node itself utils.StartNode(stack) // Unlock any account specifically requested ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) - if(ctx.GlobalIsSet(utils.UnlockedAccountFlag.Name)) { - cfg.Account.Unlocks=strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") + if ctx.GlobalIsSet(utils.UnlockedAccountFlag.Name) { + cfg.Account.Unlocks = strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") } - if(ctx.GlobalIsSet(utils.PasswordFileFlag.Name)) { - cfg.Account.Passwords=utils.MakePasswordList(ctx) + if ctx.GlobalIsSet(utils.PasswordFileFlag.Name) { + cfg.Account.Passwords = utils.MakePasswordList(ctx) } for i, account := range cfg.Account.Unlocks { diff --git a/cmd/tomo/testdata/tomo.toml b/cmd/tomo/testdata/tomo.toml index 7ea88998a8..0a0852b3f5 100644 --- a/cmd/tomo/testdata/tomo.toml +++ b/cmd/tomo/testdata/tomo.toml @@ -24,24 +24,8 @@ passwords = ["PWD_DEVNET"] # list password in environment variable (sp [bootnodes] -main =["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303", - "enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303", - "enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303", - "enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303", - "enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303", - "enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"] -test =["enode://30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606@52.176.7.10:30303", - "enode://865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c@52.176.100.77:30303", - "enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303", - "enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303" ] -rinkeby =["enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303", - "enode://343149e4feefa15d882d9fe4ac7d88f885bd05ebb735e547f12e12080a9fa07c8014ca6fd7f373123488102fe5e34111f8509cf0b7de3f5b44339c9f25e87cb8@52.3.158.184:30303", - "enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303"] -discoveryv5 =["enode://06051a5573c81934c9554ef2898eb13b33a34b94cf36b202b69fde139ca17a85051979867720d4bdae4323d4943ddf9aeeb6643633aa656e0be843659795007a@35.177.226.168:30303", - "enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb946b90a34f1f19548cd3c7baccbcaea354531e5983c7d1bc0dee16ce4b6440b@40.118.3.223:30304", - "enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469a85fad36f2473c9a80eb043ae60936df905fa28f1ff614c3e5dc34f15dcd2dc@40.118.3.223:30306", - "enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247d2c75c45c6b4a60335060d072d7f5b35dd1d4c45f76941f62a4f83b6e75daaf@40.118.3.223:30307"] - +main =[] +test =[] diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index ad505e6726..cc32492c41 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -380,12 +380,12 @@ const ( // Config are the configuration parameters of the ethash. type Config struct { - CacheDir string `toml:"cachedir"` - CachesInMem int `toml:"cachesinmem"` - CachesOnDisk int `toml:"cachesinmem"` - DatasetDir string `toml:"cachesinmem"` - DatasetsInMem int `toml:"cachesinmem"` - DatasetsOnDisk int `toml:"cachesinmem"` + CacheDir string `toml:"cachedir"` + CachesInMem int `toml:"cachesinmem"` + CachesOnDisk int `toml:"cachesinmem"` + DatasetDir string `toml:"cachesinmem"` + DatasetsInMem int `toml:"cachesinmem"` + DatasetsOnDisk int `toml:"cachesinmem"` PowMode Mode } diff --git a/eth/config.go b/eth/config.go index 8969bb55f3..2aaa92d3af 100644 --- a/eth/config.go +++ b/eth/config.go @@ -79,7 +79,7 @@ type Config struct { Genesis *core.Genesis `toml:",omitempty"` // Protocol options - NetworkId uint64 `toml:"NetworkId,default=1"` // Network ID to use for selecting peers to connect to ,default=1 + NetworkId uint64 `toml:"NetworkId,default=1"` // Network ID to use for selecting peers to connect to ,default=1 SyncMode downloader.SyncMode `toml:"SyncMode,default=FastSync"` NoPruning bool @@ -98,7 +98,7 @@ type Config struct { Etherbase common.Address `toml:",omitempty"` MinerThreads int `toml:",omitempty"` ExtraData []byte `toml:",omitempty"` - GasPrice *big.Int `toml:"GasPrice"` + GasPrice *big.Int `toml:"GasPrice"` // Ethash options Ethash ethash.Config diff --git a/p2p/discover/node.go b/p2p/discover/node.go index 86275a8955..3b0c84115c 100644 --- a/p2p/discover/node.go +++ b/p2p/discover/node.go @@ -56,7 +56,6 @@ type Node struct { addedAt time.Time } - // NewNode creates a new node. It is mostly meant to be used for // testing purposes. func NewNode(id NodeID, ip net.IP, udpPort, tcpPort uint16) *Node { diff --git a/p2p/server.go b/p2p/server.go index a273f124ac..f8a87cb42f 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -121,7 +121,7 @@ type Config struct { // If the port is zero, the operating system will pick a port. The // ListenAddr field will be updated with the actual address when // the server is started. - ListenAddr string `toml:"listenaddr,default=30303"` + ListenAddr string `toml:"listenaddr,default=30303"` // If set to a non-nil value, the given NAT port mapper // is used to make the listening port available to the From c363ad52ace76fb9fb6c667571ca9a414de4d108 Mon Sep 17 00:00:00 2001 From: Nguyen Ba Tam Date: Mon, 27 Aug 2018 11:12:17 +0700 Subject: [PATCH 5/5] fix reduce change code --- cmd/tomo/config.go | 26 +++++++++++++------------- cmd/tomo/testdata/config.toml | 35 +++++++++++++++++++++++++++++++++++ cmd/tomo/testdata/tomo.toml | 35 ----------------------------------- consensus/ethash/ethash.go | 12 ++++++------ dashboard/config.go | 6 +++--- eth/config.go | 6 +++--- node/config.go | 16 ++++++++-------- p2p/server.go | 6 +++--- 8 files changed, 71 insertions(+), 71 deletions(-) create mode 100644 cmd/tomo/testdata/config.toml delete mode 100644 cmd/tomo/testdata/tomo.toml diff --git a/cmd/tomo/config.go b/cmd/tomo/config.go index 7733d5caa9..dc199a04d2 100644 --- a/cmd/tomo/config.go +++ b/cmd/tomo/config.go @@ -72,28 +72,28 @@ var tomlSettings = toml.Config{ } type ethstatsConfig struct { - URL string `toml:"url"` + URL string `toml:",omitempty"` } type account struct { - Unlocks []string `toml:"unlocks"` - Passwords []string `toml:"passwords"` + Unlocks []string + Passwords []string } type Bootnodes struct { - Mainnet []string `toml:"main"` - Testnet []string `toml:"test"` + Mainnet []string + Testnet []string } type tomoConfig struct { - Eth eth.Config `toml:"eth"` - Shh whisper.Config `toml:"ssh"` - Node node.Config `toml:"node"` - Ethstats ethstatsConfig `toml:"ethstats"` - Dashboard dashboard.Config `toml:"dashboard"` - Account account `toml:"account"` - StakeEnable bool `toml:"stake"` - Bootnodes Bootnodes `toml:"bootnodes"` + Eth eth.Config + Shh whisper.Config + Node node.Config + Ethstats ethstatsConfig + Dashboard dashboard.Config + Account account + StakeEnable bool + Bootnodes Bootnodes } func loadConfig(file string, cfg *tomoConfig) error { diff --git a/cmd/tomo/testdata/config.toml b/cmd/tomo/testdata/config.toml new file mode 100644 index 0000000000..5185af3dc0 --- /dev/null +++ b/cmd/tomo/testdata/config.toml @@ -0,0 +1,35 @@ +StakeEnable = true # flag --miner ( true : enable staker , false : disable ) +[Eth] +NetworkId = 89 # flag --networkid +SyncMode = "full" # flag --syncmode +GasPrice = 1 # flag --gasprice + +[Shh] + +[Node] +DataDir = "node1/" # flag --datadir +HTTPHost = "localhost" # flag --rpcaddr +HTTPPort = 8501 # flag --rpcport +HTTPModules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi +[Node.P2P] +ListenAddr = ":30311" # flag --port +BootstrapNodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] +# flag --bootnodes + +[Ethstats] +[Dashboard] +[Account] +Unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt in flag --unlock +Passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789 + + +[Bootnodes] +Mainnet =[] +Testnet =[] + + + + + + + diff --git a/cmd/tomo/testdata/tomo.toml b/cmd/tomo/testdata/tomo.toml deleted file mode 100644 index 0a0852b3f5..0000000000 --- a/cmd/tomo/testdata/tomo.toml +++ /dev/null @@ -1,35 +0,0 @@ -stake = true # flag --stake ( true : enable staker , false : disable ) -[eth] -NetworkId = 1515 # flag --networkid -SyncMode = "full" # flag --syncmode -GasPrice = 1 # flag --gasprice - -[ssh] - -[node] -datadir = "node1/" # flag --datadir -http_host = "localhost" # flag --rpcaddr -http_port = 8501 # flag --rpcport -http_modules = ["personal","db","eth","net","web3","txpool","miner"] # flag --rpcapi -[node.p2p] -listenaddr = ":30311" # flag --port -bootnodes = ["enode://a890c5762c406fe046fb93fd307577a8454d571b6bf789f7dbfbf3c559be751f5fa400bc10639691245a9b22be1cfce0bbf82b322a24d06c6dcf29bf7eeb930c@127.0.0.1:30310"] -# flag --bootnodes - -[ethstats] -[dashboard] -[account] -unlocks = ["0x12f90a417f41bedd4bbcc99d52971803fb4c3f8b"] # list account slipt in flag --unlock -passwords = ["PWD_DEVNET"] # list password in environment variable (split by ',') : ex : export PWD_DEVNET=123456,123456789 - - -[bootnodes] -main =[] -test =[] - - - - - - - diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go index cc32492c41..1b3dcee302 100644 --- a/consensus/ethash/ethash.go +++ b/consensus/ethash/ethash.go @@ -380,12 +380,12 @@ const ( // Config are the configuration parameters of the ethash. type Config struct { - CacheDir string `toml:"cachedir"` - CachesInMem int `toml:"cachesinmem"` - CachesOnDisk int `toml:"cachesinmem"` - DatasetDir string `toml:"cachesinmem"` - DatasetsInMem int `toml:"cachesinmem"` - DatasetsOnDisk int `toml:"cachesinmem"` + CacheDir string + CachesInMem int + CachesOnDisk int + DatasetDir string + DatasetsInMem int + DatasetsOnDisk int PowMode Mode } diff --git a/dashboard/config.go b/dashboard/config.go index c3477fcfab..c260ed4f0e 100644 --- a/dashboard/config.go +++ b/dashboard/config.go @@ -29,13 +29,13 @@ var DefaultConfig = Config{ type Config struct { // Host is the host interface on which to start the dashboard server. If this // field is empty, no dashboard will be started. - Host string `toml:"host,default=localhost"` + Host string `toml:",omitempty"` // Port is the TCP port number on which to start the dashboard server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). - Port int `toml:"port,default=8080"` + Port int `toml:",omitempty"` // Refresh is the refresh rate of the data updates, the chartEntry will be collected this often. - Refresh time.Duration + Refresh time.Duration `toml:",omitempty"` } diff --git a/eth/config.go b/eth/config.go index 2aaa92d3af..dd7f42c7d9 100644 --- a/eth/config.go +++ b/eth/config.go @@ -79,8 +79,8 @@ type Config struct { Genesis *core.Genesis `toml:",omitempty"` // Protocol options - NetworkId uint64 `toml:"NetworkId,default=1"` // Network ID to use for selecting peers to connect to ,default=1 - SyncMode downloader.SyncMode `toml:"SyncMode,default=FastSync"` + NetworkId uint64 // Network ID to use for selecting peers to connect to + SyncMode downloader.SyncMode NoPruning bool // Light client options @@ -98,7 +98,7 @@ type Config struct { Etherbase common.Address `toml:",omitempty"` MinerThreads int `toml:",omitempty"` ExtraData []byte `toml:",omitempty"` - GasPrice *big.Int `toml:"GasPrice"` + GasPrice *big.Int // Ethash options Ethash ethash.Config diff --git a/node/config.go b/node/config.go index fc91ecefac..dda24583ee 100644 --- a/node/config.go +++ b/node/config.go @@ -53,7 +53,7 @@ type Config struct { Name string `toml:"-"` // UserIdent, if set, is used as an additional component in the devp2p node identifier. - UserIdent string `toml:"identity"` + UserIdent string `toml:",omitempty"` // Version should be set to the version number of the program. It is used // in the devp2p node identifier. @@ -64,10 +64,10 @@ type Config struct { // registered services, instead those can use utility methods to create/access // databases or flat files. This enables ephemeral nodes which can fully reside // in memory. - DataDir string `toml:"datadir"` + DataDir string // Configuration of peer-to-peer networking. - P2P p2p.Config `toml:"p2p"` + P2P p2p.Config // KeyStoreDir is the file system folder that contains private keys. The directory can // be specified as a relative path, in which case it is resolved relative to the @@ -76,11 +76,11 @@ type Config struct { // If KeyStoreDir is empty, the default location is the "keystore" subdirectory of // DataDir. If DataDir is unspecified and KeyStoreDir is empty, an ephemeral directory // is created by New and destroyed when the node is stopped. - KeyStoreDir string `toml:"keystore"` + KeyStoreDir string `toml:",omitempty"` // UseLightweightKDF lowers the memory and CPU requirements of the key store // scrypt KDF at the expense of security. - UseLightweightKDF bool `toml:"lightkdf"` + UseLightweightKDF bool `toml:",omitempty"` // NoUSB disables hardware wallet monitoring and connectivity. NoUSB bool `toml:",omitempty"` @@ -93,12 +93,12 @@ type Config struct { // HTTPHost is the host interface on which to start the HTTP RPC server. If this // field is empty, no HTTP API endpoint will be started. - HTTPHost string `toml:"http_host"` + HTTPHost string `toml:",omitempty"` // HTTPPort is the TCP port number on which to start the HTTP RPC server. The // default zero value is/ valid and will pick a port number randomly (useful // for ephemeral nodes). - HTTPPort int `toml:"http_port"` + HTTPPort int `toml:",omitempty"` // HTTPCors is the Cross-Origin Resource Sharing header to send to requesting // clients. Please be aware that CORS is a browser enforced security, it's fully @@ -117,7 +117,7 @@ type Config struct { // HTTPModules is a list of API modules to expose via the HTTP RPC interface. // If the module list is empty, all RPC API endpoints designated public will be // exposed. - HTTPModules []string `toml:"http_modules"` + HTTPModules []string `toml:",omitempty"` // WSHost is the host interface on which to start the websocket RPC server. If // this field is empty, no websocket API endpoint will be started. diff --git a/p2p/server.go b/p2p/server.go index f8a87cb42f..c41d1dc156 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -86,12 +86,12 @@ type Config struct { // BootstrapNodes are used to establish connectivity // with the rest of the network. - BootstrapNodes []*discover.Node `toml:"bootnodes"` + BootstrapNodes []*discover.Node // BootstrapNodesV5 are used to establish connectivity // with the rest of the network using the V5 discovery // protocol. - BootstrapNodesV5 []*discv5.Node `toml:"bootnodes_v5"` + BootstrapNodesV5 []*discv5.Node `toml:",omitempty"` // Static nodes are used as pre-configured connections which are always // maintained and re-connected on disconnects. @@ -121,7 +121,7 @@ type Config struct { // If the port is zero, the operating system will pick a port. The // ListenAddr field will be updated with the actual address when // the server is started. - ListenAddr string `toml:"listenaddr,default=30303"` + ListenAddr string // If set to a non-nil value, the given NAT port mapper // is used to make the listening port available to the