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.
Summary
Move
Hook.AfterRuncalls to fire before flush+commit in the FCU and ProcessFrozenBlocks paths. Currently notifications are sent aftertx.Commit()via a freshdb.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:
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
AfterRunbefore flush+commit.Two sites changed:
runForkchoiceCommit(forkchoice.go) — AfterRun moved beforesd.Flush+tx.CommitProcessFrozenBlocks(stageloop.go) — AfterRun moved beforetx.Commit,db.View()removedTwo sites already pre-commit (unchanged):
stageLoopIteration— already uses the RwTx before commitProcessFrozenBlocksintermediate loop — already uses the RwTxRelationship to other work
Accumulator.SendAndReset()call moved pre-commit will be restructured into a fan-outnotifyConsumer.Also documents the
execmodule.Cacheshim's role and relationship to these issues.Branch
feat/pre-commit-notifications— not ready to PR yet, waiting for dependent work.