mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-13 05:44:40 +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);
|
premix.renderRow(body, nimbus, geth, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(nimbus.error) {
|
||||||
|
geth.error = '';
|
||||||
|
premix.renderRow(body, nimbus, geth, 'error');
|
||||||
|
}
|
||||||
|
|
||||||
function renderExtra(name) {
|
function renderExtra(name) {
|
||||||
let nk = Object.keys(nimbus[name]);
|
let nk = Object.keys(nimbus[name]);
|
||||||
let gk = Object.keys(geth[name]);
|
let gk = Object.keys(geth[name]);
|
||||||
@ -95,6 +100,8 @@ function opCodeRenderer(txId, nimbus, geth) {
|
|||||||
|
|
||||||
function analyze(nimbus, geth) {
|
function analyze(nimbus, geth) {
|
||||||
for(var x of premix.fields) {
|
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;
|
if(nimbus[x].toString().toLowerCase() != geth[x].toString().toLowerCase()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +117,22 @@ function opCodeRenderer(txId, nimbus, geth) {
|
|||||||
var sideBar = $('#opCodeSideBar').empty();
|
var sideBar = $('#opCodeSideBar').empty();
|
||||||
$('#opCodeTitle').text(`Tx #${(txId+1)}`);
|
$('#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) {
|
for(var i in ncs) {
|
||||||
var pc = ncs[i];
|
var pc = ncs[i];
|
||||||
if(!analyze(ncs[i], gcs[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();
|
windowResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,14 +181,12 @@ function transactionsRenderer(txId, nimbus, geth) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fillEmptyLogs(a, b) {
|
function fillEmptyLogs(a, b) {
|
||||||
function emptyLog() {
|
const emptyLog = {address: '', topics: [], data: ''};
|
||||||
return {address: '', topics: [], data: ''};
|
|
||||||
}
|
|
||||||
|
|
||||||
if(a.logs.length > b.logs.length) {
|
if(a.logs.length > b.logs.length) {
|
||||||
for(var i in a.logs) {
|
for(var i in a.logs) {
|
||||||
if(b.logs[i] === undefined) {
|
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
|
postState.add txTrace
|
||||||
|
|
||||||
proc hasTracerData(tx: JsonNode, blockNumber: Uint256): bool =
|
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:
|
if t.isContractCreation:
|
||||||
let t = parseTransaction(tx)
|
return recipientHasCode or t.payload.len > 0
|
||||||
let code = request("eth_getCode", %[%t.getRecipient.prefixHex, number])
|
|
||||||
return code.getStr.len > 2 or t.payload.len > 0
|
|
||||||
|
|
||||||
let code = request("eth_getCode", %[tx["to"], number])
|
recipientHasCode
|
||||||
result = code.getStr.len > 2 # "0x"
|
|
||||||
|
|
||||||
proc requestPostState(n: JsonNode, jsTracer: string, thisBlock: Block): JsonNode =
|
proc requestPostState(n: JsonNode, jsTracer: string, thisBlock: Block): JsonNode =
|
||||||
let txs = n["transactions"]
|
let txs = n["transactions"]
|
||||||
@ -206,9 +207,17 @@ proc main() =
|
|||||||
thisBlock = downloader.requestBlock(blockNumber, {DownloadReceipts, DownloadTxTrace})
|
thisBlock = downloader.requestBlock(blockNumber, {DownloadReceipts, DownloadTxTrace})
|
||||||
accounts = requestPostState(thisBlock)
|
accounts = requestPostState(thisBlock)
|
||||||
|
|
||||||
|
# remove duplicate accounts with same address
|
||||||
|
# and only take newest one
|
||||||
removePostStateDup(nimbus)
|
removePostStateDup(nimbus)
|
||||||
|
|
||||||
|
# premix data goes to report page
|
||||||
generatePremixData(nimbus, blockNumber, thisBlock, accounts)
|
generatePremixData(nimbus, blockNumber, thisBlock, accounts)
|
||||||
|
|
||||||
|
# prestate data goes to debug tool and contains data
|
||||||
|
# needed to execute single block
|
||||||
generatePrestate(nimbus, blockNumber, thisBlock)
|
generatePrestate(nimbus, blockNumber, thisBlock)
|
||||||
|
|
||||||
printDebugInstruction(blockNumber)
|
printDebugInstruction(blockNumber)
|
||||||
except:
|
except:
|
||||||
echo getCurrentExceptionMsg()
|
echo getCurrentExceptionMsg()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user