Skip to content

Conversation

@niran
Copy link
Contributor

@niran niran commented Jan 11, 2026

Summary

Add timing measurement for state root calculation in bundle metering. This provides visibility into the I/O cost of computing state roots, which is critical for understanding the full execution costs of a given bundle.

Key changes:

  • Add MeterBundleOutput struct to replace tuple return type with named fields
  • Add state_root_time_us field to measure state root calculation time separately
  • Add total_time_us field for overall metering time (includes tx execution + state root)
  • Calculate state root after transaction execution using hashed_post_state and state_root_with_updates
  • Add meter_bundle_state_root_time_invariant test to verify timing consistency

Test plan

  • cargo test -p base-reth-metering - all 20 tests pass
  • cargo +nightly fmt --all -- --check - passes
  • cargo +nightly clippy --all-targets --all-features -- -D warnings - passes

@niran niran force-pushed the niran/meter-state-root-timing branch from fda8f6c to c53ce7c Compare January 11, 2026 07:30
@niran niran force-pushed the niran/metering-test-harness branch 2 times, most recently from fa14653 to 64ae567 Compare January 12, 2026 17:38
@danyalprout danyalprout added this to the v0.3.0 milestone Jan 12, 2026
@niran niran force-pushed the niran/meter-state-root-timing branch from c53ce7c to d59c560 Compare January 12, 2026 19:06
@niran niran force-pushed the niran/meter-state-root-timing branch from d59c560 to 51db7aa Compare January 12, 2026 19:28
refcell
refcell previously approved these changes Jan 12, 2026
Copy link
Contributor

@refcell refcell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM

danyalprout
danyalprout previously approved these changes Jan 12, 2026
Base automatically changed from niran/metering-test-harness to main January 12, 2026 19:35
@niran niran dismissed stale reviews from danyalprout and refcell January 12, 2026 19:35

The base branch was changed.

@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Jan 12, 2026

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/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

@cb-heimdall
Copy link
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

@niran niran force-pushed the niran/meter-state-root-timing branch from 51db7aa to c9302b7 Compare January 12, 2026 20:03
@niran
Copy link
Contributor Author

niran commented Jan 12, 2026

Updated the builder tests with the new state_root_time_ms field, without which the builder can't compile.

@niran niran requested review from danyalprout and refcell January 12, 2026 20:07
refcell
refcell previously approved these changes Jan 12, 2026
Copy link
Contributor

@refcell refcell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

Measure and report time spent calculating state root separately from
transaction execution, enabling better performance analysis:

- Add MeterBundleOutput struct with state_root_time_us field
- Calculate state root after transaction execution using merge_transitions
- Track state root calculation time separately from total execution time
- Update RPC to log state_root_time_us in metering response
- Add meter_bundle_state_root_time_invariant test

The state root is computed by calling hashed_post_state on the bundle
and then state_root_with_updates on the state provider.
@niran niran force-pushed the niran/meter-state-root-timing branch from c9302b7 to 8319f27 Compare January 13, 2026 01:22
@niran niran added this pull request to the merge queue Jan 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2026
@danyalprout danyalprout added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit a51b99e Jan 13, 2026
27 checks passed
@danyalprout danyalprout deleted the niran/meter-state-root-timing branch January 13, 2026 02:13
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.

5 participants