Skip to content

Enhance query capability for Block and Transaction endpoints #1890

Open
@jack-linden

Description

@jack-linden

With the Nakamoto release effectively increasing the number of blocks by 100x, we need more query capabilities for fetching transaction details from block ranges.

Scenario: I need to fetch all transactions (and their events) from blocks 1000-2000.

Currently, in order to achieve this there is an inefficient waterfall of steps that must be taken.

  1. Fetch all transactions for each block within the range. Requires 1000 calls to /extended/v2/blocks/:height_or_hash/transactions in order to aggregate all transactions in that range.
  2. Now we have all the transactions but we encounter a new issue - the above endpoint does not return any transaction events as part of the transaction resource - this ultimately leads to step 3
  3. Paginate through /extended/v1/tx/multiple with batches of 100 transaction ids at a time (100-110 is the magic number of how many TX ids you can fit in the URL before getting a 400 response).
  4. Additional pagination is needed on /extended/v1/tx/multiple for any transactions that have > 50 events.

The inefficiencies with this approach will be greatly compounded with Nakamoto as the number of blocks increases drastically in which it will be the case that there are many more blocks likely containing fewer transactions.

Proposed enhancements to GET /extended/v1/tx

  1. Add query parameters from_block_height and to_block_height to allow filtering through block ranges
  2. Add query parameters event_limit and event_offset to allow for fetching events eagerly
  3. Add query parameters for ordering results set (e.g., by block_height)

Proposed enhancements to GET /extended/v2/blocks/:height_or_hash/transactions

  1. Add query parameters event_limit and event_offset to allow for fetching events eagerly. Default behavior can remain unchanged if event_limit defaults to 0 (i.e., return no events).

Proposed enhancements to GET /extended/v2/blocks

  1. Add query parameters from_block_height and to_block_height to allow filtering through block ranges
  2. Add query parameters for ordering results set (e.g., by block_height)
  3. Add query parameter canonical to allow filtering by canonical/not-canonical

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

📋 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions