From c0484adfa0bd20670d7dad2e57fd0ae8ac507d97 Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 28 Jan 2019 20:17:20 +0700 Subject: [PATCH 1/2] remove tabs from js_tracer.nim --- premix/js_tracer.nim | 108 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/premix/js_tracer.nim b/premix/js_tracer.nim index 1dc29a6e9..7e319398f 100644 --- a/premix/js_tracer.nim +++ b/premix/js_tracer.nim @@ -1,66 +1,66 @@ const postStateTracer* = """{ - postState: {}, + postState: {}, - // lookupAccount injects the specified account into the postState object. - lookupAccount: function(addr, db){ - var acc = toHex(addr); - if (this.postState[acc] === undefined) { - this.postState[acc] = { - code: toHex(db.getCode(addr)), - storage: {} - }; - } - }, + // lookupAccount injects the specified account into the postState object. + lookupAccount: function(addr, db){ + var acc = toHex(addr); + if (this.postState[acc] === undefined) { + this.postState[acc] = { + code: toHex(db.getCode(addr)), + storage: {} + }; + } + }, - // lookupStorage injects the specified storage entry of the given account into - // the postState object. - lookupStorage: function(addr, key, db){ - var acc = toHex(addr); - var idx = toHex(key); + // lookupStorage injects the specified storage entry of the given account into + // the postState object. + lookupStorage: function(addr, key, db){ + var acc = toHex(addr); + var idx = toHex(key); this.lookupAccount(addr, db); - if (this.postState[acc].storage[idx] === undefined) { + if (this.postState[acc].storage[idx] === undefined) { this.postState[acc].storage[idx] = ""; - } - }, + } + }, - // result is invoked when all the opcodes have been iterated over and returns - // the final result of the tracing. - result: function(ctx, db) { - this.lookupAccount(ctx.from, db); + // result is invoked when all the opcodes have been iterated over and returns + // the final result of the tracing. + result: function(ctx, db) { + this.lookupAccount(ctx.from, db); this.lookupAccount(ctx.to, db); - // Return the assembled allocations (postState) - return this.postState; - }, + // Return the assembled allocations (postState) + return this.postState; + }, - // step is invoked for every opcode that the VM executes. - step: function(log, db) { - // Add the current account if we just started tracing - if (this.postState === null){ - this.postState = {}; - // Balance will potentially be wrong here, since this will include the value - // sent along with the message. We fix that in 'result()'. - this.lookupAccount(log.contract.getAddress(), db); - } - // Whenever new state is accessed, add it to the postState - switch (log.op.toString()) { - case "EXTCODECOPY": case "EXTCODESIZE": case "BALANCE": - this.lookupAccount(toAddress(log.stack.peek(0).toString(16)), db); - break; - case "CREATE": - var from = log.contract.getAddress(); - this.lookupAccount(toContract(from, db.getNonce(from)), db); - break; - case "CALL": case "CALLCODE": case "DELEGATECALL": case "STATICCALL": - this.lookupAccount(toAddress(log.stack.peek(1).toString(16)), db); - break; - case 'SSTORE':case 'SLOAD': - this.lookupStorage(log.contract.getAddress(), toWord(log.stack.peek(0).toString(16)), db); - break; - } - }, + // step is invoked for every opcode that the VM executes. + step: function(log, db) { + // Add the current account if we just started tracing + if (this.postState === null){ + this.postState = {}; + // Balance will potentially be wrong here, since this will include the value + // sent along with the message. We fix that in 'result()'. + this.lookupAccount(log.contract.getAddress(), db); + } + // Whenever new state is accessed, add it to the postState + switch (log.op.toString()) { + case "EXTCODECOPY": case "EXTCODESIZE": case "BALANCE": + this.lookupAccount(toAddress(log.stack.peek(0).toString(16)), db); + break; + case "CREATE": + var from = log.contract.getAddress(); + this.lookupAccount(toContract(from, db.getNonce(from)), db); + break; + case "CALL": case "CALLCODE": case "DELEGATECALL": case "STATICCALL": + this.lookupAccount(toAddress(log.stack.peek(1).toString(16)), db); + break; + case 'SSTORE':case 'SLOAD': + this.lookupStorage(log.contract.getAddress(), toWord(log.stack.peek(0).toString(16)), db); + break; + } + }, - // fault is invoked when the actual execution of an opcode fails. - fault: function(log, db) {} + // fault is invoked when the actual execution of an opcode fails. + fault: function(log, db) {} } """ From 33716888df4da3e08ae0cb598684cb527efdb293 Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 28 Jan 2019 20:58:06 +0700 Subject: [PATCH 2/2] sign with GPG --- premix/js_tracer.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/premix/js_tracer.nim b/premix/js_tracer.nim index 7e319398f..1399eefb9 100644 --- a/premix/js_tracer.nim +++ b/premix/js_tracer.nim @@ -19,6 +19,8 @@ const postStateTracer* = """{ var idx = toHex(key); this.lookupAccount(addr, db); if (this.postState[acc].storage[idx] === undefined) { + // bug in geth js tracer + // we will use eth_getProof to fill the storage later this.postState[acc].storage[idx] = ""; } },