diff --git a/remix-lib/src/web3Provider/web3VmProvider.js b/remix-lib/src/web3Provider/web3VmProvider.js index 6a064bcdf2..1f892fae9c 100644 --- a/remix-lib/src/web3Provider/web3VmProvider.js +++ b/remix-lib/src/web3Provider/web3VmProvider.js @@ -139,9 +139,13 @@ web3VmProvider.prototype.pushTrace = function (self, data) { console.log('no tx processing') return } - if (this.previousDepth > depth) { + var previousopcode + if (self.vmTraces[self.processingHash] && self.vmTraces[self.processingHash].structLogs[this.processingIndex - 1]) { + previousopcode = self.vmTraces[self.processingHash].structLogs[this.processingIndex - 1] + } + + if (this.previousDepth > depth && previousopcode) { // returning from context, set error it is not STOP, RETURN - var previousopcode = self.vmTraces[self.processingHash].structLogs[this.processingIndex - 1] previousopcode.invalidDepthChange = previousopcode.op !== 'RETURN' && previousopcode.op !== 'STOP' } var step = { @@ -169,14 +173,14 @@ web3VmProvider.prototype.pushTrace = function (self, data) { } } } - if (traceHelper.isSHA3Instruction(step)) { - var sha3Input = getSha3Input(step.stack, step.memory) - var preimage = sha3Input - var imageHash = ethutil.sha3('0x' + sha3Input).toString('hex') + if (previousopcode && traceHelper.isSHA3Instruction(previousopcode)) { + var preimage = getSha3Input(previousopcode.stack, previousopcode.memory) + var imageHash = step.stack[step.stack.length - 1].replace('0x', '') self.sha3Preimages[imageHash] = { 'preimage': preimage } } + this.processingIndex++ this.previousDepth = depth }