nimbus-eth1/premix/dumper.nim
Jordan Hrycaj 8ed40c78e0
Core db+aristo provides tracer funtionality (#2089)
* Aristo: Provide descriptor fork based on search in transaction stack

details:
  Try to find the tx that has a particular pair `(vertex-id,hash-key)`,
  and by extension try filter and backend if the former fails.

* Cleanup & docu

* CoreDb+Aristo: Implement context re-position to earlier in-memory state

why:
  It is a easy way to explore how there can be concurrent access to the
  same backend storage DB with different view states. This one can access
  an earlier state from the transaction stack.

* CoreDb+Aristo: Populate tracer stubs with real functionality

* Update `tracer.nim` to new API

why:
  Legacy API does not sufficiently support `Aristo`

* Fix logging problems in tracer

details:
  Debug logging turned off by default

* Fix function prototypes

* Add Copyright header

* Add tables import

why:
  For older compiler versions on CI
2024-03-21 10:45:57 +00:00

71 lines
1.9 KiB
Nim

# Nimbus
# Copyright (c) 2020-2024 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.
#
# helper tool to dump debugging data for persisted block
# usage: dumper [--datadir:your_path] --head:blockNumber
#
import
stint,
../nimbus/common/common,
../nimbus/db/core_db/persistent,
../nimbus/core/executor,
../nimbus/[vm_state, vm_types],
../nimbus/tracer,
./configuration # must be late (compilation annoyance)
proc dumpDebug(com: CommonRef, blockNumber: UInt256) =
var
capture = com.db.capture()
captureCom = com.clone(capture.recorder)
let transaction = capture.recorder.beginTransaction()
defer: transaction.dispose()
let
parentNumber = blockNumber - 1
parent = captureCom.db.getBlockHeader(parentNumber)
header = captureCom.db.getBlockHeader(blockNumber)
headerHash = header.blockHash
body = captureCom.db.getBlockBody(headerHash)
vmState = BaseVMState.new(parent, header, captureCom)
discard captureCom.db.setHead(parent, true)
discard vmState.processBlock(header, body)
transaction.rollback()
vmState.dumpDebuggingMetaData(header, body, false)
proc main() {.used.} =
let conf = getConfiguration()
let com = CommonRef.new(newCoreDbRef(LegacyDbPersistent, conf.dataDir), false)
if conf.head != 0.u256:
dumpDebug(com, 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()