add more options to debug_traceTransaction
This commit is contained in:
parent
7ed20542cd
commit
581ec4b8f7
|
@ -18,6 +18,7 @@ type
|
||||||
disableStorage: Option[bool]
|
disableStorage: Option[bool]
|
||||||
disableMemory: Option[bool]
|
disableMemory: Option[bool]
|
||||||
disableStack: Option[bool]
|
disableStack: Option[bool]
|
||||||
|
disableState: Option[bool]
|
||||||
|
|
||||||
proc isTrue(x: Option[bool]): bool =
|
proc isTrue(x: Option[bool]): bool =
|
||||||
result = x.isSome and x.get() == true
|
result = x.isSome and x.get() == true
|
||||||
|
@ -40,6 +41,7 @@ proc setupDebugRpc*(chainDB: BaseChainDB, rpcsrv: RpcServer) =
|
||||||
## * disableStorage: BOOL. Setting this to true will disable storage capture (default = false).
|
## * disableStorage: BOOL. Setting this to true will disable storage capture (default = false).
|
||||||
## * disableMemory: BOOL. Setting this to true will disable memory capture (default = false).
|
## * disableMemory: BOOL. Setting this to true will disable memory capture (default = false).
|
||||||
## * disableStack: BOOL. Setting this to true will disable stack capture (default = false).
|
## * disableStack: BOOL. Setting this to true will disable stack capture (default = false).
|
||||||
|
## * disableState: BOOL. Setting this to true will disable state trie capture (default = false).
|
||||||
let
|
let
|
||||||
txHash = toHash(data)
|
txHash = toHash(data)
|
||||||
txDetails = chainDB.getTransactionKey(txHash)
|
txDetails = chainDB.getTransactionKey(txHash)
|
||||||
|
@ -55,5 +57,6 @@ proc setupDebugRpc*(chainDB: BaseChainDB, rpcsrv: RpcServer) =
|
||||||
if opts.disableStorage.isTrue: flags.incl TracerFlags.DisableStorage
|
if opts.disableStorage.isTrue: flags.incl TracerFlags.DisableStorage
|
||||||
if opts.disableMemory.isTrue: flags.incl TracerFlags.DisableMemory
|
if opts.disableMemory.isTrue: flags.incl TracerFlags.DisableMemory
|
||||||
if opts.disableStack.isTrue: flags.incl TracerFlags.DisableStack
|
if opts.disableStack.isTrue: flags.incl TracerFlags.DisableStack
|
||||||
|
if opts.disableState.isTrue: flags.incl TracerFlags.DisableState
|
||||||
|
|
||||||
traceTransaction(chainDB, blockHeader, blockBody, txDetails.index, flags)
|
traceTransaction(chainDB, blockHeader, blockBody, txDetails.index, flags)
|
||||||
|
|
|
@ -13,14 +13,14 @@ proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
||||||
body: BlockBody, txIndex: int, tracerFlags: set[TracerFlags]): JsonNode =
|
body: BlockBody, txIndex: int, tracerFlags: set[TracerFlags]): JsonNode =
|
||||||
let
|
let
|
||||||
parent = db.getParentHeader(header)
|
parent = db.getParentHeader(header)
|
||||||
# we add a memory layer between backend/upper layer db
|
# we add a memory layer between backend/lower layer db
|
||||||
# and capture state db snapshot during transaction execution
|
# 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})
|
vmState = newBaseVMState(parent, captureChainDB, tracerFlags + {TracerFlags.EnableTracing})
|
||||||
|
|
||||||
var stateDb = newAccountStateDB(captureTrieDB, parent.stateRoot, db.pruneTrie)
|
var stateDb = newAccountStateDB(captureTrieDB, parent.stateRoot, db.pruneTrie)
|
||||||
if header.txRoot == BLANK_ROOT_HASH: return
|
if header.txRoot == BLANK_ROOT_HASH: return
|
||||||
assert(body.transactions.calcTxRoot == header.txRoot)
|
assert(body.transactions.calcTxRoot == header.txRoot)
|
||||||
|
@ -40,7 +40,8 @@ proc traceTransaction*(db: BaseChainDB, header: BlockHeader,
|
||||||
result["gas"] = %gasUsed
|
result["gas"] = %gasUsed
|
||||||
|
|
||||||
# now we dump captured state db
|
# now we dump captured state db
|
||||||
var n = newJObject()
|
if TracerFlags.DisableState notin tracerFlags:
|
||||||
for k, v in pairsInMemoryDB(memoryDB):
|
var n = newJObject()
|
||||||
n[k.prefixHex] = %v.prefixHex
|
for k, v in pairsInMemoryDB(memoryDB):
|
||||||
result["snapshot"] = n
|
n[k.prefixHex] = %v.prefixHex
|
||||||
|
result["state"] = n
|
||||||
|
|
|
@ -32,6 +32,7 @@ type
|
||||||
DisableStorage
|
DisableStorage
|
||||||
DisableMemory
|
DisableMemory
|
||||||
DisableStack
|
DisableStack
|
||||||
|
DisableState
|
||||||
|
|
||||||
TransactionTracer* = object
|
TransactionTracer* = object
|
||||||
trace*: JsonNode
|
trace*: JsonNode
|
||||||
|
|
Loading…
Reference in New Issue