sol-dbg 0.3.7 → 0.4.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 (73) hide show
  1. package/dist/artifacts/helpers.d.ts +2 -3
  2. package/dist/artifacts/helpers.d.ts.map +1 -1
  3. package/dist/artifacts/helpers.js +45 -14
  4. package/dist/artifacts/helpers.js.map +1 -1
  5. package/dist/debug/abi.d.ts +10 -4
  6. package/dist/debug/abi.d.ts.map +1 -1
  7. package/dist/debug/abi.js +41 -11
  8. package/dist/debug/abi.js.map +1 -1
  9. package/dist/debug/artifact_manager.d.ts +9 -10
  10. package/dist/debug/artifact_manager.d.ts.map +1 -1
  11. package/dist/debug/artifact_manager.js +7 -6
  12. package/dist/debug/artifact_manager.js.map +1 -1
  13. package/dist/debug/decoding/calldata.d.ts.map +1 -1
  14. package/dist/debug/decoding/calldata.js +5 -6
  15. package/dist/debug/decoding/calldata.js.map +1 -1
  16. package/dist/debug/decoding/general.js +2 -3
  17. package/dist/debug/decoding/general.js.map +1 -1
  18. package/dist/debug/decoding/memory.d.ts.map +1 -1
  19. package/dist/debug/decoding/memory.js +4 -5
  20. package/dist/debug/decoding/memory.js.map +1 -1
  21. package/dist/debug/decoding/stack.js +2 -3
  22. package/dist/debug/decoding/stack.js.map +1 -1
  23. package/dist/debug/decoding/storage.d.ts.map +1 -1
  24. package/dist/debug/decoding/storage.js +9 -9
  25. package/dist/debug/decoding/storage.js.map +1 -1
  26. package/dist/debug/foundry_cheatcodes.d.ts +31 -30
  27. package/dist/debug/foundry_cheatcodes.d.ts.map +1 -1
  28. package/dist/debug/foundry_cheatcodes.js +127 -143
  29. package/dist/debug/foundry_cheatcodes.js.map +1 -1
  30. package/dist/debug/opcode_interposing.d.ts +2 -1
  31. package/dist/debug/opcode_interposing.d.ts.map +1 -1
  32. package/dist/debug/opcode_interposing.js +28 -30
  33. package/dist/debug/opcode_interposing.js.map +1 -1
  34. package/dist/debug/opcodes.js +6 -6
  35. package/dist/debug/opcodes.js.map +1 -1
  36. package/dist/debug/sol_debugger.d.ts +10 -165
  37. package/dist/debug/sol_debugger.d.ts.map +1 -1
  38. package/dist/debug/sol_debugger.js +74 -102
  39. package/dist/debug/sol_debugger.js.map +1 -1
  40. package/dist/debug/types.d.ts +157 -0
  41. package/dist/debug/types.d.ts.map +1 -1
  42. package/dist/debug/types.js +14 -0
  43. package/dist/debug/types.js.map +1 -1
  44. package/dist/utils/ethereumjs_internal/exceptions.d.ts +44 -0
  45. package/dist/utils/ethereumjs_internal/exceptions.d.ts.map +1 -0
  46. package/dist/utils/ethereumjs_internal/exceptions.js +59 -0
  47. package/dist/utils/ethereumjs_internal/exceptions.js.map +1 -0
  48. package/dist/utils/ethereumjs_internal/index.d.ts +3 -0
  49. package/dist/utils/ethereumjs_internal/index.d.ts.map +1 -0
  50. package/dist/utils/ethereumjs_internal/index.js +19 -0
  51. package/dist/utils/ethereumjs_internal/index.js.map +1 -0
  52. package/dist/utils/ethereumjs_internal/opcodes.d.ts +33 -0
  53. package/dist/utils/ethereumjs_internal/opcodes.d.ts.map +1 -0
  54. package/dist/utils/ethereumjs_internal/opcodes.js +79 -0
  55. package/dist/utils/ethereumjs_internal/opcodes.js.map +1 -0
  56. package/dist/utils/index.d.ts +2 -2
  57. package/dist/utils/index.d.ts.map +1 -1
  58. package/dist/utils/index.js +2 -2
  59. package/dist/utils/index.js.map +1 -1
  60. package/dist/utils/misc.d.ts +12 -20
  61. package/dist/utils/misc.d.ts.map +1 -1
  62. package/dist/utils/misc.js +39 -83
  63. package/dist/utils/misc.js.map +1 -1
  64. package/dist/utils/pp.d.ts.map +1 -1
  65. package/dist/utils/pp.js +10 -10
  66. package/dist/utils/pp.js.map +1 -1
  67. package/dist/utils/srcmap.js +2 -3
  68. package/dist/utils/srcmap.js.map +1 -1
  69. package/dist/utils/test_runner.d.ts +6 -6
  70. package/dist/utils/test_runner.d.ts.map +1 -1
  71. package/dist/utils/test_runner.js +11 -9
  72. package/dist/utils/test_runner.js.map +1 -1
  73. package/package.json +14 -12
@@ -1,166 +1,12 @@
1
- /// <reference types="node" />
2
1
  import { Block } from "@ethereumjs/block";
3
- import { Transaction } from "@ethereumjs/tx";
2
+ import { EVMStateManagerInterface } from "@ethereumjs/common";
4
3
  import { InterpreterStep } from "@ethereumjs/evm";
5
- import { StateManager } from "@ethereumjs/statemanager";
4
+ import { TypedTransaction } from "@ethereumjs/tx";
6
5
  import { RunTxResult, VM } from "@ethereumjs/vm";
7
- import { Address } from "ethereumjs-util";
8
- import { ASTNode, TypeNode } from "solc-typed-ast";
9
- import { DecodedBytecodeSourceMapEntry, HexString, ImmMap } from "..";
6
+ import { ASTNode } from "solc-typed-ast";
7
+ import { DecodedBytecodeSourceMapEntry } from "..";
10
8
  import { ContractInfo, IArtifactManager } from "./artifact_manager";
11
- import { EVMOpInfo } from "./opcodes";
12
- export declare enum FrameKind {
13
- Call = "call",
14
- Creation = "creation",
15
- InternalCall = "internal_call"
16
- }
17
- /**
18
- * Base interface for Stack frames maintained by the debugger
19
- */
20
- interface BaseFrame {
21
- readonly kind: FrameKind;
22
- /**
23
- * AST node causing the call. Note that this is not always a FunctionCall. For example this could be:
24
- * 1. A contract public state var VariableDeclaration
25
- * 2. Any checked arithmetic operation in sol > 0.8.0 (these are implemented as internal functions)
26
- * 3. Some other random non-call AST node, that is implemented as a compiler generated function
27
- */
28
- readonly callee: ASTNode | undefined;
29
- /**
30
- * If we have a `callee` try and infer where the arguments are placed in the VM state. Some arguments may not
31
- * exist in the case of msg.data generated from a fuzzer for example.
32
- */
33
- readonly arguments: Array<[string, DataView | undefined]> | undefined;
34
- readonly startStep: number;
35
- }
36
- /**
37
- * Base class for a stack frame corresponding to an external call.
38
- */
39
- interface BaseExternalFrame extends BaseFrame {
40
- readonly sender: HexString;
41
- readonly msgData: Buffer;
42
- readonly address: Address;
43
- }
44
- /**
45
- * Stack frame corresponding to an external call
46
- */
47
- interface CallFrame extends BaseExternalFrame {
48
- readonly kind: FrameKind.Call;
49
- readonly receiver: HexString;
50
- readonly code: Buffer;
51
- readonly info?: ContractInfo;
52
- }
53
- /**
54
- * Stack frame corresponding to a contract creation call
55
- */
56
- interface CreationFrame extends BaseExternalFrame {
57
- readonly kind: FrameKind.Creation;
58
- readonly creationCode: Buffer;
59
- readonly info?: ContractInfo;
60
- }
61
- /**
62
- * Stack frame corresponding to an internal function call
63
- */
64
- interface InternalCallFrame extends BaseFrame {
65
- readonly kind: FrameKind.InternalCall;
66
- readonly nearestExtFrame: CallFrame | CreationFrame;
67
- readonly offset: number;
68
- }
69
- export type ExternalFrame = CallFrame | CreationFrame;
70
- export type Frame = ExternalFrame | InternalCallFrame;
71
- export type DbgStack = Frame[];
72
- export declare enum DataLocationKind {
73
- Stack = "stack",
74
- Memory = "memory",
75
- Storage = "storage",
76
- CallData = "calldata"
77
- }
78
- export type MemoryLocationKind = DataLocationKind.Memory | DataLocationKind.CallData | DataLocationKind.Storage;
79
- export interface BaseDataLocation {
80
- kind: DataLocationKind;
81
- }
82
- export interface StackLocation extends BaseDataLocation {
83
- kind: DataLocationKind.Stack;
84
- offsetFromTop: number;
85
- }
86
- export interface BaseMemoryLocation extends BaseDataLocation {
87
- address: bigint;
88
- }
89
- export interface CalldataLocation extends BaseMemoryLocation {
90
- kind: DataLocationKind.CallData;
91
- }
92
- export interface LinearMemoryLocation extends BaseMemoryLocation {
93
- kind: DataLocationKind.Memory;
94
- }
95
- export interface StorageLocation extends BaseMemoryLocation {
96
- kind: DataLocationKind.Storage;
97
- endOffsetInWord: number;
98
- }
99
- export type ByteAddressableMemoryLocation = CalldataLocation | LinearMemoryLocation;
100
- export type MemoryLocation = ByteAddressableMemoryLocation | StorageLocation;
101
- export type DataLocation = StackLocation | MemoryLocation;
102
- export interface DataView {
103
- type: TypeNode;
104
- abiType?: TypeNode;
105
- loc: DataLocation;
106
- }
107
- export type Memory = Buffer;
108
- export type Stack = Buffer[];
109
- export type Storage = ImmMap<bigint, Buffer>;
110
- export interface EventDesc {
111
- payload: Buffer;
112
- topics: bigint[];
113
- }
114
- /**
115
- * TODO(dimo): Make memory and storage be computed only for instructions that change them, and for all other
116
- * instructions alias the previous steps' memory/storage
117
- *
118
- * Low-level machine state at a given trace step. It directly mirrors the state reported from Web3
119
- * and doesn't include any higher-level information that requires debug info.
120
- */
121
- export interface StepVMState {
122
- evmStack: Stack;
123
- memory: Memory;
124
- storage: Storage;
125
- op: EVMOpInfo;
126
- pc: number;
127
- gasCost: bigint;
128
- dynamicGasCost: bigint;
129
- gas: bigint;
130
- depth: number;
131
- address: Address;
132
- codeAddress: Address;
133
- }
134
- /**
135
- * State that the debugger maintains for each trace step.
136
- * It includes the basic VM state (`StepVmState`) and optionally (if we have debug info for this contract)
137
- * includes the decoded source location, any AST nodes that are mapped to this instruction and any events
138
- * that may be emitted on this step.
139
- */
140
- export interface StepState extends StepVMState {
141
- code: Buffer;
142
- codeMdHash: HexString | undefined;
143
- stack: DbgStack;
144
- src: DecodedBytecodeSourceMapEntry | undefined;
145
- astNode: ASTNode | undefined;
146
- emittedEvent: EventDesc | undefined;
147
- contractInfo: ContractInfo | undefined;
148
- }
149
- /**
150
- * Trace step struct contained in the array returned by web3.debug.traceTransaction().
151
- * We translate this into `StepVmState`.
152
- */
153
- export interface Web3DbgState {
154
- stack: HexString[];
155
- memory: HexString[];
156
- storage?: any;
157
- op: string;
158
- pc: number;
159
- gasCost: string;
160
- gas: string;
161
- depth: number;
162
- error?: any;
163
- }
9
+ import { DbgStack, ExternalFrame, Frame, StepState } from "./types";
164
10
  /**
165
11
  * Give a stack or a stack frame, find the last **external** stack frame under it (include itself).
166
12
  */
@@ -219,7 +65,7 @@ export declare class SolTxDebugger {
219
65
  * @param trace - trace up to the current state
220
66
  */
221
67
  private getCodeAndMdHash;
222
- processRawTraceStep(vm: VM, stateManager: StateManager, step: InterpreterStep, trace: StepState[], stack: Frame[]): Promise<StepState>;
68
+ processRawTraceStep(vm: VM, stateManager: EVMStateManagerInterface, step: InterpreterStep, trace: StepState[], stack: Frame[]): Promise<StepState>;
223
69
  private static getEVM;
224
70
  /**
225
71
  * Releases references to the EVM stored inside VM from the
@@ -229,10 +75,10 @@ export declare class SolTxDebugger {
229
75
  * used.
230
76
  */
231
77
  static releaseVM(vm: VM): void;
232
- static createVm(stateManager: StateManager | undefined, foundryCheatcodes: boolean): Promise<VM>;
233
- debugTx(tx: Transaction, block: Block | undefined, stateManager: StateManager): Promise<[StepState[], RunTxResult]>;
78
+ static createVm(stateManager: EVMStateManagerInterface | undefined, foundryCheatcodes: boolean): Promise<VM>;
79
+ debugTx(tx: TypedTransaction, block: Block | undefined, stateManager: EVMStateManagerInterface): Promise<[StepState[], RunTxResult]>;
234
80
  /**
235
- * Build a `CreationFrame` from the given `sender` address, `data` `Buffer`(msg.data) and the current trace step number.
81
+ * Build a `CreationFrame` from the given `sender` address, `data` `Uint8Array`(msg.data) and the current trace step number.
236
82
  */
237
83
  private makeCreationFrame;
238
84
  /**
@@ -243,7 +89,7 @@ export declare class SolTxDebugger {
243
89
  */
244
90
  private findEntryPoint;
245
91
  /**
246
- * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Buffer`, (msg.data) and the current trace step number.
92
+ * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Uint8Array`, (msg.data) and the current trace step number.
247
93
  */
248
94
  private makeCallFrame;
249
95
  /**
@@ -264,5 +110,4 @@ export declare class SolTxDebugger {
264
110
  */
265
111
  private decodeFunArgs;
266
112
  }
267
- export {};
268
113
  //# sourceMappingURL=sol_debugger.d.ts.map
@@ -1 +1 @@
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;AAI1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAuB,Y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DtC;;OAEG;YACW,iBAAiB;IA0B/B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IActB;;OAEG;YACW,aAAa;IAqD3B;;;;;;;;;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,57 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolTxDebugger = exports.getContractInfo = exports.lastExternalFrame = exports.DataLocationKind = exports.FrameKind = void 0;
3
+ exports.SolTxDebugger = void 0;
4
+ exports.lastExternalFrame = lastExternalFrame;
5
+ exports.getContractInfo = getContractInfo;
4
6
  const blockchain_1 = require("@ethereumjs/blockchain");
5
7
  const common_1 = require("@ethereumjs/common");
6
- const evm_1 = require("@ethereumjs/evm/dist/evm");
8
+ const evm_1 = require("@ethereumjs/evm");
9
+ const rlp_1 = require("@ethereumjs/rlp");
7
10
  const statemanager_1 = require("@ethereumjs/statemanager");
11
+ const util_1 = require("@ethereumjs/util");
8
12
  const vm_1 = require("@ethereumjs/vm");
9
- const ethereumjs_util_1 = require("ethereumjs-util");
13
+ const utils_1 = require("ethereum-cryptography/utils");
10
14
  const solc_typed_ast_1 = require("solc-typed-ast");
11
15
  const __1 = require("..");
12
16
  const artifacts_1 = require("../artifacts");
17
+ const utils_2 = require("../utils");
13
18
  const abi_1 = require("./abi");
14
- const utils_1 = require("../utils");
15
19
  const artifact_manager_1 = require("./artifact_manager");
16
20
  const decoding_1 = require("./decoding");
17
21
  const foundry_cheatcodes_1 = require("./foundry_cheatcodes");
18
- const opcodes_1 = require("@ethereumjs/evm/dist/opcodes");
19
22
  const opcode_interposing_1 = require("./opcode_interposing");
20
- const stream_1 = require("stream");
21
- const opcodes_2 = require("./opcodes");
22
- var FrameKind;
23
- (function (FrameKind) {
24
- FrameKind["Call"] = "call";
25
- FrameKind["Creation"] = "creation";
26
- FrameKind["InternalCall"] = "internal_call";
27
- })(FrameKind || (exports.FrameKind = FrameKind = {}));
28
- var DataLocationKind;
29
- (function (DataLocationKind) {
30
- DataLocationKind["Stack"] = "stack";
31
- DataLocationKind["Memory"] = "memory";
32
- DataLocationKind["Storage"] = "storage";
33
- DataLocationKind["CallData"] = "calldata";
34
- })(DataLocationKind || (exports.DataLocationKind = DataLocationKind = {}));
23
+ const opcodes_1 = require("./opcodes");
24
+ const types_1 = require("./types");
35
25
  // Helper functions
36
26
  /**
37
27
  * Give a stack or a stack frame, find the last **external** stack frame under it (include itself).
38
28
  */
39
29
  function lastExternalFrame(arg) {
40
30
  const frame = arg instanceof Array ? arg[arg.length - 1] : arg;
41
- return frame.kind === FrameKind.InternalCall ? frame.nearestExtFrame : frame;
31
+ return frame.kind === types_1.FrameKind.InternalCall ? frame.nearestExtFrame : frame;
42
32
  }
43
- exports.lastExternalFrame = lastExternalFrame;
44
33
  function getContractInfo(arg) {
45
34
  const frame = lastExternalFrame(arg);
46
35
  return frame.info;
47
36
  }
48
- exports.getContractInfo = getContractInfo;
49
37
  async function getStorage(manager, addr) {
50
38
  const rawStorage = await manager.dumpStorage(addr);
51
39
  const storageEntries = [];
52
40
  for (const [keyStr, valStr] of Object.entries(rawStorage)) {
53
- const valBuf = (0, __1.padStart)(ethereumjs_util_1.rlp.decode(Buffer.from(valStr, "hex")), 32, 0);
54
- storageEntries.push([BigInt("0x" + keyStr), valBuf]);
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]);
55
45
  }
56
46
  return __1.ImmMap.fromEntries(storageEntries);
57
47
  }
@@ -114,23 +104,23 @@ class SolTxDebugger {
114
104
  if (lastStep.depth !== state.depth) {
115
105
  const lastStackTop = lastStep.evmStack.length - 1;
116
106
  if (state.depth > lastStep.depth) {
117
- (0, solc_typed_ast_1.assert)((0, opcodes_2.increasesDepth)(lastOp), `Unexpected depth increase on op ${lastOp.mnemonic}`);
118
- if ((0, opcodes_2.createsContract)(lastOp)) {
107
+ (0, solc_typed_ast_1.assert)((0, opcodes_1.increasesDepth)(lastOp), `Unexpected depth increase on op ${lastOp.mnemonic}`);
108
+ if ((0, opcodes_1.createsContract)(lastOp)) {
119
109
  // Contract creation call
120
- const off = (0, utils_1.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 1]);
121
- const size = (0, utils_1.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 2]);
110
+ const off = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 1]);
111
+ const size = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 2]);
122
112
  const creationBytecode = lastStep.memory.slice(off, off + size);
123
113
  const curFrame = await this.makeCreationFrame(lastExtFrame.address.toString(), creationBytecode, trace.length);
124
114
  stack.push(curFrame);
125
115
  }
126
116
  else {
127
117
  // External call
128
- const argStackOff = lastOp.opcode === opcodes_2.OPCODES.CALL || lastOp.opcode === opcodes_2.OPCODES.CALLCODE
118
+ const argStackOff = lastOp.opcode === opcodes_1.OPCODES.CALL || lastOp.opcode === opcodes_1.OPCODES.CALLCODE
129
119
  ? 3
130
120
  : 2;
131
121
  const argSizeStackOff = argStackOff + 1;
132
- const argOff = (0, utils_1.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - argStackOff]);
133
- const argSize = (0, utils_1.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - argSizeStackOff]);
122
+ const argOff = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - argStackOff]);
123
+ const argSize = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - argSizeStackOff]);
134
124
  const receiver = (0, __1.wordToAddress)(lastStep.evmStack[lastStackTop - 1]);
135
125
  const msgData = lastStep.memory.slice(argOff, argOff + argSize);
136
126
  const newFrame = await this.makeCallFrame(lastExtFrame.address.toString(), receiver, msgData, code, codeHash, trace.length);
@@ -144,7 +134,7 @@ class SolTxDebugger {
144
134
  // depth reported by web3. We need the loop since we don't count the internal frames as decreasing depth
145
135
  while (nFramesPopped > 0 && stack.length > 0) {
146
136
  const topFrame = stack[stack.length - 1];
147
- if (topFrame.kind === FrameKind.Creation || topFrame.kind === FrameKind.Call) {
137
+ if (topFrame.kind === types_1.FrameKind.Creation || topFrame.kind === types_1.FrameKind.Call) {
148
138
  nFramesPopped--;
149
139
  }
150
140
  stack.pop();
@@ -186,7 +176,7 @@ class SolTxDebugger {
186
176
  args = this.decodeFunArgs(ast, state.evmStack, curExtFrame.info);
187
177
  }
188
178
  const newFrame = {
189
- kind: FrameKind.InternalCall,
179
+ kind: types_1.FrameKind.InternalCall,
190
180
  nearestExtFrame: lastExtFrame,
191
181
  callee: ast,
192
182
  offset: state.pc,
@@ -200,11 +190,11 @@ class SolTxDebugger {
200
190
  if (state.op.mnemonic === "JUMP" && src.jump === "o") {
201
191
  const topFrame = stack[stack.length - 1];
202
192
  if (this.strict) {
203
- (0, solc_typed_ast_1.assert)(topFrame.kind === FrameKind.InternalCall, `Mismatched internal return from frame `, topFrame.kind);
193
+ (0, solc_typed_ast_1.assert)(topFrame.kind === types_1.FrameKind.InternalCall, `Mismatched internal return from frame `, topFrame.kind);
204
194
  stack.pop();
205
195
  }
206
196
  else {
207
- if (topFrame.kind === FrameKind.InternalCall) {
197
+ if (topFrame.kind === types_1.FrameKind.InternalCall) {
208
198
  stack.pop();
209
199
  }
210
200
  // @todo log an error somewhere
@@ -228,36 +218,43 @@ class SolTxDebugger {
228
218
  const lastStep = trace.length > 0 ? trace[trace.length - 1] : undefined;
229
219
  let code;
230
220
  let codeMdHash;
231
- if (lastStep !== undefined && (0, opcodes_2.createsContract)(lastStep.op)) {
221
+ const getCodeAddress = (s) => s.codeAddress !== undefined ? s.codeAddress : s.address;
222
+ // Case 1: First step in the trace
223
+ if (lastStep === undefined) {
224
+ const code = await vm.stateManager.getContractCode(getCodeAddress(step));
225
+ const codeMdHash = (0, artifacts_1.getCodeHash)(code);
226
+ return [code, codeMdHash];
227
+ }
228
+ // Case 2: Just entering a constructor from another contract
229
+ if ((0, opcodes_1.createsContract)(lastStep.op)) {
232
230
  const lastStackTop = lastStep.evmStack.length - 1;
233
- const off = (0, utils_1.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 1]);
234
- const size = (0, utils_1.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 2]);
235
- code = lastStep.memory.slice(off, off + size);
236
- codeMdHash = (0, artifacts_1.getCreationCodeHash)(code);
231
+ const off = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 1]);
232
+ const size = (0, utils_2.bigEndianBufToNumber)(lastStep.evmStack[lastStackTop - 2]);
233
+ const code = lastStep.memory.slice(off, off + size);
234
+ const codeMdHash = (0, artifacts_1.getCreationCodeHash)(code);
235
+ return [code, codeMdHash];
237
236
  }
238
- else if (lastStep === undefined || !lastStep.codeAddress.equals(step.codeAddress)) {
239
- code = await vm.stateManager.getContractCode(step.codeAddress);
237
+ // Case 3: The code changed - either we are in a different contract or a delegate call context
238
+ if (!getCodeAddress(lastStep).equals(getCodeAddress(step))) {
239
+ // Case 3: We are changing the code address
240
+ code = await vm.stateManager.getContractCode(getCodeAddress(step));
240
241
  codeMdHash = (0, artifacts_1.getCodeHash)(code);
242
+ return [code, codeMdHash];
241
243
  }
242
- else {
243
- code = lastStep.code;
244
- codeMdHash = lastStep.codeMdHash;
245
- }
244
+ // Case 4: We are still in the same contract
245
+ code = lastStep.code;
246
+ codeMdHash = lastStep.codeMdHash;
246
247
  return [code, codeMdHash];
247
248
  }
248
249
  async processRawTraceStep(vm, stateManager, step, trace, stack) {
249
- const evmStack = step.stack.map((word) => (0, utils_1.bigIntToBuf)(word, 32, "big"));
250
+ const evmStack = step.stack.map((word) => (0, utils_2.bigIntToBuf)(word, 32, "big"));
250
251
  const lastStep = trace.length > 0 ? trace[trace.length - 1] : undefined;
251
- let memory;
252
- if (lastStep === undefined || (0, opcodes_2.changesMemory)(lastStep.op)) {
253
- memory = Buffer.from(step.memory);
254
- }
255
- else {
256
- memory = lastStep.memory;
257
- }
258
- const op = (0, opcodes_2.getOpInfo)(step.opcode.name);
252
+ const memory = lastStep === undefined || (0, opcodes_1.changesMemory)(lastStep.op)
253
+ ? new Uint8Array(step.memory)
254
+ : lastStep.memory;
255
+ const op = (0, opcodes_1.getOpInfo)(step.opcode.name);
259
256
  let storage;
260
- if (lastStep === undefined || lastStep.op.opcode === opcodes_2.OPCODES.SSTORE) {
257
+ if (lastStep === undefined || lastStep.op.opcode === opcodes_1.OPCODES.SSTORE) {
261
258
  storage = await getStorage(stateManager, step.address);
262
259
  }
263
260
  else {
@@ -293,8 +290,8 @@ class SolTxDebugger {
293
290
  let emittedEvent = undefined;
294
291
  // Finally check if an event is being emitted for this step
295
292
  if (step.opcode.name.startsWith("LOG")) {
296
- const off = (0, utils_1.bigEndianBufToNumber)(evmStack[evmStack.length - 1]);
297
- const size = (0, utils_1.bigEndianBufToNumber)(evmStack[evmStack.length - 2]);
293
+ const off = (0, utils_2.bigEndianBufToNumber)(evmStack[evmStack.length - 1]);
294
+ const size = (0, utils_2.bigEndianBufToNumber)(evmStack[evmStack.length - 2]);
298
295
  const nTopics = step.opcode.name[3] - "0";
299
296
  const payload = memory.slice(off, off + size);
300
297
  emittedEvent = {
@@ -321,7 +318,7 @@ class SolTxDebugger {
321
318
  if (!foundryCheatcodes) {
322
319
  return tmpEvm;
323
320
  }
324
- const opcodes = (0, opcodes_1.getOpcodesForHF)(tmpEvm._common);
321
+ const opcodes = (0, evm_1.getOpcodesForHF)(tmpEvm.common);
325
322
  const [precompile, foundryCtx] = (0, foundry_cheatcodes_1.makeFoundryCheatcodePrecompile)();
326
323
  const optsCopy = {
327
324
  ...opts,
@@ -338,11 +335,7 @@ class SolTxDebugger {
338
335
  ]
339
336
  };
340
337
  const res = await evm_1.EVM.create(optsCopy);
341
- const emitter = new stream_1.EventEmitter();
342
- emitter.on("beforeInterpRun", foundryCtx.beforeInterpRunCB.bind(foundryCtx));
343
- emitter.on("afterInterpRun", foundryCtx.afterInterpRunCB.bind(foundryCtx));
344
- foundry_cheatcodes_1.interpRunListeners.set(res, emitter);
345
- (0, foundry_cheatcodes_1.setFoundryCtx)(res, foundryCtx);
338
+ foundry_cheatcodes_1.foundryCtxMap.set(res, foundryCtx);
346
339
  return res;
347
340
  }
348
341
  /**
@@ -355,7 +348,7 @@ class SolTxDebugger {
355
348
  static releaseVM(vm) {
356
349
  const evm = vmToEVMMap.get(vm);
357
350
  if (evm) {
358
- foundry_cheatcodes_1.interpRunListeners.delete(evm);
351
+ foundry_cheatcodes_1.foundryCtxMap.delete(evm);
359
352
  }
360
353
  vmToEVMMap.delete(vm);
361
354
  }
@@ -365,8 +358,7 @@ class SolTxDebugger {
365
358
  if (!stateManager) {
366
359
  stateManager = new statemanager_1.DefaultStateManager();
367
360
  }
368
- const eei = new vm_1.EEI(stateManager, common, blockchain);
369
- const evm = await SolTxDebugger.getEVM({ common, eei, allowUnlimitedContractSize: true }, foundryCheatcodes);
361
+ const evm = await SolTxDebugger.getEVM({ common, blockchain, stateManager, allowUnlimitedContractSize: true }, foundryCheatcodes);
370
362
  const vm = await vm_1.VM.create({
371
363
  common,
372
364
  blockchain,
@@ -378,7 +370,7 @@ class SolTxDebugger {
378
370
  return vm;
379
371
  }
380
372
  async debugTx(tx, block, stateManager) {
381
- const vm = await SolTxDebugger.createVm(stateManager, this.foundryCheatcodes);
373
+ const vm = await SolTxDebugger.createVm(stateManager.shallowCopy(true), this.foundryCheatcodes);
382
374
  const sender = tx.getSenderAddress().toString();
383
375
  const receiver = tx.to === undefined ? __1.ZERO_ADDRESS_STRING : tx.to.toString();
384
376
  const isCreation = receiver === __1.ZERO_ADDRESS_STRING;
@@ -388,7 +380,7 @@ class SolTxDebugger {
388
380
  curFrame = await this.makeCreationFrame(sender, tx.data, 0);
389
381
  }
390
382
  else {
391
- (0, solc_typed_ast_1.assert)(tx.to !== undefined, 'Expected "to" of tx {0} to be defined, got undefined instead', tx.hash().toString("hex"));
383
+ (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()));
392
384
  const code = await vm.stateManager.getContractCode(tx.to);
393
385
  /// @todo remove - arbitrary restriction, only good for debugging
394
386
  (0, solc_typed_ast_1.assert)(code.length > 0, "Missing code for address {0}", tx.to.toString());
@@ -414,7 +406,7 @@ class SolTxDebugger {
414
406
  return [trace, txRes];
415
407
  }
416
408
  /**
417
- * Build a `CreationFrame` from the given `sender` address, `data` `Buffer`(msg.data) and the current trace step number.
409
+ * Build a `CreationFrame` from the given `sender` address, `data` `Uint8Array`(msg.data) and the current trace step number.
418
410
  */
419
411
  async makeCreationFrame(sender, data, step) {
420
412
  const contractInfo = await this.artifactManager.getContractFromCreationBytecode(data);
@@ -424,7 +416,7 @@ class SolTxDebugger {
424
416
  // TODO: Try and find the arguments inside the creation code and decode them
425
417
  }
426
418
  return {
427
- kind: FrameKind.Creation,
419
+ kind: types_1.FrameKind.Creation,
428
420
  sender,
429
421
  msgData: data,
430
422
  creationCode: data,
@@ -447,38 +439,16 @@ class SolTxDebugger {
447
439
  }
448
440
  const contract = info.ast;
449
441
  const infer = this.artifactManager.infer(info.artifact.compilerVersion);
450
- for (const base of contract.vLinearizedBaseContracts) {
451
- // Need to be defensive here, as in some cases with partial AST information the base may be missing
452
- if (base === undefined) {
453
- continue;
454
- }
455
- const matchingFuns = base.vFunctions.filter((fun) => (0, __1.getFunctionSelector)(fun, infer) === selector);
456
- if (matchingFuns.length === 1) {
457
- return matchingFuns[0];
458
- }
459
- const matchingGetters = base.vStateVariables.filter((vDef) => {
460
- try {
461
- return (vDef.visibility === solc_typed_ast_1.StateVariableVisibility.Public &&
462
- infer.signatureHash(vDef));
463
- }
464
- catch (e) {
465
- return false;
466
- }
467
- });
468
- if (matchingGetters.length === 1) {
469
- return matchingGetters[0];
470
- }
471
- }
472
- return undefined;
442
+ return (0, abi_1.findMethodBySelector)(selector, contract, infer);
473
443
  }
474
444
  /**
475
- * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Buffer`, (msg.data) and the current trace step number.
445
+ * Build a `CallFrame` from the given `sender` address, `receiver` address, `data` `Uint8Array`, (msg.data) and the current trace step number.
476
446
  */
477
447
  async makeCallFrame(sender, receiver, data, receiverCode, codeHash, step) {
478
448
  const contractInfo = codeHash === undefined
479
449
  ? codeHash
480
450
  : this.artifactManager.getContractFromMDHash(codeHash);
481
- const selector = data.slice(0, 4).toString("hex");
451
+ const selector = (0, utils_1.bytesToHex)(data.slice(0, 4));
482
452
  let callee;
483
453
  let args;
484
454
  if (contractInfo && contractInfo.ast) {
@@ -487,7 +457,7 @@ class SolTxDebugger {
487
457
  callee = this.findEntryPoint(contractInfo, selector);
488
458
  if (callee !== undefined) {
489
459
  try {
490
- args = (0, abi_1.buildMsgDataViews)(callee, data, DataLocationKind.CallData, infer, abiVersion);
460
+ args = (0, abi_1.buildMsgDataViews)(callee, data, types_1.DataLocationKind.CallData, infer, abiVersion);
491
461
  }
492
462
  catch (e) {
493
463
  args = undefined;
@@ -495,7 +465,7 @@ class SolTxDebugger {
495
465
  }
496
466
  }
497
467
  return {
498
- kind: FrameKind.Call,
468
+ kind: types_1.FrameKind.Call,
499
469
  sender,
500
470
  msgData: data,
501
471
  receiver: receiver.toString(),
@@ -521,7 +491,7 @@ class SolTxDebugger {
521
491
  if (!ctx.info) {
522
492
  return [undefined, undefined];
523
493
  }
524
- const bytecodeInfo = ctx.kind === FrameKind.Creation ? ctx.info.bytecode : ctx.info.deployedBytecode;
494
+ const bytecodeInfo = ctx.kind === types_1.FrameKind.Creation ? ctx.info.bytecode : ctx.info.deployedBytecode;
525
495
  const src = (0, artifact_manager_1.getOffsetSrc)(instrOffset, bytecodeInfo);
526
496
  const astNode = ctx.info.artifact.srcMap.get(`${src.start}:${src.length}:${src.sourceIndex}`);
527
497
  return [src, astNode];
@@ -542,7 +512,9 @@ class SolTxDebugger {
542
512
  argDef.name,
543
513
  infer.variableDeclarationToTypeNode(argDef)
544
514
  ])
545
- : infer.getterArgsAndReturn(callee)[0].map((typ, i) => [`ARG_${i}`, typ]);
515
+ : infer
516
+ .getterArgsAndReturn(callee)[0]
517
+ .map((typ, i) => [`ARG_${i}`, typ]);
546
518
  }
547
519
  catch (e) {
548
520
  // `variableDeclarationToTypeNode` may fail when referencing structs/contracts that are defined
@@ -563,7 +535,7 @@ class SolTxDebugger {
563
535
  {
564
536
  type: typ,
565
537
  loc: {
566
- kind: DataLocationKind.Stack,
538
+ kind: types_1.DataLocationKind.Stack,
567
539
  offsetFromTop
568
540
  }
569
541
  }