Skip to content

Commit 429926a

Browse files
committed
fix: enable state size tracker if metrics and flag are enabled
Signed-off-by: jsvisa <[email protected]>
1 parent 827afdd commit 429926a

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

cmd/geth/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ func applyMetricConfig(ctx *cli.Context, cfg *gethConfig) {
375375
if ctx.IsSet(utils.MetricsInfluxDBOrganizationFlag.Name) {
376376
cfg.Metrics.InfluxDBOrganization = ctx.String(utils.MetricsInfluxDBOrganizationFlag.Name)
377377
}
378-
if ctx.IsSet(utils.MetricsStateSizeFlag.Name) {
379-
cfg.Metrics.EnableStateSizeTracking = ctx.Bool(utils.MetricsStateSizeFlag.Name)
380-
}
381378
// Sanity-check the commandline flags. It is fine if some unused fields is part
382379
// of the toml-config, but we expect the commandline to only contain relevant
383380
// arguments, otherwise it indicates an error.

cmd/utils/flags.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
970970
MetricsStateSizeFlag = &cli.BoolFlag{
971971
Name: "metrics.statesize",
972972
Usage: "Enable state size tracking for metrics collection",
973-
Value: metrics.DefaultConfig.EnableStateSizeTracking,
973+
Value: ethconfig.Defaults.EnableStateSizeTracking,
974974
Category: flags.MetricsCategory,
975975
}
976976
)
@@ -1733,6 +1733,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
17331733
cfg.EthDiscoveryURLs = SplitAndTrim(urls)
17341734
}
17351735
}
1736+
1737+
if ctx.Bool(MetricsEnabledFlag.Name) && ctx.Bool(MetricsStateSizeFlag.Name) {
1738+
log.Error("Enabling state size metrics")
1739+
cfg.EnableStateSizeTracking = true
1740+
}
17361741
// Override any default configs for hard coded networks.
17371742
switch {
17381743
case ctx.Bool(MainnetFlag.Name):
@@ -2225,10 +2230,6 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
22252230
} else if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheSnapshotFlag.Name) {
22262231
options.SnapshotLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheSnapshotFlag.Name) / 100
22272232
}
2228-
if ctx.Bool(MetricsStateSizeFlag.Name) {
2229-
log.Info("Enabling state size tracking")
2230-
options.EnableStateSizeTracking = true
2231-
}
22322233
// If we're in readonly, do not bother generating snapshot data.
22332234
if readonly {
22342235
options.SnapshotNoBuild = true

eth/backend.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
240240
// within the data directory. The corresponding paths will be either:
241241
// - DATADIR/triedb/merkle.journal
242242
// - DATADIR/triedb/verkle.journal
243-
TrieJournalDirectory: stack.ResolvePath("triedb"),
243+
TrieJournalDirectory: stack.ResolvePath("triedb"),
244+
EnableStateSizeTracking: config.EnableStateSizeTracking,
244245
}
245246
)
246247
if config.VMTrace != "" {

eth/ethconfig/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ type Config struct {
144144
// Enables tracking of SHA3 preimages in the VM
145145
EnablePreimageRecording bool
146146

147+
// Enables tracking of state size
148+
EnableStateSizeTracking bool
149+
147150
// Enables VM tracing
148151
VMTrace string
149152
VMTraceJsonConfig string

metrics/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ type Config struct {
3333
InfluxDBToken string `toml:",omitempty"`
3434
InfluxDBBucket string `toml:",omitempty"`
3535
InfluxDBOrganization string `toml:",omitempty"`
36-
37-
EnableStateSizeTracking bool `toml:",omitempty"`
3836
}
3937

4038
// DefaultConfig is the default config for metrics used in go-ethereum.
@@ -55,6 +53,4 @@ var DefaultConfig = Config{
5553
InfluxDBToken: "test",
5654
InfluxDBBucket: "geth",
5755
InfluxDBOrganization: "geth",
58-
59-
EnableStateSizeTracking: false,
6056
}

0 commit comments

Comments
 (0)