2023-11-01 03:32:09 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2019-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.
|
|
|
|
|
2018-12-12 15:18:46 +00:00
|
|
|
import
|
2023-08-04 11:10:09 +00:00
|
|
|
json,
|
|
|
|
../nimbus/common/common, # must be early (compilation annoyance)
|
|
|
|
../nimbus/db/core_db/persistent,
|
|
|
|
../nimbus/[config, tracer, vm_types]
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2022-12-02 04:39:12 +00:00
|
|
|
proc dumpTest(com: CommonRef, blockNumber: int) =
|
2018-12-25 10:31:51 +00:00
|
|
|
let
|
|
|
|
blockNumber = blockNumber.u256
|
|
|
|
|
2018-12-12 15:18:46 +00:00
|
|
|
var
|
2023-08-04 11:10:09 +00:00
|
|
|
capture = com.db.capture()
|
|
|
|
captureCom = com.clone(capture.recorder)
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2018-12-25 10:31:51 +00:00
|
|
|
let
|
2022-12-02 04:39:12 +00:00
|
|
|
header = captureCom.db.getBlockHeader(blockNumber)
|
2018-12-25 10:31:51 +00:00
|
|
|
headerHash = header.blockHash
|
2022-12-02 04:39:12 +00:00
|
|
|
blockBody = captureCom.db.getBlockBody(headerHash)
|
|
|
|
txTrace = traceTransactions(captureCom, header, blockBody)
|
|
|
|
stateDump = dumpBlockState(captureCom, header, blockBody)
|
|
|
|
blockTrace = traceBlock(captureCom, header, blockBody, {DisableState})
|
|
|
|
receipts = dumpReceipts(captureCom.db, 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
|
|
|
|
2023-08-04 11:10:09 +00:00
|
|
|
metaData.dumpMemoryDB(capture)
|
2018-12-25 10:31:51 +00:00
|
|
|
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()
|
2023-08-04 11:10:09 +00:00
|
|
|
let db = newCoreDbRef(LegacyDbPersistent, string conf.dataDir)
|
|
|
|
let com = CommonRef.new(db, false)
|
2018-12-12 15:18:46 +00:00
|
|
|
|
2022-12-02 04:39:12 +00:00
|
|
|
com.dumpTest(97)
|
|
|
|
com.dumpTest(46147)
|
|
|
|
com.dumpTest(46400)
|
|
|
|
com.dumpTest(46402)
|
|
|
|
com.dumpTest(47205)
|
|
|
|
com.dumpTest(48712)
|
|
|
|
com.dumpTest(48915)
|
|
|
|
com.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()
|