Skip to content

feat(builder): emit validity-predicate state-load metrics - #4611

Open
BrianBland wants to merge 1 commit into
mainfrom
brianbland/base-246-emit-block-builder-metrics-related-to-validity-criteria
Open

feat(builder): emit validity-predicate state-load metrics#4611
BrianBland wants to merge 1 commit into
mainfrom
brianbland/base-246-emit-block-builder-metrics-related-to-validity-criteria

Conversation

@BrianBland

Copy link
Copy Markdown
Contributor

Track the accounts and storage slots read while evaluating validity predicates during a block build, emitted once per block as histograms of total reads (every read, including re-reads across flashblocks and parked-transaction rescans) and distinct locations (the predicate state footprint).

A PredicateReadRecorder wraps the builder State for the duration of each predicate evaluation and records reads into a per-block PredicateLoadTracker carried on ExecutionInfo, respecting short-circuit evaluation. This is the footprint signal a predicate-state prewarmer must cover; disk-tier cost is covered separately by reth's sync.caching miss metrics and by predicate evaluation time.

@linear

linear Bot commented Aug 21, 2026

Copy link
Copy Markdown

BASE-246

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Comment thread crates/builder/core/src/flashblocks/predicate_loads.rs Outdated
@BrianBland
BrianBland force-pushed the brianbland/base-246-emit-block-builder-metrics-related-to-validity-criteria branch from 2bab459 to 9a936d0 Compare August 21, 2026 20:41
Track the accounts and storage slots read while evaluating validity
predicates during a block build, emitted once per block as histograms of
total reads (every read, including re-reads across flashblocks and
parked-transaction rescans) and distinct locations (the predicate state
footprint).

A PredicateReadRecorder wraps the builder State for the duration of each
predicate evaluation and records reads into a per-block
PredicateLoadTracker carried on ExecutionInfo, respecting short-circuit
evaluation. This is the footprint signal a predicate-state prewarmer must
cover; disk-tier cost is covered separately by reth's sync.caching miss
metrics and by predicate evaluation time.

Co-Authored-By: Claude <noreply@anthropic.com>
@BrianBland
BrianBland force-pushed the brianbland/base-246-emit-block-builder-metrics-related-to-validity-criteria branch from 9a936d0 to 0618373 Compare August 21, 2026 21:42
@BrianBland
BrianBland requested a review from refcell August 21, 2026 21:44
@github-actions

Copy link
Copy Markdown
Contributor

Review Summary

PR: feat(builder): emit validity-predicate state-load metrics

This PR adds per-block observability for validity-predicate state reads by introducing a PredicateReadRecorder (a Database wrapper) and a PredicateLoadTracker accumulator. The recorder wraps the builder's State during predicate evaluation, counts account and storage-slot reads (total and distinct), and emits four histogram metrics at block finalization.

Block Production Safety

This PR touches the flashblock build loop (context.rs) — a block-production-sensitive path. I reviewed it against the block production review guide and found no critical issues:

  • No new error paths: PredicateReadRecorder delegates all Database methods transparently with the same error type (<State<DB> as Database>::Error). Errors propagate identically to the current code.
  • No panics: Counter increments use += 1 on u64 (unreachable overflow), HashSet::len() as u64 is safe on 64-bit.
  • No I/O boundary changes: Metrics are recorded in-process via the metrics crate — no new data transport.
  • No concurrency issues: The recorder is created and consumed synchronously within accumulate_elapsed.
  • Bounded collections: unique_accounts and unique_slots HashSet growth is bounded by gas limits and per-tx predicate cap (default 64).

Findings

No issues found. The implementation is clean:

  • The Database wrapper pattern correctly delegates all four trait methods, recording only the two relevant to predicates (basic, storage).
  • Short-circuit semantics are naturally preserved since reads flow through the wrapper as issued.
  • The has_activity() gate prevents zero-observation dilution on ordinary blocks.
  • Tests cover counting, short-circuit behavior, and the no-activity case for both the tracker and the metrics emission.

@github-actions

Copy link
Copy Markdown
Contributor

Base Std historical fork tests

Fork Result Passed Failed Skipped base/base base-anvil base-std
Beryl pass 616 0 13 21b8baa1 8d0f5b8a 4658f1b7
Cobalt pass 721 0 14 21b8baa1 9df661bc e30b3421

View run

@github-actions

Copy link
Copy Markdown
Contributor

Tip

Nice, this PR improves performance. 1 benchmark(s) faster by more than 10% beyond the noise band: frame_parse/parse_frames_8x128KiB (-30.0%).

Benchmark results (advisory)

Median time on the PR head versus the base branch, measured on the same host. Wall-clock, so a change is only flagged when it clears ±10% and the confidence intervals do not overlap. Only benchmarks past the ±10% threshold (plus new or dropped ones) are listed. This check never blocks a merge.

Benchmark Base Head Δ median
frame_parse/parse_frames_8x128KiB 34.31 µs 24.03 µs -30.0% ✅ faster

48 benchmark(s) within ±10% omitted.

View run · Re-run benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants