diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-14 18:38:36 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-14 18:39:38 +0800 |
commit | ab5cd8f9387e601677de697c7573c6c13383e932 (patch) | |
tree | 5f7968d5bd932419551c7d4688194b3903e56140 /packages/sol-tracing-utils/src | |
parent | bb992458a3550bfd1e79c583f98d3a1c31be5a8b (diff) | |
download | dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.tar dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.tar.gz dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.tar.bz2 dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.tar.lz dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.tar.xz dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.tar.zst dexon-sol-tools-ab5cd8f9387e601677de697c7573c6c13383e932.zip |
Use a custom JS tracer
Diffstat (limited to 'packages/sol-tracing-utils/src')
-rw-r--r-- | packages/sol-tracing-utils/src/trace_info_subprovider.ts | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/packages/sol-tracing-utils/src/trace_info_subprovider.ts b/packages/sol-tracing-utils/src/trace_info_subprovider.ts index 8713ccb5e..43853e152 100644 --- a/packages/sol-tracing-utils/src/trace_info_subprovider.ts +++ b/packages/sol-tracing-utils/src/trace_info_subprovider.ts @@ -1,4 +1,3 @@ -import { StructLog } from 'ethereum-types'; import * as _ from 'lodash'; import { constants } from './constants'; @@ -16,22 +15,24 @@ export abstract class TraceInfoSubprovider extends TraceCollectionSubprovider { // For very large traces we use a custom tracer that outputs a format compatible with a // regular trace. We only need the 2nd item on the stack when the instruction is a call. // By not including othe stack values, we severly limit the amount of data to be collectd. - const tracer = - '{' + - ' data: [],' + - ' step: function(log) {' + - ' const op = log.op.toString();' + - ' const opn = 0 | log.op.toNumber();' + - ' const pc = 0 | log.getPC();' + - ' const depth = 0 | log.getDepth();' + - ' const gas = 0 | log.getGas();' + - ' const isCall = opn == 0xf1 || opn == 0xf2 || opn == 0xf4 || opn == 0xf5;' + - " const stack = isCall ? ['0x'+log.stack.peek(1).toString(16), null] : null;" + - ' this.data.push({ pc, gas, depth, op, stack}); ' + - ' },' + - ' fault: function() { },' + - ' result: function() { return {structLogs: this.data}; }' + - '}'; + const tracer = ` + { + data: [], + step: function(log) { + const op = log.op.toString(); + const opn = 0 | log.op.toNumber(); + const pc = 0 | log.getPC(); + const depth = 0 | log.getDepth(); + const gasCost = 0 | log.getCost(); + const gas = 0 | log.getGas(); + const isCall = opn == 0xf1 || opn == 0xf2 || opn == 0xf4 || opn == 0xf5; + const stack = isCall ? ['0x'+log.stack.peek(1).toString(16), null] : null; + this.data.push({ pc, gasCost, depth, op, stack, gas }); + }, + fault: function() { }, + result: function() { return {structLogs: this.data}; } + } + `; const trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, { tracer, timeout: '600s' }); const tracesByContractAddress = getTracesByContractAddress(trace.structLogs, address); const subcallAddresses = _.keys(tracesByContractAddress); |