harmony icon indicating copy to clipboard operation
harmony copied to clipboard

[Feature] Need better api's for querying transactions, their receipts

Open SmartStake opened this issue 3 years ago • 1 comments

Problem/limitation At Hand

In order to obtain all transactions for a given block, I need to call hmyv2_getTransactionByBlockNumberAndIndex n number of times (e.g. 30 times if there are 30 txs in a block). Similarly, I need to call hmyv2_getStakingTransactionByBlockNumberAndIndex n times for getting staking txs in a block. To obtain transaction details, a subsequent call is needed for hmyv2_getTransactionReceipt.

This means that in order to process 30 txs per block, analytics tools need to make 60 rpc calls. The current pace at which these calls respond implies that only about 5-10 blocks can be processed by a reasonably powerful server. Having parallel jobs targeting different block ranges hasnt been very helpful either as increased parallelism slows down the APIs

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] With the current api's analytical tools cannot catch up with network and will always lag (by more and more time)

Which component?

  • [ ] consensus
  • [ ] deploy script
  • [ ] wallet
  • [ ] explorer
  • [ ] node script
  • [ ] test automation
  • [ ] demo app
  • [x] others ...

Proposed Solution

Provide a new API that allows querying all txs including their tx receipt using a range of blocks. e.g. hmyv2_getTransactionAndReceiptByBlockRange and hmyv2_getStakingTransactionAndReceiptByBlockRange. Allow 100 block range to be passed in the API.

A clear and concise description of what you want to happen. Have used this approach with other chains where this kind of one call can replace up to 6000 calls (with 30 tx per block) thereby eliminating the overheads associated with the cyclic calls. It will indirectly also help boost the health of public nodes.

Alternatives Considered

None available. Single process vs multiple process approaches have been tried but they are not good enough.

A clear and concise description of any alternative solutions or features you've considered.

Additional Context

Add any other context or screenshots about the feature request here.

SmartStake avatar Jul 10 '21 15:07 SmartStake

@rlan35 is is something that can be implemented in the future ?

sophoah avatar Jul 12 '21 03:07 sophoah