diff --git a/core/blockchain.go b/core/blockchain.go index 77b15fad49..bd2eb66727 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -52,12 +52,12 @@ import ( "github.com/ava-labs/coreth/triedb" "github.com/ava-labs/coreth/triedb/hashdb" "github.com/ava-labs/coreth/triedb/pathdb" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) var ( diff --git a/core/main_test.go b/core/main_test.go index db4ccc8652..6ea70c4b6c 100644 --- a/core/main_test.go +++ b/core/main_test.go @@ -15,7 +15,7 @@ func TestMain(m *testing.M) { opts := []goleak.Option{ // No good way to shut down these goroutines: goleak.IgnoreTopFunction("github.com/ava-labs/coreth/core/state/snapshot.(*diskLayer).generate"), - goleak.IgnoreTopFunction("github.com/ethereum/go-ethereum/metrics.(*meterArbiter).tick"), + goleak.IgnoreTopFunction("github.com/ava-labs/libevm/metrics.(*meterArbiter).tick"), goleak.IgnoreTopFunction("github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain"), } goleak.VerifyTestMain(m, opts...) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 53fe9ac15f..8d79dbc1c4 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -32,9 +32,9 @@ import ( "encoding/binary" "github.com/ava-labs/avalanchego/utils/wrappers" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/metrics" ) // The fields below define the low level database schema prefixing. diff --git a/core/state/metrics.go b/core/state/metrics.go index 096bfe504f..4fbc86c2f5 100644 --- a/core/state/metrics.go +++ b/core/state/metrics.go @@ -26,7 +26,7 @@ package state -import "github.com/ethereum/go-ethereum/metrics" +import "github.com/ava-labs/libevm/metrics" var ( accountUpdatedMeter = metrics.NewRegisteredMeter("state/update/account", nil) diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index 9c9b2f08ea..53cb8b7ccc 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -37,10 +37,10 @@ import ( "github.com/ava-labs/coreth/core/rawdb" "github.com/ava-labs/coreth/core/types" "github.com/ava-labs/coreth/triedb" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) const ( diff --git a/core/state/state_object.go b/core/state/state_object.go index 36aff41ba6..ed3f16ff9e 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -35,9 +35,9 @@ import ( "github.com/ava-labs/coreth/core/types" "github.com/ava-labs/coreth/trie/trienode" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" "github.com/holiman/uint256" ) diff --git a/core/state/statedb.go b/core/state/statedb.go index 26e4f28ccd..850859bbdc 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -43,10 +43,10 @@ import ( "github.com/ava-labs/coreth/trie/trienode" "github.com/ava-labs/coreth/trie/triestate" "github.com/ava-labs/coreth/utils" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" "github.com/holiman/uint256" ) diff --git a/core/state/trie_prefetcher.go b/core/state/trie_prefetcher.go index f700010d46..b82edf5be7 100644 --- a/core/state/trie_prefetcher.go +++ b/core/state/trie_prefetcher.go @@ -20,9 +20,9 @@ import ( "sync" "github.com/ava-labs/coreth/libevm/options" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) var ( diff --git a/core/state/trie_prefetcher_extra_test.go b/core/state/trie_prefetcher_extra_test.go index 0087678a79..968f9916fc 100644 --- a/core/state/trie_prefetcher_extra_test.go +++ b/core/state/trie_prefetcher_extra_test.go @@ -18,9 +18,9 @@ import ( "github.com/ava-labs/coreth/core/types" "github.com/ava-labs/coreth/triedb" "github.com/ava-labs/coreth/triedb/hashdb" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/metrics" "github.com/stretchr/testify/require" ) diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index bd9c846e9b..9f9cd09668 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -46,10 +46,10 @@ import ( "github.com/ava-labs/coreth/core/types" "github.com/ava-labs/coreth/params" "github.com/ava-labs/coreth/plugin/evm/header" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" "github.com/holiman/billy" "github.com/holiman/uint256" diff --git a/core/txpool/blobpool/metrics.go b/core/txpool/blobpool/metrics.go index 0192e897aa..ccd4dbb574 100644 --- a/core/txpool/blobpool/metrics.go +++ b/core/txpool/blobpool/metrics.go @@ -26,7 +26,7 @@ package blobpool -import "github.com/ethereum/go-ethereum/metrics" +import "github.com/ava-labs/libevm/metrics" var ( // datacapGauge tracks the user's configured capacity for the blob pool. It diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 5040320c72..d3da5c300b 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -43,11 +43,11 @@ import ( "github.com/ava-labs/coreth/params" "github.com/ava-labs/coreth/plugin/evm/header" "github.com/ava-labs/coreth/utils" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/prque" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" "github.com/holiman/uint256" ) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 71b6ad3c96..7cfa58d3ef 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -35,10 +35,10 @@ import ( "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/types" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) var ( diff --git a/go.mod b/go.mod index deb8d6e2bf..fb8951b10c 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.23.6 require ( github.com/VictoriaMetrics/fastcache v1.12.1 github.com/ava-labs/avalanchego v1.12.3-name-fortuna.0 + github.com/ava-labs/libevm v0.0.0-20250320152422-7be6bee7ab32 github.com/cespare/cp v0.1.0 github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index fbb8eba3f3..a4c9f9fbb2 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/ava-labs/avalanchego v1.12.3-name-fortuna.0 h1:jABN/xZU6Tp0PTw3Q5lpaHJN/FBseVfJu81lH/2s2hw= github.com/ava-labs/avalanchego v1.12.3-name-fortuna.0/go.mod h1:SlofKg/9oP71zX8BQT78JWPBNff19tBNY7Cvp6QGQL0= +github.com/ava-labs/libevm v0.0.0-20250320152422-7be6bee7ab32 h1:l8Q4JyvTY+22e6lMLcd6WamMYFJc36MfJmeKflis7nQ= +github.com/ava-labs/libevm v0.0.0-20250320152422-7be6bee7ab32/go.mod h1:+Iol+sVQ1KyoBsHf3veyrBmHCXr3xXRWq6ZXkgVfNLU= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= diff --git a/metrics/prometheus/enabled_test.go b/metrics/prometheus/enabled_test.go new file mode 100644 index 0000000000..ed967e0ece --- /dev/null +++ b/metrics/prometheus/enabled_test.go @@ -0,0 +1,29 @@ +// (c) 2021-2025, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package prometheus_test + +import ( + "testing" + + // NOTE: This test assumes that there are no imported packages that might + // change the default value of [metrics.Enabled]. It is therefore in package + // `prometheus_test` in case any other tests modify the variable. If any + // imports here or in the implementation do actually do so then this test + // may have false negatives. + "github.com/stretchr/testify/assert" + + "github.com/ava-labs/libevm/metrics" +) + +func TestMetricsEnabledByDefault(t *testing.T) { + assert.True(t, metrics.Enabled, "libevm/metrics.Enabled") + + switch m := metrics.NewCounter().(type) { + case metrics.NilCounter: + t.Errorf("metrics.NewCounter() got %T; want %T", m, new(metrics.StandardCounter)) + case *metrics.StandardCounter: + default: + t.Errorf("metrics.NewCounter() got unknown type %T", m) + } +} diff --git a/metrics/prometheus/prometheus.go b/metrics/prometheus/prometheus.go index 07c14004ff..cd478e9249 100644 --- a/metrics/prometheus/prometheus.go +++ b/metrics/prometheus/prometheus.go @@ -11,7 +11,7 @@ import ( "github.com/prometheus/client_golang/prometheus" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" dto "github.com/prometheus/client_model/go" ) diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index 00cce63c85..4263abed7d 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -1,4 +1,4 @@ -// (c) 2021-2025, Ava Labs, Inc. All rights reserved. +// (c) 2025, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. package prometheus @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) func TestGatherer_Gather(t *testing.T) { diff --git a/peer/peer_tracker.go b/peer/peer_tracker.go index ca11a4faf6..30f73d854d 100644 --- a/peer/peer_tracker.go +++ b/peer/peer_tracker.go @@ -15,7 +15,7 @@ import ( "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) const ( diff --git a/peer/stats/stats.go b/peer/stats/stats.go index a23772540c..5a3c2918f4 100644 --- a/peer/stats/stats.go +++ b/peer/stats/stats.go @@ -6,7 +6,7 @@ package stats import ( "time" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) // RequestHandlerStats provides the interface for metrics for app requests. diff --git a/plugin/evm/atomic/mempool.go b/plugin/evm/atomic/mempool.go index f84dcf1840..83e668077b 100644 --- a/plugin/evm/atomic/mempool.go +++ b/plugin/evm/atomic/mempool.go @@ -15,8 +15,8 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/ava-labs/coreth/plugin/evm/config" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) const ( diff --git a/plugin/evm/network_handler.go b/plugin/evm/network_handler.go index 6d9a282b7f..a461122cf6 100644 --- a/plugin/evm/network_handler.go +++ b/plugin/evm/network_handler.go @@ -14,8 +14,8 @@ import ( "github.com/ava-labs/coreth/triedb" "github.com/ava-labs/coreth/warp" warpHandlers "github.com/ava-labs/coreth/warp/handlers" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/metrics" ) var _ message.RequestHandler = &networkHandler{} diff --git a/plugin/evm/testutils/metrics.go b/plugin/evm/testutils/metrics.go index aa2ee19037..afb2ea7f43 100644 --- a/plugin/evm/testutils/metrics.go +++ b/plugin/evm/testutils/metrics.go @@ -3,7 +3,7 @@ package testutils import ( "testing" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) // WithMetrics enables go-ethereum metrics globally for the test. diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index fcd029e7af..acd59d4585 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -48,7 +48,7 @@ import ( "github.com/ava-labs/coreth/triedb" "github.com/ava-labs/coreth/triedb/hashdb" "github.com/ava-labs/coreth/utils" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" warpcontract "github.com/ava-labs/coreth/precompile/contracts/warp" "github.com/ava-labs/coreth/rpc" diff --git a/rpc/handler.go b/rpc/handler.go index 82d1235ab1..cabbd10cde 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -38,8 +38,8 @@ import ( "sync" "time" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" "golang.org/x/time/rate" ) diff --git a/rpc/metrics.go b/rpc/metrics.go index bafdcf591c..a4469545d7 100644 --- a/rpc/metrics.go +++ b/rpc/metrics.go @@ -30,7 +30,7 @@ import ( "fmt" "time" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) var ( diff --git a/sync/client/stats/stats.go b/sync/client/stats/stats.go index 0bd47ce96d..2be86a1d16 100644 --- a/sync/client/stats/stats.go +++ b/sync/client/stats/stats.go @@ -8,7 +8,7 @@ import ( "time" "github.com/ava-labs/coreth/plugin/evm/message" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) var ( diff --git a/sync/handlers/stats/stats.go b/sync/handlers/stats/stats.go index d6e3271911..0d1171b82b 100644 --- a/sync/handlers/stats/stats.go +++ b/sync/handlers/stats/stats.go @@ -6,7 +6,7 @@ package stats import ( "time" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) // HandlerStats reports prometheus metrics for the state sync handlers diff --git a/sync/statesync/trie_sync_stats.go b/sync/statesync/trie_sync_stats.go index 4cc6a0c5b2..5083b590f9 100644 --- a/sync/statesync/trie_sync_stats.go +++ b/sync/statesync/trie_sync_stats.go @@ -10,9 +10,9 @@ import ( utils_math "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/utils/timer" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) const ( diff --git a/sync/statesync/trie_sync_stats_test.go b/sync/statesync/trie_sync_stats_test.go index 1d01cd29ec..e2c1b0c340 100644 --- a/sync/statesync/trie_sync_stats_test.go +++ b/sync/statesync/trie_sync_stats_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" "github.com/stretchr/testify/require" ) diff --git a/trie/stacktrie.go b/trie/stacktrie.go index cf71416ce4..7321c4bff9 100644 --- a/trie/stacktrie.go +++ b/trie/stacktrie.go @@ -32,9 +32,9 @@ import ( "sync" "github.com/ava-labs/coreth/core/types" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" ) var ( diff --git a/trie/utils/verkle.go b/trie/utils/verkle.go index ce059edc64..ca733d1d7e 100644 --- a/trie/utils/verkle.go +++ b/trie/utils/verkle.go @@ -20,9 +20,9 @@ import ( "encoding/binary" "sync" + "github.com/ava-labs/libevm/metrics" "github.com/crate-crypto/go-ipa/bandersnatch/fr" "github.com/ethereum/go-ethereum/common/lru" - "github.com/ethereum/go-ethereum/metrics" "github.com/gballet/go-verkle" "github.com/holiman/uint256" ) diff --git a/triedb/hashdb/database.go b/triedb/hashdb/database.go index d0d7bafb92..92053ad583 100644 --- a/triedb/hashdb/database.go +++ b/triedb/hashdb/database.go @@ -38,10 +38,10 @@ import ( "github.com/ava-labs/coreth/trie/trienode" "github.com/ava-labs/coreth/trie/triestate" "github.com/ava-labs/coreth/utils" + "github.com/ava-labs/libevm/metrics" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" ) diff --git a/triedb/pathdb/metrics.go b/triedb/pathdb/metrics.go index e2df1ca156..21038ecfc6 100644 --- a/triedb/pathdb/metrics.go +++ b/triedb/pathdb/metrics.go @@ -26,7 +26,7 @@ package pathdb -import "github.com/ethereum/go-ethereum/metrics" +import "github.com/ava-labs/libevm/metrics" // nolint: unused var ( diff --git a/utils/metered_cache.go b/utils/metered_cache.go index dfaeac7cca..ee1807e36f 100644 --- a/utils/metered_cache.go +++ b/utils/metered_cache.go @@ -9,7 +9,7 @@ import ( "time" "github.com/VictoriaMetrics/fastcache" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) // MeteredCache wraps *fastcache.Cache and periodically pulls stats from it. diff --git a/warp/handlers/stats.go b/warp/handlers/stats.go index d81bce0e02..6a56d54076 100644 --- a/warp/handlers/stats.go +++ b/warp/handlers/stats.go @@ -6,7 +6,7 @@ package handlers import ( "time" - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) type handlerStats struct { diff --git a/warp/verifier_stats.go b/warp/verifier_stats.go index a092751e8b..6a47c31397 100644 --- a/warp/verifier_stats.go +++ b/warp/verifier_stats.go @@ -4,7 +4,7 @@ package warp import ( - "github.com/ethereum/go-ethereum/metrics" + "github.com/ava-labs/libevm/metrics" ) type verifierStats struct {