Skip to content

feat(evm): standardize slow block JSON output for cross-client metrics#21237

Closed
CPerezz wants to merge 13 commits intoparadigmxyz:mainfrom
CPerezz:feature/execution-metrics-standardization
Closed

feat(evm): standardize slow block JSON output for cross-client metrics#21237
CPerezz wants to merge 13 commits intoparadigmxyz:mainfrom
CPerezz:feature/execution-metrics-standardization

Conversation

@CPerezz
Copy link
Copy Markdown
Contributor

@CPerezz CPerezz commented Jan 21, 2026

Summary

Implement standardized JSON format for slow block logging to enable cross-client performance analysis and protocol research.

This change is part of the Cross-Client Execution Metrics initiative proposed by Gary Rong and CPerezz.

Motivation

Standardized execution metrics are critical for:

  • Cross-client performance comparison
  • Network health monitoring
  • Data-driven protocol research

Real-world example: The EIP-7907 analysis used execution metrics to measure code read latency, per-call overhead scaling, and block execution breakdown. Without standardized metrics across clients, such analysis cannot be validated cross-client.

References

JSON Format

{
  "level": "warn",
  "msg": "Slow block",
  "block": { "number": ..., "hash": ..., "gas_used": ..., "tx_count": ... },
  "timing": { "execution_ms": ..., "total_ms": ... },
  "throughput": { "mgas_per_sec": ... },
  "state_reads": { "accounts": ..., "storage_slots": ..., "code": ..., "code_bytes": ... },
  "state_writes": { "accounts": ..., "storage_slots": ... },
  "cache": {
    "account": { "hits": ..., "misses": ..., "hit_rate": ... },
    "storage": { ... },
    "code": { ... }
  }
}

Example trace:

{
    "timestamp": "2026-01-25T12:33:51.268394Z",
    "level": "WARN",
    "fields": {
        "message": "Slow block",
        "block.number": 9,
        "block.hash": "0x02e95075ddbb6866370968d92014b789f5917c05784e6091217a6a22e234be86",
        "block.gas_used": 105393,
        "block.tx_count": 1,
        "timing.execution_ms": "0.063",
        "timing.state_read_ms": "0.006",
        "timing.state_hash_ms": "0.465",
        "timing.commit_ms": "73.504",
        "timing.total_ms": "74.039",
        "throughput.mgas_per_sec": "1671.79",
        "state_reads.accounts": 7,
        "state_reads.storage_slots": 0,
        "state_reads.code": 0,
        "state_reads.code_bytes": 0,
        "state_writes.accounts": 3,
        "state_writes.accounts_deleted": 0,
        "state_writes.storage_slots": 0,
        "state_writes.storage_slots_deleted": 0,
        "state_writes.code": 1,
        "state_writes.code_bytes": 240,
        "state_writes.eip7702_delegations_set": 0,
        "state_writes.eip7702_delegations_cleared": 0,
        "cache.account.hits": 32,
        "cache.account.misses": 52,
        "cache.account.hit_rate": "38.10",
        "cache.storage.hits": 0,
        "cache.storage.misses": 0,
        "cache.storage.hit_rate": "0.00",
        "cache.code.hits": 0,
        "cache.code.misses": 0,
        "cache.code.hit_rate": "0.00"
    },
    "target": "reth::slow_block"
}

@github-project-automation github-project-automation Bot moved this to Backlog in Reth Tracker Jan 21, 2026
@CPerezz CPerezz force-pushed the feature/execution-metrics-standardization branch 2 times, most recently from 0c03b2d to 7754be2 Compare January 21, 2026 09:41
@CPerezz CPerezz changed the title evm: standardize slow block JSON output for cross-client metrics feat(evm): standardize slow block JSON output for cross-client metrics Jan 21, 2026
@CPerezz CPerezz force-pushed the feature/execution-metrics-standardization branch from 7754be2 to 64e1bfc Compare January 21, 2026 13:43
@CPerezz CPerezz requested a review from klkvr as a code owner January 21, 2026 22:37
@CPerezz CPerezz force-pushed the feature/execution-metrics-standardization branch 3 times, most recently from 310af2a to d37c498 Compare January 25, 2026 17:26
Implements execution metrics following the cross-client specification:
https://github.com/ethereum/execution-specs/blob/main/docs/execution-metrics-spec.md

- Add slow block logging method to ExecutorMetrics
- Output structured JSON log entries for cross-client analysis
- Include timing, throughput, and state access counts
- Threshold configurable via SLOW_BLOCK_THRESHOLD_MS constant
Implement standardized JSON format for slow block logging to enable
cross-client performance analysis and protocol research.

This change is part of the Cross-Client Execution Metrics initiative
proposed by Gary Rong: https://hackmd.io/dg7rizTyTXuCf2LSa2LsyQ

The standardized metrics enabled data-driven analysis like the EIP-7907
research: https://ethresear.ch/t/data-driven-analysis-on-eip-7907/23850

JSON format includes:
- block: number, hash, gas_used, tx_count
- timing: execution_ms, total_ms
- throughput: mgas_per_sec
- state_reads: accounts, storage_slots, code, code_bytes
- state_writes: accounts, storage_slots
- cache: account/storage/code hits, misses, hit_rate
Convert timing parameters from u64 to f64 to preserve sub-millisecond
precision in slow block JSON output.

Changes:
- log_slow_block() timing params: u64 -> f64
- is_slow_block(): u64 -> f64 with threshold cast
- Tracing format: add {:.3} for 3 decimal places
- Update tests for f64 values
Add tracking for EIP-7702 delegation set/cleared operations as part of
the cross-client execution metrics standardization effort.

New parameters in log_slow_block():
- eip7702_delegations_set: Number of EIP-7702 delegations set
- eip7702_delegations_cleared: Number of EIP-7702 delegations cleared

These fields will be 0 for pre-Pectra blocks per spec.
Add core infrastructure for tracking block execution metrics:
- ExecutionStats struct with state reads/writes/cache fields
- EIP-7702 delegation counters
- Timing breakdown (execution, state_read, state_hash, commit)
Wire ExecutionStats collection into the engine tree:
- Add instrumented state wrapper for metrics capture
- Integrate with payload validation pipeline
- Add slow block logging with JSON output
- Fix eip7702_delegations_cleared detection logic

The fix changes from checking was_destroyed() to detecting
bytecode transition from EIP-7702 format to empty.
Add CLI configuration for slow block metrics:
- --debug.slow-block-threshold <duration> to set logging threshold
- Default: disabled (no slow block logging)
- Set to 0 to log all blocks
Add comprehensive tests for slow block metrics:
- EIP-7702 delegation set/cleared scenarios
- Contract deployment metrics
- Storage operation metrics
- Edge cases (revert, OOG)
Fix compilation errors from rebase onto upstream/main:
- Remove orphaned SlotStatus/inc_* merge remnants in cached_state.rs
- Add missing executor.finish() and db.merge_transitions() in payload_validator.rs
- Add account_cache_size field and get_cache_stats() method to CachedStateMetrics
- Add missing closing brace in metrics.rs record_block_execution
- Enable slow block logging in threshold filtering test
- Update verification report with post-rebase test results
…on report

Add 5 new tests to execution_metrics_test.rs for complete coverage of
slow_block_test_vectors.json:

- test_transfer_to_new_account_creates_account (A2)
- test_factory_deploys_multiple_contracts (C2)
- test_empty_block_metrics (EDGE1)
- test_reverted_transaction_excludes_state_changes (EDGE2)
- test_out_of_gas_reverts_all_changes (EDGE3)
- Add `const` to `timing_stats` function in ExecutedBlock
- Fix tab-to-space indentation in crates/evm/evm/Cargo.toml std features
@CPerezz CPerezz force-pushed the feature/execution-metrics-standardization branch from ccc64e3 to 2e45bc7 Compare January 26, 2026 13:43
@shekhirin
Copy link
Copy Markdown
Member

Thank you for the initial implementation, taking this over here #21433

@shekhirin shekhirin closed this Jan 26, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Reth Tracker Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants