sol-dbg 0.4.2 → 0.6.1

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 (101) hide show
  1. package/dist/debug/decoding/general.d.ts +2 -1
  2. package/dist/debug/decoding/general.d.ts.map +1 -1
  3. package/dist/debug/decoding/general.js +8 -7
  4. package/dist/debug/decoding/general.js.map +1 -1
  5. package/dist/debug/decoding/storage.d.ts +6 -3
  6. package/dist/debug/decoding/storage.d.ts.map +1 -1
  7. package/dist/debug/decoding/storage.js +73 -13
  8. package/dist/debug/decoding/storage.js.map +1 -1
  9. package/dist/debug/foundry_cheatcodes.d.ts +2 -1
  10. package/dist/debug/foundry_cheatcodes.d.ts.map +1 -1
  11. package/dist/debug/foundry_cheatcodes.js +4 -0
  12. package/dist/debug/foundry_cheatcodes.js.map +1 -1
  13. package/dist/debug/index.d.ts +2 -1
  14. package/dist/debug/index.d.ts.map +1 -1
  15. package/dist/debug/index.js +2 -1
  16. package/dist/debug/index.js.map +1 -1
  17. package/dist/debug/layout.d.ts +9 -0
  18. package/dist/debug/layout.d.ts.map +1 -0
  19. package/dist/debug/layout.js +80 -0
  20. package/dist/debug/layout.js.map +1 -0
  21. package/dist/debug/tracers/base_tracer.d.ts +33 -0
  22. package/dist/debug/tracers/base_tracer.d.ts.map +1 -0
  23. package/dist/debug/tracers/base_tracer.js +118 -0
  24. package/dist/debug/tracers/base_tracer.js.map +1 -0
  25. package/dist/debug/tracers/index.d.ts +5 -0
  26. package/dist/debug/tracers/index.d.ts.map +1 -0
  27. package/dist/debug/tracers/index.js +21 -0
  28. package/dist/debug/tracers/index.js.map +1 -0
  29. package/dist/debug/tracers/sol_debugger.d.ts +9 -0
  30. package/dist/debug/tracers/sol_debugger.d.ts.map +1 -0
  31. package/dist/debug/tracers/sol_debugger.js +22 -0
  32. package/dist/debug/tracers/sol_debugger.js.map +1 -0
  33. package/dist/debug/tracers/support_tracer.d.ts +15 -0
  34. package/dist/debug/tracers/support_tracer.d.ts.map +1 -0
  35. package/dist/debug/tracers/support_tracer.js +22 -0
  36. package/dist/debug/tracers/support_tracer.js.map +1 -0
  37. package/dist/debug/tracers/transformers/basic_info.d.ts +25 -0
  38. package/dist/debug/tracers/transformers/basic_info.d.ts.map +1 -0
  39. package/dist/debug/tracers/transformers/basic_info.js +54 -0
  40. package/dist/debug/tracers/transformers/basic_info.js.map +1 -0
  41. package/dist/debug/tracers/transformers/contract_lifetime.d.ts +21 -0
  42. package/dist/debug/tracers/transformers/contract_lifetime.d.ts.map +1 -0
  43. package/dist/debug/tracers/transformers/contract_lifetime.js +70 -0
  44. package/dist/debug/tracers/transformers/contract_lifetime.js.map +1 -0
  45. package/dist/debug/tracers/transformers/events.d.ts +12 -0
  46. package/dist/debug/tracers/transformers/events.d.ts.map +1 -0
  47. package/dist/debug/tracers/transformers/events.js +30 -0
  48. package/dist/debug/tracers/transformers/events.js.map +1 -0
  49. package/dist/debug/tracers/transformers/ext_stack.d.ts +17 -0
  50. package/dist/debug/tracers/transformers/ext_stack.d.ts.map +1 -0
  51. package/dist/debug/tracers/transformers/ext_stack.js +200 -0
  52. package/dist/debug/tracers/transformers/ext_stack.js.map +1 -0
  53. package/dist/debug/tracers/transformers/index.d.ts +12 -0
  54. package/dist/debug/tracers/transformers/index.d.ts.map +1 -0
  55. package/dist/debug/tracers/transformers/index.js +25 -0
  56. package/dist/debug/tracers/transformers/index.js.map +1 -0
  57. package/dist/debug/tracers/transformers/int_stack.d.ts +13 -0
  58. package/dist/debug/tracers/transformers/int_stack.d.ts.map +1 -0
  59. package/dist/debug/tracers/transformers/int_stack.js +139 -0
  60. package/dist/debug/tracers/transformers/int_stack.js.map +1 -0
  61. package/dist/debug/tracers/transformers/keccak256_invert.d.ts +29 -0
  62. package/dist/debug/tracers/transformers/keccak256_invert.d.ts.map +1 -0
  63. package/dist/debug/tracers/transformers/keccak256_invert.js +65 -0
  64. package/dist/debug/tracers/transformers/keccak256_invert.js.map +1 -0
  65. package/dist/debug/tracers/transformers/op.d.ts +11 -0
  66. package/dist/debug/tracers/transformers/op.d.ts.map +1 -0
  67. package/dist/debug/tracers/transformers/op.js +11 -0
  68. package/dist/debug/tracers/transformers/op.js.map +1 -0
  69. package/dist/debug/tracers/transformers/source.d.ts +26 -0
  70. package/dist/debug/tracers/transformers/source.d.ts.map +1 -0
  71. package/dist/debug/tracers/transformers/source.js +38 -0
  72. package/dist/debug/tracers/transformers/source.js.map +1 -0
  73. package/dist/debug/types.d.ts +3 -6
  74. package/dist/debug/types.d.ts.map +1 -1
  75. package/dist/debug/types.js +8 -0
  76. package/dist/debug/types.js.map +1 -1
  77. package/dist/utils/index.d.ts +2 -0
  78. package/dist/utils/index.d.ts.map +1 -1
  79. package/dist/utils/index.js +2 -0
  80. package/dist/utils/index.js.map +1 -1
  81. package/dist/utils/map.d.ts +5 -0
  82. package/dist/utils/map.d.ts.map +1 -0
  83. package/dist/utils/map.js +12 -0
  84. package/dist/utils/map.js.map +1 -0
  85. package/dist/utils/pp.d.ts +4 -2
  86. package/dist/utils/pp.d.ts.map +1 -1
  87. package/dist/utils/pp.js +22 -10
  88. package/dist/utils/pp.js.map +1 -1
  89. package/dist/utils/set.d.ts +9 -0
  90. package/dist/utils/set.d.ts.map +1 -0
  91. package/dist/utils/set.js +21 -0
  92. package/dist/utils/set.js.map +1 -0
  93. package/dist/utils/test_runner.d.ts +22 -10
  94. package/dist/utils/test_runner.d.ts.map +1 -1
  95. package/dist/utils/test_runner.js +73 -33
  96. package/dist/utils/test_runner.js.map +1 -1
  97. package/package.json +1 -1
  98. package/dist/debug/sol_debugger.d.ts +0 -107
  99. package/dist/debug/sol_debugger.d.ts.map +0 -1
  100. package/dist/debug/sol_debugger.js +0 -521
  101. package/dist/debug/sol_debugger.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"test_runner.js","sourceRoot":"","sources":["../../src/utils/test_runner.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,+CAAwE;AAGx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AG,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAA,uBAAM,EAAC,GAAG,KAAK,SAAS,EAAE,kCAAkC,MAAM,EAAE,CAAC,CAAC;QAEtE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,QAAQ,CAAC,EAAoB;QACzB,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAExC,IAAA,uBAAM,EAAC,GAAG,KAAK,SAAS,EAAE,+BAA+B,MAAM,EAAE,CAAC,CAAC;QAEnE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,kBAAkB,CAAC,EAAoB;QACnC,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAA,uBAAM,EAAC,GAAG,KAAK,SAAS,EAAE,mCAAmC,MAAM,EAAE,CAAC,CAAC;QAEvE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,wBAAwB,CAAC,EAAoB;QACzC,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEtD,IAAA,uBAAM,EAAC,GAAG,KAAK,SAAS,EAAE,0CAA0C,MAAM,EAAE,CAAC,CAAC;QAE9E,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AA9MD,oCA8MC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol-dbg",
3
- "version": "0.4.2",
3
+ "version": "0.6.1",
4
4
  "description": "Small (experimental) Solidity-level debugger built around EthereumJS",
5
5
  "keywords": [],
6
6
  "files": [
@@ -1,107 +0,0 @@
1
- import { Block } from "@ethereumjs/block";
2
- import { EVMStateManagerInterface } from "@ethereumjs/common";
3
- import { InterpreterStep } from "@ethereumjs/evm";
4
- import { TypedTransaction } from "@ethereumjs/tx";
5
- import { RunTxResult, VM } from "@ethereumjs/vm";
6
- import { ASTNode } from "solc-typed-ast";
7
- import { DecodedBytecodeSourceMapEntry } from "..";
8
- import { ContractInfo, IArtifactManager } from "./artifact_manager";
9
- import { DbgStack, ExternalFrame, Frame, StepState } from "./types";
10
- /**
11
- * Give a stack or a stack frame, find the last **external** stack frame under it (include itself).
12
- */
13
- export declare function lastExternalFrame(arg: Frame | DbgStack): ExternalFrame;
14
- export declare function getContractInfo(arg: Frame | DbgStack): ContractInfo | undefined;
15
- export interface SolTxDebuggerOpts {
16
- strict?: boolean;
17
- foundryCheatcodes?: boolean;
18
- }
19
- /**
20
- * `SolTxDebugger` is the main debugger class. It contains a VM and a
21
- * corresponding Web3 provider that can be used to run transactions on that VM.
22
- *
23
- * Once a particular transaction `tx` has been run against the vm, you can call
24
- * `debugger.loadTx(tx)` to debug that transaction.
25
- *
26
- * `loadTx(tx)` walks over every step of the tx and computes the following information for it:
27
- *
28
- * 1. What is the currently deployed contract in which we are executing?
29
- * 2. Did the `ArtifactManager` have debugging info for this contract? (src map? ast?)
30
- * 3. If we have source map compute the corresponding src tripple for this instruction
31
- * 4. If we have an ast, see if the src tripple of this instruction matches any node in the AST
32
- * 5. If this is a LOGN instruction, extract the event payload and topics
33
- * 6. Maintain a stack trace, containing all external and internal calls for
34
- * this step. Note that we can compute internal stack frames only for contracts
35
- * with debug info.
36
- *
37
- * All the above information is held for each step in the `DbgState` struct.
38
- */
39
- export declare class SolTxDebugger {
40
- readonly artifactManager: IArtifactManager;
41
- private readonly strict;
42
- private readonly foundryCheatcodes;
43
- constructor(artifactManager: IArtifactManager, opts?: SolTxDebuggerOpts);
44
- /**
45
- * Decode a *CALL* instruction. Computes:
46
- * 1. The receiver address
47
- * 2. The code address
48
- * 3. The msg.data
49
- * @param step
50
- */
51
- private decodeCall;
52
- /**
53
- * Given the VM state of a trace step adjust the stack trace accordingly. This handles the following cases:
54
- *
55
- * - op is CREATE or CREATE2 - push a new external frame for the creation context of the contract
56
- * - op is CALL/CALLCODE/DELEGATECALL/STATICCALL - push a new external frame for the callee context
57
- * - stack depth decreased and previous instruction was RETURN, REVERT or was in an error state - pop external frames from the stack
58
- * - 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
59
- * - return from internal call - pop the last frame
60
- */
61
- private adjustStackFrame;
62
- processRawTraceStep(vm: VM, stateManager: EVMStateManagerInterface, step: InterpreterStep, trace: StepState[], stack: Frame[]): Promise<StepState>;
63
- private static getEVM;
64
- /**
65
- * Releases references to the EVM stored inside VM from the
66
- * `interpRunListeners` map. This avoids memory leaks when repeatedly
67
- * calling the debugger on different transactions. Should be called once
68
- * for every vm created by `SolTxDebugger.createVm` after its done being
69
- * used.
70
- */
71
- static releaseVM(vm: VM): void;
72
- static createVm(stateManager: EVMStateManagerInterface | undefined, foundryCheatcodes: boolean): Promise<VM>;
73
- debugTx(tx: TypedTransaction, block: Block | undefined, stateManager: EVMStateManagerInterface): Promise<[StepState[], RunTxResult]>;
74
- /**
75
- * Build a `CreationFrame` from the given `sender` address, `data` `Uint8Array`(msg.data) and the current trace step number.
76
- */
77
- private makeCreationFrame;
78
- /**
79
- * Given a contract info and a function selector find the (potentially inherited) entry point (function or public var getter).
80
- * @param info
81
- * @param selector
82
- * @returns
83
- */
84
- private findEntryPoint;
85
- /**
86
- * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Uint8Array`, (msg.data) and the current trace step number.
87
- */
88
- private makeCallFrame;
89
- /**
90
- * Helper function to get the source information for the instruction at a given `instrOffset`,
91
- * in the context of the external call `ctx`.
92
- *
93
- * There are several cases this handles:
94
- *
95
- * 1. If there is no debug info for the contract executing in `ctx` return undefined
96
- * 2. If there is debug info, but no AST return only the decoded bytecode sourcemap entry
97
- * 3. If there is both debug info and an AST return the decoded source location and any AST nodes that match this location
98
- */
99
- decodeSourceLoc(instrOffset: number, ctx: ExternalFrame): [DecodedBytecodeSourceMapEntry | undefined, ASTNode | undefined];
100
- /**
101
- * WIP: TODO document
102
- * TODO: Rename - this function doesn't do any actual decoding - just building up DataView for the arguments
103
- * of a function
104
- */
105
- private decodeFunArgs;
106
- }
107
- //# sourceMappingURL=sol_debugger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sol_debugger.d.ts","sourceRoot":"","sources":["../../src/debug/sol_debugger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAiB,wBAAwB,EAAY,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAO,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAA6D,MAAM,gBAAgB,CAAC;AACpG,OAAO,EACH,6BAA6B,EAQhC,MAAM,IAAI,CAAC;AAIZ,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAgB,MAAM,oBAAoB,CAAC;AASlF,OAAO,EAKH,QAAQ,EAGR,aAAa,EACb,KAAK,EAKL,SAAS,EAGZ,MAAM,SAAS,CAAC;AAIjB;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,KAAK,GAAG,QAAQ,GAAG,aAAa,CAItE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,CAI/E;AAiBD,MAAM,WAAW,iBAAiB;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAQD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAa;IAEtB,SAAgB,eAAe,EAAE,gBAAgB,CAAC;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAU;gBAEhC,eAAe,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,iBAAiB;IAgBvE;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IA0BlB;;;;;;;;OAQG;YACW,gBAAgB;IA8JxB,mBAAmB,CACrB,EAAE,EAAE,EAAE,EACN,YAAY,EAAE,wBAAwB,EACtC,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,SAAS,EAAE,EAClB,KAAK,EAAE,KAAK,EAAE,GACf,OAAO,CAAC,SAAS,CAAC;mBAgFA,MAAM;IA8B3B;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI;WAUjB,QAAQ,CACjB,YAAY,EAAE,wBAAwB,GAAG,SAAS,EAClD,iBAAiB,EAAE,OAAO,GAC3B,OAAO,CAAC,EAAE,CAAC;IA0BR,OAAO,CACT,EAAE,EAAE,gBAAgB,EACpB,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,YAAY,EAAE,wBAAwB,GACvC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,WAAW,CAAC,CAAC;IA2DtC;;OAEG;YACW,iBAAiB;IA2B/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IActB;;OAEG;YACW,aAAa;IAwD3B;;;;;;;;;OASG;IACH,eAAe,CACX,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,aAAa,GACnB,CAAC,6BAA6B,GAAG,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;IAiBnE;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAoDxB"}
@@ -1,521 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolTxDebugger = void 0;
4
- exports.lastExternalFrame = lastExternalFrame;
5
- exports.getContractInfo = getContractInfo;
6
- const blockchain_1 = require("@ethereumjs/blockchain");
7
- const common_1 = require("@ethereumjs/common");
8
- const evm_1 = require("@ethereumjs/evm");
9
- const rlp_1 = require("@ethereumjs/rlp");
10
- const statemanager_1 = require("@ethereumjs/statemanager");
11
- const util_1 = require("@ethereumjs/util");
12
- const vm_1 = require("@ethereumjs/vm");
13
- const utils_1 = require("ethereum-cryptography/utils");
14
- const solc_typed_ast_1 = require("solc-typed-ast");
15
- const __1 = require("..");
16
- const artifacts_1 = require("../artifacts");
17
- const utils_2 = require("../utils");
18
- const abi_1 = require("./abi");
19
- const artifact_manager_1 = require("./artifact_manager");
20
- const decoding_1 = require("./decoding");
21
- const foundry_cheatcodes_1 = require("./foundry_cheatcodes");
22
- const opcode_interposing_1 = require("./opcode_interposing");
23
- const opcodes_1 = require("./opcodes");
24
- const types_1 = require("./types");
25
- // Helper functions
26
- /**
27
- * Give a stack or a stack frame, find the last **external** stack frame under it (include itself).
28
- */
29
- function lastExternalFrame(arg) {
30
- const frame = arg instanceof Array ? arg[arg.length - 1] : arg;
31
- return frame.kind === types_1.FrameKind.InternalCall ? frame.nearestExtFrame : frame;
32
- }
33
- function getContractInfo(arg) {
34
- const frame = lastExternalFrame(arg);
35
- return frame.info;
36
- }
37
- async function getStorage(manager, addr) {
38
- const rawStorage = await manager.dumpStorage(addr);
39
- const storageEntries = [];
40
- for (const [keyStr, valStr] of Object.entries(rawStorage)) {
41
- const decoded = rlp_1.RLP.decode((0, utils_1.hexToBytes)(valStr));
42
- (0, solc_typed_ast_1.assert)(decoded instanceof Uint8Array, "");
43
- const valBuf = (0, util_1.setLengthLeft)(decoded, 32);
44
- storageEntries.push([BigInt(keyStr), valBuf]);
45
- }
46
- return __1.ImmMap.fromEntries(storageEntries);
47
- }
48
- /**
49
- * Private map tracking VM-to-EVM mapping, used when releasing EVMs from the
50
- * global listener map for foundry cheatcodes.
51
- */
52
- const vmToEVMMap = new Map();
53
- /**
54
- * `SolTxDebugger` is the main debugger class. It contains a VM and a
55
- * corresponding Web3 provider that can be used to run transactions on that VM.
56
- *
57
- * Once a particular transaction `tx` has been run against the vm, you can call
58
- * `debugger.loadTx(tx)` to debug that transaction.
59
- *
60
- * `loadTx(tx)` walks over every step of the tx and computes the following information for it:
61
- *
62
- * 1. What is the currently deployed contract in which we are executing?
63
- * 2. Did the `ArtifactManager` have debugging info for this contract? (src map? ast?)
64
- * 3. If we have source map compute the corresponding src tripple for this instruction
65
- * 4. If we have an ast, see if the src tripple of this instruction matches any node in the AST
66
- * 5. If this is a LOGN instruction, extract the event payload and topics
67
- * 6. Maintain a stack trace, containing all external and internal calls for
68
- * this step. Note that we can compute internal stack frames only for contracts
69
- * with debug info.
70
- *
71
- * All the above information is held for each step in the `DbgState` struct.
72
- */
73
- class SolTxDebugger {
74
- constructor(artifactManager, opts) {
75
- this.artifactManager = artifactManager;
76
- this.strict = true;
77
- this.foundryCheatcodes = false;
78
- if (opts) {
79
- this.strict = opts.strict !== undefined ? opts.strict : this.strict;
80
- this.foundryCheatcodes =
81
- opts.foundryCheatcodes !== undefined
82
- ? opts.foundryCheatcodes
83
- : this.foundryCheatcodes;
84
- }
85
- }
86
- /**
87
- * Decode a *CALL* instruction. Computes:
88
- * 1. The receiver address
89
- * 2. The code address
90
- * 3. The msg.data
91
- * @param step
92
- */
93
- decodeCall(step) {
94
- const op = step.op;
95
- (0, solc_typed_ast_1.assert)(op.opcode === opcodes_1.OPCODES.CALL ||
96
- op.opcode === opcodes_1.OPCODES.CALLCODE ||
97
- op.opcode === opcodes_1.OPCODES.DELEGATECALL ||
98
- op.opcode === opcodes_1.OPCODES.STATICCALL, `Unexpected call instruction {0}`, op.mnemonic);
99
- const stackTop = step.evmStack.length - 1;
100
- const argStackOff = op.opcode === opcodes_1.OPCODES.CALL || op.opcode === opcodes_1.OPCODES.CALLCODE ? 3 : 2;
101
- const argSizeStackOff = argStackOff + 1;
102
- const receiverArg = (0, __1.wordToAddress)(step.evmStack[stackTop - 1]);
103
- const argOff = (0, utils_2.bigEndianBufToNumber)(step.evmStack[stackTop - argStackOff]);
104
- const argSize = (0, utils_2.bigEndianBufToNumber)(step.evmStack[stackTop - argSizeStackOff]);
105
- const receiver = op.opcode === opcodes_1.OPCODES.DELEGATECALL ? step.address : receiverArg;
106
- const codeAddr = receiverArg;
107
- const msgData = step.memory.slice(argOff, argOff + argSize);
108
- return [receiver, codeAddr, msgData];
109
- }
110
- /**
111
- * Given the VM state of a trace step adjust the stack trace accordingly. This handles the following cases:
112
- *
113
- * - op is CREATE or CREATE2 - push a new external frame for the creation context of the contract
114
- * - op is CALL/CALLCODE/DELEGATECALL/STATICCALL - push a new external frame for the callee context
115
- * - stack depth decreased and previous instruction was RETURN, REVERT or was in an error state - pop external frames from the stack
116
- * - 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
117
- * - return from internal call - pop the last frame
118
- */
119
- async adjustStackFrame(vm, stack, state, trace) {
120
- const lastExtFrame = lastExternalFrame(stack);
121
- // First instruction - nothing to do
122
- if (trace.length === 0) {
123
- return;
124
- }
125
- const lastStep = trace[trace.length - 1];
126
- const lastOp = lastStep.op;
127
- // Case 1: Change in external call depth - contract creation, external call, external call return or revert
128
- if (lastStep.depth !== state.depth) {
129
- const lastStackTop = lastStep.evmStack.length - 1;
130
- if (state.depth > lastStep.depth) {
131
- (0, solc_typed_ast_1.assert)((0, opcodes_1.increasesDepth)(lastOp), `Unexpected depth increase on op ${lastOp.mnemonic}`);
132
- if ((0, opcodes_1.createsContract)(lastOp)) {
133
- // Contract creation call
134
- const off = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 1]);
135
- const size = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 2]);
136
- const creationBytecode = lastStep.memory.slice(off, off + size);
137
- const curFrame = await this.makeCreationFrame(lastExtFrame.address, creationBytecode, trace.length);
138
- stack.push(curFrame);
139
- }
140
- else {
141
- const [receiver, codeAddr, msgData] = this.decodeCall(lastStep);
142
- const code = await vm.stateManager.getContractCode(codeAddr);
143
- const codeHash = (0, artifacts_1.getCodeHash)(code);
144
- const newFrame = await this.makeCallFrame(lastExtFrame.address, receiver, codeAddr, msgData, code, codeHash, trace.length);
145
- stack.push(newFrame);
146
- }
147
- }
148
- else {
149
- // External return or exception
150
- let nFramesPopped = lastStep.depth - state.depth;
151
- // Pop as many external frames as neccessary to match the decrease in
152
- // depth reported by web3. We need the loop since we don't count the internal frames as decreasing depth
153
- while (nFramesPopped > 0 && stack.length > 0) {
154
- const topFrame = stack[stack.length - 1];
155
- if (topFrame.kind === types_1.FrameKind.Creation || topFrame.kind === types_1.FrameKind.Call) {
156
- nFramesPopped--;
157
- }
158
- stack.pop();
159
- }
160
- }
161
- return;
162
- }
163
- // Case 2: No change in external depth - check if there is an internal call or return happening
164
- const curExtFrame = lastExternalFrame(stack);
165
- const [src, ast] = this.decodeSourceLoc(state.pc, curExtFrame);
166
- // If there is no debug info for the current contract nothing we can do
167
- if (src === undefined) {
168
- return;
169
- }
170
- // There are 2 ways to enter an internal function:
171
- let enteringInternalFun = false;
172
- // 1. Jumping into an internal function (the previous instruction is a JUMP with source map jump index i)
173
- if (state.op.mnemonic === "JUMPDEST" &&
174
- lastStep.op.mnemonic === "JUMP" &&
175
- lastStep.src &&
176
- lastStep.src.jump === "i") {
177
- enteringInternalFun = true;
178
- }
179
- // 2. Fall-through (the previous instruction is literally the pervious instruction in the contract body,
180
- // AND the current JUMPDEST corresponds to a whole function, AND the pervious instructions' callee is different
181
- // from the current instruction's function.
182
- if (!enteringInternalFun &&
183
- state.op.mnemonic === "JUMPDEST" &&
184
- (ast instanceof solc_typed_ast_1.FunctionDefinition ||
185
- (ast instanceof solc_typed_ast_1.VariableDeclaration && ast.stateVariable)) &&
186
- lastStep.stack[lastStep.stack.length - 1].callee !== ast) {
187
- enteringInternalFun = true;
188
- }
189
- if (enteringInternalFun) {
190
- let args;
191
- if (ast instanceof solc_typed_ast_1.FunctionDefinition ||
192
- (ast instanceof solc_typed_ast_1.VariableDeclaration && ast.stateVariable)) {
193
- (0, solc_typed_ast_1.assert)(curExtFrame.info !== undefined, ``);
194
- args = this.decodeFunArgs(ast, state.evmStack, curExtFrame.info);
195
- }
196
- const newFrame = {
197
- kind: types_1.FrameKind.InternalCall,
198
- nearestExtFrame: lastExtFrame,
199
- callee: ast,
200
- offset: state.pc,
201
- startStep: trace.length,
202
- arguments: args
203
- };
204
- stack.push(newFrame);
205
- return;
206
- }
207
- // Returning from an internal function call
208
- if (state.op.mnemonic === "JUMP" && src.jump === "o") {
209
- const topFrame = stack[stack.length - 1];
210
- if (this.strict) {
211
- (0, solc_typed_ast_1.assert)(topFrame.kind === types_1.FrameKind.InternalCall, `Mismatched internal return from frame `, topFrame.kind);
212
- stack.pop();
213
- }
214
- else {
215
- if (topFrame.kind === types_1.FrameKind.InternalCall) {
216
- stack.pop();
217
- }
218
- // @todo log an error somewhere
219
- }
220
- }
221
- }
222
- async processRawTraceStep(vm, stateManager, step, trace, stack) {
223
- const evmStack = step.stack.map((word) => (0, utils_2.bigIntToBuf)(word, 32, "big"));
224
- const lastStep = trace.length > 0 ? trace[trace.length - 1] : undefined;
225
- const memory = lastStep === undefined || (0, opcodes_1.changesMemory)(lastStep.op)
226
- ? new Uint8Array(step.memory)
227
- : lastStep.memory;
228
- const op = (0, opcodes_1.getOpInfo)(step.opcode.name);
229
- let storage;
230
- if (lastStep === undefined || lastStep.op.opcode === opcodes_1.OPCODES.SSTORE) {
231
- storage = await getStorage(stateManager, step.address);
232
- }
233
- else {
234
- storage = lastStep.storage;
235
- }
236
- const gasCost = BigInt(step.opcode.fee);
237
- const dynamicGasCost = step.opcode.dynamicFee === undefined ? gasCost : step.opcode.dynamicFee;
238
- // First translate the basic VM state
239
- const vmState = {
240
- evmStack,
241
- memory,
242
- storage,
243
- op,
244
- pc: step.pc,
245
- gasCost,
246
- dynamicGasCost,
247
- gas: step.gasLeft,
248
- depth: step.depth + 1, // Match geth's depth starting at 1
249
- address: step.address,
250
- codeAddress: step.codeAddress
251
- };
252
- await this.adjustStackFrame(vm, stack, vmState, trace);
253
- const curExtFrame = lastExternalFrame(stack);
254
- let src;
255
- let astNode;
256
- try {
257
- [src, astNode] = this.decodeSourceLoc(step.pc, curExtFrame);
258
- }
259
- catch (e) {
260
- // Nothing to do
261
- }
262
- let emittedEvent = undefined;
263
- // Finally check if an event is being emitted for this step
264
- if (step.opcode.name.startsWith("LOG")) {
265
- const off = (0, utils_2.bigEndianBufToNumber)(evmStack[evmStack.length - 1]);
266
- const size = (0, utils_2.bigEndianBufToNumber)(evmStack[evmStack.length - 2]);
267
- const nTopics = step.opcode.name[3] - "0";
268
- const payload = memory.slice(off, off + size);
269
- emittedEvent = {
270
- payload,
271
- topics: evmStack
272
- .slice(evmStack.length - 2 - nTopics, evmStack.length - 2)
273
- .reverse()
274
- .map(__1.bigEndianBufToBigint)
275
- };
276
- }
277
- return {
278
- ...vmState,
279
- stack: [...stack],
280
- src,
281
- astNode,
282
- emittedEvent,
283
- contractInfo: curExtFrame.info
284
- };
285
- }
286
- static async getEVM(opts, foundryCheatcodes) {
287
- const tmpEvm = await evm_1.EVM.create(opts);
288
- if (!foundryCheatcodes) {
289
- return tmpEvm;
290
- }
291
- const opcodes = (0, evm_1.getOpcodesForHF)(tmpEvm.common);
292
- const [precompile, foundryCtx] = (0, foundry_cheatcodes_1.makeFoundryCheatcodePrecompile)();
293
- const optsCopy = {
294
- ...opts,
295
- customOpcodes: [
296
- ...(opts.customOpcodes ? opts.customOpcodes : []),
297
- ...(0, opcode_interposing_1.foundryInterposedOps)(opcodes, foundryCtx)
298
- ],
299
- customPrecompiles: [
300
- ...(opts.customPrecompiles ? opts.customPrecompiles : []),
301
- {
302
- address: foundry_cheatcodes_1.FoundryCheatcodesAddress,
303
- function: precompile
304
- }
305
- ]
306
- };
307
- const res = await evm_1.EVM.create(optsCopy);
308
- foundry_cheatcodes_1.foundryCtxMap.set(res, foundryCtx);
309
- return res;
310
- }
311
- /**
312
- * Releases references to the EVM stored inside VM from the
313
- * `interpRunListeners` map. This avoids memory leaks when repeatedly
314
- * calling the debugger on different transactions. Should be called once
315
- * for every vm created by `SolTxDebugger.createVm` after its done being
316
- * used.
317
- */
318
- static releaseVM(vm) {
319
- const evm = vmToEVMMap.get(vm);
320
- if (evm) {
321
- foundry_cheatcodes_1.foundryCtxMap.delete(evm);
322
- }
323
- vmToEVMMap.delete(vm);
324
- }
325
- static async createVm(stateManager, foundryCheatcodes) {
326
- const common = new common_1.Common({ chain: common_1.Chain.Mainnet, hardfork: common_1.Hardfork.Shanghai });
327
- const blockchain = await blockchain_1.Blockchain.create({ common });
328
- if (!stateManager) {
329
- stateManager = new statemanager_1.DefaultStateManager();
330
- }
331
- const evm = await SolTxDebugger.getEVM({ common, blockchain, stateManager, allowUnlimitedContractSize: true }, foundryCheatcodes);
332
- const vm = await vm_1.VM.create({
333
- common,
334
- blockchain,
335
- stateManager,
336
- evm,
337
- activatePrecompiles: true
338
- });
339
- vmToEVMMap.set(vm, evm);
340
- return vm;
341
- }
342
- async debugTx(tx, block, stateManager) {
343
- const vm = await SolTxDebugger.createVm(stateManager.shallowCopy(true), this.foundryCheatcodes);
344
- const sender = tx.getSenderAddress();
345
- const receiver = tx.to === undefined ? __1.ZERO_ADDRESS_STRING : tx.to.toString();
346
- const isCreation = receiver === __1.ZERO_ADDRESS_STRING;
347
- const stack = [];
348
- let curFrame;
349
- if (isCreation) {
350
- curFrame = await this.makeCreationFrame(sender, tx.data, 0);
351
- }
352
- else {
353
- (0, solc_typed_ast_1.assert)(tx.to !== undefined, 'Expected "to" of tx {0} to be defined, got undefined instead', (0, utils_1.bytesToHex)(tx.hash()));
354
- const code = await vm.stateManager.getContractCode(tx.to);
355
- /// @todo remove - arbitrary restriction, only good for debugging
356
- (0, solc_typed_ast_1.assert)(code.length > 0, "Missing code for address {0}", tx.to.toString());
357
- const codeHash = (0, artifacts_1.getCodeHash)(code);
358
- curFrame = await this.makeCallFrame(sender, tx.to, tx.to, tx.data, code, codeHash, 0);
359
- }
360
- stack.push(curFrame);
361
- const trace = [];
362
- (0, solc_typed_ast_1.assert)(vm.evm.events !== undefined, "Unable to access EVM events at this point");
363
- vm.evm.events.on("step", async (step, next) => {
364
- const curStep = await this.processRawTraceStep(vm, vm.stateManager, step, trace, stack);
365
- trace.push(curStep);
366
- next();
367
- });
368
- const txRes = await vm.runTx({
369
- tx,
370
- block,
371
- skipBalance: true,
372
- skipNonce: true,
373
- skipBlockGasLimitValidation: true
374
- });
375
- SolTxDebugger.releaseVM(vm);
376
- return [trace, txRes];
377
- }
378
- /**
379
- * Build a `CreationFrame` from the given `sender` address, `data` `Uint8Array`(msg.data) and the current trace step number.
380
- */
381
- async makeCreationFrame(sender, data, step) {
382
- const contractInfo = await this.artifactManager.getContractFromCreationBytecode(data);
383
- let args;
384
- const callee = contractInfo && contractInfo.ast ? contractInfo.ast.vConstructor : undefined;
385
- if (contractInfo && callee instanceof solc_typed_ast_1.FunctionDefinition) {
386
- // TODO: Try and find the arguments inside the creation code and decode them
387
- }
388
- return {
389
- kind: types_1.FrameKind.Creation,
390
- sender,
391
- msgData: data,
392
- code: data,
393
- info: contractInfo,
394
- callee,
395
- address: __1.ZERO_ADDRESS,
396
- startStep: step,
397
- arguments: args,
398
- codeMdHash: (0, artifacts_1.getCreationCodeHash)(data)
399
- };
400
- }
401
- /**
402
- * Given a contract info and a function selector find the (potentially inherited) entry point (function or public var getter).
403
- * @param info
404
- * @param selector
405
- * @returns
406
- */
407
- findEntryPoint(info, selector) {
408
- if (info.ast === undefined) {
409
- return undefined;
410
- }
411
- const contract = info.ast;
412
- const infer = this.artifactManager.infer(info.artifact.compilerVersion);
413
- return (0, abi_1.findMethodBySelector)(selector, contract, infer);
414
- }
415
- /**
416
- * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Uint8Array`, (msg.data) and the current trace step number.
417
- */
418
- async makeCallFrame(sender, receiver, codeAddress, data, receiverCode, codeHash, step) {
419
- const contractInfo = codeHash === undefined
420
- ? codeHash
421
- : this.artifactManager.getContractFromMDHash(codeHash);
422
- const selector = (0, utils_1.bytesToHex)(data.slice(0, 4));
423
- let callee;
424
- let args;
425
- if (contractInfo && contractInfo.ast) {
426
- const abiVersion = contractInfo.artifact.abiEncoderVersion;
427
- const infer = this.artifactManager.infer(contractInfo.artifact.compilerVersion);
428
- callee = this.findEntryPoint(contractInfo, selector);
429
- if (callee !== undefined) {
430
- try {
431
- args = (0, abi_1.buildMsgDataViews)(callee, data, types_1.DataLocationKind.CallData, infer, abiVersion);
432
- }
433
- catch (e) {
434
- args = undefined;
435
- }
436
- }
437
- }
438
- return {
439
- kind: types_1.FrameKind.Call,
440
- sender, // TODO: This should be Address
441
- msgData: data,
442
- receiver: receiver, // TODO: This should be Address
443
- code: receiverCode,
444
- info: contractInfo,
445
- callee,
446
- address: receiver,
447
- startStep: step,
448
- arguments: args,
449
- codeMdHash: codeHash,
450
- codeAddress
451
- };
452
- }
453
- /**
454
- * Helper function to get the source information for the instruction at a given `instrOffset`,
455
- * in the context of the external call `ctx`.
456
- *
457
- * There are several cases this handles:
458
- *
459
- * 1. If there is no debug info for the contract executing in `ctx` return undefined
460
- * 2. If there is debug info, but no AST return only the decoded bytecode sourcemap entry
461
- * 3. If there is both debug info and an AST return the decoded source location and any AST nodes that match this location
462
- */
463
- decodeSourceLoc(instrOffset, ctx) {
464
- if (!ctx.info) {
465
- return [undefined, undefined];
466
- }
467
- const bytecodeInfo = ctx.kind === types_1.FrameKind.Creation ? ctx.info.bytecode : ctx.info.deployedBytecode;
468
- const src = (0, artifact_manager_1.getOffsetSrc)(instrOffset, bytecodeInfo);
469
- const astNode = ctx.info.artifact.srcMap.get(`${src.start}:${src.length}:${src.sourceIndex}`);
470
- return [src, astNode];
471
- }
472
- /**
473
- * WIP: TODO document
474
- * TODO: Rename - this function doesn't do any actual decoding - just building up DataView for the arguments
475
- * of a function
476
- */
477
- decodeFunArgs(callee, stack, contractInfo) {
478
- const res = [];
479
- let formals;
480
- const infer = this.artifactManager.infer(contractInfo.artifact.compilerVersion);
481
- try {
482
- formals =
483
- callee instanceof solc_typed_ast_1.FunctionDefinition
484
- ? callee.vParameters.vParameters.map((argDef) => [
485
- argDef.name,
486
- infer.variableDeclarationToTypeNode(argDef)
487
- ])
488
- : infer
489
- .getterArgsAndReturn(callee)[0]
490
- .map((typ, i) => [`ARG_${i}`, typ]);
491
- }
492
- catch (e) {
493
- // `variableDeclarationToTypeNode` may fail when referencing structs/contracts that are defined
494
- // in SourceUnits that are missing
495
- return undefined;
496
- }
497
- let offsetFromTop = -1;
498
- for (let i = formals.length - 1; i >= 0; i--) {
499
- const [name, typ] = formals[i];
500
- const stackSize = (0, decoding_1.isCalldataType2Slots)(typ) ? 2 : 1;
501
- offsetFromTop += stackSize;
502
- if (offsetFromTop > stack.length) {
503
- // Stack underflow. Could be due to optimized code?
504
- return undefined;
505
- }
506
- res.unshift([
507
- name,
508
- {
509
- type: typ,
510
- loc: {
511
- kind: types_1.DataLocationKind.Stack,
512
- offsetFromTop
513
- }
514
- }
515
- ]);
516
- }
517
- return res;
518
- }
519
- }
520
- exports.SolTxDebugger = SolTxDebugger;
521
- //# sourceMappingURL=sol_debugger.js.map