2018-12-12 15:18:46 +00:00
|
|
|
import
|
2020-07-21 06:15:06 +00:00
|
|
|
json, eth/common, stint, chronicles,
|
2019-02-05 19:15:50 +00:00
|
|
|
eth/trie/db, ../nimbus/db/[db_chain, capturedb, select_backend],
|
2021-09-11 14:58:01 +00:00
|
|
|
../nimbus/[tracer, config, vm_types]
|
2018-12-12 15:18:46 +00:00
|
|
|
|
|
|
|
proc dumpTest(chainDB: BaseChainDB, blockNumber: int) =
|
2018-12-25 10:31:51 +00:00
|
|
|
let
|
|
|
|
blockNumber = blockNumber.u256
|
|
|
|
|
2018-12-12 15:18:46 +00:00
|
|
|
var
|
|
|
|
memoryDB = newMemoryDB()
|
|
|
|
captureDB = newCaptureDB(chainDB.db, memoryDB)
|
|
|
|
captureTrieDB = trieDB captureDB
|
|
|
|
captureChainDB = newBaseChainDB(captureTrieDB, false)
|
|
|
|
|
2018-12-25 10:31:51 +00:00
|
|
|
let
|
|
|
|
header = captureChainDB.getBlockHeader(blockNumber)
|
|
|
|
headerHash = header.blockHash
|
|
|
|
blockBody = captureChainDB.getBlockBody(headerHash)
|
|
|
|
txTrace = traceTransactions(captureChainDB, header, blockBody)
|
|
|
|
stateDump = dumpBlockState(captureChainDB, header, blockBody)
|
|
|
|
blockTrace = traceBlock(captureChainDB, header, blockBody, {DisableState})
|
|
|
|
receipts = dumpReceipts(captureChainDB, header)
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2018-12-25 10:31:51 +00:00
|
|
|
var metaData = %{
|
|
|
|
"blockNumber": %blockNumber.toHex,
|
|
|
|
"txTraces": txTrace,
|
|
|
|
"stateDump": stateDump,
|
|
|
|
"blockTrace": blockTrace,
|
|
|
|
"receipts": receipts
|
|
|
|
}
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2018-12-25 10:31:51 +00:00
|
|
|
metaData.dumpMemoryDB(memoryDB)
|
|
|
|
writeFile("block" & $blockNumber & ".json", metaData.pretty())
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2020-07-21 06:15:06 +00:00
|
|
|
proc main() {.used.} =
|
2018-12-12 15:18:46 +00:00
|
|
|
# 97 block with uncles
|
|
|
|
# 46147 block with first transaction
|
|
|
|
# 46400 block with transaction
|
|
|
|
# 46402 block with first contract: failed
|
|
|
|
# 47205 block with first success contract
|
|
|
|
# 48712 block with 5 transactions
|
|
|
|
# 48915 block with contract
|
|
|
|
# 49018 first problematic block
|
|
|
|
# 52029 first block with receipts logs
|
|
|
|
# 66407 failed transaction
|
|
|
|
|
2021-09-16 15:59:46 +00:00
|
|
|
# nimbus --rpc-api: eth, debug --prune: archive
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2021-09-11 14:58:01 +00:00
|
|
|
var conf = makeConfig()
|
|
|
|
let db = newChainDb(string conf.dataDir)
|
2018-12-12 15:18:46 +00:00
|
|
|
let trieDB = trieDB db
|
|
|
|
let chainDB = newBaseChainDB(trieDB, false)
|
|
|
|
|
|
|
|
chainDB.dumpTest(97)
|
|
|
|
chainDB.dumpTest(46147)
|
|
|
|
chainDB.dumpTest(46400)
|
|
|
|
chainDB.dumpTest(46402)
|
|
|
|
chainDB.dumpTest(47205)
|
|
|
|
chainDB.dumpTest(48712)
|
|
|
|
chainDB.dumpTest(48915)
|
2018-12-31 03:28:12 +00:00
|
|
|
chainDB.dumpTest(49018)
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2019-02-07 06:00:20 +00:00
|
|
|
when isMainModule:
|
|
|
|
try:
|
|
|
|
main()
|
|
|
|
except:
|
|
|
|
echo getCurrentExceptionMsg()
|