premix report page: modify header section to display block summary

This commit is contained in:
andri lim 2019-02-03 16:08:13 +07:00 committed by zah
parent f75faf54c3
commit 817bce3555
6 changed files with 19 additions and 6 deletions

View File

@ -47,7 +47,7 @@ method persistBlocks*(c: Chain, headers: openarray[BlockHeader], bodies: openarr
when not defined(release):
if validationResult == ValidationResult.Error:
dumpDebuggingMetaData(c.db, headers[i], bodies[i], vmState.receipts)
dumpDebuggingMetaData(c.db, headers[i], bodies[i], vmState)
raise newException(Exception, "Validation error. Debugging metadata dumped.")
if validationResult != ValidationResult.OK:

View File

@ -232,7 +232,7 @@ proc traceTransactions*(chainDB: BaseChainDB, header: BlockHeader, blockBody: Bl
result.add traceTransaction(chainDB, header, blockBody, i, {DisableState})
proc dumpDebuggingMetaData*(chainDB: BaseChainDB, header: BlockHeader,
blockBody: BlockBody, receipts: seq[Receipt], launchDebugger = true) =
blockBody: BlockBody, vmState: BaseVMState, launchDebugger = true) =
let
blockNumber = header.blockNumber
@ -241,13 +241,21 @@ proc dumpDebuggingMetaData*(chainDB: BaseChainDB, header: BlockHeader,
captureDB = newCaptureDB(chainDB.db, memoryDB)
captureTrieDB = trieDB captureDB
captureChainDB = newBaseChainDB(captureTrieDB, false)
bloom = createBloom(vmState.receipts)
let blockSummary = %{
"receiptsRoot": %("0x" & toHex(calcReceiptRoot(vmState.receipts).data)),
"stateRoot": %("0x" & toHex(vmState.accountDb.rootHash.data)),
"logsBloom": %("0x" & toHex(bloom))
}
var metaData = %{
"blockNumber": %blockNumber.toHex,
"txTraces": traceTransactions(captureChainDB, header, blockBody),
"stateDump": dumpBlockState(captureChainDB, header, blockBody),
"blockTrace": traceBlock(captureChainDB, header, blockBody, {DisableState}),
"receipts": toJson(receipts)
"receipts": toJson(vmState.receipts),
"block": blockSummary
}
metaData.dumpMemoryDB(memoryDB)

View File

@ -367,6 +367,11 @@ function headerRenderer(nimbus, geth) {
let container = $('#headerContainer').empty();
$('#headerTitle').text('Block #' + parseInt(geth.block.number, 16));
let body = premix.newTable(container);
const blockSummary = ['stateRoot', 'receiptsRoot', 'logsBloom'];
for(var idx of blockSummary) {
premix.renderRow(body, nimbus.block, geth.block, idx);
}
}
function generateNavigation(txs, nimbus, geth) {

View File

@ -28,7 +28,7 @@ proc executeBlock(blockEnv: JsonNode, memoryDB: TrieDatabaseRef, blockNumber: Ui
else:
info "block validation success", validationResult, blockNumber
dumpDebuggingMetaData(chainDB, header, body, vmState.receipts, false)
dumpDebuggingMetaData(chainDB, header, body, vmState, false)
let
fileName = "debug" & $blockNumber & ".json"
nimbus = json.parseFile(fileName)

View File

@ -26,7 +26,7 @@ proc dumpDebug(chainDB: BaseChainDB, blockNumber: Uint256) =
captureChainDB.setHead(parent, true)
let validationResult = processBlock(captureChainDB, parent, header, body, vmState)
dumpDebuggingMetaData(captureChainDB, header, body, vmState.receipts, false)
dumpDebuggingMetaData(captureChainDB, header, body, vmState, false)
proc main() =
let conf = getConfiguration()

View File

@ -75,7 +75,7 @@ proc huntProblematicBlock(blockNumber: Uint256): ValidationResult =
if validationResult != ValidationResult.OK:
transaction.dispose()
dumpDebuggingMetaData(chainDB, thisBlock.header, thisBlock.body, vmState.receipts, false)
dumpDebuggingMetaData(chainDB, thisBlock.header, thisBlock.body, vmState, false)
result = validationResult