mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-26 12:08:59 +00:00
catch premix and persit tool exception
This commit is contained in:
parent
b0f4a236fa
commit
da75707912
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
eth_common, stint, byteutils, nimcrypto,
|
eth_common, stint, byteutils, nimcrypto,
|
||||||
chronicles, rlp, downloader, configuration
|
chronicles, rlp, downloader, configuration,
|
||||||
|
../nimbus/errors
|
||||||
|
|
||||||
import
|
import
|
||||||
eth_trie/[hexary, db, defs],
|
eth_trie/[hexary, db, defs],
|
||||||
@ -73,7 +74,7 @@ proc main() =
|
|||||||
if numBlocks == numBlocksToCommit:
|
if numBlocks == numBlocksToCommit:
|
||||||
persistToDb(db):
|
persistToDb(db):
|
||||||
if chain.persistBlocks(headers, bodies) != ValidationResult.OK:
|
if chain.persistBlocks(headers, bodies) != ValidationResult.OK:
|
||||||
break
|
raise newException(ValidationError, "Error when validating blocks")
|
||||||
numBlocks = 0
|
numBlocks = 0
|
||||||
headers.setLen(0)
|
headers.setLen(0)
|
||||||
bodies.setLen(0)
|
bodies.setLen(0)
|
||||||
@ -84,7 +85,8 @@ proc main() =
|
|||||||
|
|
||||||
if numBlocks > 0:
|
if numBlocks > 0:
|
||||||
persistToDb(db):
|
persistToDb(db):
|
||||||
discard chain.persistBlocks(headers, bodies)
|
if chain.persistBlocks(headers, bodies) != ValidationResult.OK:
|
||||||
|
raise newException(ValidationError, "Error when validating blocks")
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
var message: string
|
var message: string
|
||||||
@ -98,4 +100,7 @@ when isMainModule:
|
|||||||
echo message
|
echo message
|
||||||
quit(QuitSuccess)
|
quit(QuitSuccess)
|
||||||
|
|
||||||
main()
|
try:
|
||||||
|
main()
|
||||||
|
except:
|
||||||
|
echo getCurrentExceptionMsg()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import
|
import
|
||||||
json, downloader, stint, strutils,
|
json, downloader, stint, strutils, os,
|
||||||
../nimbus/tracer, chronicles, prestate
|
../nimbus/tracer, chronicles, prestate
|
||||||
|
|
||||||
proc fakeAlloc(n: JsonNode) =
|
proc fakeAlloc(n: JsonNode) =
|
||||||
@ -93,15 +93,35 @@ proc generatePremixData(nimbus: JsonNode, blockNumber: Uint256, thisBlock: Block
|
|||||||
var data = "var debugMetaData = " & metaData.pretty & "\n"
|
var data = "var debugMetaData = " & metaData.pretty & "\n"
|
||||||
writeFile("premixData.js", data)
|
writeFile("premixData.js", data)
|
||||||
|
|
||||||
proc main() =
|
proc printDebugInstruction(blockNumber: Uint256) =
|
||||||
let
|
var text = """
|
||||||
nimbus = parseFile("debug_meta_data.json")
|
|
||||||
blockNumber = UInt256.fromHex(nimbus["blockNumber"].getStr())
|
|
||||||
thisBlock = downloader.requestBlock(blockNumber, {DownloadReceipts, DownloadTxTrace})
|
|
||||||
postState = requestPostState(thisBlock)
|
|
||||||
accounts = processPostState(postState)
|
|
||||||
|
|
||||||
generatePremixData(nimbus, blockNumber, thisBlock, postState, accounts)
|
Successfully created debugging environment for block $1.
|
||||||
generatePrestate(nimbus, blockNumber, thisBlock)
|
You can continue to find nimbus EVM bug by viewing premix report page `./index.html`.
|
||||||
|
After that you can try to debug that single block using `nim c -r debug block$1.json` command.
|
||||||
|
|
||||||
|
Happy bug hunting
|
||||||
|
""" % [$blockNumber]
|
||||||
|
|
||||||
|
echo text
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
if paramCount() == 0:
|
||||||
|
echo "usage: premix debug_meta_data.json"
|
||||||
|
quit(QuitFailure)
|
||||||
|
|
||||||
|
try:
|
||||||
|
let
|
||||||
|
nimbus = json.parseFile(paramStr(1))
|
||||||
|
blockNumber = UInt256.fromHex(nimbus["blockNumber"].getStr())
|
||||||
|
thisBlock = downloader.requestBlock(blockNumber, {DownloadReceipts, DownloadTxTrace})
|
||||||
|
postState = requestPostState(thisBlock)
|
||||||
|
accounts = processPostState(postState)
|
||||||
|
|
||||||
|
generatePremixData(nimbus, blockNumber, thisBlock, postState, accounts)
|
||||||
|
generatePrestate(nimbus, blockNumber, thisBlock)
|
||||||
|
printDebugInstruction(blockNumber)
|
||||||
|
except:
|
||||||
|
echo getCurrentExceptionMsg()
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user