format the memory in the traceManager

pull/3285/head^2
yann300 2 years ago committed by Aniket
parent 1ae17e97aa
commit f50ac473ec
  1. 6
      libs/remix-debug/src/trace/traceCache.ts
  2. 7
      libs/remix-debug/src/trace/traceManager.ts
  3. 7
      libs/remix-simulator/src/VmProxy.ts

@ -17,6 +17,7 @@ export class TraceCache {
memoryChanges
storageChanges
sstore
formattedMemory
constructor () {
this.init()
@ -36,6 +37,7 @@ export class TraceCache {
this.addresses = []
this.callDataChanges = []
this.memoryChanges = []
this.formattedMemory = {}
this.storageChanges = []
this.sstore = {} // all sstore occurence in the trace
}
@ -53,6 +55,10 @@ export class TraceCache {
this.memoryChanges.push(value)
}
setFormattedMemory (stepIndex, memory) {
this.formattedMemory[stepIndex] = memory
}
// outOfGas has been removed because gas left logging is apparently made differently
// in the vm/geth/eth. TODO add the error property (with about the error in all clients)
pushCall (step, index, address, callStack, reverted) {

@ -196,7 +196,12 @@ export class TraceManager {
if (lastChanges === null) {
throw new Error('no memory found')
}
return this.trace[lastChanges].memory
if (this.traceCache.formattedMemory[lastChanges]) {
return this.traceCache.formattedMemory[lastChanges]
}
const memory = util.formatMemory(this.trace[lastChanges].memory)
this.traceCache.setFormattedMemory(lastChanges, memory)
return memory
}
getCurrentPC (stepIndex) {

@ -249,8 +249,9 @@ export class VmProxy {
gas: data.gasLeft.toString(),
depth: depth
}
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)
if (previousOpcode.op === 'CALLDATACOPY' || previousOpcode.op === 'CODECOPY' || previousOpcode.op === 'EXTCODECOPY' || previousOpcode.op === 'RETURNDATACOPY' || previousOpcode.op === 'MSTORE' || previousOpcode.op === 'MSTORE8') {
step.memory = data.memory
this.lastMemoryUpdate = step.memory
}
this.vmTraces[this.processingHash].structLogs.push(step)
@ -258,7 +259,7 @@ export class VmProxy {
if (step.op === 'STATICCALL' && step.stack[step.stack.length - 2] === '0x000000000000000000000000000000000000000000636f6e736f6c652e6c6f67') {
const stackLength = step.stack.length
const payloadStart = parseInt(step.stack[stackLength - 3], 16)
const memory = step.memory || formatMemory(data.memory)
const memory = formatMemory(data.memory)
const memoryStr = memory.join('')
let payload = memoryStr.substring(payloadStart * 2, memory.length)
const fnselectorStr = payload.substring(0, 8)

Loading…
Cancel
Save