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

store used gas as separate entry #3821

Open
hypnagonia opened this issue Jul 9, 2021 · 4 comments
Open

store used gas as separate entry #3821

hypnagonia opened this issue Jul 9, 2021 · 4 comments
Assignees
Labels
design Design and architectural plans/issues

Comments

@hypnagonia
Copy link

hypnagonia commented Jul 9, 2021

Summary

currently getting usedGas is only possible from tx receipt. which requires an extra query for each tx for explorer and increases load on rpc/slowing the syncing speed down

Current Design

tx receipt is only available only in tx receipt payload

Problems

requires an extra query for each tx for explorer and increases load on RPC

Proposal

modify the explorer node to save that data as a separate entry and serve usedGas in getBlockByNumber (with full tx info flag) response

@hypnagonia hypnagonia added the design Design and architectural plans/issues label Jul 9, 2021
@hypnagonia hypnagonia assigned hypnagonia and rlan35 and unassigned hypnagonia Jul 9, 2021
@rlan35 rlan35 assigned AlexiaChen and unassigned rlan35 Jul 9, 2021
@AlexiaChen
Copy link
Contributor

AlexiaChen commented Jul 13, 2021

I just look through your proposal, you just want to usedGas for each tx in RPC GetBlockByNumber repsonse to you ? or extra new RPC for query usedGas for each tx ? I want to confirm your requirement again. Thanks.

replied to me on discord: to GetBlockByNumber

@AlexiaChen
Copy link
Contributor

Hey .@hypnagonia, the RPC GetBlockByNumber reponse body has 3 version: v1, v2, eth. all three block versions need to support usedGas for each tx with FullTx flag ?

@AlexiaChen
Copy link
Contributor

@hypnagonia @gupadhyaya

Although the PR is almost complete, I have thought about the problems with the design here.

  • Storing a redundant usedGas field in this way will increase the storage pressure on levelDB, and the pressure on writing and reading explorer db will also increase
  • explorer db may be gradually deprecated

Is this design reasonable?

My Proposal

In fact there is no need to store usedGas for each Tx, because there is already an interface like GetReceiptsByHash in the blockchain, which reads all Receipts of the whole block in bulk, probably faster than <txhash, usedGas> which is a DB entries query. I can meet the requirements described by Jenya based on this interface

@gupadhyaya
Copy link
Contributor

agree with @AlexiaChen it is better to utilize GetReceiptsByHash which is just one additional rpc call per block. not a good idea to introduce additional read/write logic in the explorer db.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design and architectural plans/issues
Projects
None yet
Development

No branches or pull requests

4 participants