Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit for indexer catchup #36

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ Any [filter](#extensive-subscription-filtering) you apply will be seamlessly tra

To see this in action, you can run the Data History Museum example in this repository against MainNet and see it sync millions of rounds in seconds.

The indexer catchup isn't magic - if the filter you are trying to catch up with generates an enormous number of transactions (e.g. hundreds of thousands or millions) then it will run very slowly and has the potential for running out of compute and memory time depending on what the constraints are in the deployment environment you are running in. To understand how the indexer behaviour works to know if you are likely to generate a lot of transactions it's worth understanding the architecture of the indexer catchup.
The indexer catchup isn't magic - if the filter you are trying to catch up with generates an enormous number of transactions (e.g. hundreds of thousands or millions) then it will run very slowly and has the potential for running out of compute and memory time depending on what the constraints are in the deployment environment you are running in. In that instance though, there is a config parameter you can use `maxIndexerRoundsToSync` so you can break the indexer catchup into multiple "polls" e.g. 100,000 rounds at a time. This allows a smaller batch of transactions to be retrieved and persisted in multiple batches.

Indexer catchup runs in two stages:
To understand how the indexer behaviour works to know if you are likely to generate a lot of transactions it's worth understanding the architecture of the indexer catchup; indexer catchup runs in two stages:

1. **Pre-filtering**: Any filters that can be translated to the [indexer search transactions endpoint](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions). This query is then run between the rounds that need to be synced and paginated in the max number of results (1000) at a time until all of the transactions are retrieved. This ensures we get round-based transactional consistency. This is the filter that can easily explode out though and take a long time when using indexer catchup. For avoidance of doubt, the following filters are the ones that are converted to a pre-filter:
- `sender`
Expand Down
2 changes: 2 additions & 0 deletions docs/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
### Modules

- [index](modules/index.md)
- [types](modules/types.md)
- [types/arc-28](modules/types_arc_28.md)
- [types/async-event-emitter](modules/types_async_event_emitter.md)
- [types/block](modules/types_block.md)
- [types/subscription](modules/types_subscription.md)
34 changes: 17 additions & 17 deletions docs/code/classes/index.AlgorandSubscriber.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Handles the logic for subscribing to the Algorand blockchain and emitting events

- [abortController](index.AlgorandSubscriber.md#abortcontroller)
- [algod](index.AlgorandSubscriber.md#algod)
- [config](index.AlgorandSubscriber.md#config)
- [eventEmitter](index.AlgorandSubscriber.md#eventemitter)
- [filterNames](index.AlgorandSubscriber.md#filternames)
- [indexer](index.AlgorandSubscriber.md#indexer)
- [startPromise](index.AlgorandSubscriber.md#startpromise)
- [started](index.AlgorandSubscriber.md#started)
- [subscription](index.AlgorandSubscriber.md#subscription)

### Methods

Expand All @@ -35,15 +35,15 @@ Handles the logic for subscribing to the Algorand blockchain and emitting events

### constructor

• **new AlgorandSubscriber**(`subscription`, `algod`, `indexer?`): [`AlgorandSubscriber`](index.AlgorandSubscriber.md)
• **new AlgorandSubscriber**(`config`, `algod`, `indexer?`): [`AlgorandSubscriber`](index.AlgorandSubscriber.md)

Create a new `AlgorandSubscriber`.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `subscription` | [`SubscriptionConfig`](../interfaces/types_subscription.SubscriptionConfig.md) | The subscription configuration |
| `config` | [`AlgorandSubscriberConfig`](../interfaces/types_subscription.AlgorandSubscriberConfig.md) | The subscriber configuration |
| `algod` | `default` | An algod client |
| `indexer?` | `default` | An (optional) indexer client; only needed if `subscription.syncBehaviour` is `catchup-with-indexer` |

Expand Down Expand Up @@ -77,6 +77,16 @@ ___

___

### config

• `Private` **config**: [`AlgorandSubscriberConfig`](../interfaces/types_subscription.AlgorandSubscriberConfig.md)

#### Defined in

[subscriber.ts:21](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L21)

___

### eventEmitter

• `Private` **eventEmitter**: [`AsyncEventEmitter`](types_async_event_emitter.AsyncEventEmitter.md)
Expand Down Expand Up @@ -125,16 +135,6 @@ ___

[subscriber.ts:24](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L24)

___

### subscription

• `Private` **subscription**: [`SubscriptionConfig`](../interfaces/types_subscription.SubscriptionConfig.md)

#### Defined in

[subscriber.ts:21](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L21)

## Methods

### on
Expand Down Expand Up @@ -166,7 +166,7 @@ The subscriber so `on`/`onBatch` calls can be chained

#### Defined in

[subscriber.ts:162](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L162)
[subscriber.ts:159](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L159)

___

Expand Down Expand Up @@ -203,7 +203,7 @@ The subscriber so `on`/`onBatch` calls can be chained

#### Defined in

[subscriber.ts:179](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L179)
[subscriber.ts:176](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L176)

___

Expand Down Expand Up @@ -251,7 +251,7 @@ An object that contains a promise you can wait for after calling stop

#### Defined in

[subscriber.ts:101](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L101)
[subscriber.ts:98](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L98)

___

Expand All @@ -275,4 +275,4 @@ A promise that can be awaited to ensure the subscriber has finished stopping

#### Defined in

[subscriber.ts:144](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L144)
[subscriber.ts:141](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/subscriber.ts#L141)
51 changes: 51 additions & 0 deletions docs/code/interfaces/types_arc_28.Arc28Event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[@algorandfoundation/algokit-subscriber](../README.md) / [types/arc-28](../modules/types_arc_28.md) / Arc28Event

# Interface: Arc28Event

[types/arc-28](../modules/types_arc_28.md).Arc28Event

The definition of metadata for an ARC-28 event per https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0028.md#event.

## Table of contents

### Properties

- [args](types_arc_28.Arc28Event.md#args)
- [desc](types_arc_28.Arc28Event.md#desc)
- [name](types_arc_28.Arc28Event.md#name)

## Properties

### args

• **args**: \{ `desc?`: `string` ; `name?`: `string` ; `type`: `string` }[]

The arguments of the event, in order

#### Defined in

[types/arc-28.ts:15](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L15)

___

### desc

• `Optional` **desc**: `string`

Optional, user-friendly description for the event

#### Defined in

[types/arc-28.ts:13](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L13)

___

### name

• **name**: `string`

The name of the event

#### Defined in

[types/arc-28.ts:11](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L11)
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[@algorandfoundation/algokit-subscriber](../README.md) / [types/subscription](../modules/types_subscription.md) / Arc28EventGroup
[@algorandfoundation/algokit-subscriber](../README.md) / [types/arc-28](../modules/types_arc_28.md) / Arc28EventGroup

# Interface: Arc28EventGroup

[types/subscription](../modules/types_subscription.md).Arc28EventGroup
[types/arc-28](../modules/types_arc_28.md).Arc28EventGroup

Specifies a group of ARC-28 event definitions along with instructions for when to attempt to process the events.

## Table of contents

### Properties

- [continueOnError](types_subscription.Arc28EventGroup.md#continueonerror)
- [events](types_subscription.Arc28EventGroup.md#events)
- [groupName](types_subscription.Arc28EventGroup.md#groupname)
- [processForAppIds](types_subscription.Arc28EventGroup.md#processforappids)
- [processTransaction](types_subscription.Arc28EventGroup.md#processtransaction)
- [continueOnError](types_arc_28.Arc28EventGroup.md#continueonerror)
- [events](types_arc_28.Arc28EventGroup.md#events)
- [groupName](types_arc_28.Arc28EventGroup.md#groupname)
- [processForAppIds](types_arc_28.Arc28EventGroup.md#processforappids)
- [processTransaction](types_arc_28.Arc28EventGroup.md#processtransaction)

## Properties

Expand All @@ -26,19 +26,19 @@ Whether or not to silently (with warning log) continue if an error is encountere

#### Defined in

[types/subscription.ts:56](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L56)
[types/arc-28.ts:56](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L56)

___

### events

• **events**: [`Arc28Event`](types_subscription.Arc28Event.md)[]
• **events**: [`Arc28Event`](types_arc_28.Arc28Event.md)[]

The list of ARC-28 event definitions

#### Defined in

[types/subscription.ts:58](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L58)
[types/arc-28.ts:58](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L58)

___

Expand All @@ -50,7 +50,7 @@ The name to designate for this group of events.

#### Defined in

[types/subscription.ts:50](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L50)
[types/arc-28.ts:50](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L50)

___

Expand All @@ -62,7 +62,7 @@ Optional list of app IDs that this event should apply to

#### Defined in

[types/subscription.ts:52](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L52)
[types/arc-28.ts:52](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L52)

___

Expand All @@ -88,4 +88,4 @@ Optional predicate to indicate if these ARC-28 events should be processed for th

#### Defined in

[types/subscription.ts:54](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/subscription.ts#L54)
[types/arc-28.ts:54](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L54)
83 changes: 83 additions & 0 deletions docs/code/interfaces/types_arc_28.Arc28EventToProcess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[@algorandfoundation/algokit-subscriber](../README.md) / [types/arc-28](../modules/types_arc_28.md) / Arc28EventToProcess

# Interface: Arc28EventToProcess

[types/arc-28](../modules/types_arc_28.md).Arc28EventToProcess

An ARC-28 event to be processed

## Hierarchy

- **`Arc28EventToProcess`**

↳ [`EmittedArc28Event`](types_arc_28.EmittedArc28Event.md)

## Table of contents

### Properties

- [eventDefinition](types_arc_28.Arc28EventToProcess.md#eventdefinition)
- [eventName](types_arc_28.Arc28EventToProcess.md#eventname)
- [eventPrefix](types_arc_28.Arc28EventToProcess.md#eventprefix)
- [eventSignature](types_arc_28.Arc28EventToProcess.md#eventsignature)
- [groupName](types_arc_28.Arc28EventToProcess.md#groupname)

## Properties

### eventDefinition

• **eventDefinition**: [`Arc28Event`](types_arc_28.Arc28Event.md)

The ARC-28 definition of the event

#### Defined in

[types/arc-28.ts:36](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L36)

___

### eventName

• **eventName**: `string`

The name of the ARC-28 event that was triggered

#### Defined in

[types/arc-28.ts:30](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L30)

___

### eventPrefix

• **eventPrefix**: `string`

The 4-byte hex prefix for the event

#### Defined in

[types/arc-28.ts:34](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L34)

___

### eventSignature

• **eventSignature**: `string`

The signature of the event e.g. `EventName(type1,type2)`

#### Defined in

[types/arc-28.ts:32](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L32)

___

### groupName

• **groupName**: `string`

The name of the ARC-28 event group the event belongs to

#### Defined in

[types/arc-28.ts:28](https://github.com/algorandfoundation/algokit-subscriber-ts/blob/main/src/types/arc-28.ts#L28)
Loading
Loading