Skip to content

Conversation

@niran
Copy link
Contributor

@niran niran commented Jan 12, 2026

Summary

Enable bundle metering to use the current pending flashblocks state instead of just the canonical block state. This ensures that bundle simulations see the same state that will be used when the bundle is actually included in a flashblock.

Changes

Metering Crate

  • meter.rs: Add PendingState struct containing BundleState and optional PendingTrieInput. Update meter_bundle to accept an optional PendingState parameter. Use with_bundle_prestate() to layer pending flashblock state on top of canonical state.
  • rpc.rs: Update MeteringApiImpl to integrate with flashblocks API. Get pending blocks state and pass it to meter_bundle. Include state_flashblock_index in response.
  • extension.rs: Update MeteringExtension to accept FlashblocksConfig for state access.
  • lib.rs: Export PendingState and PendingTrieInput.

Flashblocks Crate

  • state.rs: Add Default impl for FlashblocksState.
  • extension.rs: Add Clone derive to FlashblocksConfig.
  • tests/state.rs: Add integration tests verifying that bundle metering correctly sees pending flashblock state changes.

Architecture

Bundle Metering with Pending State:

┌─────────────────────────────────┐
│  State (bundle tracking)        │  ← Tracks bundle writes
│  with_bundle_prestate()         │  ← Includes flashblock state as prestate
├─────────────────────────────────┤
│  StateProviderDatabase          │  ← Reads from canonical chain state
└─────────────────────────────────┘

Test Plan

  • Bundle metering correctly fails for nonce=1 tx without flashblock state (canonical nonce is 0)
  • Bundle metering succeeds for nonce=1 tx with flashblock state showing pending nonce=1
  • State visibility tests pass
  • cargo +nightly clippy passes
  • cargo +nightly fmt passes

@niran niran force-pushed the niran/flashblocks-layering-fix branch from da51cc3 to 75e8eaf Compare January 12, 2026 20:03
@niran niran force-pushed the niran/meter-flashblocks-state-v2 branch from 994978c to 13ef63c Compare January 12, 2026 20:03
@danyalprout danyalprout added this to the v0.3.0 milestone Jan 12, 2026
@niran niran force-pushed the niran/meter-flashblocks-state-v2 branch from 13ef63c to 6817f24 Compare January 12, 2026 22:06
@niran niran force-pushed the niran/flashblocks-layering-fix branch from 75e8eaf to 0cba54d Compare January 13, 2026 00:58
@niran niran force-pushed the niran/meter-flashblocks-state-v2 branch from 6817f24 to 8dadef0 Compare January 13, 2026 00:58
@niran niran force-pushed the niran/flashblocks-layering-fix branch from 0cba54d to 8bca81f Compare January 13, 2026 01:22
@niran niran force-pushed the niran/meter-flashblocks-state-v2 branch 2 times, most recently from 724a0c9 to be1c7a5 Compare January 13, 2026 01:55
@niran niran force-pushed the niran/flashblocks-layering-fix branch from 8bca81f to 25c0260 Compare January 13, 2026 01:55
Base automatically changed from niran/flashblocks-layering-fix to main January 13, 2026 02:30
@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Jan 13, 2026

✅ Heimdall Review Status

Requirement Status More Info
Reviews 2/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-flashblocks-state-v2 branch from be1c7a5 to f1a198a Compare January 13, 2026 17:43
Add support for metering bundles against the current flashblocks pending
state instead of just the canonical block state. This ensures that bundle
simulations see the same state that will be used when the bundle is
actually included.

Key changes:
- Add FlashblocksState struct containing Cache and BundleState
- Update meter_bundle to accept optional FlashblocksState parameter
- Implement three-layer database architecture in metering
- Add integration tests for flashblock state visibility
@niran niran force-pushed the niran/meter-flashblocks-state-v2 branch from f1a198a to 3e17305 Compare January 13, 2026 18:01
@niran niran requested a review from danyalprout January 13, 2026 18:03
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 looks good to me pending @danyalprout

Copy link
Collaborator

@danyalprout danyalprout left a comment

Choose a reason for hiding this comment

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

thank you! this looks great

@danyalprout danyalprout added this pull request to the merge queue Jan 13, 2026
Any commits made after this event will not be merged.
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