This commit is contained in:
andri lim 2019-02-25 20:02:16 +07:00
parent 750ea067d2
commit 0d64e0a6c3
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
3 changed files with 9 additions and 2 deletions

View File

@ -344,3 +344,6 @@ proc traceOpCodeEnded*(c: BaseComputation, op: Op, lastIndex: int) =
proc traceError*(c: BaseComputation) = proc traceError*(c: BaseComputation) =
c.vmState.tracer.traceError(c) c.vmState.tracer.traceError(c)
proc prepareTracer*(c: BaseComputation) =
c.vmState.tracer.prepare(c.msg.depth)

View File

@ -228,6 +228,7 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
# Wrap the case statement in while true + computed goto # Wrap the case statement in while true + computed goto
result = quote do: result = quote do:
`computation`.prepareTracer()
var `instr` = `computation`.code.next() var `instr` = `computation`.code.next()
while true: while true:
{.computedGoto.} {.computedGoto.}

View File

@ -24,13 +24,16 @@ proc initTracer*(tracer: var TransactionTracer, flags: set[TracerFlags] = {}) =
tracer.accounts = initSet[EthAddress]() tracer.accounts = initSet[EthAddress]()
tracer.storageKeys = @[] tracer.storageKeys = @[]
proc rememberStorageKey(tracer: var TransactionTracer, compDepth: int, key: Uint256) = proc prepare*(tracer: var TransactionTracer, compDepth: int) =
if compDepth >= tracer.storageKeys.len: if compDepth >= tracer.storageKeys.len:
let prevLen = tracer.storageKeys.len let prevLen = tracer.storageKeys.len
tracer.storageKeys.setLen(compDepth + 1) tracer.storageKeys.setLen(compDepth + 1)
for i in prevLen ..< tracer.storageKeys.len: for i in prevLen ..< tracer.storageKeys.len - 1:
tracer.storageKeys[i] = initSet[Uint256]() tracer.storageKeys[i] = initSet[Uint256]()
tracer.storageKeys[compDepth] = initSet[Uint256]()
proc rememberStorageKey(tracer: var TransactionTracer, compDepth: int, key: Uint256) =
tracer.storageKeys[compDepth].incl key tracer.storageKeys[compDepth].incl key
iterator storage(tracer: TransactionTracer, compDepth: int): Uint256 = iterator storage(tracer: TransactionTracer, compDepth: int): Uint256 =