fuel-core icon indicating copy to clipboard operation
fuel-core copied to clipboard

Help `fuel-indexer` fetch transactions efficiently

Open ra0x3 opened this issue 1 year ago • 2 comments

  • Currently on the fuel-indexer, when fetching transactions for a block, we're grabbing the transaction fragments, and then making requests to fuel-core via the GQL client, for each transaction fragment
    • Meaning, we're making a GraphQL request for each transaction (not very efficient)
  • It would be great if, for a given block, we could either fetch the transactions in bulk OR, if we could have the transactions included in the block itself
  • We tried some previous work with this in https://github.com/FuelLabs/fuel-core/issues/764
    • This issue also references the original issue in fuel-indexer
  • @xgreenx, @Voxelot mentions I should reach out to you personally about this :)
  • Happy to provide any other details

ra0x3 avatar May 04 '23 15:05 ra0x3

You should already be able to fetch blocks with all transactions and any additional data via GraphQL. image

On the rust side, you can reuse types from fuel-core-client and compose them into the type that should fetch all data in one run. For example, you can define FullBlock type that fetches Transaction instead of TransactionIdFragment, which should return the full block for you. if you need some additional data from transactions, you can define your own Mytransaction that returns limited/extended fields.

image

xgreenx avatar May 04 '23 17:05 xgreenx

Hmm, the FuelClient::query function is private but with https://github.com/FuelLabs/fuel-core/pull/1175 you can write your own queries=)

xgreenx avatar May 04 '23 17:05 xgreenx

Solved on the indexer side https://github.com/FuelLabs/fuel-indexer/issues/288

xgreenx avatar Jul 12 '23 23:07 xgreenx