Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions eth/tracers/native/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type callLog struct {
// Position of the log relative to subcalls within the same trace
// See https://github.com/ethereum/go-ethereum/pull/28389 for details
Position hexutil.Uint `json:"position"`
Removed bool `json:"removed,omitempty"`
}

type callFrame struct {
Expand Down Expand Up @@ -120,8 +121,9 @@ type callTracer struct {
}

type callTracerConfig struct {
OnlyTopCall bool `json:"onlyTopCall"` // If true, call tracer won't collect any subcalls
WithLog bool `json:"withLog"` // If true, call tracer will collect event logs
OnlyTopCall bool `json:"onlyTopCall"` // If true, call tracer won't collect any subcalls
WithLog bool `json:"withLog"` // If true, call tracer will collect event logs
WithRemovedLog bool `json:"withRemovedLog"` // If true, mark failed logs as removed instead of deleting them
}

// newCallTracer returns a native go tracer which tracks
Expand Down Expand Up @@ -229,7 +231,7 @@ func (t *callTracer) OnTxEnd(receipt *types.Receipt, err error) {
}
if t.config.WithLog {
// Logs are not emitted when the call fails
clearFailedLogs(&t.callstack[0], false)
clearFailedLogs(&t.callstack[0], false, t.config.WithRemovedLog)
}
}

Expand Down Expand Up @@ -277,13 +279,19 @@ func (t *callTracer) Stop(err error) {

// clearFailedLogs clears the logs of a callframe and all its children
// in case of execution failure.
func clearFailedLogs(cf *callFrame, parentFailed bool) {
func clearFailedLogs(cf *callFrame, parentFailed bool, withRemovedLog bool) {
failed := cf.failed() || parentFailed
// Clear own logs
if failed {
cf.Logs = nil
if withRemovedLog {
for i := range cf.Logs {
cf.Logs[i].Removed = true
}
} else {
cf.Logs = nil
}
}
for i := range cf.Calls {
clearFailedLogs(&cf.Calls[i], failed)
clearFailedLogs(&cf.Calls[i], failed, withRemovedLog)
}
}