mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
add enable/disableTracing to vm_state
This commit is contained in:
parent
b159b5c945
commit
9d6dbceefc
@ -19,7 +19,7 @@ proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
||||
captureDB = newCaptureDB(db.db, memoryDB)
|
||||
captureTrieDB = trieDB captureDB
|
||||
captureChainDB = newBaseChainDB(captureTrieDB, false) # prune or not prune?
|
||||
vmState = newBaseVMState(parent, captureChainDB, tracerFlags + {TracerFlags.EnableTracing})
|
||||
vmState = newBaseVMState(parent, captureChainDB, tracerFlags)
|
||||
|
||||
var stateDb = newAccountStateDB(captureTrieDB, parent.stateRoot, db.pruneTrie)
|
||||
if header.txRoot == BLANK_ROOT_HASH: return
|
||||
@ -30,9 +30,13 @@ proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
||||
for idx, tx in body.transactions:
|
||||
var sender: EthAddress
|
||||
if tx.getSender(sender):
|
||||
if idx == txIndex:
|
||||
vmState.enableTracing()
|
||||
let txFee = processTransaction(stateDb, tx, sender, vmState)
|
||||
gasUsed = (txFee div tx.gasPrice.u256).truncate(GasInt)
|
||||
if idx == txIndex: break
|
||||
if idx == txIndex:
|
||||
vmState.disableTracing()
|
||||
break
|
||||
else:
|
||||
assert(false, "Could not get sender")
|
||||
|
||||
|
@ -128,3 +128,9 @@ proc getAndClearLogEntries*(vmState: BaseVMState): seq[Log] =
|
||||
proc clearLogs*(vmState: BaseVMState) =
|
||||
# call this when computation error
|
||||
vmState.logEntries.setLen(0)
|
||||
|
||||
proc enableTracing*(vmState: BaseVMState) =
|
||||
vmState.tracingEnabled = true
|
||||
|
||||
proc disableTracing*(vmState: BaseVMState) =
|
||||
vmState.tracingEnabled = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user