Skip to content

Commit

Permalink
eth/tracers: add position field for callTracer logs (#28389)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alvarosevilla95 and jsvisa authored Nov 3, 2023
1 parent a3be381 commit b1cec85
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 98 deletions.
9 changes: 5 additions & 4 deletions eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ type callContext struct {

// callLog is the result of LOG opCode
type callLog struct {
Address common.Address `json:"address"`
Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"`
Address common.Address `json:"address"`
Topics []common.Hash `json:"topics"`
Data hexutil.Bytes `json:"data"`
Position hexutil.Uint `json:"position"`
}

// callTrace is the result of a callTracer run.
Expand Down Expand Up @@ -324,7 +325,7 @@ func TestInternals(t *testing.T) {
byte(vm.LOG0),
},
tracer: mkTracer("callTracer", json.RawMessage(`{ "withLog": true }`)),
want: `{"from":"0x000000000000000000000000000000000000feed","gas":"0x13880","gasUsed":"0x5b9e","to":"0x00000000000000000000000000000000deadbeef","input":"0x","logs":[{"address":"0x00000000000000000000000000000000deadbeef","topics":[],"data":"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}],"value":"0x0","type":"CALL"}`,
want: `{"from":"0x000000000000000000000000000000000000feed","gas":"0x13880","gasUsed":"0x5b9e","to":"0x00000000000000000000000000000000deadbeef","input":"0x","logs":[{"address":"0x00000000000000000000000000000000deadbeef","topics":[],"data":"0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","position":"0x0"}],"value":"0x0","type":"CALL"}`,
},
{
// Leads to OOM on the prestate tracer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@
"topics": [
"0xe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda"
],
"data": "0x0000000000000000000000004f5777744b500616697cb655dcb02ee6cd51deb5be96016bb57376da7a6d296e0a405ee1501778227dfa604df0a81cb1ae018598"
"data": "0x0000000000000000000000004f5777744b500616697cb655dcb02ee6cd51deb5be96016bb57376da7a6d296e0a405ee1501778227dfa604df0a81cb1ae018598",
"position": "0x0"
},
{
"address": "0x200edd17f30485a8735878661960cd7a9a95733f",
"topics": [
"0xacbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000000"
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"position": "0x0"
}
],
"value": "0x8ac7230489e80000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@
"0x0000000000000000000000003de712784baf97260455ae25fb74f574ec9c1add",
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5"
],
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
"position": "0x0"
}
],
"value": "0x0",
Expand All @@ -278,7 +279,8 @@
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd"
],
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
"position": "0x0"
}
],
"value": "0x0",
Expand Down Expand Up @@ -307,7 +309,8 @@
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd"
],
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac"
"data": "0x00000000000000000000000000000000000000000000000080d29fa5cccfadac",
"position": "0x0"
}
],
"value": "0x0",
Expand All @@ -328,7 +331,8 @@
"0x0000000000000000000000005aae5c59d642e5fd45b427df6ed478b49d55fefd",
"0x000000000000000000000000950ca4a06c78934a148b7a3ff3ea8fc366f77a06"
],
"data": "0x0000000000000000000000000000000000000000000000000041f50e27d56848"
"data": "0x0000000000000000000000000000000000000000000000000041f50e27d56848",
"position": "0x0"
}
],
"value": "0x0",
Expand Down Expand Up @@ -391,7 +395,8 @@
"0x0000000000000000000000006ca7f214ab2ddbb9a8e1a1e2c8550e3164e9dba5",
"0x0000000000000000000000003de712784baf97260455ae25fb74f574ec9c1add"
],
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000"
"data": "0x000000000000000000000000000000000000000000000000de0b6b3a76400000",
"position": "0x0"
}
],
"type": "DELEGATECALL",
Expand Down
Loading

0 comments on commit b1cec85

Please sign in to comment.