Skip to content

Commit b1cec85

Browse files
eth/tracers: add position field for callTracer logs (#28389)
Currently, one can use the "withLogs" parameter to include logs in the callTracer results, which allows the user to see at which trace level was each log emitted. This commit adds a position field to the logs which determine the exact ordering of a call's logs and its subcalls. This would be useful e.g. for explorers wishing to display the flow of execution. Co-authored-by: jsvisa <[email protected]>
1 parent a3be381 commit b1cec85

File tree

9 files changed

+200
-98
lines changed

9 files changed

+200
-98
lines changed

eth/tracers/internal/tracetest/calltrace_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ type callContext struct {
4747

4848
// callLog is the result of LOG opCode
4949
type callLog struct {
50-
Address common.Address `json:"address"`
51-
Topics []common.Hash `json:"topics"`
52-
Data hexutil.Bytes `json:"data"`
50+
Address common.Address `json:"address"`
51+
Topics []common.Hash `json:"topics"`
52+
Data hexutil.Bytes `json:"data"`
53+
Position hexutil.Uint `json:"position"`
5354
}
5455

5556
// callTrace is the result of a callTracer run.
@@ -324,7 +325,7 @@ func TestInternals(t *testing.T) {
324325
byte(vm.LOG0),
325326
},
326327
tracer: mkTracer("callTracer", json.RawMessage(`{ "withLog": true }`)),
327-
want: `{"from":"0x000000000000000000000000000000000000feed","gas":"0x13880","gasUsed":"0x5b9e","to":"0x00000000000000000000000000000000deadbeef","input":"0x","logs":[{"address":"0x00000000000000000000000000000000deadbeef","topics":[],"data":"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}],"value":"0x0","type":"CALL"}`,
328+
want: `{"from":"0x000000000000000000000000000000000000feed","gas":"0x13880","gasUsed":"0x5b9e","to":"0x00000000000000000000000000000000deadbeef","input":"0x","logs":[{"address":"0x00000000000000000000000000000000deadbeef","topics":[],"data":"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","position":"0x0"}],"value":"0x0","type":"CALL"}`,
328329
},
329330
{
330331
// Leads to OOM on the prestate tracer

eth/tracers/internal/tracetest/testdata/call_tracer_withLog/calldata.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@
9595
"topics": [
9696
"0xe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda"
9797
],
98-
"data": "0x0000000000000000000000004f5777744b500616697cb655dcb02ee6cd51deb5be96016bb57376da7a6d296e0a405ee1501778227dfa604df0a81cb1ae018598"
98+
"data": "0x0000000000000000000000004f5777744b500616697cb655dcb02ee6cd51deb5be96016bb57376da7a6d296e0a405ee1501778227dfa604df0a81cb1ae018598",
99+
"position": "0x0"
99100
},
100101
{
101102
"address": "0x200edd17f30485a8735878661960cd7a9a95733f",
102103
"topics": [
103104
"0xacbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da"
104105
],
105-
"data": "0x0000000000000000000000000000000000000000000000000000000000000000"
106+
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
107+
"position": "0x0"
106108
}
107109
],
108110
"value": "0x8ac7230489e80000",

eth/tracers/internal/tracetest/testdata/call_tracer_withLog/delegatecall.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@
257257
"0x0000000000000000000000003de712784baf97260455ae25fb74f574ec9c1add",
258258
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5"
259259
],
260-
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
260+
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
261+
"position": "0x0"
261262
}
262263
],
263264
"value": "0x0",
@@ -278,7 +279,8 @@
278279
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
279280
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd"
280281
],
281-
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
282+
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
283+
"position": "0x0"
282284
}
283285
],
284286
"value": "0x0",
@@ -307,7 +309,8 @@
307309
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
308310
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd"
309311
],
310-
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
312+
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
313+
"position": "0x0"
311314
}
312315
],
313316
"value": "0x0",
@@ -328,7 +331,8 @@
328331
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd",
329332
"0x000000000000000000000000950ca4a06c78934a148b7a3ff3ea8fc366f77a06"
330333
],
331-
"data": "0x0000000000000000000000000000000000000000000000000041f50e27d56848"
334+
"data": "0x0000000000000000000000000000000000000000000000000041f50e27d56848",
335+
"position": "0x0"
332336
}
333337
],
334338
"value": "0x0",
@@ -391,7 +395,8 @@
391395
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
392396
"0x0000000000000000000000003de712784baf97260455ae25fb74f574ec9c1add"
393397
],
394-
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000"
398+
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000",
399+
"position": "0x0"
395400
}
396401
],
397402
"type": "DELEGATECALL",

0 commit comments

Comments
 (0)