fix(metrics): coreth metrics do not conflict with libevm metrics #848
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this should be merged
Direct or indirect imports of libevm packages could execute first (depending on compilation/import oder) and register metrics "in libevm", and the coreth defined global metrics would fail silently at registering.
How this works
Use ava-labs/libevm#159 which:
metrics.New*constructors using their correspondingmetrics.GetOrRegister*function. That way the metrics, whether registered first in coreth or in libevm, are shared between the two, and we don't missing metric changes from the one of the two sides.metrics.GetOrRegisterOrOverrideCounterfunction for metrics defined as counters in coreth but defined as another type (timer) in libevm, such that it unregisters the libevm metric and replaces it with the coreth metric of another type. Note we could, if we want, replace it with justOverrideCounterwhere it would not even attempt to get the already registered metric and check its type, let me know.The side effect is that some tests in warp/ had to be changed a tiny bit to clear metrics, since these are now shared between subtest even after calling a
metrics.New*constructor.How this was tested
CI passing
Need to be documented?
No
Need to update RELEASES.md?
No