|
| 1 | +package utils |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/ethereum/go-ethereum/metrics" |
| 5 | + "github.com/ethereum/go-ethereum/node" |
| 6 | + "github.com/optimism-java/shisui2/internal/flags" |
| 7 | + "github.com/optimism-java/shisui2/portalwire" |
| 8 | + "github.com/urfave/cli/v2" |
| 9 | +) |
| 10 | + |
| 11 | +var ( |
| 12 | + // Metrics flags |
| 13 | + MetricsEnabledFlag = &cli.BoolFlag{ |
| 14 | + Name: "metrics", |
| 15 | + Usage: "Enable metrics collection and reporting", |
| 16 | + Category: flags.MetricsCategory, |
| 17 | + } |
| 18 | + // MetricsHTTPFlag defines the endpoint for a stand-alone metrics HTTP endpoint. |
| 19 | + // Since the pprof service enables sensitive/vulnerable behavior, this allows a user |
| 20 | + // to enable a public-OK metrics endpoint without having to worry about ALSO exposing |
| 21 | + // other profiling behavior or information. |
| 22 | + MetricsHTTPFlag = &cli.StringFlag{ |
| 23 | + Name: "metrics.addr", |
| 24 | + Usage: `Enable stand-alone metrics HTTP server listening interface.`, |
| 25 | + Category: flags.MetricsCategory, |
| 26 | + } |
| 27 | + MetricsPortFlag = &cli.IntFlag{ |
| 28 | + Name: "metrics.port", |
| 29 | + Usage: `Metrics HTTP server listening port. |
| 30 | +Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.`, |
| 31 | + Value: metrics.DefaultConfig.Port, |
| 32 | + Category: flags.MetricsCategory, |
| 33 | + } |
| 34 | + MetricsEnableInfluxDBFlag = &cli.BoolFlag{ |
| 35 | + Name: "metrics.influxdb", |
| 36 | + Usage: "Enable metrics export/push to an external InfluxDB database", |
| 37 | + Category: flags.MetricsCategory, |
| 38 | + } |
| 39 | + MetricsInfluxDBEndpointFlag = &cli.StringFlag{ |
| 40 | + Name: "metrics.influxdb.endpoint", |
| 41 | + Usage: "InfluxDB API endpoint to report metrics to", |
| 42 | + Value: metrics.DefaultConfig.InfluxDBEndpoint, |
| 43 | + Category: flags.MetricsCategory, |
| 44 | + } |
| 45 | + MetricsInfluxDBDatabaseFlag = &cli.StringFlag{ |
| 46 | + Name: "metrics.influxdb.database", |
| 47 | + Usage: "InfluxDB database name to push reported metrics to", |
| 48 | + Value: metrics.DefaultConfig.InfluxDBDatabase, |
| 49 | + Category: flags.MetricsCategory, |
| 50 | + } |
| 51 | + MetricsInfluxDBUsernameFlag = &cli.StringFlag{ |
| 52 | + Name: "metrics.influxdb.username", |
| 53 | + Usage: "Username to authorize access to the database", |
| 54 | + Value: metrics.DefaultConfig.InfluxDBUsername, |
| 55 | + Category: flags.MetricsCategory, |
| 56 | + } |
| 57 | + MetricsInfluxDBPasswordFlag = &cli.StringFlag{ |
| 58 | + Name: "metrics.influxdb.password", |
| 59 | + Usage: "Password to authorize access to the database", |
| 60 | + Value: metrics.DefaultConfig.InfluxDBPassword, |
| 61 | + Category: flags.MetricsCategory, |
| 62 | + } |
| 63 | + // Tags are part of every measurement sent to InfluxDB. Queries on tags are faster in InfluxDB. |
| 64 | + // For example `host` tag could be used so that we can group all nodes and average a measurement |
| 65 | + // across all of them, but also so that we can select a specific node and inspect its measurements. |
| 66 | + // https://docs.influxdata.com/influxdb/v1.4/concepts/key_concepts/#tag-key |
| 67 | + MetricsInfluxDBTagsFlag = &cli.StringFlag{ |
| 68 | + Name: "metrics.influxdb.tags", |
| 69 | + Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements", |
| 70 | + Value: metrics.DefaultConfig.InfluxDBTags, |
| 71 | + Category: flags.MetricsCategory, |
| 72 | + } |
| 73 | + |
| 74 | + MetricsEnableInfluxDBV2Flag = &cli.BoolFlag{ |
| 75 | + Name: "metrics.influxdbv2", |
| 76 | + Usage: "Enable metrics export/push to an external InfluxDB v2 database", |
| 77 | + Category: flags.MetricsCategory, |
| 78 | + } |
| 79 | + |
| 80 | + MetricsInfluxDBTokenFlag = &cli.StringFlag{ |
| 81 | + Name: "metrics.influxdb.token", |
| 82 | + Usage: "Token to authorize access to the database (v2 only)", |
| 83 | + Value: metrics.DefaultConfig.InfluxDBToken, |
| 84 | + Category: flags.MetricsCategory, |
| 85 | + } |
| 86 | + |
| 87 | + MetricsInfluxDBBucketFlag = &cli.StringFlag{ |
| 88 | + Name: "metrics.influxdb.bucket", |
| 89 | + Usage: "InfluxDB bucket name to push reported metrics to (v2 only)", |
| 90 | + Value: metrics.DefaultConfig.InfluxDBBucket, |
| 91 | + Category: flags.MetricsCategory, |
| 92 | + } |
| 93 | + |
| 94 | + MetricsInfluxDBOrganizationFlag = &cli.StringFlag{ |
| 95 | + Name: "metrics.influxdb.organization", |
| 96 | + Usage: "InfluxDB organization name (v2 only)", |
| 97 | + Value: metrics.DefaultConfig.InfluxDBOrganization, |
| 98 | + Category: flags.MetricsCategory, |
| 99 | + } |
| 100 | + |
| 101 | + PortalRPCListenAddrFlag = &cli.StringFlag{ |
| 102 | + Name: "rpc.addr", |
| 103 | + Usage: "HTTP-RPC server listening interface", |
| 104 | + Category: flags.PortalNetworkCategory, |
| 105 | + } |
| 106 | + |
| 107 | + PortalRPCPortFlag = &cli.IntFlag{ |
| 108 | + Name: "rpc.port", |
| 109 | + Usage: "HTTP-RPC server listening port", |
| 110 | + Value: node.DefaultHTTPPort, |
| 111 | + Category: flags.PortalNetworkCategory, |
| 112 | + } |
| 113 | + |
| 114 | + PortalDataDirFlag = &cli.StringFlag{ |
| 115 | + Name: "data.dir", |
| 116 | + Usage: "Data dir of where the data file located", |
| 117 | + Value: "./", |
| 118 | + Category: flags.PortalNetworkCategory, |
| 119 | + } |
| 120 | + |
| 121 | + PortalDataCapacityFlag = &cli.Uint64Flag{ |
| 122 | + Name: "data.capacity", |
| 123 | + Usage: "The capacity of the data stored, the unit is MB", |
| 124 | + Value: 1000 * 10, // 10 GB |
| 125 | + Category: flags.PortalNetworkCategory, |
| 126 | + } |
| 127 | + |
| 128 | + PortalNATFlag = &cli.StringFlag{ |
| 129 | + Name: "nat", |
| 130 | + Usage: "NAT port mapping mechanism (any|none|upnp|pmp|stun|pmp:<IP>|extip:<IP>|stun:<IP>)", |
| 131 | + Value: "any", |
| 132 | + Category: flags.PortalNetworkCategory, |
| 133 | + } |
| 134 | + |
| 135 | + PortalUDPListenAddrFlag = &cli.StringFlag{ |
| 136 | + Name: "udp.addr", |
| 137 | + Usage: "Protocol UDP server listening interface", |
| 138 | + Value: "", |
| 139 | + Category: flags.PortalNetworkCategory, |
| 140 | + } |
| 141 | + |
| 142 | + PortalUDPPortFlag = &cli.IntFlag{ |
| 143 | + Name: "udp.port", |
| 144 | + Usage: "Protocol UDP server listening port", |
| 145 | + Value: node.DefaultUDPPort, |
| 146 | + Category: flags.PortalNetworkCategory, |
| 147 | + } |
| 148 | + |
| 149 | + PortalLogLevelFlag = &cli.IntFlag{ |
| 150 | + Name: "loglevel", |
| 151 | + Usage: "Loglevel of portal network", |
| 152 | + Value: node.DefaultLoglevel, |
| 153 | + Category: flags.PortalNetworkCategory, |
| 154 | + } |
| 155 | + |
| 156 | + PortalLogFormatFlag = &cli.StringFlag{ |
| 157 | + Name: "logformat", |
| 158 | + Usage: "Log format to use (json|logfmt|terminal)", |
| 159 | + Category: flags.PortalNetworkCategory, |
| 160 | + } |
| 161 | + |
| 162 | + PortalPrivateKeyFlag = &cli.StringFlag{ |
| 163 | + Name: "private.key", |
| 164 | + Usage: "Private key of p2p node, hex format without 0x prifix", |
| 165 | + Category: flags.PortalNetworkCategory, |
| 166 | + } |
| 167 | + |
| 168 | + PortalBootNodesFlag = &cli.StringFlag{ |
| 169 | + Name: "bootnodes", |
| 170 | + Usage: "Comma separated enode URLs for P2P discovery bootstrap", |
| 171 | + Category: flags.PortalNetworkCategory, |
| 172 | + } |
| 173 | + |
| 174 | + PortalNetworksFlag = &cli.StringSliceFlag{ |
| 175 | + Name: "networks", |
| 176 | + Usage: "Portal sub networks: history, beacon, state", |
| 177 | + Category: flags.PortalNetworkCategory, |
| 178 | + Value: cli.NewStringSlice(portalwire.History.Name()), |
| 179 | + } |
| 180 | +) |
0 commit comments