aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-12-21 07:31:25 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2019-01-11 18:26:38 +0800
commite1b99b5e2f0098d97a0d73d60889f0ef7d14b6f7 (patch)
treee80af9d88d43f38abc65df407ebe42b9855aa163 /packages
parent7af0818dffe67483491f99062071b582fba456cb (diff)
downloaddexon-0x-contracts-e1b99b5e2f0098d97a0d73d60889f0ef7d14b6f7.tar.gz
dexon-0x-contracts-e1b99b5e2f0098d97a0d73d60889f0ef7d14b6f7.tar.zst
dexon-0x-contracts-e1b99b5e2f0098d97a0d73d60889f0ef7d14b6f7.zip
Use tracer for debug traces
Diffstat (limited to 'packages')
-rw-r--r--packages/sol-tracing-utils/src/trace_info_subprovider.ts26
1 files changed, 21 insertions, 5 deletions
diff --git a/packages/sol-tracing-utils/src/trace_info_subprovider.ts b/packages/sol-tracing-utils/src/trace_info_subprovider.ts
index 635a68f58..8713ccb5e 100644
--- a/packages/sol-tracing-utils/src/trace_info_subprovider.ts
+++ b/packages/sol-tracing-utils/src/trace_info_subprovider.ts
@@ -1,3 +1,4 @@
+import { StructLog } from 'ethereum-types';
import * as _ from 'lodash';
import { constants } from './constants';
@@ -12,11 +13,26 @@ export abstract class TraceInfoSubprovider extends TraceCollectionSubprovider {
protected abstract _handleTraceInfoAsync(traceInfo: TraceInfo): Promise<void>;
protected async _recordTxTraceAsync(address: string, data: string | undefined, txHash: string): Promise<void> {
await this._web3Wrapper.awaitTransactionMinedAsync(txHash, 0);
- const trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, {
- disableMemory: true,
- disableStack: false,
- disableStorage: true,
- });
+ // 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 trace = await this._web3Wrapper.getTransactionTraceAsync(txHash, { tracer, timeout: '600s' });
const tracesByContractAddress = getTracesByContractAddress(trace.structLogs, address);
const subcallAddresses = _.keys(tracesByContractAddress);
if (address === constants.NEW_CONTRACT) {