feat: more metrics (#21481)

This commit is contained in:
Arsenii Kulikov
2026-01-27 19:17:49 +04:00
committed by GitHub
parent bff11ab663
commit af3601c65d
3 changed files with 5 additions and 24 deletions

View File

@@ -312,14 +312,7 @@ impl<S: AccountReader> AccountReader for CachedStateProvider<S> {
match self.caches.get_or_try_insert_account_with(*address, || {
self.state_provider.basic_account(address)
})? {
CachedStatus::NotCached(value) => {
self.metrics.account_cache_misses.increment(1);
Ok(value)
}
CachedStatus::Cached(value) => {
self.metrics.account_cache_hits.increment(1);
Ok(value)
}
CachedStatus::NotCached(value) | CachedStatus::Cached(value) => Ok(value),
}
} else if let Some(account) = self.caches.account_cache.get(address) {
self.metrics.account_cache_hits.increment(1);
@@ -350,14 +343,7 @@ impl<S: StateProvider> StateProvider for CachedStateProvider<S> {
match self.caches.get_or_try_insert_storage_with(account, storage_key, || {
self.state_provider.storage(account, storage_key).map(Option::unwrap_or_default)
})? {
CachedStatus::NotCached(value) => {
self.metrics.storage_cache_misses.increment(1);
// The slot that was never written to is indistinguishable from a slot
// explicitly set to zero. We return `None` in both cases.
Ok(Some(value).filter(|v| !v.is_zero()))
}
CachedStatus::Cached(value) => {
self.metrics.storage_cache_hits.increment(1);
CachedStatus::NotCached(value) | CachedStatus::Cached(value) => {
// The slot that was never written to is indistinguishable from a slot
// explicitly set to zero. We return `None` in both cases.
Ok(Some(value).filter(|v| !v.is_zero()))
@@ -379,14 +365,7 @@ impl<S: BytecodeReader> BytecodeReader for CachedStateProvider<S> {
match self.caches.get_or_try_insert_code_with(*code_hash, || {
self.state_provider.bytecode_by_hash(code_hash)
})? {
CachedStatus::NotCached(code) => {
self.metrics.code_cache_misses.increment(1);
Ok(code)
}
CachedStatus::Cached(code) => {
self.metrics.code_cache_hits.increment(1);
Ok(code)
}
CachedStatus::NotCached(code) | CachedStatus::Cached(code) => Ok(code),
}
} else if let Some(code) = self.caches.code_cache.get(code_hash) {
self.metrics.code_cache_hits.increment(1);

View File

@@ -563,6 +563,7 @@ where
index,
tx_hash = %tx.tx().tx_hash(),
is_success = tracing::field::Empty,
gas_used = tracing::field::Empty,
)
.entered();

View File

@@ -1302,6 +1302,7 @@ where
target: "trie::proof_task",
"Account multiproof calculation",
targets = targets.len(),
num_slots = targets.values().map(|slots| slots.len()).sum::<usize>(),
worker_id=self.worker_id,
);
let _span_guard = span.enter();