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

gasUsed incorrect when using debug_traceBlockByHash #26018

Closed
imnotanoob opened this issue Oct 20, 2022 · 2 comments · Fixed by #26048
Closed

gasUsed incorrect when using debug_traceBlockByHash #26018

imnotanoob opened this issue Oct 20, 2022 · 2 comments · Fixed by #26048
Assignees
Labels

Comments

@imnotanoob
Copy link

System information

Geth version: Geth 1.10.24
CL client & version: prysm:3.1.1
OS & Version: Linux
Commit hash : 1.10.24 release branch

Expected behaviour

When using debug_traceBlockByHash with callTracer I expect the gasUsed to be the gasUsed by the transaction. (https://geth.ethereum.org/docs/dapp/builtin-tracers#calltracer) documentation

i.e. on Goerli Testnet

curl --request POST \
  --url http://127.0.0.1:8546/ \
  --header 'content-type: application/json' \
  --data '{"method":"debug_traceBlockByHash","params":["0x436ec05f6768296d48150241a1217000f2d7a4cfd8e36803150f2d5219ebab7b", {
	"tracer": "callTracer"
}], "jsonrpc":"2.0", "id": 0}'

(https://goerli.etherscan.io/tx/0x5bd8217569235b62252bc5c5063d1e6e9ee9e450ae7370c2d9c349ca1692ef8a) is an example

Actual behaviour

It outputs the wrong gasUsed. For that specific txn: gas used is: 0x24ca6
Out put is:

		{
			"result": {
				"type": "CALL",
				"from": "0x7afe817effeaffd965f6336137c027a15dbde4c7",
				"to": "0x120b1b0a44d680524419f76e1a41976b6ea0add5",
				"value": "0x11c37937e080000",
				"gas": "0x46790",
				"gasUsed": "0x24ca6",
				"input": "0xcf11d58d00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
				"output": "0x",
				"calls": [
					{
						"type": "CALL",
						"from": "0x120b1b0a44d680524419f76e1a41976b6ea0add5",
						"to": "0x727b51b3cebe69eaabdcfd5a2db0c521ba308112",
						"value": "0x11c37937e080000",
						"gas": "0x8fc",
						"gasUsed": "0x0",
						"input": "0x",
						"output": "0x"
					}
				]
			}
		}

if you run eth_getTransactionReceipt on the same tx hash: 0x5bd8217569235b62252bc5c5063d1e6e9ee9e450ae7370c2d9c349ca1692ef8a
gas used is: 0x2a006


{
	"jsonrpc": "2.0",
	"id": 0,
	"result": {
		"blockHash": "0x8b973f65653ba08a81fe728ede379cc748ae5ee959b8925ef637a35162bdb0ca",
		"blockNumber": "0x764710",
		"contractAddress": null,
		"cumulativeGasUsed": "0x2f20e",
		"effectiveGasPrice": "0x113abe6400",
		"from": "0x7afe817effeaffd965f6336137c027a15dbde4c7",
		"gasUsed": "0x2a006",
		"logs": [
			{
				"address": "0x120b1b0a44d680524419f76e1a41976b6ea0add5",
				"topics": [
					"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
					"0x0000000000000000000000000000000000000000000000000000000000000000",
					"0x0000000000000000000000007afe817effeaffd965f6336137c027a15dbde4c7",
					"0x000000000000000000000000000000000000000000000000000000000000002b"
				],
				"data": "0x",
				"blockNumber": "0x764710",
				"transactionHash": "0x5bd8217569235b62252bc5c5063d1e6e9ee9e450ae7370c2d9c349ca1692ef8a",
				"transactionIndex": "0x1",
				"blockHash": "0x8b973f65653ba08a81fe728ede379cc748ae5ee959b8925ef637a35162bdb0ca",
				"logIndex": "0x0",
				"removed": false
			}
		],
		"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000800008000000000000000000000000000000000000000000000000020000000000000000000800000000000000080000000010002000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000200000000000000000000000000000000002000000100000000000000000000000000000000000000000000020000000000000000000000008000000000000000000000000000000000000000002",
		"status": "0x1",
		"to": "0x120b1b0a44d680524419f76e1a41976b6ea0add5",
		"transactionHash": "0x5bd8217569235b62252bc5c5063d1e6e9ee9e450ae7370c2d9c349ca1692ef8a",
		"transactionIndex": "0x1",
		"type": "0x2"
	}
}

Steps to reproduce the behaviour

  1. Pick any block hash you want on the network. In this example I'm using goerli with: 0x436ec05f6768296d48150241a1217000f2d7a4cfd8e36803150f2d5219ebab7b
  2. Run debug command:
{"method":"debug_traceBlockByHash","params":["0x436ec05f6768296d48150241a1217000f2d7a4cfd8e36803150f2d5219ebab7b", {
	"tracer": "callTracer"
}], "jsonrpc":"2.0", "id": 0}
  1. The gasUsed is incorrect for every transaction. If you look at the second one, you will see.
				"gasUsed": "0x24ca6",

  1. Now if you run
curl --request POST \
  --url http://0.0.0.0:8546/ \
  --header 'Authorization: Bearer 0xc9cdf7d459216ebd1218521b7df4946f28bf547d6d97effb6e79ab1550ca2dd3' \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc" : "2.0",
  "method" : "eth_getTransactionReceipt",
  "params" : ["0x5bd8217569235b62252bc5c5063d1e6e9ee9e450ae7370c2d9c349ca1692ef8a"],
  "id" : 0
}
'

the gas used is different.

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

@imnotanoob
Copy link
Author

I also verified this on mainnet. Same issue.

@s1na
Copy link
Contributor

s1na commented Oct 24, 2022

I can reproduce the issue, thanks for reporting. Will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants