mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 06:23:47 +00:00
commit
439d588fc9
7 changed files with 76 additions and 19 deletions
|
|
@ -329,7 +329,7 @@ func setDefaultMumbaiGethConfig(ctx *cli.Context, config *gethConfig) {
|
||||||
config.Eth.TxPool.AccountQueue = 64
|
config.Eth.TxPool.AccountQueue = 64
|
||||||
config.Eth.TxPool.GlobalQueue = 131072
|
config.Eth.TxPool.GlobalQueue = 131072
|
||||||
config.Eth.TxPool.Lifetime = 90 * time.Minute
|
config.Eth.TxPool.Lifetime = 90 * time.Minute
|
||||||
config.Node.P2P.MaxPeers = 200
|
config.Node.P2P.MaxPeers = 50
|
||||||
config.Metrics.Enabled = true
|
config.Metrics.Enabled = true
|
||||||
// --pprof is enabled in 'internal/debug/flags.go'
|
// --pprof is enabled in 'internal/debug/flags.go'
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +352,7 @@ func setDefaultBorMainnetGethConfig(ctx *cli.Context, config *gethConfig) {
|
||||||
config.Eth.TxPool.AccountQueue = 64
|
config.Eth.TxPool.AccountQueue = 64
|
||||||
config.Eth.TxPool.GlobalQueue = 131072
|
config.Eth.TxPool.GlobalQueue = 131072
|
||||||
config.Eth.TxPool.Lifetime = 90 * time.Minute
|
config.Eth.TxPool.Lifetime = 90 * time.Minute
|
||||||
config.Node.P2P.MaxPeers = 200
|
config.Node.P2P.MaxPeers = 50
|
||||||
config.Metrics.Enabled = true
|
config.Metrics.Enabled = true
|
||||||
// --pprof is enabled in 'internal/debug/flags.go'
|
// --pprof is enabled in 'internal/debug/flags.go'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,16 @@
|
||||||
|
|
||||||
- [Configuration file](./config.md)
|
- [Configuration file](./config.md)
|
||||||
|
|
||||||
## Deprecation notes
|
## Additional notes
|
||||||
|
|
||||||
- The new entrypoint to run the Bor client is ```server```.
|
- The new entrypoint to run the Bor client is ```server```.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ bor server
|
$ bor server <flags>
|
||||||
```
|
```
|
||||||
|
|
||||||
- Toml files to configure nodes are being deprecated. Currently, we only allow for static and trusted nodes to be configured using toml files.
|
- Toml files used earlier just to configure static/trusted nodes are being deprecated. Instead, a toml file now can be used instead of flags and can contain all configuration for the node to run. The link to a sample config file is given above. To simply run bor with a configuration file, the following command can be used.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ bor server --config ./legacy.toml
|
$ bor server --config <path_to_config.toml>
|
||||||
```
|
```
|
||||||
|
|
||||||
- ```Admin```, ```Personal``` and account related endpoints in ```Eth``` are being removed from the JsonRPC interface. Some of this functionality will be moved to the new GRPC server for operational tasks.
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ ethstats = ""
|
||||||
["eth.requiredblocks"]
|
["eth.requiredblocks"]
|
||||||
|
|
||||||
[p2p]
|
[p2p]
|
||||||
maxpeers = 30
|
maxpeers = 50
|
||||||
maxpendpeers = 50
|
maxpendpeers = 50
|
||||||
bind = "0.0.0.0"
|
bind = "0.0.0.0"
|
||||||
port = 30303
|
port = 30303
|
||||||
|
|
|
||||||
|
|
@ -396,7 +396,7 @@ func DefaultConfig() *Config {
|
||||||
LogLevel: "INFO",
|
LogLevel: "INFO",
|
||||||
DataDir: DefaultDataDir(),
|
DataDir: DefaultDataDir(),
|
||||||
P2P: &P2PConfig{
|
P2P: &P2PConfig{
|
||||||
MaxPeers: 30,
|
MaxPeers: 50,
|
||||||
MaxPendPeers: 50,
|
MaxPendPeers: 50,
|
||||||
Bind: "0.0.0.0",
|
Bind: "0.0.0.0",
|
||||||
Port: 30303,
|
Port: 30303,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/metrics/influxdb"
|
"github.com/ethereum/go-ethereum/metrics/influxdb"
|
||||||
"github.com/ethereum/go-ethereum/metrics/prometheus"
|
"github.com/ethereum/go-ethereum/metrics/prometheus"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
|
|
||||||
|
// Force-load the tracer engines to trigger registration
|
||||||
|
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
|
||||||
|
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
|
@ -229,6 +233,12 @@ func (s *Server) Stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error {
|
func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error {
|
||||||
|
// Check the global metrics if they're matching with the provided config
|
||||||
|
if metrics.Enabled != config.Enabled || metrics.EnabledExpensive != config.Expensive {
|
||||||
|
log.Warn("Metric misconfiguration, some of them might not be visible")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the values anyways (for services which don't need immediate attention)
|
||||||
metrics.Enabled = config.Enabled
|
metrics.Enabled = config.Enabled
|
||||||
metrics.EnabledExpensive = config.Expensive
|
metrics.EnabledExpensive = config.Expensive
|
||||||
|
|
||||||
|
|
@ -239,6 +249,10 @@ func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error
|
||||||
|
|
||||||
log.Info("Enabling metrics collection")
|
log.Info("Enabling metrics collection")
|
||||||
|
|
||||||
|
if metrics.EnabledExpensive {
|
||||||
|
log.Info("Enabling expensive metrics collection")
|
||||||
|
}
|
||||||
|
|
||||||
// influxdb
|
// influxdb
|
||||||
if v1Enabled, v2Enabled := config.InfluxDB.V1Enabled, config.InfluxDB.V2Enabled; v1Enabled || v2Enabled {
|
if v1Enabled, v2Enabled := config.InfluxDB.V1Enabled, config.InfluxDB.V2Enabled; v1Enabled || v2Enabled {
|
||||||
if v1Enabled && v2Enabled {
|
if v1Enabled && v2Enabled {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enabled is checked by the constructor functions for all of the
|
// Enabled is checked by the constructor functions for all of the
|
||||||
|
|
@ -32,26 +32,71 @@ var enablerFlags = []string{"metrics"}
|
||||||
// expensiveEnablerFlags is the CLI flag names to use to enable metrics collections.
|
// expensiveEnablerFlags is the CLI flag names to use to enable metrics collections.
|
||||||
var expensiveEnablerFlags = []string{"metrics.expensive"}
|
var expensiveEnablerFlags = []string{"metrics.expensive"}
|
||||||
|
|
||||||
|
// configFlag is the CLI flag name to use to start node by providing a toml based config
|
||||||
|
var configFlag = "config"
|
||||||
|
|
||||||
// Init enables or disables the metrics system. Since we need this to run before
|
// Init enables or disables the metrics system. Since we need this to run before
|
||||||
// any other code gets to create meters and timers, we'll actually do an ugly hack
|
// any other code gets to create meters and timers, we'll actually do an ugly hack
|
||||||
// and peek into the command line args for the metrics flag.
|
// and peek into the command line args for the metrics flag.
|
||||||
func init() {
|
func init() {
|
||||||
for _, arg := range os.Args {
|
var configFile string
|
||||||
|
|
||||||
|
for i := 0; i < len(os.Args); i++ {
|
||||||
|
arg := os.Args[i]
|
||||||
|
|
||||||
flag := strings.TrimLeft(arg, "-")
|
flag := strings.TrimLeft(arg, "-")
|
||||||
|
|
||||||
|
// check for existence of `config` flag
|
||||||
|
if flag == configFlag && i < len(os.Args)-1 {
|
||||||
|
configFile = strings.TrimLeft(os.Args[i+1], "-") // find the value of flag
|
||||||
|
}
|
||||||
|
|
||||||
for _, enabler := range enablerFlags {
|
for _, enabler := range enablerFlags {
|
||||||
if !Enabled && flag == enabler {
|
if !Enabled && flag == enabler {
|
||||||
log.Info("Enabling metrics collection")
|
|
||||||
Enabled = true
|
Enabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, enabler := range expensiveEnablerFlags {
|
for _, enabler := range expensiveEnablerFlags {
|
||||||
if !EnabledExpensive && flag == enabler {
|
if !EnabledExpensive && flag == enabler {
|
||||||
log.Info("Enabling expensive metrics collection")
|
|
||||||
EnabledExpensive = true
|
EnabledExpensive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the global metrics value, if they're provided in the config file
|
||||||
|
updateMetricsFromConfig(configFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateMetricsFromConfig(path string) {
|
||||||
|
// Don't act upon any errors here. They're already taken into
|
||||||
|
// consideration when the toml config file will be parsed in the cli.
|
||||||
|
data, err := os.ReadFile(path)
|
||||||
|
tomlData := string(data)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a minimal config to decode
|
||||||
|
type TelemetryConfig struct {
|
||||||
|
Enabled bool `hcl:"metrics,optional" toml:"metrics,optional"`
|
||||||
|
Expensive bool `hcl:"expensive,optional" toml:"expensive,optional"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CliConfig struct {
|
||||||
|
Telemetry *TelemetryConfig `hcl:"telemetry,block" toml:"telemetry,block"`
|
||||||
|
}
|
||||||
|
|
||||||
|
conf := &CliConfig{}
|
||||||
|
|
||||||
|
if _, err := toml.Decode(tomlData, &conf); err != nil || conf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// We have the values now, update them
|
||||||
|
Enabled = conf.Telemetry.Enabled
|
||||||
|
EnabledExpensive = conf.Telemetry.Expensive
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectProcessMetrics periodically collects various metrics about the running
|
// CollectProcessMetrics periodically collects various metrics about the running
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env sh
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Instructions:
|
# Instructions:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue