eth/tracers/native: add log index field to callTracer output
- [x] Analyze the issue and understand the expected behavior
- [x] Identify the relevant code in
eth/tracers/native/call.go - [x] Add
Indexfield tocallLogstruct incall.go - [x] Update
OnLogfunction to populate theIndexfield fromlog.Index - [x] Update
erc7562.goto also include Index in log output - [x] Update test struct in
calltrace_test.goto includeIndexfield - [x] Update test data files to include
indexfield in expected output - [x] Run existing tests to verify the changes work correctly
- [x] Run code review and address any feedback
- [x] Run CodeQL security checks
- [x] Fix commit message format to follow BSC conventions
Summary
This PR adds the missing index field to the log entries returned by debug_traceTransaction when using the callTracer with withLog: true.
Problem
When calling debug_traceTransaction with the callTracer and withLog: true config, the returned logs were missing the index field which indicates the position of each log in the block/transaction. This made it inconsistent with other implementations like Erigon that include this field.
Solution
- Added
Indexfield of typehexutil.Uintto thecallLogstruct ineth/tracers/native/call.go - Updated the
OnLogfunction to populate theIndexfield fromlog.Index(which is set by the EVM state during log emission) - Applied the same fix to
erc7562.gotracer for consistency - Updated all test files to expect the new
indexfield in log output
Example Output
{
"logs": [
{
"address": "0xf4eced2f682ce333f96f2d8966c613ded8fc95dd",
"topics": ["0xddf252ad..."],
"data": "0x...",
"position": "0x0",
"index": "0x0"
}
]
}
Original prompt
This section details on the original issue you should resolve
<issue_title>debug_traceTransaction missing log index</issue_title> <issue_description>#### System information Geth version:
v1.6.3OS & Version: Linux Arguments:ExecStart=/usr/local/bin/geth \ --datadir=/data/geth/ \ --http \ --http.port=8545 \ --http.addr=0.0.0.0 \ --http.api=eth,txpool,net,web3,debug \ --http.vhosts="*" \ --http.corsdomain="*" \ --ws \ --ws.port=8546 \ --ws.addr=0.0.0.0 \ --ws.origins="*" \ --ws.api=eth,txpool,net,web3,debug \ --networkid=56 \ --verbosity=3 \ --syncmode=full \ --gcmode=archive \ --state.scheme=path \ --history.state=0 \ --history.transactions=0 \ --maxpeers=100 \ --metrics \ --metrics.addr=0.0.0.0 \ --metrics.port="6060" \ --cache=51200 \ --cache.database=50 \ --cache.trie=30 \ --cache.snapshot=15 \ --cache.gc=5 \ --cache.blocklogs=1024 \ --triesInMemory=256 \ --rpc.allow-unprotected-txs=true \ --rpc.gascap=0 \ --miner.gasprice=50000000 \ --txpool.pricelimit=50000000 \ --rpc.batch-response-max-size=250000000Description
- Steps to reproduce the behaviour call:
{ "jsonrpc": "2.0", "id": 12120, "method": "debug_traceTransaction", "params": [ "0xec1081486c18067d6fa39aa5eae131955da91d6194fd1cbdb541330328ce5c1a", { "tracer": "callTracer", "tracerConfig": { "onlyTopCall": false, "withLog": true } } ] }
Expected behaviour Logs have indexes.
Actual behaviour Indexes are missing for logs.
left: geth, right: erigon
![]()
Comments on the Issue (you are @copilot in this section)
- Fixes bnb-chain/bsc#3474
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
@copilot go-ethereum has the same issue?
@copilot go-ethereum has the same issue?
Yes, go-ethereum has the same issue. Their callLog struct in eth/tracers/native/call.go also lacks the index field - it only has Address, Topics, Data, and Position. This fix could be upstreamed to go-ethereum as well.
@copilot go-ethereum has the same issue?
Yes, go-ethereum has the same issue. Their
callLogstruct ineth/tracers/native/call.goalso lacks theindexfield - it only hasAddress,Topics,Data, andPosition. This fix could be upstreamed to go-ethereum as well.
@copilot so I think, bsc aligning the beheaviour with go-thereum is better, what's your opion?
@copilot go-ethereum has the same issue?
Yes, go-ethereum has the same issue. Their
callLogstruct ineth/tracers/native/call.goalso lacks theindexfield - it only hasAddress, `T...
That's a fair point. The tradeoff is:
Align with go-ethereum (revert this PR): Maintains consistency with upstream, but leaves users without the index field that Erigon provides.
Keep this fix: Provides better compatibility with tools expecting Erigon-style output, but diverges from go-ethereum.
If you prefer aligning with go-ethereum, I can revert these changes. Let me know your decision.
the Lint CI fails:
in bsc, the commit msg begins with the path of mainly changed files, so the commit msg begin with "eth/tracers/native:" is better, also watch the total length of msg @copilot
the Lint CI fails:
in bsc, the commit msg begins with the path of mainly changed files, so the commit msg begin with "eth/tracers/native:" is better, also watch the total length of msg ...
Fixed the commit message format in 1444613: eth/tracers/native: add log index field to callTracer output
@copilot please solve this issue base on latest develop branch, not master
@copilot please solve this issue base on latest develop branch, not master
I cannot rebase or change the branch base directly as I don't have access to force push. The current branch is based on master (v1.6.4), which is a merge commit from develop.
Options:
- You can rebase this branch onto develop manually
- I can create a new PR description noting it should target develop instead of master
- Close this PR and I can describe the changes needed for someone to apply on develop
Please let me know how you'd like to proceed.
based
ok, I have done it manually
شماهرراهی که دسترسی بدهدراانجام دهید،مجوز دارید
در تاریخ جمعه ۵ دسامبر ۲۰۲۵، ۰۹:۳۹ buddho @.***> نوشت:
buddh0 left a comment (bnb-chain/bsc#3476) https://github.com/bnb-chain/bsc/pull/3476#issuecomment-3615451319
based
ok, I have done it manually
— Reply to this email directly, view it on GitHub https://github.com/bnb-chain/bsc/pull/3476#issuecomment-3615451319, or unsubscribe https://github.com/notifications/unsubscribe-auth/BELDIUQ3QTQZJMBOSWP3E4T4AEOTFAVCNFSM6AAAAACODKF5WWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMJVGQ2TCMZRHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
جناب کمک خلبان ازطرف من اجازه دارندکه هرراهی که به ختم هرچه سریعتراین قضیه میشود راانجام دهید
در تاریخ جمعه ۵ دسامبر ۲۰۲۵، ۰۶:۱۵ Copilot @.***> نوشت:
Copilot left a comment (bnb-chain/bsc#3476) https://github.com/bnb-chain/bsc/pull/3476#issuecomment-3615086963
the Lint CI fails:
in bsc, the commit msg begins with the path of mainly changed files, so the commit msg begin with "eth/tracers/native:" is better, also watch the total length of msg ...
Fixed the commit message format in 1444613 https://github.com/bnb-chain/bsc/commit/1444613c9ae42f55fecef65b41e4c84e46126fe6: eth/tracers/native: add log index field to callTracer output
— Reply to this email directly, view it on GitHub https://github.com/bnb-chain/bsc/pull/3476#issuecomment-3615086963, or unsubscribe https://github.com/notifications/unsubscribe-auth/BELDIUR6WMLILUAV4O5XYKL4ADWUBAVCNFSM6AAAAACODKF5WWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMJVGA4DMOJWGM . You are receiving this because you are subscribed to this thread.Message ID: @.***>