Skip to content

Commit 4abe982

Browse files
authored
fix(ui): handle missing block log metrics gracefully (#168)
## Summary - Make `timing`, `throughput`, `state_reads`, `state_writes`, and `cache` optional on `BlockLogEntry` type - **BlockLogDetails**: conditionally render timing breakdown, overhead pie, cache chart, and state ops sections only when their data exists. Metric cards show "N/A" instead of misleading zeros - **BlockLogsComparison / TestComparisonTable / useProcessedData**: use optional chaining (`?.`) with `?? 0` fallbacks for safe metric extraction ## Test plan - [x] View a run with complete block log data — all sections render as before - [x] View a run with partial block log data (e.g. missing `state_read_ms`) — missing metrics show "N/A", sections without data are hidden - [x] Compare page still works with partial block log data - [x] Block logs dashboard table/charts handle partial data without crashes
1 parent 8065a48 commit 4abe982

5 files changed

Lines changed: 256 additions & 208 deletions

File tree

ui/src/api/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ export interface BlockLogCache {
491491

492492
export interface BlockLogEntry {
493493
block: BlockLogBlock
494-
timing: BlockLogTiming
495-
throughput: BlockLogThroughput
496-
state_reads: BlockLogStateReads
497-
state_writes: BlockLogStateWrites
498-
cache: BlockLogCache
494+
timing?: BlockLogTiming
495+
throughput?: BlockLogThroughput
496+
state_reads?: BlockLogStateReads
497+
state_writes?: BlockLogStateWrites
498+
cache?: BlockLogCache
499499
}
500500

501501
export type BlockLogs = Record<string, BlockLogEntry>

ui/src/components/compare/BlockLogsComparison.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ function buildBlockLogDataPoints(
6969
points.push({
7070
testIndex: index + 1,
7171
testName,
72-
throughput: entry.throughput.mgas_per_sec,
73-
executionMs: entry.timing.execution_ms,
74-
overheadMs: entry.timing.state_read_ms + entry.timing.state_hash_ms + entry.timing.commit_ms,
75-
accountCacheHitRate: entry.cache.account.hit_rate,
76-
storageCacheHitRate: entry.cache.storage.hit_rate,
77-
codeCacheHitRate: entry.cache.code.hit_rate,
72+
throughput: entry.throughput?.mgas_per_sec ?? 0,
73+
executionMs: entry.timing?.execution_ms ?? 0,
74+
overheadMs: (entry.timing?.state_read_ms ?? 0) + (entry.timing?.state_hash_ms ?? 0) + (entry.timing?.commit_ms ?? 0),
75+
accountCacheHitRate: entry.cache?.account?.hit_rate ?? 0,
76+
storageCacheHitRate: entry.cache?.storage?.hit_rate ?? 0,
77+
codeCacheHitRate: entry.cache?.code?.hit_rate ?? 0,
7878
})
7979
})
8080
return points

ui/src/components/compare/TestComparisonTable.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ const BLOCK_LOG_METRICS: MetricTab[] = [
5050

5151
function extractBlockLogMetric(entry: BlockLogEntry, metricId: string): number {
5252
switch (metricId) {
53-
case 'bl-throughput': return entry.throughput.mgas_per_sec
54-
case 'bl-execution': return entry.timing.execution_ms
55-
case 'bl-overhead': return entry.timing.state_read_ms + entry.timing.state_hash_ms + entry.timing.commit_ms
56-
case 'bl-account-cache': return entry.cache.account.hit_rate
57-
case 'bl-storage-cache': return entry.cache.storage.hit_rate
58-
case 'bl-code-cache': return entry.cache.code.hit_rate
53+
case 'bl-throughput': return entry.throughput?.mgas_per_sec ?? 0
54+
case 'bl-execution': return entry.timing?.execution_ms ?? 0
55+
case 'bl-overhead': return (entry.timing?.state_read_ms ?? 0) + (entry.timing?.state_hash_ms ?? 0) + (entry.timing?.commit_ms ?? 0)
56+
case 'bl-account-cache': return entry.cache?.account?.hit_rate ?? 0
57+
case 'bl-storage-cache': return entry.cache?.storage?.hit_rate ?? 0
58+
case 'bl-code-cache': return entry.cache?.code?.hit_rate ?? 0
5959
default: return 0
6060
}
6161
}

0 commit comments

Comments
 (0)