forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add indexer service spec (cosmos#1264)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. --> ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [x] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [ ] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [ ] Linked issues closed with keywords --------- Co-authored-by: Matthew Sevey <[email protected]> Co-authored-by: Ganesha Upadhyaya <[email protected]>
- Loading branch information
1 parent
969bb6b
commit 517e6cb
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../state/indexer-service.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Indexer Service | ||
|
||
## Abstract | ||
|
||
The Indexer service indexes transactions and blocks using events emitted by the block executor that can later be used to build services like block explorers that ingest this data. | ||
|
||
## Protocol/Component Description | ||
|
||
The Indexer service consists of three main components: an event bus, a transaction indexer and a block indexer. | ||
|
||
### Event Bus | ||
|
||
The event bus is a messaging service between the full node and the indexer service. It serves events emitted by the block executor of the full node to the indexer service where events are routed to the relevant indexer component based on type. | ||
|
||
### Block Indexer | ||
|
||
The [Block Indexer][block_indexer] indexes BeginBlock and EndBlock events with an underlying KV store. Block events are indexed by their height, such that matching search criteria returns the respective block height(s). | ||
|
||
### Transaction Indexer | ||
|
||
The [Transaction Indexer][tx_indexer] is a key-value store-backed indexer that provides functionalities for indexing and searching transactions. It allows for the addition of a batch of transactions, indexing and storing a single transaction, retrieving a transaction specified by hash, and querying for transactions based on specific conditions. The indexer also supports range queries and can return results based on the intersection of multiple conditions. | ||
|
||
## Message Structure/Communication Format | ||
|
||
The [`publishEvents` method][publish_events_method] in the block executor is responsible for broadcasting several types of events through the event bus. These events include `EventNewBlock`, `EventNewBlockHeader`, `EventNewBlockEvents`, `EventNewEvidence`, and `EventTx`. Each of these events carries specific data related to the block or transaction they represent. | ||
|
||
1. `EventNewBlock`: Triggered when a new block is finalized. It carries the block data along with the results of the `FinalizeBlock` ABCI method. | ||
|
||
2. `EventNewBlockHeader`: Triggered alongside the `EventNewBlock` event. It carries the block header data. | ||
|
||
3. `EventNewBlockEvents`: Triggered when a new block is finalized. It carries the block height, the events associated with the block, and the number of transactions in the block. | ||
|
||
4. `EventNewEvidence`: Triggered for each piece of evidence in the block. It carries the evidence and the height of the block. | ||
|
||
5. `EventTx`: Triggered for each transaction in the block. It carries the result of the `DeliverTx` ABCI method for the transaction. | ||
|
||
The `OnStart` method in `indexer_service.go` subscribes to these events. It listens for new blocks and transactions, and upon receiving these events, it indexes the transactions and blocks accordingly. The block indexer indexes `EventNewBlockEvents`, while the transaction indexer indexes the events inside `EventTx`. The events, `EventNewBlock`, `EventNewBlockHeader`, and `EventNewEvidence` are not currently used by the indexer service. | ||
|
||
## Assumptions and Considerations | ||
|
||
The indexer service assumes that the messages passed by the block executor are valid block headers and valid transactions with the required fields such that they can be indexed by the respective block indexer and transaction indexer. | ||
|
||
## Implementation | ||
|
||
See [indexer service] | ||
|
||
## References | ||
|
||
[1] [Block Indexer][block_indexer] | ||
|
||
[2] [Transaction Indexer][tx_indexer] | ||
|
||
[3] [Publish Events][publish_events_method] | ||
|
||
[4] [Indexer Service][indexer service] | ||
|
||
[block_indexer]: https://github.com/rollkit/rollkit/blob/main/state/indexer/block.go#L11 | ||
[tx_indexer]: https://github.com/rollkit/rollkit/blob/main/state/txindex/indexer.go#L14 | ||
[publish_events_method]: https://github.com/rollkit/rollkit/blob/main/state/executor.go#L352 | ||
[indexer service]: https://github.com/rollkit/rollkit/blob/main/state/txindex/indexer_service.go#L20 |