From 16cebc469bf66e484e108cda7a11502b26b4f726 Mon Sep 17 00:00:00 2001 From: andri lim Date: Tue, 15 Jan 2019 16:18:27 +0700 Subject: [PATCH] add txKind to report page --- premix/assets/js/index.js | 3 ++- premix/index.html | 6 ++++++ premix/premixcore.nim | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/premix/assets/js/index.js b/premix/assets/js/index.js index fdb403862..f6070e41f 100644 --- a/premix/assets/js/index.js +++ b/premix/assets/js/index.js @@ -209,7 +209,7 @@ function transactionsRenderer(txId, nimbus, geth) { } } - txId = parseInt(txId); + let tx = geth.block.transactions[txId]; let ntx = nimbus.txTraces[txId]; let gtx = geth.txTraces[txId]; @@ -231,6 +231,7 @@ function transactionsRenderer(txId, nimbus, geth) { geth.receipts[txId] ); + $(`

Transaction Kind: ${tx.txKind}

`).appendTo(container); renderTx(ncr, gcr); } diff --git a/premix/index.html b/premix/index.html index 3ef313b66..9d49037e8 100644 --- a/premix/index.html +++ b/premix/index.html @@ -153,6 +153,12 @@ of other transactions. In opcode section, the same thing happened, perhaps only the first instruction with red colored text have the problem, but it will affect the rest of other instructions.

+ +

+ In Transactions section, you'll see the transaction kind. + It has three kind: Regular, ContractCreation, and ContractCall. + Each kind will help you locate the bug in Nimbus implementation, they have their own proc. +

diff --git a/premix/premixcore.nim b/premix/premixcore.nim index acb3fce07..d28899dde 100644 --- a/premix/premixcore.nim +++ b/premix/premixcore.nim @@ -130,21 +130,32 @@ proc updateAccount*(address: string, account: JsonNode, blockNumber: Uint256) = account["storage"][x["key"].getStr] = x["value"] proc requestPostState*(premix, n: JsonNode, blockNumber: Uint256) = + type + TxKind {.pure.} = enum + Regular + ContractCreation + ContractCall + let txs = n["transactions"] if txs.len == 0: return let tracer = jsonTracer(postStateTracer) for t in txs: + var txKind = TxKind.Regular let tx = parseTransaction(t) + if tx.isContractCreation: txKind = TxKind.ContractCreation if hasInternalTx(tx, blockNumber): let txTrace = requestInternalTx(t["hash"], tracer) for address, account in txTrace: updateAccount(address, account, blockNumber) premix.add account + if not tx.isContractCreation: txKind = TxKind.ContractCall else: premix.requestAccount(blockNumber, tx.getRecipient) premix.requestAccount(blockNumber, tx.getSender) + t["txKind"] = %($txKind) + proc requestPostState*(thisBlock: Block): JsonNode = let blockNumber = thisBlock.header.blockNumber var premix = newJArray()