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,
|
2019-01-10 08:23:18 +00:00
|
|
|
../nimbus/db/[storage_types, db_chain, select_backend, capturedb],
|
2019-02-05 19:15:50 +00:00
|
|
|
eth/trie/[hexary, db, trie_defs], ../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)
|
|
|
|
let validationResult = processBlock(captureChainDB, parent, 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
|
|
|
|
|
|
|
proc main() =
|
|
|
|
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()
|