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

transaction.gasUsed is not gasUsed. #2619

Closed
Amxx opened this issue Sep 30, 2019 · 15 comments
Closed

transaction.gasUsed is not gasUsed. #2619

Amxx opened this issue Sep 30, 2019 · 15 comments
Labels
bug Something isn't working chains/ethereum

Comments

@Amxx
Copy link
Contributor

Amxx commented Sep 30, 2019

When handling an event, I wanted to log gas-related information.
However, I noticed that event.trasaction.gasUsed does not contain the gas used but gas limit.

It would be nice to gas these 2 entries (gasUsed and gasLimit) in the transaction object

@smsunarto
Copy link

Happened to me too. I know this might be a niche use case but would really love to have a fix for this.

I'm desperate: https://twitter.com/smsunarto/status/1318195502127542273

@leoyvens
Copy link
Collaborator

@smsunarto Sorry that you lost time with this! First this needs to be renamed to gasLimit. Then we need to figure out the best way to expose gasUsed, which comes in the transaction receipt which is more expensive to fetch so we don't want to fetch it by default.

@krishan711
Copy link

I'd be keen to help with this if I can but I don't know where to start. Any pointers would be greatly appreciated.

@sc0Vu
Copy link

sc0Vu commented Mar 8, 2021

It happened to me, I thought the gasUsed is the gas cost for transaction.

IMHO, before add transaction receipt's gasUsed, it would be better rename the gasUsed to gas?

@benesjan
Copy link

benesjan commented Jun 27, 2021

Hello, is there any plan to fix this? It is causing issues in Uniswap v3 subgraph. Thank you

@drortirosh
Copy link

any chance of adding real gasUsed ?
Probably has to be added as a method call - since indeed not all handlers need actual gas, and it takes an extra call to the node, much like view calls into the contracts.

@azf20
Copy link
Contributor

azf20 commented Jul 1, 2021

Thanks all - @leoyvens was looking into options here, as you say @drortirosh this requires an extra eth call to the node so there are performance considerations

@crazyrabbitLTC
Copy link

crazyrabbitLTC commented Jul 9, 2021

Hey folks, we've been tracking gasUsed in all our subgraphs, assuming it was a real number. We've only just now discovered that actually, it's not a real number now that we're in the middle of exposing to users the real costs of transactions, meaning we have to go back to the drawing board for both new product features and a research report.

I understand that maybe it's a performance consideration for not fetching the real gasUsed but was it ever considered to return null or 0 so that the developer knew this wasn't a real feature and so that we don't build our products on top of it thinking it's real? (since 2019?!)

Using TheGraph as a source of truth instead of the blockchain requires that we trust the data from TheGraph. Feels pretty important that if the data returned is known to not be correct, or be something different, that this gets flagged for the developer in the code.

@azf20 azf20 transferred this issue from graphprotocol/graph-ts Jul 9, 2021
@azf20
Copy link
Contributor

azf20 commented Jul 9, 2021

Hey @crazyrabbitLTC very sorry about that. In the immediate term @leoyvens has made a change to rename gasUsed to gasLimit graphprotocol/graph-ts#192 (will be in a new graph-ts version). We have also been making changes to fetch tx receipts, which could extend to surface the actual gasUsed, will keep this issue open to track.
Definitely heard on the developer communication point, and apologies for any time lost

@NelsonGaldeman
Copy link

Hi @leoyvens & @azf20 ! Is there any ETA for gasUsed support? We've been relying on gasUsed at SimpleFi. We started upgrading our subgraphs to 24.1 and found it's always been gasLimit. Thank you.

@twotimeseleven
Copy link

Bumping this issue. Would be fantastic to track gasUsed for transactions, even if the team could provide a workaround calculation method (though I am not aware of one).

@mariorz
Copy link

mariorz commented Mar 1, 2022

Bumped and agree with the sentiment here, gasUsed is confusingly named and getting actual gasSpent should be considered an absolute requirement. Thanks!

@leoyvens
Copy link
Collaborator

leoyvens commented Mar 1, 2022

Including the receipt is being worked on and tracked here #3218

@azf20
Copy link
Contributor

azf20 commented May 3, 2022

Hi this is available on the Hosted Service with the alpha versions of graph-ts and graph-cli, and will be in the next Graph Node release, documentation here graphprotocol/docs#102. Note that an eventHandler has to specifically require receipts. Kudos to @tilacog and @evaporei

@nhd98z
Copy link

nhd98z commented Dec 13, 2023

Can you also add the l1GasUsed, l1GasPrice, l1FeeScalar of to event.transaction? (For optimism transactions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chains/ethereum
Projects
None yet
Development

No branches or pull requests