mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-10 11:06:49 +00:00
previously, every time the VMState was created, it will also create new stateDB, and this action will nullify the advantages of cached accounts. the new changes will conserve the accounts cache if the executed blocks are contiguous. if not the stateDB need to be reinited. this changes also allow rpcCallEvm and rpcEstimateGas executed properly using current stateDB instead of creating new one each time they are called.
65 lines
1.7 KiB
Nim
65 lines
1.7 KiB
Nim
#
|
|
# helper tool to dump debugging data for persisted block
|
|
# usage: dumper [--datadir:your_path] --head:blockNumber
|
|
#
|
|
|
|
import
|
|
configuration, stint, eth/common,
|
|
../nimbus/db/[db_chain, select_backend, capturedb],
|
|
eth/trie/[hexary, db], ../nimbus/p2p/executor,
|
|
../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()
|
|
|
|
|
|
let
|
|
parentNumber = blockNumber - 1
|
|
parent = captureChainDB.getBlockHeader(parentNumber)
|
|
header = captureChainDB.getBlockHeader(blockNumber)
|
|
headerHash = header.blockHash
|
|
body = captureChainDB.getBlockBody(headerHash)
|
|
|
|
captureChainDB.initStateDB(parent.stateRoot)
|
|
let
|
|
vmState = newBaseVMState(captureChainDB.stateDB, header, captureChainDB)
|
|
|
|
captureChainDB.setHead(parent, true)
|
|
discard vmState.processBlockNotPoA(header, body)
|
|
|
|
transaction.rollback()
|
|
dumpDebuggingMetaData(captureChainDB, header, body, vmState, false)
|
|
|
|
proc main() {.used.} =
|
|
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()
|