reorder captureDB in traceTransaction
This commit is contained in:
parent
2552d6452a
commit
8d42ad997e
|
@ -11,18 +11,19 @@ proc prefixHex(x: openArray[byte]): string =
|
||||||
|
|
||||||
proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
||||||
body: BlockBody, txIndex: int, tracerFlags: set[TracerFlags]): JsonNode =
|
body: BlockBody, txIndex: int, tracerFlags: set[TracerFlags]): JsonNode =
|
||||||
let parent = db.getParentHeader(header)
|
|
||||||
var stateDb = newAccountStateDB(db.db, parent.stateRoot, db.pruneTrie)
|
|
||||||
assert(body.transactions.calcTxRoot == header.txRoot)
|
|
||||||
if header.txRoot == BLANK_ROOT_HASH: return
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
parent = db.getParentHeader(header)
|
||||||
|
# we add a memory layer between backend/upper layer db
|
||||||
|
# and capture state db snapshot during transaction execution
|
||||||
memoryDB = newMemoryDB()
|
memoryDB = newMemoryDB()
|
||||||
captureDB = newCaptureDB(db.db, memoryDB)
|
captureDB = newCaptureDB(db.db, memoryDB)
|
||||||
captureTrieDB = trieDB captureDB
|
captureTrieDB = trieDB captureDB
|
||||||
captureChainDB = newBaseChainDB(captureTrieDB, false) # prune or not prune?
|
captureChainDB = newBaseChainDB(captureTrieDB, false) # prune or not prune?
|
||||||
|
vmState = newBaseVMState(parent, captureChainDB, tracerFlags + {TracerFlags.EnableTracing})
|
||||||
|
|
||||||
let vmState = newBaseVMState(parent, captureChainDB, tracerFlags + {TracerFlags.EnableTracing})
|
var stateDb = newAccountStateDB(captureTrieDB, parent.stateRoot, db.pruneTrie)
|
||||||
|
if header.txRoot == BLANK_ROOT_HASH: return
|
||||||
|
assert(body.transactions.calcTxRoot == header.txRoot)
|
||||||
assert(body.transactions.len != 0)
|
assert(body.transactions.len != 0)
|
||||||
|
|
||||||
var gasUsed: GasInt
|
var gasUsed: GasInt
|
||||||
|
@ -38,6 +39,7 @@ proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
||||||
result = vmState.getTracingResult()
|
result = vmState.getTracingResult()
|
||||||
result["gas"] = %gasUsed
|
result["gas"] = %gasUsed
|
||||||
|
|
||||||
|
# now we dump captured state db
|
||||||
var n = newJObject()
|
var n = newJObject()
|
||||||
for k, v in pairsInMemoryDB(memoryDB):
|
for k, v in pairsInMemoryDB(memoryDB):
|
||||||
n[k.prefixHex] = %v.prefixHex
|
n[k.prefixHex] = %v.prefixHex
|
||||||
|
|
Loading…
Reference in New Issue