Skip to content

Commit 582e1ee

Browse files
s1nazzyalbert
authored andcommitted
eth/tracers: fix callTracer fault handling (ethereum#23667)
* eth/tracers: fix calltracer fault handling * eth/tracers: fix calltracer indentation
1 parent 042f9ae commit 582e1ee

File tree

3 files changed

+64
-76
lines changed

3 files changed

+64
-76
lines changed

eth/tracers/internal/tracers/assets.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eth/tracers/internal/tracers/call_tracer.js

Lines changed: 61 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,77 +18,68 @@
1818
// callFrameTracer uses the new call frame tracing methods to report useful information
1919
// about internal messages of a transaction.
2020
{
21-
callstack: [{}],
22-
fault: function(log, db) {
23-
var len = this.callstack.length
24-
if (len > 1) {
25-
var call = this.callstack.pop()
26-
if (this.callstack[len-1].calls === undefined) {
27-
this.callstack[len-1].calls = []
28-
}
29-
this.callstack[len-1].calls.push(call)
30-
}
31-
},
32-
result: function(ctx, db) {
33-
// Prepare outer message info
34-
var result = {
35-
type: ctx.type,
36-
from: toHex(ctx.from),
37-
to: toHex(ctx.to),
38-
value: '0x' + ctx.value.toString(16),
39-
gas: '0x' + bigInt(ctx.gas).toString(16),
40-
gasUsed: '0x' + bigInt(ctx.gasUsed).toString(16),
41-
input: toHex(ctx.input),
42-
output: toHex(ctx.output),
43-
}
44-
if (this.callstack[0].calls !== undefined) {
45-
result.calls = this.callstack[0].calls
46-
}
47-
if (this.callstack[0].error !== undefined) {
48-
result.error = this.callstack[0].error
49-
} else if (ctx.error !== undefined) {
50-
result.error = ctx.error
51-
}
52-
if (result.error !== undefined && (result.error !== "execution reverted" || result.output ==="0x")) {
53-
delete result.output
54-
}
21+
callstack: [{}],
22+
fault: function(log, db) {},
23+
result: function(ctx, db) {
24+
// Prepare outer message info
25+
var result = {
26+
type: ctx.type,
27+
from: toHex(ctx.from),
28+
to: toHex(ctx.to),
29+
value: '0x' + ctx.value.toString(16),
30+
gas: '0x' + bigInt(ctx.gas).toString(16),
31+
gasUsed: '0x' + bigInt(ctx.gasUsed).toString(16),
32+
input: toHex(ctx.input),
33+
output: toHex(ctx.output),
34+
}
35+
if (this.callstack[0].calls !== undefined) {
36+
result.calls = this.callstack[0].calls
37+
}
38+
if (this.callstack[0].error !== undefined) {
39+
result.error = this.callstack[0].error
40+
} else if (ctx.error !== undefined) {
41+
result.error = ctx.error
42+
}
43+
if (result.error !== undefined && (result.error !== "execution reverted" || result.output ==="0x")) {
44+
delete result.output
45+
}
5546

56-
return this.finalize(result)
57-
},
58-
enter: function(frame) {
59-
var call = {
60-
type: frame.getType(),
61-
from: toHex(frame.getFrom()),
62-
to: toHex(frame.getTo()),
63-
input: toHex(frame.getInput()),
64-
gas: '0x' + bigInt(frame.getGas()).toString('16'),
65-
}
66-
if (frame.getValue() !== undefined){
67-
call.value='0x' + bigInt(frame.getValue()).toString(16)
68-
}
69-
this.callstack.push(call)
70-
},
71-
exit: function(frameResult) {
72-
var len = this.callstack.length
73-
if (len > 1) {
74-
var call = this.callstack.pop()
75-
call.gasUsed = '0x' + bigInt(frameResult.getGasUsed()).toString('16')
76-
var error = frameResult.getError()
77-
if (error === undefined) {
78-
call.output = toHex(frameResult.getOutput())
79-
} else {
80-
call.error = error
81-
if (call.type === 'CREATE' || call.type === 'CREATE2') {
82-
delete call.to
83-
}
84-
}
85-
len -= 1
86-
if (this.callstack[len-1].calls === undefined) {
87-
this.callstack[len-1].calls = []
88-
}
89-
this.callstack[len-1].calls.push(call)
90-
}
91-
},
47+
return this.finalize(result)
48+
},
49+
enter: function(frame) {
50+
var call = {
51+
type: frame.getType(),
52+
from: toHex(frame.getFrom()),
53+
to: toHex(frame.getTo()),
54+
input: toHex(frame.getInput()),
55+
gas: '0x' + bigInt(frame.getGas()).toString('16'),
56+
}
57+
if (frame.getValue() !== undefined){
58+
call.value='0x' + bigInt(frame.getValue()).toString(16)
59+
}
60+
this.callstack.push(call)
61+
},
62+
exit: function(frameResult) {
63+
var len = this.callstack.length
64+
if (len > 1) {
65+
var call = this.callstack.pop()
66+
call.gasUsed = '0x' + bigInt(frameResult.getGasUsed()).toString('16')
67+
var error = frameResult.getError()
68+
if (error === undefined) {
69+
call.output = toHex(frameResult.getOutput())
70+
} else {
71+
call.error = error
72+
if (call.type === 'CREATE' || call.type === 'CREATE2') {
73+
delete call.to
74+
}
75+
}
76+
len -= 1
77+
if (this.callstack[len-1].calls === undefined) {
78+
this.callstack[len-1].calls = []
79+
}
80+
this.callstack[len-1].calls.push(call)
81+
}
82+
},
9283
// finalize recreates a call object using the final desired field oder for json
9384
// serialization. This is a nicety feature to pass meaningfully ordered results
9485
// to users who don't interpret it, just display it.

eth/tracers/tracer.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,6 @@ func (jst *Tracer) CaptureExit(output []byte, gasUsed uint64, err error) {
795795
if !jst.traceCallFrames {
796796
return
797797
}
798-
if jst.err != nil {
799-
return
800-
}
801798
// If tracing was interrupted, set the error and stop
802799
if atomic.LoadUint32(&jst.interrupt) > 0 {
803800
jst.err = jst.reason

0 commit comments

Comments
 (0)