Skip to content

Conversation

zsfelfoldi
Copy link
Contributor

@zsfelfoldi zsfelfoldi commented Jul 29, 2025

This PR implements the new indexer interface (core.Indexer) that greatly simplifies the implementation of chain indexers. The serving mechanism is integrated into core.BlockChain which makes it possible to guarantee that a chain index always stays in sync with the canonical chain. New heads are always delivered before chain events are sent, ensuring that any consumer of these events can also rely on the chain index being in sync. Required historic chain sections are delivered asynchronously on demand. It is always guaranteed that any delivered blocks(including historic ones) are part of the canonical chain ending with the latest delivered/reverted head.

Note that the interface currently only delivers headers and receipts which are required by the log indexer. If we want to make it more general purpose then we should somehow make it configurable (delivering full blocks and receipts could be optional).

Also note that the PR also adds two new features to core.BlockChain that I wanted to add for a very long time:

  • GetReceipts(hash common.Hash, number uint64) types.Receipts which saves an unnecessary hash -> number lookup (an expensive random db read).
  • GetCanonicalHashes(numbers []uint64) ([]common.Hash, error) which reads multiple canonical hashes under the chainMu mutex lock, guaranteeing that they are consistent with each other.

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