go-ethereum/core/state
Martin HS 9045b79bc2
metrics, cmd/geth: change init-process of metrics (#30814)
This PR modifies how the metrics library handles `Enabled`: previously,
the package `init` decided whether to serve real metrics or just
dummy-types.

This has several drawbacks: 
- During pkg init, we need to determine whether metrics are enabled or
not. So we first hacked in a check if certain geth-specific
commandline-flags were enabled. Then we added a similar check for
geth-env-vars. Then we almost added a very elaborate check for
toml-config-file, plus toml parsing.

- Using "real" types and dummy types interchangeably means that
everything is hidden behind interfaces. This has a performance penalty,
and also it just adds a lot of code.

This PR removes the interface stuff, uses concrete types, and allows for
the setting of Enabled to happen later. It is still assumed that
`metrics.Enable()` is invoked early on.

The somewhat 'heavy' operations, such as ticking meters and exp-decay,
now checks the enable-flag to prevent resource leak.

The change may be large, but it's mostly pretty trivial, and from the
last time I gutted the metrics, I ensured that we have fairly good test
coverage.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-12-10 13:27:29 +01:00
..
pruner all: clean up goerli flag and config (#30289) 2024-08-20 15:59:48 +02:00
snapshot core/state/snapshot: handle legacy journal (#30802) 2024-11-28 11:21:31 +08:00
access_events.go core, trie: verkle state processor tests (#30672) 2024-11-04 14:19:50 +01:00
access_events_test.go core/state, core/vm: Nyota contract create init simplification (#30409) 2024-09-13 15:37:30 +02:00
access_list.go core/state: rename all the AccessList receivers to 'al' (#29921) 2024-06-11 11:24:44 +03:00
database.go core/state: enable partial-functional reader (snapshot integration pt 3) (#30650) 2024-12-10 10:10:49 +08:00
dump.go eth/tracers: live chain tracing with hooks (#29189) 2024-03-22 18:53:53 +01:00
iterator.go core/state: introduce code reader interface (#30816) 2024-11-29 15:32:45 +01:00
iterator_test.go core/state: state reader abstraction (#29761) 2024-09-05 13:10:47 +03:00
journal.go core/state: get rid of field pointer in journal (#30361) 2024-09-06 15:42:59 +08:00
metrics.go core: add metrics for state access (#30353) 2024-08-26 20:02:10 +08:00
reader.go core/state: introduce code reader interface (#30816) 2024-11-29 15:32:45 +01:00
state_object.go core/state: introduce code reader interface (#30816) 2024-11-29 15:32:45 +01:00
state_object_test.go build: use golangci-lint (#20295) 2019-11-18 10:49:17 +02:00
state_test.go core/state: move state log mechanism to a separate layer (#30569) 2024-10-23 08:03:36 +02:00
statedb.go core/state: introduce code reader interface (#30816) 2024-11-29 15:32:45 +01:00
statedb_fuzz_test.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00
statedb_hooked.go core/state: invoke OnCodeChange-hook on selfdestruct (#30686) 2024-11-08 15:25:30 +01:00
statedb_hooked_test.go core: fix typos (#30767) 2024-11-19 14:26:39 +08:00
statedb_test.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00
stateupdate.go core, triedb: remove destruct flag in state snapshot (#30752) 2024-11-22 16:55:43 +08:00
sync.go core,eth,internal: fix typo (#29024) 2024-02-20 19:42:48 +08:00
sync_test.go core/state: introduce code reader interface (#30816) 2024-11-29 15:32:45 +01:00
transient_storage.go core/state: better randomized testing (postcheck) on journalling (#29627) 2024-04-25 09:56:25 +02:00
trie_prefetcher.go metrics, cmd/geth: change init-process of metrics (#30814) 2024-12-10 13:27:29 +01:00
trie_prefetcher_test.go core/state: fix runaway alloc caused by prefetcher heap escape (#30629) 2024-10-20 13:25:15 +03:00