diff --git a/nimbus.nimble b/nimbus.nimble index 43d67eafc..33f1267bb 100644 --- a/nimbus.nimble +++ b/nimbus.nimble @@ -39,9 +39,10 @@ task test, "Run tests": test "all_tests" # debugging tools don't yet have tests # but they should be compilable - buildBinary "premix", "premix/" - buildBinary "persist", "premix/" - buildBinary "debug", "premix/" + exec "nim c premix/premix" + exec "nim c premix/persist" + exec "nim c premix/debug" + exec "nim c premix/dumper" task nimbus, "Build Nimbus": buildBinary "nimbus", "nimbus/" diff --git a/nimbus/tracer.nim b/nimbus/tracer.nim index 8062811b3..8fdaeb659 100644 --- a/nimbus/tracer.nim +++ b/nimbus/tracer.nim @@ -2,7 +2,7 @@ import db/[db_chain, state_db, capturedb], eth_common, utils, json, constants, vm_state, vm_types, transaction, p2p/executor, eth_trie/db, nimcrypto, strutils, ranges, ./utils/addresses, - chronicles + chronicles, rpc/hexstrings proc getParentHeader(self: BaseChainDB, header: BlockHeader): BlockHeader = self.getBlockHeader(header.parentHash) @@ -46,19 +46,19 @@ proc getRecipient*(tx: Transaction): EthAddress = proc captureAccount(n: JsonNode, db: AccountStateDB, address: EthAddress, name: string) = var jaccount = newJObject() jaccount["name"] = %name - jaccount["address"] = %($address) + jaccount["address"] = %("0x" & $address) let account = db.getAccount(address) - jaccount["nonce"] = %(account.nonce.toHex) - jaccount["balance"] = %(account.balance.toHex) + jaccount["nonce"] = %(encodeQuantity(account.nonce).toLowerAscii) + jaccount["balance"] = %("0x" & account.balance.toHex) let code = db.getCode(address) - jaccount["codeHash"] = %(($account.codeHash).toLowerAscii) - jaccount["code"] = %(toHex(code.toOpenArray, true)) - jaccount["storageRoot"] = %(($account.storageRoot).toLowerAscii) + jaccount["codeHash"] = %("0x" & ($account.codeHash).toLowerAscii) + jaccount["code"] = %("0x" & toHex(code.toOpenArray, true)) + jaccount["storageRoot"] = %("0x" & ($account.storageRoot).toLowerAscii) var storage = newJObject() for key, value in db.storage(address): - storage[key.dumpHex] = %(value.dumpHex) + storage["0x" & key.dumpHex] = %("0x" & value.dumpHex) jaccount["storage"] = storage n.add jaccount diff --git a/premix/assets/js/index.js b/premix/assets/js/index.js index d504418af..8ec30552c 100644 --- a/premix/assets/js/index.js +++ b/premix/assets/js/index.js @@ -120,6 +120,7 @@ function opCodeRenderer(txId, nimbus, geth) { } function transactionsRenderer(txId, nimbus, geth) { + txId = parseInt(txId); $('#transactionsTitle').text(`Tx #${(txId+1)}`); let container = $('#transactionsContainer').empty(); @@ -130,13 +131,17 @@ function transactionsRenderer(txId, nimbus, geth) { premix.renderRow(body, nimbus, geth, x); } - // TODO: receipt logs + // TODO: render receipt logs } txId = parseInt(txId); let ntx = nimbus.txTraces[txId]; let gtx = geth.txTraces[txId]; + if(ntx.returnValue.length == 0) { + ntx.returnValue = "0x"; + } + let ncr = $.extend({ gas: ntx.gas, returnValue: ntx.returnValue @@ -155,36 +160,52 @@ function transactionsRenderer(txId, nimbus, geth) { } function headerRenderer(nimbus, geth) { + function emptyAccount() { + return { + address: '', + nonce: '', + balance: '', + codeHash: '', + code: '', + storageRoot: '', + storage: {} + }; + } + let container = $('#headerContainer').empty(); let ncs = nimbus.stateDump.after; let gcs = geth.accounts; + let accounts = []; - - for(var n of ncs) { - n.address = '0x' + n.address; - n.balance = '0x' + n.balance; - n.code = '0x' + n.code; - let g = gcs[n.address]; - + for(var address in ncs) { + let n = ncs[address]; + n.address = address; + if(gcs[address]) { + let geth = gcs[address]; + geth.address = address; + accounts.push({name: n.name, nimbus: n, geth: geth}); + delete gcs[address]; + } else { + accounts.push({name: n.name, nimbus: n, geth: emptyAccount()}); + } } - /*"name": "internalTx0", - "address": "0000000000000000000000000000000000000004", - "nonce": "0000000000000000", - "balance": "0", - "codeHash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", - "code": "", - "storageRoot": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "storage": {}*/ - - /*"0xf927a40c8b7f6e07c5af7fa2155b4864a4112b13": { - "balance": "0x607c9cea65ef7e19dd8", - "nonce": "0000000000000000", - "code": "0x", - "storage": {}*/ - + for(var address in gcs) { + let geth = gcs[address]; + geth.address = address; + accounts.push({name: "unknown", nimbus: emptyAccount(), geth: geth}); + } + for(var acc of accounts) { + $(`

Account Name: ${acc.name}

`).appendTo(container); + let body = premix.newTable(container); + const fields = ['address', 'nonce', 'balance', 'codeHash', 'code', 'storageRoot']; + for(var x of fields) { + premix.renderRow(body, acc.nimbus, acc.geth, x); + } + $('
').appendTo(container); + } } function generateNavigation(txs, nimbus, geth) { @@ -201,8 +222,8 @@ function generateNavigation(txs, nimbus, geth) { let list = $('