diff --git a/src/trace/traceAnalyser.js b/src/trace/traceAnalyser.js index ad346ea4bc..b87850610b 100644 --- a/src/trace/traceAnalyser.js +++ b/src/trace/traceAnalyser.js @@ -112,9 +112,9 @@ TraceAnalyser.prototype.buildDepth = function (index, step, tx, callStack, conte context.lastCallIndex = context.currentCallIndex context.currentCallIndex = 0 } else if (traceHelper.isReturnInstruction(step) || traceHelper.isStopInstruction(step) || outOfGas || step.error || step.invalidDepthChange) { - if (index + 1 < this.trace.length) { + if (index < this.trace.length) { callStack.pop() - this.traceCache.pushCall(step, index + 1, null, callStack.slice(0), outOfGas) + this.traceCache.pushCall(step, index + 1, null, callStack.slice(0), outOfGas || step.error || step.invalidDepthChange, outOfGas) this.buildCalldata(index, step, tx, false) this.traceCache.pushSteps(index, context.currentCallIndex) context.currentCallIndex = context.lastCallIndex + 1 diff --git a/src/trace/traceCache.js b/src/trace/traceCache.js index d2fa4664a4..000b9bee7c 100644 --- a/src/trace/traceCache.js +++ b/src/trace/traceCache.js @@ -33,17 +33,18 @@ TraceCache.prototype.pushMemoryChanges = function (value) { this.memoryChanges.push(value) } -TraceCache.prototype.pushCall = function (step, index, address, callStack, outofGas) { - if (step.op === 'RETURN' || step.op === 'STOP' || outofGas) { - this.currentCall.call.return = index +TraceCache.prototype.pushCall = function (step, index, address, callStack, reverted, outOfGas) { + if (step.op === 'RETURN' || step.op === 'STOP' || reverted) { + this.currentCall.call.return = index - 1 + this.currentCall.call.reverted = reverted + this.currentCall.call.outOfGas = outOfGas var parent = this.currentCall.parent - this.currentCall = { call: parent.call, parent: parent.parent } + this.currentCall = parent ? { call: parent.call, parent: parent.parent } : null } else { var call = { op: step.op, address: address, callStack: callStack, - outofGas: outofGas, calls: {}, start: index }