fix keep track of memory update

pull/5370/head
yann300 2 years ago committed by Aniket
parent 44e8df72ac
commit f78fc15667
  1. 6
      libs/remix-simulator/src/VmProxy.ts

@ -44,6 +44,7 @@ export class VmProxy {
blocks blocks
stateCopy: StateManager stateCopy: StateManager
flagDoNotRecordEVMSteps: boolean flagDoNotRecordEVMSteps: boolean
lastMemoryUpdate: Array<string>
constructor (vmContext: VMContext) { constructor (vmContext: VMContext) {
this.vmContext = vmContext this.vmContext = vmContext
@ -86,6 +87,7 @@ export class VmProxy {
this.utils = utils this.utils = utils
this.txsMapBlock = {} this.txsMapBlock = {}
this.blocks = {} this.blocks = {}
this.lastMemoryUpdate = []
} }
setVM (vm) { setVM (vm) {
@ -116,6 +118,7 @@ export class VmProxy {
async txWillProcess (data: TypedTransaction) { async txWillProcess (data: TypedTransaction) {
if (this.flagDoNotRecordEVMSteps) return if (this.flagDoNotRecordEVMSteps) return
this.lastMemoryUpdate = []
this.stateCopy = await this.vm.stateManager.copy() this.stateCopy = await this.vm.stateManager.copy()
this.incr++ this.incr++
this.processingHash = bufferToHex(data.hash()) this.processingHash = bufferToHex(data.hash())
@ -248,6 +251,7 @@ export class VmProxy {
} }
if (data.opcode.name === 'CALLDATACOPY' || data.opcode.name === 'CODECOPY' || data.opcode.name === 'EXTCODECOPY' || data.opcode.name === 'RETURNDATACOPY' || data.opcode.name === 'MSTORE' || data.opcode.name === 'MSTORE8') { if (data.opcode.name === 'CALLDATACOPY' || data.opcode.name === 'CODECOPY' || data.opcode.name === 'EXTCODECOPY' || data.opcode.name === 'RETURNDATACOPY' || data.opcode.name === 'MSTORE' || data.opcode.name === 'MSTORE8') {
step.memory = formatMemory(data.memory) step.memory = formatMemory(data.memory)
this.lastMemoryUpdate = step.memory
} }
this.vmTraces[this.processingHash].structLogs.push(step) this.vmTraces[this.processingHash].structLogs.push(step)
// Track hardhat console.log call // Track hardhat console.log call
@ -301,7 +305,7 @@ export class VmProxy {
} }
} }
if (previousOpcode && previousOpcode.op === 'SHA3') { if (previousOpcode && previousOpcode.op === 'SHA3') {
const preimage = this.getSha3Input(previousOpcode.stack, previousOpcode.memory) const preimage = this.getSha3Input(previousOpcode.stack, this.lastMemoryUpdate)
const imageHash = step.stack[step.stack.length - 1].replace('0x', '') const imageHash = step.stack[step.stack.length - 1].replace('0x', '')
this.sha3Preimages[imageHash] = { this.sha3Preimages[imageHash] = {
preimage: preimage preimage: preimage

Loading…
Cancel
Save