mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
fix some renderer logic
This commit is contained in:
parent
07ab94cdf0
commit
2b66716d9c
@ -65,6 +65,11 @@ function renderTrace(title, nimbus, geth) {
|
||||
premix.renderRow(body, nimbus, geth, x);
|
||||
}
|
||||
|
||||
if(nimbus.error) {
|
||||
geth.error = '';
|
||||
premix.renderRow(body, nimbus, geth, 'error');
|
||||
}
|
||||
|
||||
function renderExtra(name) {
|
||||
let nk = Object.keys(nimbus[name]);
|
||||
let gk = Object.keys(geth[name]);
|
||||
@ -95,6 +100,8 @@ function opCodeRenderer(txId, nimbus, geth) {
|
||||
|
||||
function analyze(nimbus, geth) {
|
||||
for(var x of premix.fields) {
|
||||
if(nimbus[x] === undefined) nimbus[x] = '';
|
||||
if(geth[x] === undefined) geth[x] = '';
|
||||
if(nimbus[x].toString().toLowerCase() != geth[x].toString().toLowerCase()) return false;
|
||||
}
|
||||
|
||||
@ -110,6 +117,22 @@ function opCodeRenderer(txId, nimbus, geth) {
|
||||
var sideBar = $('#opCodeSideBar').empty();
|
||||
$('#opCodeTitle').text(`Tx #${(txId+1)}`);
|
||||
|
||||
function fillEmptyOp(a, b) {
|
||||
const emptyOp = {op: '', pc: '', gas: '', gasCost: '', depth: '',
|
||||
storage:{}, memory: [], stack: []};
|
||||
|
||||
if(a.length > b.length) {
|
||||
for(var i in a) {
|
||||
if(b[i] === undefined) {
|
||||
b[i] = emptyOp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fillEmptyOp(ncs, gcs);
|
||||
fillEmptyOp(gcs, ncs);
|
||||
|
||||
for(var i in ncs) {
|
||||
var pc = ncs[i];
|
||||
if(!analyze(ncs[i], gcs[i])) {
|
||||
@ -125,7 +148,10 @@ function opCodeRenderer(txId, nimbus, geth) {
|
||||
});
|
||||
}
|
||||
|
||||
renderTrace("tx", ncs[0], gcs[0]);
|
||||
if(ncs.length > 0) {
|
||||
renderTrace("tx", ncs[0], gcs[0]);
|
||||
}
|
||||
|
||||
windowResize();
|
||||
}
|
||||
|
||||
@ -155,14 +181,12 @@ function transactionsRenderer(txId, nimbus, geth) {
|
||||
}
|
||||
|
||||
function fillEmptyLogs(a, b) {
|
||||
function emptyLog() {
|
||||
return {address: '', topics: [], data: ''};
|
||||
}
|
||||
const emptyLog = {address: '', topics: [], data: ''};
|
||||
|
||||
if(a.logs.length > b.logs.length) {
|
||||
for(var i in a.logs) {
|
||||
if(b.logs[i] === undefined) {
|
||||
b.logs[i] = emptyLog();
|
||||
b.logs[i] = emptyLog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,15 +48,16 @@ proc requestBlockState(postState: JsonNode, thisBlock: Block, addresses: openArr
|
||||
postState.add txTrace
|
||||
|
||||
proc hasTracerData(tx: JsonNode, blockNumber: Uint256): bool =
|
||||
let number = %(blockNumber.prefixHex)
|
||||
let
|
||||
number = %(blockNumber.prefixHex)
|
||||
t = parseTransaction(tx)
|
||||
code = request("eth_getCode", %[%t.getRecipient.prefixHex, number])
|
||||
recipientHasCode = code.getStr.len > 2 # "0x"
|
||||
|
||||
if tx["to"].kind == JNull:
|
||||
let t = parseTransaction(tx)
|
||||
let code = request("eth_getCode", %[%t.getRecipient.prefixHex, number])
|
||||
return code.getStr.len > 2 or t.payload.len > 0
|
||||
if t.isContractCreation:
|
||||
return recipientHasCode or t.payload.len > 0
|
||||
|
||||
let code = request("eth_getCode", %[tx["to"], number])
|
||||
result = code.getStr.len > 2 # "0x"
|
||||
recipientHasCode
|
||||
|
||||
proc requestPostState(n: JsonNode, jsTracer: string, thisBlock: Block): JsonNode =
|
||||
let txs = n["transactions"]
|
||||
@ -206,9 +207,17 @@ proc main() =
|
||||
thisBlock = downloader.requestBlock(blockNumber, {DownloadReceipts, DownloadTxTrace})
|
||||
accounts = requestPostState(thisBlock)
|
||||
|
||||
# remove duplicate accounts with same address
|
||||
# and only take newest one
|
||||
removePostStateDup(nimbus)
|
||||
|
||||
# premix data goes to report page
|
||||
generatePremixData(nimbus, blockNumber, thisBlock, accounts)
|
||||
|
||||
# prestate data goes to debug tool and contains data
|
||||
# needed to execute single block
|
||||
generatePrestate(nimbus, blockNumber, thisBlock)
|
||||
|
||||
printDebugInstruction(blockNumber)
|
||||
except:
|
||||
echo getCurrentExceptionMsg()
|
||||
|
Loading…
x
Reference in New Issue
Block a user