nimbus-eth1/premix/dumper.nim

60 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,
2020-07-21 06:15:06 +00:00
../nimbus/db/[db_chain, select_backend, capturedb],
eth/trie/[hexary, db], ../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)
Feature/goerli replay clique poa (#743) * extract unused clique/mining support into separate file why: mining is currently unsupported by nimbus * Replay first 51840 transactions from Goerli block chain why: Currently Goerli is loaded but the block headers are not verified. Replaying allows real data PoA development. details: Simple stupid gzipped dump/undump layer for debugging based on the zlib module (no nim-faststream support.) This is a replay running against p2p/chain.persistBlocks() where the data were captured from. * prepare stubs for PoA engine * split executor source into sup-modules why: make room for updates, clique integration should go into executor/update_poastate.nim * Simplify p2p/executor.processBlock() function prototype why: vmState argument always wraps basicChainDB * split processBlock() into sub-functions why: isolate the part where it will support clique/poa * provided additional processTransaction() function prototype without _fork_ argument why: with the exception of some tests, the _fork_ argument is always derived from the other prototype argument _vmState_ details: similar situation with makeReceipt() * provide new processBlock() version explicitly supporting PoA details: The new processBlock() version supporting PoA is the general one also supporting non-PoA networks, it needs an additional _Clique_ descriptor function argument for PoA state (if any.) The old processBlock() function without the _Clique_ descriptor argument retorns an error on PoA networgs (e.g. Goerli.) * re-implemented Clique descriptor as _ref object_ why: gives more flexibility when moving around the descriptor object details: also cleaned up a bit the clique sources * comments for clarifying handling of Clique/PoA state descriptor
2021-07-06 13:14:45 +00:00
discard vmState.processBlock(header, body)
transaction.rollback()
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()
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()