Skip to content

feat(firehose): add a post-block hook for state changes outside the EVM - #108

Open
maoueh wants to merge 3 commits into
release/reth-2.xfrom
feature/post-block-hook
Open

maoueh wants to merge 3 commits into
release/reth-2.xfrom
feature/post-block-hook

Conversation

@maoueh

@maoueh maoueh commented Nov 20, 2026

Copy link
Copy Markdown

Replaces #98 (same commit by @valvecitydev, plus a follow-up), since the fork branch did not accept maintainer pushes.

Some chains change state in the block executor's finish, outside the EVM, where the Firehose inspector cannot see it.

  • PostTxExtras::capture_post_block runs before the inner finish and returns a PostBlockChanges, emitted as the block's last changes, after the withdrawal balance changes. The default captures nothing, so Ethereum output does not change. Those changes must not touch a withdrawal recipient, since withdrawals are rebuilt backwards from final balances.
  • The hook receives the block's BlockFees, which now exposes the block number, coinbase, chain id and spec, so a hook can decide from the block alone (for example pre-Merge block rewards, see feat(firehose): emit pre-Merge block and uncle reward balance changes #97).
  • FirehoseEvmConfig<F> now installs F's hooks on the engine path (FirehoseLiveHooks) and the pipeline path (new LiveChainHooks), instead of the no-op ones. ConfigureEvm for FirehoseEvmConfig<F> now requires F: FirehoseLiveHooks.

valvecitydev and others added 3 commits November 11, 2026 18:49
Some chains change state in the block executor's finish, outside the
EVM, where the Firehose inspector cannot see it. PostTxExtras gains
capture_post_block, which runs before the inner finish and returns a
PostBlockChanges. The wrapper emits it after the inner finish, after
the withdrawal balance changes. The default captures nothing, so
Ethereum output does not change.

FirehoseEvmConfig<F> now uses F's hooks instead of the no-op ones: on
the engine path through FirehoseLiveHooks, and on the pipeline path
through a new LiveChainHooks for its batch executor. Before, a chain
that wrapped its EVM configuration in FirehoseEvmConfig lost its hooks.
capture_post_block now receives the block's BlockFees, which exposes
the block number, coinbase, chain id and spec, so a hook can decide
from the block alone, as the pre-Merge rewards of #97 need. Both
finish variants share one emission helper, and the docs state that
post-block changes come last and must not touch withdrawal recipients,
whose changes are rebuilt backwards from the final balances. A new
test covers the live path's finish variant and both tests check the
block invariants.
# Conflicts:
#	crates/firehose-tests/Cargo.toml
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