2023-11-01 03:32:09 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2020-2023 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
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
|
2023-08-04 11:10:09 +00:00
|
|
|
stint,
|
2022-12-02 04:39:12 +00:00
|
|
|
../nimbus/common/common,
|
2023-08-04 11:10:09 +00:00
|
|
|
../nimbus/db/core_db/persistent,
|
2022-12-02 04:39:12 +00:00
|
|
|
../nimbus/core/executor,
|
|
|
|
../nimbus/[vm_state, vm_types],
|
2023-08-04 11:10:09 +00:00
|
|
|
../nimbus/tracer,
|
|
|
|
./configuration # must be late (compilation annoyance)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
2022-12-02 04:39:12 +00:00
|
|
|
proc dumpDebug(com: CommonRef, blockNumber: UInt256) =
|
2019-01-10 08:23:18 +00:00
|
|
|
var
|
2023-08-04 11:10:09 +00:00
|
|
|
capture = com.db.capture()
|
|
|
|
captureCom = com.clone(capture.recorder)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
2023-08-04 11:10:09 +00:00
|
|
|
let transaction = capture.recorder.beginTransaction()
|
2019-02-07 10:10:04 +00:00
|
|
|
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
|
2022-12-02 04:39:12 +00:00
|
|
|
parent = captureCom.db.getBlockHeader(parentNumber)
|
|
|
|
header = captureCom.db.getBlockHeader(blockNumber)
|
2019-01-10 08:23:18 +00:00
|
|
|
headerHash = header.blockHash
|
2022-12-02 04:39:12 +00:00
|
|
|
body = captureCom.db.getBlockBody(headerHash)
|
|
|
|
vmState = BaseVMState.new(parent, header, captureCom)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
2022-12-02 04:39:12 +00:00
|
|
|
discard captureCom.db.setHead(parent, true)
|
2023-10-05 03:04:12 +00:00
|
|
|
discard vmState.processBlock(header, body)
|
2019-02-07 03:55:49 +00:00
|
|
|
|
2019-02-22 08:22:20 +00:00
|
|
|
transaction.rollback()
|
2022-12-02 04:39:12 +00:00
|
|
|
dumpDebuggingMetaData(captureCom, 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()
|
2023-08-04 11:10:09 +00:00
|
|
|
let com = CommonRef.new(newCoreDbRef(LegacyDbPersistent, conf.dataDir), false)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
|
|
|
if conf.head != 0.u256:
|
2022-12-02 04:39:12 +00:00
|
|
|
dumpDebug(com, conf.head)
|
2019-01-10 08:23:18 +00:00
|
|
|
|
|
|
|
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()
|