Skip to content

Add BlockHandler hooks to the sync engine - #54

Merged
ryansmith3136 merged 1 commit into
indexsupply:masterfrom
frolic:block-handler-hooks
Jul 4, 2026
Merged

ryansmith3136 merged 1 commit into
indexsupply:masterfrom
frolic:block-handler-hooks

Conversation

@frolic

@frolic frolic commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

An optional, chain-data-agnostic hook for deriving additional state from synced data, in lockstep with the canonical tables — for embedders using golden-axe as a library who want derived state (app-specific projections, decoded views, aggregates) without forking the sync loop.

  • on_block runs inside the same transaction that writes blocks/txs/logs (invoked before copy_logs consumes the batch), so whatever a handler derives commits atomically with the canonical data.
  • on_rollback mirrors a reorg delete: called with the first removed block number inside the same transaction as delete_after's deletes, so derived state reverts in lockstep with the canonical tables.

Attach via Downloader::with_handler(...); with no handler attached (the default), behavior is unchanged. Adds an async-trait dependency to be.

We've been running this in production against Base Sepolia (a downstream consumer deriving reduced state from logs) — the transactional coupling has held up through backfill, live tailing, and reorg paths.

🤖 Generated with Claude Code

An optional, chain-data-agnostic hook for deriving additional state from
synced data, in lockstep with the canonical tables:

- on_block runs inside the same transaction that writes blocks/txs/logs
  (before copy_logs consumes them), so derived state commits atomically
  with the batch.
- on_rollback mirrors a reorg delete with the first removed block number,
  so derived state reverts in the same transaction as the canonical
  delete.

Attach via Downloader::with_handler. No behavior change when unused;
golden-axe knows nothing about what a handler derives (app-specific
projections, aggregates, etc.).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ryansmith3136
ryansmith3136 merged commit ca1c764 into indexsupply:master Jul 4, 2026
1 check failed
@frolic
frolic deleted the block-handler-hooks branch July 4, 2026 18:23
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