Skip to content

execmodule: send notifications before DB commit #19957

Description

@mh0lt

Summary

Move Hook.AfterRun calls to fire before flush+commit in the FCU and ProcessFrozenBlocks paths. Currently notifications are sent after tx.Commit() via a fresh db.View(), adding unnecessary latency and coupling to committed DB state.

Background

The original reason for post-commit notifications (comment in events.go:276): "need send notification after rwtx.Commit (or user will recv notification, but can't request new data by RPC)".

Investigation confirms this concern is no longer valid:

Consumer Reads DB after notification?
Filters.onNewHeader No — decodes from RLP payload
RecentReceipts subscribers No — uses payload proto
Coherent.OnNewBlock No — updates in-memory btree from payload
EthBackendServer.Subscribe No — forwards to gRPC stream

All notification consumers use the payload data directly and never read back from the DB.

Change

The pipeline's RwTx/overlay already contains all data that notifications read (headers, stage progress, forkchoice hashes, state version). Pass it directly to AfterRun before flush+commit.

Two sites changed:

  • runForkchoiceCommit (forkchoice.go) — AfterRun moved before sd.Flush + tx.Commit
  • ProcessFrozenBlocks (stageloop.go) — AfterRun moved before tx.Commit, db.View() removed

Two sites already pre-commit (unchanged):

  • stageLoopIteration — already uses the RwTx before commit
  • ProcessFrozenBlocks intermediate loop — already uses the RwTx

Relationship to other work

Also documents the execmodule.Cache shim's role and relationship to these issues.

Branch

feat/pre-commit-notifications — not ready to PR yet, waiting for dependent work.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions