Skip to content

Add flashblocks support for gas estimation#2

Open
kbak wants to merge 2 commits intoinfra402:mainfrom
kbak:feature/flashblocks-support
Open

Add flashblocks support for gas estimation#2
kbak wants to merge 2 commits intoinfra402:mainfrom
kbak:feature/flashblocks-support

Conversation

@kbak
Copy link

@kbak kbak commented Feb 11, 2026

Summary

  • Adds flashblocks: bool config flag to ChainConfig for chains with sub-200ms block production (e.g., Base Flashblocks)
  • When enabled, gas estimation uses BlockId::latest() instead of BlockId::pending(), which is unreliable on fast-block chains
  • Ports the behavior from the upstream x402-rs crate into infra402's TOML config + EvmProvider

Changes

  • src/config.rs: New flashblocks field on ChainConfig (defaults to false)
  • src/chain/evm.rs: Thread flashblocks through EvmProvider, use in send_transaction() gas estimation
  • config.toml: Enable flashblocks = true for Base chain

Test plan

  • cargo test --lib — 141 tests pass
  • cargo clippy — no new warnings
  • Deploy to staging and verify Base transactions use correct gas estimation

🤖 Generated with Claude Code

Chains with sub-200ms block production (e.g., Base Flashblocks) have
unreliable "pending" block state. When `flashblocks = true` is set in
a chain's config, gas estimation uses `BlockId::latest()` instead of
`BlockId::pending()`, matching the upstream x402-rs behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kbak added a commit to kbak/infra402-facilitator that referenced this pull request Feb 11, 2026
…as estimation

When flashblocks=true, the previous commit only changed gas estimation to
use BlockId::latest(). But verification simulation calls (via
call_with_fallback) still tried the default "pending" block tag first,
which is unreliable on chains with sub-200ms blocks (e.g., Base
Flashblocks). The "pending" state can return stale/inconsistent data
causing simulations to revert with generic "Contract call failed" errors
that don't match the "Unsupported pending" fallback check.

Now call_with_fallback accepts a flashblocks flag and skips the pending
attempt entirely when true, going straight to BlockId::latest(). This
aligns with upstream x402-rs which never forces "pending" on verification
calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant