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,
|
2022-01-18 16:19:32 +00:00
|
|
|
../nimbus/[tracer, vm_state, vm_types]
|
2019-01-10 08:23:18 +00:00
|
|
|
|
2022-04-08 04:54:11 +00:00
|
|
|
proc dumpDebug(chainDB: BaseChainDB, blockNumber: UInt256) =
|
2019-01-10 08:23:18 +00:00
|
|
|
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()
|
2021-10-28 09:42:39 +00:00
|
|
|
|
2022-04-08 04:54:11 +00:00
|
|
|
|
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)
|
2022-01-18 16:19:32 +00:00
|
|
|
vmState = BaseVMState.new(parent, header, captureChainDB)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
2022-07-04 05:35:56 +00:00
|
|
|
discard captureChainDB.setHead(parent, true)
|
2021-07-30 14:06:51 +00:00
|
|
|
discard vmState.processBlockNotPoA(header, body)
|
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()
|
2022-04-08 04:54:11 +00:00
|
|
|
let db = newChainDB(conf.dataDir)
|
2019-01-10 08:23:18 +00:00
|
|
|
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()
|