From 8c78449a9ef8f2a77cc1ff94f9a0a3178af21408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 19 Oct 2017 13:59:02 +0300 Subject: cmd/puppeth: reorganize stats reports to make it readable --- cmd/puppeth/module_node.go | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'cmd/puppeth/module_node.go') diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index 375e3e646..ad50cd80a 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -18,6 +18,7 @@ package main import ( "bytes" + "encoding/json" "fmt" "math/rand" "path/filepath" @@ -25,6 +26,7 @@ import ( "strings" "text/template" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" ) @@ -164,14 +166,37 @@ type nodeInfos struct { gasPrice float64 } -// String implements the stringer interface. -func (info *nodeInfos) String() string { - discv5 := "" +// Report converts the typed struct into a plain string->string map, cotnaining +// most - but not all - fields for reporting to the user. +func (info *nodeInfos) Report() map[string]string { + report := map[string]string{ + "Data directory": info.datadir, + "Listener port (full nodes)": strconv.Itoa(info.portFull), + "Peer count (all total)": strconv.Itoa(info.peersTotal), + "Peer count (light nodes)": strconv.Itoa(info.peersLight), + "Ethstats username": info.ethstats, + } if info.peersLight > 0 { - discv5 = fmt.Sprintf(", portv5=%d", info.portLight) + report["Listener port (light nodes)"] = strconv.Itoa(info.portLight) + } + if info.gasTarget > 0 { + report["Gas limit (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget) + report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice) + } + if info.etherbase != "" { + report["Miner account"] = info.etherbase + } + if info.keyJSON != "" { + var key struct { + Address string `json:"address"` + } + if err := json.Unmarshal([]byte(info.keyJSON), &key); err == nil { + report["Signer account"] = common.HexToAddress(key.Address).Hex() + } else { + log.Error("Failed to retrieve signer address", "err", err) + } } - return fmt.Sprintf("port=%d%s, datadir=%s, peers=%d, lights=%d, ethstats=%s, gastarget=%0.3f MGas, gasprice=%0.3f GWei", - info.portFull, discv5, info.datadir, info.peersTotal, info.peersLight, info.ethstats, info.gasTarget, info.gasPrice) + return report } // checkNode does a health-check against an boot or seal node server to verify -- cgit v1.2.3 From da3b9f831e6bb8f8a3c589e5cd8426fd9da72eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 19 Oct 2017 16:00:55 +0300 Subject: cmd/puppeth: support deploying services with forced rebuilds --- cmd/puppeth/module_node.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cmd/puppeth/module_node.go') diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index ad50cd80a..17e8a1a99 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -81,7 +81,7 @@ services: // deployNode deploys a new Ethereum node container to a remote machine via SSH, // docker and docker-compose. If an instance with the specified network name // already exists there, it will be overwritten! -func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos) ([]byte, error) { +func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos, nocache bool) ([]byte, error) { kind := "sealnode" if config.keyJSON == "" && config.etherbase == "" { kind = "bootnode" @@ -143,7 +143,10 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf defer client.Run("rm -rf " + workdir) // Build and deploy the boot or seal node service - return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build", workdir, network)) + if nocache { + return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s build --pull --no-cache && docker-compose -p %s up -d --force-recreate", workdir, network, network)) + } + return nil, client.Stream(fmt.Sprintf("cd %s && docker-compose -p %s up -d --build --force-recreate", workdir, network)) } // nodeInfos is returned from a boot or seal node status check to allow reporting -- cgit v1.2.3 From 9e095251b71255ff346ee9300df8754eb6b64903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 19 Oct 2017 17:50:34 +0300 Subject: cmd/puppeth: mount ethash dir from the host to cache DAGs --- cmd/puppeth/module_node.go | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'cmd/puppeth/module_node.go') diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index 17e8a1a99..37da770aa 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -42,7 +42,7 @@ ADD genesis.json /genesis.json RUN \ echo 'geth init /genesis.json' > geth.sh && \{{if .Unlock}} echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}} - echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine{{end}}{{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh + echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh ENTRYPOINT ["/bin/sh", "geth.sh"] ` @@ -60,7 +60,8 @@ services: - "{{.FullPort}}:{{.FullPort}}/udp"{{if .Light}} - "{{.LightPort}}:{{.LightPort}}/udp"{{end}} volumes: - - {{.Datadir}}:/root/.ethereum + - {{.Datadir}}:/root/.ethereum{{if .Ethashdir}} + - {{.Ethashdir}}:/root/.ethash{{end}} environment: - FULL_PORT={{.FullPort}}/tcp - LIGHT_PORT={{.LightPort}}/udp @@ -116,6 +117,7 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf template.Must(template.New("").Parse(nodeComposefile)).Execute(composefile, map[string]interface{}{ "Type": kind, "Datadir": config.datadir, + "Ethashdir": config.ethashdir, "Network": network, "FullPort": config.portFull, "TotalPeers": config.peersTotal, @@ -155,6 +157,7 @@ type nodeInfos struct { genesis []byte network int64 datadir string + ethashdir string ethstats string portFull int portLight int @@ -180,23 +183,29 @@ func (info *nodeInfos) Report() map[string]string { "Ethstats username": info.ethstats, } if info.peersLight > 0 { + // Light server enabled report["Listener port (light nodes)"] = strconv.Itoa(info.portLight) } if info.gasTarget > 0 { + // Miner or signer node report["Gas limit (baseline target)"] = fmt.Sprintf("%0.3f MGas", info.gasTarget) report["Gas price (minimum accepted)"] = fmt.Sprintf("%0.3f GWei", info.gasPrice) - } - if info.etherbase != "" { - report["Miner account"] = info.etherbase - } - if info.keyJSON != "" { - var key struct { - Address string `json:"address"` + + if info.etherbase != "" { + // Ethash proof-of-work miner + report["Ethash directory"] = info.ethashdir + report["Miner account"] = info.etherbase } - if err := json.Unmarshal([]byte(info.keyJSON), &key); err == nil { - report["Signer account"] = common.HexToAddress(key.Address).Hex() - } else { - log.Error("Failed to retrieve signer address", "err", err) + if info.keyJSON != "" { + // Clique proof-of-authority signer + var key struct { + Address string `json:"address"` + } + if err := json.Unmarshal([]byte(info.keyJSON), &key); err == nil { + report["Signer account"] = common.HexToAddress(key.Address).Hex() + } else { + log.Error("Failed to retrieve signer address", "err", err) + } } } return report @@ -251,6 +260,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error) stats := &nodeInfos{ genesis: genesis, datadir: infos.volumes["/root/.ethereum"], + ethashdir: infos.volumes["/root/.ethash"], portFull: infos.portmap[infos.envvars["FULL_PORT"]], portLight: infos.portmap[infos.envvars["LIGHT_PORT"]], peersTotal: totalPeers, -- cgit v1.2.3 From 1e0c336d293367bb75df494a685cabb2029f318e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 20 Oct 2017 11:14:10 +0300 Subject: cmd/puppeth: etherchain light block explorer for PoW nets --- cmd/puppeth/module_node.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmd/puppeth/module_node.go') diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index 37da770aa..9b8d5f0f7 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -40,7 +40,7 @@ ADD genesis.json /genesis.json ADD signer.pass /signer.pass {{end}} RUN \ - echo 'geth init /genesis.json' > geth.sh && \{{if .Unlock}} + echo 'geth --cache 512 init /genesis.json' > geth.sh && \{{if .Unlock}} echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}} echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine --minerthreads 1{{end}} {{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh @@ -131,9 +131,7 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf }) files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes() - //genesisfile, _ := json.MarshalIndent(config.genesis, "", " ") files[filepath.Join(workdir, "genesis.json")] = config.genesis - if config.keyJSON != "" { files[filepath.Join(workdir, "signer.json")] = []byte(config.keyJSON) files[filepath.Join(workdir, "signer.pass")] = []byte(config.keyPass) -- cgit v1.2.3 From a3a2c6b0d9f963c9377612cae1ed6ded6f216c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 23 Nov 2017 14:22:59 +0200 Subject: cmd/puppeth: fix typos and review suggestions --- cmd/puppeth/module_node.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/puppeth/module_node.go') diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go index 9b8d5f0f7..69cb19c34 100644 --- a/cmd/puppeth/module_node.go +++ b/cmd/puppeth/module_node.go @@ -170,7 +170,7 @@ type nodeInfos struct { gasPrice float64 } -// Report converts the typed struct into a plain string->string map, cotnaining +// Report converts the typed struct into a plain string->string map, containing // most - but not all - fields for reporting to the user. func (info *nodeInfos) Report() map[string]string { report := map[string]string{ -- cgit v1.2.3