2019-01-10 08:23:18 +00:00
|
|
|
#
|
|
|
|
# helper tool to dump debugging data for persisted block
|
|
|
|
# usage: dumper [--datadir:your_path] --head:blockNumber
|
|
|
|
#
|
|
|
|
|
|
|
|
import
|
2019-02-05 19:15:50 +00:00
|
|
|
configuration, stint, eth/common,
|
2020-07-21 06:15:06 +00:00
|
|
|
../nimbus/db/[db_chain, select_backend, capturedb],
|
|
|
|
eth/trie/[hexary, db], ../nimbus/p2p/executor,
|
2019-01-10 08:23:18 +00:00
|
|
|
../nimbus/[tracer, vm_state]
|
|
|
|
|
|
|
|
proc dumpDebug(chainDB: BaseChainDB, blockNumber: Uint256) =
|
|
|
|
var
|
|
|
|
memoryDB = newMemoryDB()
|
|
|
|
captureDB = newCaptureDB(chainDB.db, memoryDB)
|
|
|
|
captureTrieDB = trieDB captureDB
|
|
|
|
captureChainDB = newBaseChainDB(captureTrieDB, false)
|
|
|
|
|
2019-02-07 10:10:04 +00:00
|
|
|
let transaction = memoryDB.beginTransaction()
|
|
|
|
defer: transaction.dispose()
|
2019-01-10 08:23:18 +00:00
|
|
|
let
|
|
|
|
parentNumber = blockNumber - 1
|
|
|
|
parent = captureChainDB.getBlockHeader(parentNumber)
|
|
|
|
header = captureChainDB.getBlockHeader(blockNumber)
|
|
|
|
headerHash = header.blockHash
|
|
|
|
body = captureChainDB.getBlockBody(headerHash)
|
2019-02-14 15:20:41 +00:00
|
|
|
vmState = newBaseVMState(parent.stateRoot, header, captureChainDB)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
|
|
|
captureChainDB.setHead(parent, true)
|
2020-07-21 06:15:06 +00:00
|
|
|
discard processBlock(captureChainDB, header, body, vmState)
|
2019-02-07 03:55:49 +00:00
|
|
|
|
2019-02-22 08:22:20 +00:00
|
|
|
transaction.rollback()
|
2019-02-03 09:08:13 +00:00
|
|
|
dumpDebuggingMetaData(captureChainDB, header, body, vmState, false)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
2020-07-21 06:15:06 +00:00
|
|
|
proc main() {.used.} =
|
2019-01-10 08:23:18 +00:00
|
|
|
let conf = getConfiguration()
|
|
|
|
let db = newChainDb(conf.dataDir)
|
|
|
|
let trieDB = trieDB db
|
|
|
|
let chainDB = newBaseChainDB(trieDB, false)
|
|
|
|
|
|
|
|
if conf.head != 0.u256:
|
|
|
|
dumpDebug(chainDB, conf.head)
|
|
|
|
|
|
|
|
when isMainModule:
|
|
|
|
var message: string
|
|
|
|
|
|
|
|
## Processing command line arguments
|
|
|
|
if processArguments(message) != Success:
|
|
|
|
echo message
|
|
|
|
quit(QuitFailure)
|
|
|
|
else:
|
|
|
|
if len(message) > 0:
|
|
|
|
echo message
|
|
|
|
quit(QuitSuccess)
|
|
|
|
|
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except:
|
|
|
|
echo getCurrentExceptionMsg()
|