nimbus-eth1/premix/dumper.nim

59 lines
1.6 KiB
Nim
Raw Normal View History

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)
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)
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()