sol-dbg 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +105 -0
  3. package/dist/artifacts/helpers.d.ts +14 -0
  4. package/dist/artifacts/helpers.d.ts.map +1 -0
  5. package/dist/artifacts/helpers.js +111 -0
  6. package/dist/artifacts/helpers.js.map +1 -0
  7. package/dist/artifacts/index.d.ts +3 -0
  8. package/dist/artifacts/index.d.ts.map +1 -0
  9. package/dist/artifacts/index.js +19 -0
  10. package/dist/artifacts/index.js.map +1 -0
  11. package/dist/artifacts/solc.d.ts +44 -0
  12. package/dist/artifacts/solc.d.ts.map +1 -0
  13. package/dist/artifacts/solc.js +3 -0
  14. package/dist/artifacts/solc.js.map +1 -0
  15. package/dist/debug/abi.d.ts +30 -0
  16. package/dist/debug/abi.d.ts.map +1 -0
  17. package/dist/debug/abi.js +183 -0
  18. package/dist/debug/abi.js.map +1 -0
  19. package/dist/debug/artifact_manager.d.ts +68 -0
  20. package/dist/debug/artifact_manager.d.ts.map +1 -0
  21. package/dist/debug/artifact_manager.js +182 -0
  22. package/dist/debug/artifact_manager.js.map +1 -0
  23. package/dist/debug/decoding/calldata.d.ts +6 -0
  24. package/dist/debug/decoding/calldata.d.ts.map +1 -0
  25. package/dist/debug/decoding/calldata.js +228 -0
  26. package/dist/debug/decoding/calldata.js.map +1 -0
  27. package/dist/debug/decoding/general.d.ts +9 -0
  28. package/dist/debug/decoding/general.d.ts.map +1 -0
  29. package/dist/debug/decoding/general.js +114 -0
  30. package/dist/debug/decoding/general.js.map +1 -0
  31. package/dist/debug/decoding/index.d.ts +6 -0
  32. package/dist/debug/decoding/index.d.ts.map +1 -0
  33. package/dist/debug/decoding/index.js +22 -0
  34. package/dist/debug/decoding/index.js.map +1 -0
  35. package/dist/debug/decoding/memory.d.ts +4 -0
  36. package/dist/debug/decoding/memory.d.ts.map +1 -0
  37. package/dist/debug/decoding/memory.js +216 -0
  38. package/dist/debug/decoding/memory.js.map +1 -0
  39. package/dist/debug/decoding/stack.d.ts +9 -0
  40. package/dist/debug/decoding/stack.d.ts.map +1 -0
  41. package/dist/debug/decoding/stack.js +85 -0
  42. package/dist/debug/decoding/stack.js.map +1 -0
  43. package/dist/debug/decoding/storage.d.ts +4 -0
  44. package/dist/debug/decoding/storage.d.ts.map +1 -0
  45. package/dist/debug/decoding/storage.js +333 -0
  46. package/dist/debug/decoding/storage.js.map +1 -0
  47. package/dist/debug/index.d.ts +7 -0
  48. package/dist/debug/index.d.ts.map +1 -0
  49. package/dist/debug/index.js +23 -0
  50. package/dist/debug/index.js.map +1 -0
  51. package/dist/debug/opcodes.d.ts +302 -0
  52. package/dist/debug/opcodes.d.ts.map +1 -0
  53. package/dist/debug/opcodes.js +2909 -0
  54. package/dist/debug/opcodes.js.map +1 -0
  55. package/dist/debug/sol_debugger.d.ts +247 -0
  56. package/dist/debug/sol_debugger.d.ts.map +1 -0
  57. package/dist/debug/sol_debugger.js +443 -0
  58. package/dist/debug/sol_debugger.js.map +1 -0
  59. package/dist/debug/types.d.ts +33 -0
  60. package/dist/debug/types.d.ts.map +1 -0
  61. package/dist/debug/types.js +3 -0
  62. package/dist/debug/types.js.map +1 -0
  63. package/dist/index.d.ts +4 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +20 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/utils/immutable_map.d.ts +13 -0
  68. package/dist/utils/immutable_map.d.ts.map +1 -0
  69. package/dist/utils/immutable_map.js +56 -0
  70. package/dist/utils/immutable_map.js.map +1 -0
  71. package/dist/utils/index.d.ts +4 -0
  72. package/dist/utils/index.d.ts.map +1 -0
  73. package/dist/utils/index.js +20 -0
  74. package/dist/utils/index.js.map +1 -0
  75. package/dist/utils/misc.d.ts +48 -0
  76. package/dist/utils/misc.d.ts.map +1 -0
  77. package/dist/utils/misc.js +221 -0
  78. package/dist/utils/misc.js.map +1 -0
  79. package/dist/utils/srcmap.d.ts +8 -0
  80. package/dist/utils/srcmap.d.ts.map +1 -0
  81. package/dist/utils/srcmap.js +28 -0
  82. package/dist/utils/srcmap.js.map +1 -0
  83. package/package.json +61 -0
@@ -0,0 +1,443 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SolTxDebugger = exports.getContractInfo = exports.lastExternalFrame = exports.DataLocationKind = exports.FrameKind = void 0;
7
+ const vm_1 = __importDefault(require("@ethereumjs/vm"));
8
+ const ethereumjs_util_1 = require("ethereumjs-util");
9
+ const solc_typed_ast_1 = require("solc-typed-ast");
10
+ const __1 = require("..");
11
+ const artifacts_1 = require("../artifacts");
12
+ const abi_1 = require("./abi");
13
+ const artifact_manager_1 = require("./artifact_manager");
14
+ const decoding_1 = require("./decoding");
15
+ const opcodes_1 = require("./opcodes");
16
+ var FrameKind;
17
+ (function (FrameKind) {
18
+ FrameKind["Call"] = "call";
19
+ FrameKind["Creation"] = "creation";
20
+ FrameKind["InternalCall"] = "internal_call";
21
+ })(FrameKind = exports.FrameKind || (exports.FrameKind = {}));
22
+ var DataLocationKind;
23
+ (function (DataLocationKind) {
24
+ DataLocationKind["Stack"] = "stack";
25
+ DataLocationKind["Memory"] = "memory";
26
+ DataLocationKind["Storage"] = "storage";
27
+ DataLocationKind["CallData"] = "calldata";
28
+ })(DataLocationKind = exports.DataLocationKind || (exports.DataLocationKind = {}));
29
+ // Helper functions
30
+ /**
31
+ * Give a stack or a stack frame, find the last **external** stack frame under it (include itself).
32
+ */
33
+ function lastExternalFrame(arg) {
34
+ const frame = arg instanceof Array ? arg[arg.length - 1] : arg;
35
+ return frame.kind === FrameKind.InternalCall ? frame.nearestExtFrame : frame;
36
+ }
37
+ exports.lastExternalFrame = lastExternalFrame;
38
+ function getContractInfo(arg) {
39
+ const frame = lastExternalFrame(arg);
40
+ return frame.info;
41
+ }
42
+ exports.getContractInfo = getContractInfo;
43
+ async function getStorage(manager, addr) {
44
+ const rawStorage = await manager.dumpStorage(addr);
45
+ const storageEntries = [];
46
+ for (const [keyStr, valStr] of Object.entries(rawStorage)) {
47
+ const valBuf = (0, __1.padStart)(ethereumjs_util_1.rlp.decode(Buffer.from(valStr, "hex")), 32, 0);
48
+ storageEntries.push([BigInt("0x" + keyStr), valBuf]);
49
+ }
50
+ return __1.ImmMap.fromEntries(storageEntries);
51
+ }
52
+ /**
53
+ * `SolTxDebugger` is the main debugger class. It contains a VM and a
54
+ * corresponding Web3 provider that can be used to run transactions on that VM.
55
+ *
56
+ * Once a particular transaction `tx` has been run against the vm, you can call
57
+ * `debugger.loadTx(tx)` to debug that transaction.
58
+ *
59
+ * `loadTx(tx)` walks over every step of the tx and computes the following information for it:
60
+ *
61
+ * 1. What is the currently deployed contract in which we are executing?
62
+ * 2. Did the `ArtifactManager` have debugging info for this contract? (src map? ast?)
63
+ * 3. If we have source map compute the corresponding src tripple for this instruction
64
+ * 4. If we have an ast, see if the src tripple of this instruction matches any node in the AST
65
+ * 5. If this is a LOGN instruction, extract the event payload and topics
66
+ * 6. Maintain a stack trace, containing all external and internal calls for
67
+ * this step. Note that we can compute internal stack frames only for contracts
68
+ * with debug info.
69
+ *
70
+ * All the above information is held for each step in the `DbgState` struct.
71
+ */
72
+ class SolTxDebugger {
73
+ constructor(artifactManager) {
74
+ this.artifactManager = artifactManager;
75
+ }
76
+ /**
77
+ * Given the VM state of a trace step adjust the stack trace accordingly. This handles the following cases:
78
+ *
79
+ * - op is CREATE or CREATE2 - push a new external frame for the creation context of the contract
80
+ * - op is CALL/CALLCODE/DELEGATECALL/STATICCALL - push a new external frame for the callee context
81
+ * - stack depth decreased and previous instruction was RETURN, REVERT or was in an error state - pop external frames from the stack
82
+ * - internal call - previous op is JUMPDEST and the source map of the current op is the begining of a new function - push a new internal call frame
83
+ * - return from internal call - TODO
84
+ */
85
+ async adjustStackFrame(stack, state, trace, code, codeHash) {
86
+ const lastExtFrame = lastExternalFrame(stack);
87
+ // First instruction - nothing to do
88
+ if (trace.length === 0) {
89
+ return;
90
+ }
91
+ const lastStep = trace[trace.length - 1];
92
+ const lastOp = lastStep.op;
93
+ // Case 1: Change in external call depth - contract creation, external call, external call return or revert
94
+ if (lastStep.depth !== state.depth) {
95
+ const lastStackTop = lastStep.evmStack.length - 1;
96
+ if (state.depth > lastStep.depth) {
97
+ (0, solc_typed_ast_1.assert)((0, opcodes_1.increasesDepth)(lastOp), `Unexpected depth increase on op ${lastOp.mnemonic}`);
98
+ if ((0, opcodes_1.createsContract)(lastOp)) {
99
+ // Contract creation call
100
+ const off = Number(lastStep.evmStack[lastStackTop - 1]);
101
+ const size = Number(lastStep.evmStack[lastStackTop - 2]);
102
+ const creationBytecode = lastStep.memory.slice(off, off + size);
103
+ const curFrame = await this.makeCreationFrame(lastExtFrame.address.toString(), creationBytecode, trace.length);
104
+ stack.push(curFrame);
105
+ }
106
+ else {
107
+ // External call
108
+ const argStackOff = lastOp.opcode === opcodes_1.OPCODES.CALL || lastOp.opcode === opcodes_1.OPCODES.CALLCODE
109
+ ? 3
110
+ : 2;
111
+ const argSizeStackOff = argStackOff + 1;
112
+ const argOff = Number(lastStep.evmStack[lastStackTop - argStackOff]);
113
+ const argSize = Number(lastStep.evmStack[lastStackTop - argSizeStackOff]);
114
+ const receiver = (0, __1.wordToAddress)(lastStep.evmStack[lastStackTop - 1]);
115
+ const msgData = lastStep.memory.slice(argOff, argOff + argSize);
116
+ const newFrame = await this.makeCallFrame(lastExtFrame.address.toString(), receiver, msgData, code, codeHash, trace.length);
117
+ stack.push(newFrame);
118
+ }
119
+ }
120
+ else {
121
+ // External return or exception
122
+ let nFramesPopped = lastStep.depth - state.depth;
123
+ // Pop as many external frames as neccessary to match the decrease in
124
+ // depth reported by web3. We need the loop since we don't count the internal frames as decreasing depth
125
+ while (nFramesPopped > 0 && stack.length > 0) {
126
+ const topFrame = stack[stack.length - 1];
127
+ if (topFrame.kind === FrameKind.Creation || topFrame.kind === FrameKind.Call) {
128
+ nFramesPopped--;
129
+ }
130
+ stack.pop();
131
+ }
132
+ }
133
+ return;
134
+ }
135
+ // Case 2: No change in external depth - check if there is an internal call or return happening
136
+ const curExtFrame = lastExternalFrame(stack);
137
+ const [src, ast] = this.decodeSourceLoc(state.pc, curExtFrame);
138
+ // If there is no debug info for the current contract nothing we can do
139
+ if (src === undefined) {
140
+ return;
141
+ }
142
+ // Jumping into an internal function call
143
+ if (state.op.mnemonic === "JUMPDEST" &&
144
+ lastStep.op.mnemonic === "JUMP" &&
145
+ lastStep.src &&
146
+ lastStep.src.jump === "i") {
147
+ let args;
148
+ if (ast instanceof solc_typed_ast_1.FunctionDefinition ||
149
+ (ast instanceof solc_typed_ast_1.VariableDeclaration && ast.stateVariable)) {
150
+ args = this.decodeFunArgs(ast, state.evmStack);
151
+ }
152
+ const newFrame = {
153
+ kind: FrameKind.InternalCall,
154
+ nearestExtFrame: lastExtFrame,
155
+ callee: ast,
156
+ offset: state.pc,
157
+ startStep: trace.length,
158
+ arguments: args
159
+ };
160
+ stack.push(newFrame);
161
+ return;
162
+ }
163
+ // Returning from an internal function call
164
+ if (state.op.mnemonic === "JUMP" && src.jump === "o") {
165
+ const topFrame = stack[stack.length - 1];
166
+ (0, solc_typed_ast_1.assert)(topFrame.kind === FrameKind.InternalCall, `Mismatched internal return from frame `, topFrame.kind);
167
+ stack.pop();
168
+ }
169
+ }
170
+ /**
171
+ * Get the executing code for the current step. There are 3 cases:
172
+ *
173
+ * 1. We just entered the creation of a new code (last step was
174
+ * CREATE/CREATE2 and depth changed). The code is whatever the memory blob
175
+ * passed to the last op was
176
+ * 2. This is the first step or the `codeAddress` changed between this and the last
177
+ * steps - obtain the code from the `vm.stateManager` using `codeAddress`.
178
+ * 3. Otherwise code is the same in the last step
179
+ * @param vm - current VM
180
+ * @param vmState - current (partial) state in the trace (for which we are computing code)
181
+ * @param trace - trace up to the current state
182
+ */
183
+ async getCodeAndMdHash(vm, step, trace) {
184
+ const lastStep = trace.length > 0 ? trace[trace.length - 1] : undefined;
185
+ let code;
186
+ let codeMdHash;
187
+ if (lastStep !== undefined && (0, opcodes_1.createsContract)(lastStep.op)) {
188
+ const lastStackTop = lastStep.evmStack.length - 1;
189
+ const off = Number(lastStep.evmStack[lastStackTop - 1]);
190
+ const size = Number(lastStep.evmStack[lastStackTop - 2]);
191
+ code = lastStep.memory.slice(off, off + size);
192
+ codeMdHash = (0, artifacts_1.getCreationCodeHash)(code);
193
+ }
194
+ else if (lastStep === undefined || !lastStep.codeAddress.equals(step.codeAddress)) {
195
+ code = await vm.stateManager.getContractCode(step.codeAddress);
196
+ codeMdHash = (0, artifacts_1.getCodeHash)(code);
197
+ }
198
+ else {
199
+ code = lastStep.code;
200
+ codeMdHash = lastStep.codeMdHash;
201
+ }
202
+ return [code, codeMdHash];
203
+ }
204
+ async processRawTraceStep(vm, step, trace, stack) {
205
+ const evmStack = step.stack.map((word) => Buffer.from(word.toArray("be", 32)));
206
+ const lastStep = trace.length > 0 ? trace[trace.length - 1] : undefined;
207
+ let memory;
208
+ if (lastStep === undefined || (0, opcodes_1.changesMemory)(lastStep.op)) {
209
+ memory = Buffer.from(step.memory);
210
+ }
211
+ else {
212
+ memory = lastStep.memory;
213
+ }
214
+ const op = (0, opcodes_1.getOpInfo)(step.opcode.name);
215
+ let storage;
216
+ if (lastStep === undefined || lastStep.op.opcode === opcodes_1.OPCODES.SSTORE) {
217
+ storage = await getStorage(step.stateManager, step.address);
218
+ }
219
+ else {
220
+ storage = lastStep.storage;
221
+ }
222
+ const gasCost = BigInt(step.opcode.fee);
223
+ const dynamicGasCost = step.opcode.dynamicFee === undefined ? gasCost : (0, __1.bnToBigInt)(step.opcode.dynamicFee);
224
+ // First translate the basic VM state
225
+ const vmState = {
226
+ evmStack,
227
+ memory,
228
+ storage,
229
+ op,
230
+ pc: step.pc,
231
+ gasCost,
232
+ dynamicGasCost,
233
+ gas: (0, __1.bnToBigInt)(step.gasLeft),
234
+ depth: step.depth + 1,
235
+ address: step.address,
236
+ codeAddress: step.codeAddress
237
+ };
238
+ const [code, codeMdHash] = await this.getCodeAndMdHash(vm, vmState, trace);
239
+ await this.adjustStackFrame(stack, vmState, trace, code, codeMdHash);
240
+ const curExtFrame = lastExternalFrame(stack);
241
+ let src;
242
+ let astNode;
243
+ try {
244
+ [src, astNode] = this.decodeSourceLoc(step.pc, curExtFrame);
245
+ }
246
+ catch (e) {
247
+ // Nothing to do
248
+ }
249
+ let emittedEvent = undefined;
250
+ // Finally check if an event is being emitted for this step
251
+ if (step.opcode.name.startsWith("LOG")) {
252
+ const off = Number(evmStack[evmStack.length - 1]);
253
+ const size = Number(evmStack[evmStack.length - 2]);
254
+ const nTopics = step.opcode.name[3] - "0";
255
+ const payload = memory.slice(off, off + size);
256
+ emittedEvent = {
257
+ payload,
258
+ topics: evmStack
259
+ .slice(evmStack.length - 2 - nTopics, evmStack.length - 2)
260
+ .reverse()
261
+ .map(__1.bigEndianBufToBigint)
262
+ };
263
+ }
264
+ return {
265
+ ...vmState,
266
+ code,
267
+ codeMdHash,
268
+ stack: [...stack],
269
+ src,
270
+ astNode,
271
+ emittedEvent,
272
+ contractInfo: curExtFrame.info
273
+ };
274
+ }
275
+ async debugTx(tx, block, stateManager) {
276
+ const vm = new vm_1.default({ stateManager });
277
+ const sender = tx.getSenderAddress().toString();
278
+ const receiver = tx.to === undefined ? __1.ZERO_ADDRESS_STRING : tx.to.toString();
279
+ const isCreation = receiver === __1.ZERO_ADDRESS_STRING;
280
+ const stack = [];
281
+ let curFrame;
282
+ if (isCreation) {
283
+ curFrame = await this.makeCreationFrame(sender, tx.data, 0);
284
+ }
285
+ else {
286
+ const code = await vm.stateManager.getContractCode(tx.to);
287
+ const codeHash = (0, artifacts_1.getCodeHash)(code);
288
+ curFrame = await this.makeCallFrame(sender, tx.to, tx.data, code, codeHash, 0);
289
+ }
290
+ stack.push(curFrame);
291
+ const trace = [];
292
+ vm.on("step", async (step, next) => {
293
+ const curStep = await this.processRawTraceStep(vm, step, trace, stack);
294
+ trace.push(curStep);
295
+ next();
296
+ });
297
+ const txRes = await vm.runTx({
298
+ tx,
299
+ block,
300
+ skipBalance: true,
301
+ skipNonce: true,
302
+ skipBlockGasLimitValidation: true
303
+ });
304
+ return [trace, txRes];
305
+ }
306
+ /**
307
+ * Build a `CreationFrame` from the given `sender` address, `data` `Buffer`(msg.data) and the current trace step number.
308
+ */
309
+ async makeCreationFrame(sender, data, step) {
310
+ const contractInfo = await this.artifactManager.getContractFromCreationBytecode(data);
311
+ let args;
312
+ const callee = contractInfo && contractInfo.ast ? contractInfo.ast.vConstructor : undefined;
313
+ if (contractInfo && callee instanceof solc_typed_ast_1.FunctionDefinition) {
314
+ // TODO: Try and find the arguments inside the creation code and decode them
315
+ }
316
+ return {
317
+ kind: FrameKind.Creation,
318
+ sender,
319
+ msgData: data,
320
+ creationCode: data,
321
+ info: contractInfo,
322
+ callee,
323
+ address: __1.ZERO_ADDRESS,
324
+ startStep: step,
325
+ arguments: args
326
+ };
327
+ }
328
+ /**
329
+ * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Buffer`, (msg.data) and the current trace step number.
330
+ */
331
+ async makeCallFrame(sender, receiver, data, receiverCode, codeHash, step) {
332
+ const contractInfo = codeHash === undefined
333
+ ? codeHash
334
+ : this.artifactManager.getContractFromMDHash(codeHash);
335
+ const selector = data.slice(0, 4).toString("hex");
336
+ let callee;
337
+ let args;
338
+ if (contractInfo && contractInfo.ast) {
339
+ const contract = contractInfo.ast;
340
+ const abiVersion = contractInfo.artifact.abiEncoderVersion;
341
+ const matchingFuns = contract.vFunctions.filter((fun) => (0, __1.getFunctionSelector)(fun) === selector);
342
+ if (matchingFuns.length === 1) {
343
+ callee = matchingFuns[0];
344
+ }
345
+ else {
346
+ const matchingGetters = contract.vStateVariables.filter((vDef) => {
347
+ try {
348
+ return (vDef.visibility === solc_typed_ast_1.StateVariableVisibility.Public &&
349
+ vDef.getterCanonicalSignatureHash(abiVersion) === selector);
350
+ }
351
+ catch (e) {
352
+ return false;
353
+ }
354
+ });
355
+ if (matchingGetters.length === 1) {
356
+ callee = matchingGetters[0];
357
+ }
358
+ }
359
+ if (callee !== undefined) {
360
+ try {
361
+ args = (0, abi_1.decodeMsgData)(callee, data, DataLocationKind.CallData, abiVersion);
362
+ }
363
+ catch (e) {
364
+ args = undefined;
365
+ }
366
+ }
367
+ }
368
+ return {
369
+ kind: FrameKind.Call,
370
+ sender,
371
+ msgData: data,
372
+ receiver: receiver.toString(),
373
+ code: receiverCode,
374
+ info: contractInfo,
375
+ callee,
376
+ address: receiver,
377
+ startStep: step,
378
+ arguments: args
379
+ };
380
+ }
381
+ /**
382
+ * Helper function to get the source information for the instruction at a given `instrOffset`,
383
+ * in the context of the external call `ctx`.
384
+ *
385
+ * There are several cases this handles:
386
+ *
387
+ * 1. If there is no debug info for the contract executing in `ctx` return undefined
388
+ * 2. If there is debug info, but no AST return only the decoded bytecode sourcemap entry
389
+ * 3. If there is both debug info and an AST return the decoded source location and any AST nodes that match this location
390
+ */
391
+ decodeSourceLoc(instrOffset, ctx) {
392
+ if (!ctx.info) {
393
+ return [undefined, undefined];
394
+ }
395
+ const bytecodeInfo = ctx.kind === FrameKind.Creation ? ctx.info.bytecode : ctx.info.deployedBytecode;
396
+ const src = (0, artifact_manager_1.getOffsetSrc)(instrOffset, bytecodeInfo);
397
+ const astNode = ctx.info.artifact.srcMap.get(`${src.start}:${src.length}:${src.sourceIndex}`);
398
+ return [src, astNode];
399
+ }
400
+ /**
401
+ * WIP: TODO document
402
+ * TODO: Rename - this function doesn't do any actual decoding - just building up DataView for the arguments
403
+ * of a function
404
+ */
405
+ decodeFunArgs(callee, stack) {
406
+ const res = [];
407
+ let formals;
408
+ try {
409
+ formals =
410
+ callee instanceof solc_typed_ast_1.FunctionDefinition
411
+ ? callee.vParameters.vParameters.map((argDef) => [
412
+ argDef.name,
413
+ (0, solc_typed_ast_1.variableDeclarationToTypeNode)(argDef)
414
+ ])
415
+ : callee.getterArgsAndReturn()[0].map((typ, i) => [`ARG_${i}`, typ]);
416
+ }
417
+ catch (e) {
418
+ // `variableDeclarationToTypeNode` may fail when referencing structs/contracts that are defined
419
+ // in SourceUnits that are missing
420
+ return undefined;
421
+ }
422
+ let offsetFromTop = -1;
423
+ for (let i = formals.length - 1; i >= 0; i--) {
424
+ const [name, typ] = formals[i];
425
+ const stackSize = (0, decoding_1.isCalldataType2Slots)(typ) ? 2 : 1;
426
+ offsetFromTop += stackSize;
427
+ (0, solc_typed_ast_1.assert)(offsetFromTop <= stack.length, `Stack underflow when trying to decode arguments of {0}`, callee, `Expected ${formals.length} entries but stack is only ${stack.length} deep`);
428
+ res.unshift([
429
+ name,
430
+ {
431
+ type: typ,
432
+ loc: {
433
+ kind: DataLocationKind.Stack,
434
+ offsetFromTop
435
+ }
436
+ }
437
+ ]);
438
+ }
439
+ return res;
440
+ }
441
+ }
442
+ exports.SolTxDebugger = SolTxDebugger;
443
+ //# sourceMappingURL=sol_debugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sol_debugger.js","sourceRoot":"","sources":["../../src/debug/sol_debugger.ts"],"names":[],"mappings":";;;;;;AAEA,wDAAgC;AAIhC,qDAA+C;AAC/C,mDAQwB;AACxB,0BAYY;AACZ,4CAAgE;AAChE,+BAAsC;AACtC,yDAAkF;AAClF,yCAAkD;AAClD,uCAOmB;AAEnB,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,0BAAa,CAAA;IACb,kCAAqB,CAAA;IACrB,2CAA8B,CAAA;AAClC,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB;AA+DD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,mCAAe,CAAA;IACf,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,yCAAqB,CAAA;AACzB,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,Q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GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1C,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,SAAS,GAAG,IAAA,+BAAoB,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAEpD,aAAa,IAAI,SAAS,CAAC;YAE3B,IAAA,uBAAM,EACF,aAAa,IAAI,KAAK,CAAC,MAAM,EAC7B,wDAAwD,EACxD,MAAM,EACN,YAAY,OAAO,CAAC,MAAM,8BAA8B,KAAK,CAAC,MAAM,OAAO,CAC9E,CAAC;YAEF,GAAG,CAAC,OAAO,CAAC;gBACR,IAAI;gBACJ;oBACI,IAAI,EAAE,GAAG;oBACT,GAAG,EAAE;wBACD,IAAI,EAAE,gBAAgB,CAAC,KAAK;wBAC5B,aAAa;qBAChB;iBACJ;aACJ,CAAC,CAAC;SACN;QAED,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAvgBD,sCAugBC"}
@@ -0,0 +1,33 @@
1
+ import { FunctionDefinition } from "solc-typed-ast";
2
+ import { HexString, UnprefixedHexString } from "../artifacts";
3
+ import { ContractInfo } from "./artifact_manager";
4
+ export interface DeployedContractInfo {
5
+ address: HexString;
6
+ code: UnprefixedHexString;
7
+ info?: ContractInfo;
8
+ }
9
+ export interface UnknownLocation {
10
+ contract: DeployedContractInfo | undefined;
11
+ }
12
+ export interface SolLocation {
13
+ contract: DeployedContractInfo | undefined;
14
+ start: number;
15
+ length: number;
16
+ jump: "o" | "i" | "-";
17
+ file: number;
18
+ }
19
+ export declare type DecodedSolValue = {
20
+ value: any;
21
+ type: string;
22
+ };
23
+ export interface StackFrame {
24
+ fun: FunctionDefinition;
25
+ argumentsAtStart: {
26
+ [argName: string]: DecodedSolValue;
27
+ };
28
+ argsAndLocals: {
29
+ [varName: string]: DecodedSolValue;
30
+ };
31
+ }
32
+ export declare type StackTrace = StackFrame[];
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/debug/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC9C;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,eAAe,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,MAAM,WAAW,UAAU;IACvB,GAAG,EAAE,kBAAkB,CAAC;IACxB,gBAAgB,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;IACzD,aAAa,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;CACzD;AAED,oBAAY,UAAU,GAAG,UAAU,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/debug/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from "./artifacts";
2
+ export * from "./debug";
3
+ export * from "./utils";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./artifacts"), exports);
18
+ __exportStar(require("./debug"), exports);
19
+ __exportStar(require("./utils"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAwB"}
@@ -0,0 +1,13 @@
1
+ export declare class ImmMap<KeyT, ValT> {
2
+ private innerM;
3
+ private _next;
4
+ static fromEntries<K, V>(arg: Iterable<[K, V]>): ImmMap<K, V>;
5
+ static fromImmMap<K, V>(arg: ImmMap<K, V>): ImmMap<K, V>;
6
+ private constructor();
7
+ get(key: KeyT): ValT | undefined;
8
+ set(key: KeyT, val: ValT): this;
9
+ setMany(entries: Iterable<[KeyT, ValT]>): this;
10
+ private collectMap;
11
+ entries(): Iterable<[KeyT, ValT]>;
12
+ }
13
+ //# sourceMappingURL=immutable_map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immutable_map.d.ts","sourceRoot":"","sources":["../../src/utils/immutable_map.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM,CAAC,IAAI,EAAE,IAAI;IAC1B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAAmB;IAEhC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAU7D,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAIxD,OAAO;IAKP,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS;IAkBhC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI;IAQ/B,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI;IAU9C,OAAO,CAAC,UAAU;IAUlB,OAAO,IAAI,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;CAGpC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImmMap = void 0;
4
+ class ImmMap {
5
+ constructor(next = undefined) {
6
+ this.innerM = new Map();
7
+ this._next = next;
8
+ }
9
+ static fromEntries(arg) {
10
+ const res = new ImmMap(undefined);
11
+ for (const [k, v] of arg) {
12
+ res.innerM.set(k, v);
13
+ }
14
+ return res;
15
+ }
16
+ static fromImmMap(arg) {
17
+ return new ImmMap(arg);
18
+ }
19
+ get(key) {
20
+ if (this.innerM.has(key)) {
21
+ return this.innerM.get(key);
22
+ }
23
+ if (this._next === undefined) {
24
+ return undefined;
25
+ }
26
+ const resInNext = this._next.get(key);
27
+ if (resInNext !== undefined) {
28
+ this.innerM.set(key, resInNext);
29
+ }
30
+ return resInNext;
31
+ }
32
+ set(key, val) {
33
+ const newMap = new ImmMap(this);
34
+ newMap.innerM.set(key, val);
35
+ return newMap;
36
+ }
37
+ setMany(entries) {
38
+ const newMap = new ImmMap(this);
39
+ for (const [key, val] of entries) {
40
+ newMap.innerM.set(key, val);
41
+ }
42
+ return newMap;
43
+ }
44
+ collectMap() {
45
+ const res = this._next ? this._next.collectMap() : new Map();
46
+ for (const [key, val] of this.innerM) {
47
+ res.set(key, val);
48
+ }
49
+ return res;
50
+ }
51
+ entries() {
52
+ return this.collectMap();
53
+ }
54
+ }
55
+ exports.ImmMap = ImmMap;
56
+ //# sourceMappingURL=immutable_map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immutable_map.js","sourceRoot":"","sources":["../../src/utils/immutable_map.ts"],"names":[],"mappings":";;;AAAA,MAAa,MAAM;IAkBf,YAAoB,OAAY,SAAS;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAjBD,MAAM,CAAC,WAAW,CAAO,GAAqB;QAC1C,MAAM,GAAG,GAAG,IAAI,MAAM,CAAO,SAAS,CAAC,CAAC;QAExC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE;YACtB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACxB;QAED,OAAO,GAAG,CAAC;IACf,C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AAG,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;YAClC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACrB;QAED,OAAO,GAAG,CAAC;IACf,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;CACJ;AAxED,wBAwEC"}
@@ -0,0 +1,4 @@
1
+ export * from "./misc";
2
+ export * from "./srcmap";
3
+ export * from "./immutable_map";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./misc"), exports);
18
+ __exportStar(require("./srcmap"), exports);
19
+ __exportStar(require("./immutable_map"), exports);
20
+ //# sourceMappingURL=index.js.map